If a Dgraph deployment type is chosen, a Dgraph cluster component is defined.
This object is used to apply actions to an entire cluster of Dgraphs, rather than manually iterating over a number of Dgraphs. In addition, the object contains logic associated with Dgraph restart strategies, which are described below. Multiple Dgraph clusters can be defined, with no restriction around which Dgraphs belong to each cluster or how many clusters a Dgraph belongs to.
<!-- ######################################################################## # Dgraph Cluster # --> <dgraph-cluster id="DgraphCluster" getDataInParallel="true"> <dgraph ref="Dgraph1" /> <dgraph ref="Dgraph2" /> </dgraph-cluster>
Two Dgraphs are defined by the template by default.
<!-- ####################################################################### # Global Dgraph settings, inherited by all dgraphs # --> <dgraph-defaults> <properties> <property name="srcIndexDir" value="./data/dgidx_output" /> <property name="srcIndexHostId" value="ITLHost" /> <property name="srcPartialsDir" value="./data/partials/forge_output" /> <property name="srcPartialsHostId" value="ITLHost" /> <property name="srcCumulativePartialsDir" value="./data/partials/cumulative_partials" /> <property name="srcCumulativePartialsHostId" value="ITLHost" /> <property name="srcDgraphConfigDir" value="./data/web_studio/dgraph_config" /> <property name="srcDgraphConfigHostId" value="ITLHost" /> <property name="srcXQueryHostId" value="ITLHost" /> <property name="srcXQueryDir" value="./config/lib/xquery" /> <property name="numLogBackups" value="10" /> <property name="shutdownTimeout" value="30" /> <property name="numIdleSecondsAfterStop" value="0" /> </properties> <directories> <directory name="localIndexDir">./data/dgraphs/local_dgraph_input</directory> <directory name="localCumulativePartialsDir">./data/dgraphs/local_cumulative_partials</directory> <directory name="localDgraphConfigDir">./data/dgraphs/local_dgraph_config</directory> <directory name="localXQueryDir">./data/dgraphs/local_xquery</directory> </directories> <args> <arg>--threads</arg> <arg>2</arg> <arg>--spl</arg> <arg>--dym</arg> <arg>--xquery_path</arg> <arg>./data/dgraphs/local_xquery</arg> </args> <startup-timeout>120</startup-timeout> </dgraph-defaults>
Each Dgraph defined in the document (via the dgraph element) inherits from the settings defined in the dgraph-defaults element, and also specifies settings that are unique to the Dgraph.
The restartGroup property indicates the Dgraph's membership in a restart group. When applying a new index or configuration updates to a cluster of Dgraphs (or when updating a cluster of Dgraphs with a provisioning change such as a new or modified process argument), the Dgraph cluster object applies changes simultaneously to all Dgraphs in a restart group.
Similarly, the updateGroup property indicates the Dgraph's membership in an update group. When applying partial updates, the Dgraph cluster object applies changes simultaneously to all Dgraphs in an update group.
<dgraph id="Dgraph1" host-id="MDEXHost" port="15000"> <properties> <property name="restartGroup" value="A" /> <property name="updateGroup" value="a" /> </properties> <log-dir>./logs/dgraphs/Dgraph1</log-dir> <input-dir>./data/dgraphs/Dgraph1/dgraph_input</input-dir> <update-dir>./data/dgraphs/Dgraph1/dgraph_input/updates</update-dir> </dgraph>
Restart and update group values are arbitrary strings. The DgraphCluster will iterate through the groups in alphabetical order, though non-standard characters may result in groups being updated in an unexpected order.
Dgraph components can specify the name of a script to invoke prior to shutdown and the name of a script to invoke after the component is started. These optional attributes must specify the ID of a Script defined in the XML file(s). These BeanShell scripts are executed just before the Dgraph is stopped or just after it is started. The scripts behave identically to other BeanShell scripts, except that they have an additional variable, invokingObject, which holds a reference to the Dgraph that invoked the script. This functionality is typically used to implement calls to a load balancer, adding or removing a Dgraph from the cluster as it is updated.
The following example shows two dummy scripts (which just log a message, but could be extended to call out to a load balancer) provisioned to run pre-shutdown and post-startup for Dgraph1.
<dgraph id="Dgraph1" host-id="MDEXHost" port="15000" pre-shutdown-script="DgraphPreShutdownScript" post-startup-script="DgraphPostStartupScript"> <properties> <property name="restartGroup" value="A" /> </properties> <log-dir>./logs/dgraphs/Dgraph1</log-dir> <input-dir>./data/dgraphs/Dgraph1/dgraph_input</input-dir> <update-dir>./data/dgraphs/Dgraph1/dgraph_input/updates</update-dir> </dgraph> <script id="DgraphPreShutdownScript"> <bean-shell-script> <![CDATA[ id = invokingObject.getElementId(); hostname = invokingObject.getHost().getHostName(); port = invokingObject.getPort(); log.info("Removing dgraph with id " + id + " (host: " + hostname + ", port: " + port + ") from load balancer cluster."); ]]> </bean-shell-script> </script> <script id="DgraphPostStartupScript"> <bean-shell-script> <![CDATA[ id = invokingObject.getElementId(); hostname = invokingObject.getHost().getHostName(); port = invokingObject.getPort(); log.info("Adding dgraph with id " + id + " (host: " + hostname + ", port: " + port + ") to load balancer cluster."); ]]> </bean-shell-script> </script>
[03.10.08 10:03:28] INFO: Applying index to dgraphs in restart group 'A'. [03.10.08 10:03:28] INFO: [MDEXHost] Starting shell utility 'mkpath_dgraph-input-new'. [03.10.08 10:03:30] INFO: [MDEXHost] Starting copy utility 'copy_index_to_temp_new_dgraph_input_dir_for_Dgraph1'. [03.10.08 10:03:35] INFO: Removing dgraph with id Dgraph1 (host: mdex1.mycompany.com, port: 15000) from load balancer cluster. [03.10.08 10:03:35] INFO: Stopping component 'Dgraph1'. [03.10.08 10:03:37] INFO: [MDEXHost] Starting shell utility 'move_dgraph-input_to_dgraph-input-old'. [03.10.08 10:03:39] INFO: [MDEXHost] Starting shell utility 'move_dgraph-input-new_to_dgraph-input'. [03.10.08 10:03:40] INFO: [MDEXHost] Starting backup utility 'backup_log_dir_for_component_Dgraph1'. [03.10.08 10:03:42] INFO: [MDEXHost] Starting component 'Dgraph1'. [03.10.08 10:03:45] INFO: Adding dgraph with id Dgraph1 (host: mdex1.mycompany.com, port: 15000) to load balancer cluster. [03.10.08 10:03:45] INFO: [MDEXHost] Starting shell utility 'rmdir_dgraph-input-old'.Note that the dgraph-default element can also specify the use of pre-shutdown and post-startup scripts as attributes, allowing all Dgraphs in an application to execute the same scripts. For example:
<dgraph-defaults pre-shutdown-script="DgraphPreShutdownScript" post-startup-script="DgraphPostStartupScript"> ... </dgraph-defaults>
The Deployment Template supports the distribution of XQuery modules to each Dgraph in the group. The [appdir]config/lib/xquery directory is provided for users to store their XQuery modules. In addition, a LoadXQueryModules script (in the AppConfig.xml file) distributes the XQuery modules to Dgraph servers and instructs the Dgraphs to load the modules.
C:\Endeca\Apps\control>runcommand LoadXQueryModules
The XQuery modules are distributed to the Dgraphs in the deployment and they are instructed to reload/compile the modules.
Both the dgraph and dgraph-defaults elements allow you to use the args sub-element to pass command-line flags to the Dgraphs. However, if you use an args section in both the dgraph and dgraph-defaults configurations, the results are not cumulative.
Instead, the args section for an individual Dgraph completely overrides the dgraph-defaults definition (i.e., it does not inherit the parameters that are specified in the dgraph-defaults section and then add the ones that are unique for that Dgraph).
All three elements are first-level children of the <dgraph-defaults> element.
<dgraph-defaults> ... <cert-file> C:\Endeca\PlatformServices\workspace\etc\eneCert.pem </cert-file> <ca-file> C:\Endeca\PlatformServices\workspace\etc\eneCA.pem </ca-file> <cipher>AES128-SHA</cipher> </dgraph-defaults>