Data replication (Java SDK V2)
How it works
Data replication automatically and asynchronously replicates objects and object changes from a source bucket to a destination bucket according to replication rules. OSS Java SDK V2 does not provide strongly typed interfaces for data replication. The following examples use the generic invokeOperation method to call the corresponding OSS API operations.
Prerequisites
OSS Java SDK V2 is installed. If you use Maven, add the following dependency to the pom.xml file:
com.aliyun:alibabacloud-oss-v2.Access credentials are configured by using environment variables. The examples in this topic use
EnvironmentVariableCredentialsProviderto read credentials from theOSS_ACCESS_KEY_IDandOSS_ACCESS_KEY_SECRETenvironment variables.The source and destination buckets must have the same versioning state (both disabled or both enabled), and the destination bucket must already exist.
Enable replication requires a synchronization role (SyncRole). Create the role and grant the permissions required for replication in advance.
Permissions
By default, an Alibaba Cloud account has full permissions. RAM users and RAM roles have no permissions by default. The Alibaba Cloud account owner or an administrator must grant the required permissions.
API | Action | Description |
PutBucketReplication |
| Enables data replication (adds a replication rule). |
GetBucketReplication |
| Views replication rules and their status. |
PutBucketRtc |
| Enables or disables replication time control (RTC). |
GetBucketReplicationLocation |
| Views the destination regions available for replication. |
GetBucketReplicationProgress |
| Views replication progress. |
DeleteBucketReplication |
| Disables data replication (deletes a replication rule). |
Sample code
References
For API details about enabling data replication, see PutBucketReplication.
For API details about viewing replication rules, see GetBucketReplication.
For API details about viewing the destination regions, see GetBucketReplicationLocation.
For API details about viewing replication progress, see GetBucketReplicationProgress.
For API details about disabling data replication, see DeleteBucketReplication.
For more information about RTC, see Replication Time Control (RTC).