Java Code Examples for com.amazonaws.services.rds.model.DBInstance#getReadReplicaSourceDBInstanceIdentifier()

The following examples show how to use com.amazonaws.services.rds.model.DBInstance#getReadReplicaSourceDBInstanceIdentifier() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RDSInstance.java    From billow with Apache License 2.0 5 votes vote down vote up
public static boolean checkIfMaster(DBInstance instance, DBCluster cluster) {
    if (instance.getDBClusterIdentifier() == null || cluster == null) {
        // It's NOT a member of a DB cluster
        return instance.getReadReplicaSourceDBInstanceIdentifier() == null;
    } else {
        // It's a member of a DB cluster
        for (DBClusterMember member : cluster.getDBClusterMembers()) {
            if (member.getDBInstanceIdentifier().equals(instance.getDBInstanceIdentifier()) && member.isClusterWriter()) {
                return true;
            }
        }
        return false;
    }
}
 
Example 2
Source File: RDSInstance.java    From billow with Apache License 2.0 4 votes vote down vote up
public RDSInstance(DBInstance instance, DBCluster cluster, List<Tag> tagList, List<String> snapshots) {
    this.allocatedStorage = instance.getAllocatedStorage();
    this.autoMinorVersionUpgrade = instance.getAutoMinorVersionUpgrade();
    this.availabilityZone = instance.getAvailabilityZone();
    this.backupRetentionPeriod = instance.getBackupRetentionPeriod();
    this.characterSetName = instance.getCharacterSetName();
    this.dBInstanceClass = instance.getDBInstanceClass();
    this.dBInstanceIdentifier = instance.getDBInstanceIdentifier();
    this.dBInstanceStatus = instance.getDBInstanceStatus();
    this.dBClusterIdentifier = instance.getDBClusterIdentifier();
    this.dBName = instance.getDBName();
    this.dBParameterGroups = instance.getDBParameterGroups();
    this.dBSecurityGroups = instance.getDBSecurityGroups();
    this.dBSubnetGroup = instance.getDBSubnetGroup();
    this.endpoint = instance.getEndpoint();
    if(this.endpoint != null) {
      this.hostname = endpoint.getAddress();
      this.privateIP = getPrivateIp(hostname);
    } else {
      this.hostname = null;
      this.privateIP = null;
    }
    this.engine = instance.getEngine();
    this.engineVersion = instance.getEngineVersion();
    this.instanceCreateTime = instance.getInstanceCreateTime();
    this.iops = instance.getIops();
    this.latestRestorableTime = instance.getLatestRestorableTime();
    this.licenseModel = instance.getLicenseModel();
    this.masterUsername = instance.getMasterUsername();
    this.multiAZ = instance.getMultiAZ();
    this.optionGroupMemberships = instance.getOptionGroupMemberships();
    this.pendingModifiedValues = instance.getPendingModifiedValues();
    this.preferredBackupWindow = instance.getPreferredBackupWindow();
    this.preferredMaintenanceWindow = instance.getPreferredMaintenanceWindow();
    this.publiclyAccessible = instance.getPubliclyAccessible();
    this.readReplicaDBInstanceIdentifiers = instance.getReadReplicaDBInstanceIdentifiers();
    this.readReplicaSourceDBInstanceIdentifier = instance.getReadReplicaSourceDBInstanceIdentifier();
    this.secondaryAvailabilityZone = instance.getSecondaryAvailabilityZone();
    this.statusInfos = instance.getStatusInfos();
    this.vpcSecurityGroups = instance.getVpcSecurityGroups();
    this.isMaster = checkIfMaster(instance, cluster);

    this.tags = new HashMap<>(tagList.size());
    for(Tag tag : tagList) {
        this.tags.put(tag.getKey(), tag.getValue());
    }

    this.snapshots = new ArrayList<>(snapshots);
    this.caCertificateIdentifier = instance.getCACertificateIdentifier();
}