in src/main/java/com/amazonaws/services/neptune/cluster/CloneCluster.java [46:104]
public Cluster cloneCluster(ConnectionConfig connectionConfig, ConcurrencyConfig concurrencyConfig) throws Exception {
if (!connectionConfig.isDirectConnection()) {
throw new IllegalStateException("neptune-export does not support cloning a Neptune cluster accessed via a load balancer");
}
String clusterId = originalClusterMetadata.clusterId();
String targetClusterIdSuffix = null;
try {
targetClusterIdSuffix = System.getenv("AWS_BATCH_JOB_ID"); // Use AWS Batch job id if running in Neptune Export Service
}
catch (SecurityException e) {
// Do nothing, will generate new ID if targetClusterIdSuffix is not set.
}
if (StringUtils.isEmpty(targetClusterIdSuffix)) {
targetClusterIdSuffix = UUID.randomUUID().toString().substring(0, 5);
}
String targetClusterId = String.format("neptune-export-cluster-%s", targetClusterIdSuffix);
AddCloneTask addCloneTask = new AddCloneTask(
clusterId,
targetClusterId,
cloneClusterInstanceType,
replicaCount,
engineVersion,
originalClusterMetadata.clientSupplier(),
cloneCorrelationId,
enableAuditLogs);
NeptuneClusterMetadata targetClusterMetadata = addCloneTask.execute();
InstanceType instanceType = InstanceType.parse(
targetClusterMetadata.instanceMetadataFor(targetClusterMetadata.primary()).instanceType());
int targetConcurrency = instanceType.concurrency() * (1 + targetClusterMetadata.replicas().size());
int newConcurrency = maxConcurrency > 0 ?
Math.min(maxConcurrency, targetConcurrency) :
targetConcurrency;
System.err.println();
System.err.println(String.format("Endpoints : %s", String.join(", ", targetClusterMetadata.endpoints())));
System.err.println(String.format("Max concurrency : %s", maxConcurrency));
System.err.println(String.format("Concurrency : %s", newConcurrency));
return new ClonedCluster(
new ConnectionConfig(
targetClusterId,
targetClusterMetadata.endpoints(),
connectionConfig.port(),
targetClusterMetadata.isIAMDatabaseAuthenticationEnabled(),
true,
connectionConfig.proxyConfig(),
connectionConfig.getCredentialsProvider()
),
new ConcurrencyConfig(newConcurrency),
targetClusterMetadata
);
}