How to create a replica in a connected environment


Summary
The following describes how to create a replica in a connected environment. A connected environment is where both replica geodatabases are connected on the same local area network (LAN) or wide area network (WAN) during replica creation.

Creating a replica

The following steps describe how to create a replica using ArcObjects:
  1. Connect to a geodatabase to host the parent replica and connect to a geodatabase to host the child replica. This requires initializing a geodataserver object for each connection. Geodataserver objects allow you to access a geodatabase on a LAN or a WAN through ArcGIS Server. To see how to initialize a geodataserver, refer to How to initialize a geodataserver object.
  2. Call the following procedure by pasting it into your application and passing in the following parameters:
gdsParent
One of the geodataservers that you initialized in Step 1. This is the geodataserver that hosts the parent replica.
gdsChild
The other geodataserver that you initialized in Step 1. This is the geodataserver that hosts the child replica.
replicaName
The name of the replica that you want to create. This name cannot already be used in either replica geodatabase.
accessType
Specifies whether you want to create a two-way, one-way, or checkout replica.
featureDataset
The fully qualified name of the feature dataset to replicate (see the following note).
geometry
The replica geometry. Only features that intersect this geometry will be included in the replica. If you pass in null, then all features are replicated.
registerOnly
False means that the child does not already have the data. True means that the data already exists in both geodatabases and you want to register new replicas for this data. In typical cases, set this to false.
Although this example can only be used to replicate a feature dataset and its contents, the code can be altered to accept feature classes and tables.
[Java]
// Creates a replica of all data in a feature dataset.
//accessType is an integer constant belonging to esriReplicaAccessType
static void createFeatureDatasetReplica(IGeoDataServer parentGDS, IGeoDataServer
    childGDS, String replicaName, int accessType, String featureDataset, IGeometry
    geometry, Boolean registerOnly)throws Exception{
    // Set and expand the replica datasets.
    IGPReplicaDataset gpReplicaDataset = new GPReplicaDataset();
    gpReplicaDataset.setDatasetType(esriDatasetType.esriDTFeatureDataset);
    gpReplicaDataset.setName(featureDataset);
    IGPReplicaDatasets gpReplicaDatasets = new GPReplicaDatasets();
    gpReplicaDatasets.add(gpReplicaDataset);
    IGPReplicaDatasets gpReplicaDatasetsExpand = parentGDS.expandReplicaDatasets
        (gpReplicaDatasets);
    // Set the replica description.
    IGPReplicaDescription gpReplicaDesc = new GPReplicaDescription();
    gpReplicaDesc.setReplicaDatasetsByRef(gpReplicaDatasetsExpand);
    gpReplicaDesc.setModelType(esriReplicaModelType.esriModelTypeFullGeodatabase);
    gpReplicaDesc.setSingleGeneration((accessType ==
        esriReplicaAccessType.esriReplicaAccessNone));
    gpReplicaDesc.setQueryGeometryByRef(geometry);
    gpReplicaDesc.setSpatialRelation
        (esriSpatialRelEnum.esriSpatialRelIndexIntersects);
    // Set the replica options.
    IGPReplicaOptions replicaOptions = new GPReplicaOptions();
    replicaOptions.setAccessType(accessType);
    replicaOptions.setChildReconcilePolicy
        (esriReplicaReconcilePolicyType.esriReplicaResolveConflictsNone);
    replicaOptions.setParentReconcilePolicy
        (esriReplicaReconcilePolicyType.esriReplicaResolveConflictsNone);
    replicaOptions.setIsChildFirstSender(true);
    replicaOptions.setRegisterReplicaOnly(registerOnly);
    // Create the replica.
    IReplicationAgent replicationAgent = new ReplicationAgent();
    replicationAgent.createReplica("", parentGDS, childGDS, replicaName,
        gpReplicaDesc, replicaOptions);
}






Development licensingDeployment licensing
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine: Geodatabase Update