# Agraphs

If an Agraph deployment type is chosen, an Agraph cluster component is defined.

This object is used to apply actions to an entire cluster of Agraphs and their associated Dgraphs, rather than manually iterating over a number of graphs. In addition, the object contains logic associated with Agraph restart strategies, which are described below. Multiple Agraph clusters can be defined, with no restriction around which graphs belong to each cluster or how many clusters a graph belongs to.

An Agraph cluster is configured with references to all Agraphs and Dgraphs that belong to that cluster. In addition, the cluster can be configured to copy data in parallel or serially. This setting applies to copies that are performed to distribute a new index, partial updates or configuration updates to each server that hosts a graph. By default, the template sets this value to true.

    <!--
    ########################################################################
    # Agraph Cluster
    #
    -->
    <agraph-cluster id="AgraphCluster" getDataInParallel="true">
      <agraph ref="Agraph1" />
      <agraph ref="Agraph2" />
      <dgraph ref="Dgraph1" />
      <dgraph ref="Dgraph2" />
    </agraph-cluster>

In an Agraph deployment, two Agraphs and two Dgraphs are defined by the template by default. In order to avoid defining shared configuration for multiple Agraphs in each Agraph's XML configuration, the document provides an agraph-defaults element, where shared settings can be configured and inherited (or overridden) by each Agraph defined in the document. This defaults object specifies a number of custom configuration properties that are used by the update scripts to define operational functionality.

- `numLogBackups` - Number of log directory backups to store.
- `shutdownTimeout` - Number of seconds to wait for a component to stop (after receiving a stop command).
- `numIdleSecondsAfterStop` - Number of seconds to pause/sleep after a component is stopped. Typically, this will be used to ensure that log file locks are release by the component before proceeding.
- `srcIndexDir` - Location from which a new index will be copied to a local directory on the Dgraph's host.
- `srcIndexHostId` - Host from which a new index will be copied to a local directory on the Dgraph's host.
- `localIndexDir` - Local directory to which a single copy of a new index is copied from the source index directory on the source index host.
- `skipTestingForFilesDuringCleanup` - Used for directory-cleaning operations. If set to "true", will skip the directory-contents test and instead proceed directly to cleaning the directory. The default behavior is to test the directory contents and skip cleanup if the directory is not empty.
- The properties documented in the "Fault tolerance and polling interval properties" topic.

     <!--
        ########################################################################
        # Global Agraph settings, inherited by all agraphs
        #
      -->
      <agraph-defaults>
        <properties>
          <property name="srcIndexDir" value="./data/agidx_output" />
          <property name="srcIndexHostId" value="ITLHost" />
          <property name="numLogBackups" value="10" />
        </properties>
        <directories>
          <directory name="localIndexDir">./data/agraphs/local_agraph_input</directory>
        </directories>
        <args>
          <arg>--no-partial</arg>
        </args>
        <startup-timeout>120</startup-timeout>
      </agraph-defaults>

Each Agraph defined in the document inherits from the settings defined in the agraph-defaults element, and also specifies settings that are unique to the Agraph. In addition to standard Agraph configuration and process arguments, Agraphs add a custom property used to define a restart strategy.

`restartGroup` - Indicates the Agraph's membership in a restart group. When applying a new index or configuration updates to a cluster of graphs (or when updating a cluster of graphs with a provisioning change such as a new or modified process argument), the Agraph cluster object applies changes simultaneously to all graphs in a restart group. This means that a few common restart strategies can be applied as follows:

1. Restart/update all Agraphs at once: specify the same `restartGroup` value for each Agraph and associated Dgraphs.
2. Restart/update Agraphs one at a time: specify a unique `restartGroup` value for each Agraph and associated Dgraphs.
3. Restart/update Agraphs on each server simultaneously: specify the same `restartGroup` value for each Agraph and associated Dgraphs on a physical server.

    <agraph id="Agraph1" host-id="MDEXHost" port="14000">
      <properties>
        <property name="restartGroup" value="A" />
      </properties>
      <dgraph-children>
        <dgraph-child>Dgraph1</dgraph-child>
        <dgraph-child>Dgraph2</dgraph-child>
      </dgraph-children>
      <log-dir>./logs/agraphs/Agraph1</log-dir>
      <input-dir>./data/agraphs/Agraph1/agraph_input</input-dir>
    </agraph>

Restart group values are arbitrary strings. The Agraph cluster iterates through the groups in alphabetical order, though non-standard characters may result in groups being updated in an unexpected order.

The Agraph component (and agraph-defaults) can specify pre-shutdown and post-startup scripts in the same way as the Dgraph component. Refer to the previous section for details.

## Enabling SSL for the Agraph

As with the Dgraph, three SSL elements can be included in the Agraph provisioning definition to specify the certificates to use. The `cert-file` element (for the eneCert.pem certificate), the `ca-file` element (for the eneCA.pem Certificate Authority file), and the optional `cipher` element can be used. as shown in this example:

    <agraph id="Agraph1" host-id="MDEXHost" port="14000">
    ...
       <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>
    </agraph>

Related concepts
Agraph notes