@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); hashCode = prime * hashCode + ((getDBInstances() == null) ? 0 : getDBInstances().hashCode()); return hashCode; }
public DescribeDBInstancesResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeDBInstancesResult describeDBInstancesResult = new DescribeDBInstancesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeDBInstancesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Marker", targetDepth)) { describeDBInstancesResult.setMarker(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("DBInstances", targetDepth)) { describeDBInstancesResult.withDBInstances(new ArrayList<DBInstance>()); continue; } if (context.testExpression("DBInstances/DBInstance", targetDepth)) { describeDBInstancesResult.withDBInstances(DBInstanceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeDBInstancesResult; } } } }
/** * <p> * A list of <a>DBInstance</a> instances. * </p> * * @param dBInstances * A list of <a>DBInstance</a> instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeDBInstancesResult withDBInstances(java.util.Collection<DBInstance> dBInstances) { setDBInstances(dBInstances); return this; }
public String getDBStatus(String dbInstanceId){ DescribeDBInstancesRequest ddbir = new DescribeDBInstancesRequest() .withDBInstanceIdentifier(dbInstanceId); DescribeDBInstancesResult ddbi = rdsClient.describeDBInstances(ddbir); try{ return ddbi.getDBInstances().get(0).getStatusInfos().toString(); }catch(Exception e){ throw new RuntimeException("DBInstance not found"); } }
private void forEachInstance(Consumer<DBInstance> consumer) { rateLimit(); DescribeDBInstancesResult result = getClient().describeDBInstances(); String marker = result.getMarker(); result.getDBInstances().forEach(consumer); while (tokenHasNext(marker)) { rateLimit(); result = getClient().describeDBInstances().withMarker(marker); marker = result.getMarker(); result.getDBInstances().forEach(consumer); } }
AmazonRDSClient rdsClient = new AmazonRDSClient(/*add your credentials and the proper constructor overload*/); DescribeDBInstancesRequest request = new DescribeDBInstancesRequest(); DescribeDBInstancesResult result = rdsClient.describeDBInstances(request); List<DBInstance> list = result.getDBInstances(); System.out.println("list length = " + list.size());
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeDBInstancesResult == false) return false; DescribeDBInstancesResult other = (DescribeDBInstancesResult) obj; if (other.getMarker() == null ^ this.getMarker() == null) return false; if (other.getMarker() != null && other.getMarker().equals(this.getMarker()) == false) return false; if (other.getDBInstances() == null ^ this.getDBInstances() == null) return false; if (other.getDBInstances() != null && other.getDBInstances().equals(this.getDBInstances()) == false) return false; return true; }
/** * Retrieves the {@link com.amazonaws.services.rds.model.DBInstance} information * * @param identifier * - the database identifier used * @return - the db instance * @throws IllegalStateException * if the db instance is not found */ protected DBInstance getDbInstance(String identifier) throws IllegalStateException { DBInstance instance; try { DescribeDBInstancesResult describeDBInstancesResult = this.amazonRds.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier(identifier)); instance = describeDBInstancesResult.getDBInstances().get(0); } catch (DBInstanceNotFoundException e) { throw new IllegalStateException(MessageFormat.format("No database instance with id:''{0}'' found. Please specify a valid db instance", identifier)); } return instance; }
public DescribeDBInstancesResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeDBInstancesResult describeDBInstancesResult = new DescribeDBInstancesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeDBInstancesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Marker", targetDepth)) { describeDBInstancesResult.setMarker(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("DBInstances", targetDepth)) { describeDBInstancesResult.withDBInstances(new ArrayList<DBInstance>()); continue; } if (context.testExpression("DBInstances/DBInstance", targetDepth)) { describeDBInstancesResult.withDBInstances(DBInstanceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeDBInstancesResult; } } } }
/** * <p> * A list of <a>DBInstance</a> instances. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setDBInstances(java.util.Collection)} or {@link #withDBInstances(java.util.Collection)} if you want to * override the existing values. * </p> * * @param dBInstances * A list of <a>DBInstance</a> instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeDBInstancesResult withDBInstances(DBInstance... dBInstances) { if (this.dBInstances == null) { setDBInstances(new com.amazonaws.internal.SdkInternalList<DBInstance>(dBInstances.length)); } for (DBInstance ele : dBInstances) { this.dBInstances.add(ele); } return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getMarker() != null) sb.append("Marker: ").append(getMarker()).append(","); if (getDBInstances() != null) sb.append("DBInstances: ").append(getDBInstances()); sb.append("}"); return sb.toString(); }
/** * Retrieves the {@link com.amazonaws.services.rds.model.DBInstance} information * * @param identifier * - the database identifier used * @return - the db instance * @throws IllegalStateException * if the db instance is not found */ protected DBInstance getDbInstance(String identifier) throws IllegalStateException { DBInstance instance; try { DescribeDBInstancesResult describeDBInstancesResult = this.amazonRds.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier(identifier)); instance = describeDBInstancesResult.getDBInstances().get(0); } catch (DBInstanceNotFoundException e) { throw new IllegalStateException(MessageFormat.format("No database instance with id:''{0}'' found. Please specify a valid db instance", identifier)); } return instance; }
/** * <p> * A list of <a>DBInstance</a> instances. * </p> * * @param dBInstances * A list of <a>DBInstance</a> instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeDBInstancesResult withDBInstances(java.util.Collection<DBInstance> dBInstances) { setDBInstances(dBInstances); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); hashCode = prime * hashCode + ((getDBInstances() == null) ? 0 : getDBInstances().hashCode()); return hashCode; }
public String getDBEndPoint(String dbInstanceId, int timeout){ DescribeDBInstancesRequest ddbir = new DescribeDBInstancesRequest() .withDBInstanceIdentifier(dbInstanceId); System.out.println("Waiting for DB endpoints"); while(timeout -- > 0){ System.out.print("-"); DescribeDBInstancesResult ddbi = rdsClient.describeDBInstances(ddbir); Endpoint endpoint = ddbi.getDBInstances().get(0).getEndpoint(); if(endpoint != null && endpoint.toString().length()!=0) return endpoint.getAddress()+":"+endpoint.getPort(); try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(BeanstalkConnector.class.getName()).log(Level.SEVERE, null, ex); } } return ""; }
/** * <p> * A list of <a>DBInstance</a> instances. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setDBInstances(java.util.Collection)} or {@link #withDBInstances(java.util.Collection)} if you want to * override the existing values. * </p> * * @param dBInstances * A list of <a>DBInstance</a> instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeDBInstancesResult withDBInstances(DBInstance... dBInstances) { if (this.dBInstances == null) { setDBInstances(new com.amazonaws.internal.SdkInternalList<DBInstance>(dBInstances.length)); } for (DBInstance ele : dBInstances) { this.dBInstances.add(ele); } return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeDBInstancesResult == false) return false; DescribeDBInstancesResult other = (DescribeDBInstancesResult) obj; if (other.getMarker() == null ^ this.getMarker() == null) return false; if (other.getMarker() != null && other.getMarker().equals(this.getMarker()) == false) return false; if (other.getDBInstances() == null ^ this.getDBInstances() == null) return false; if (other.getDBInstances() != null && other.getDBInstances().equals(this.getDBInstances()) == false) return false; return true; }
private boolean isDatabaseAvailable(RetryContext context) { DescribeDBInstancesResult describeDBInstancesResult; try { describeDBInstancesResult = this.amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier((String) context.getAttribute(DB_INSTANCE_ATTRIBUTE_NAME))); } catch (DBInstanceNotFoundException e) { LOGGER.warn("Database Instance with name {} has been removed or is not configured correctly, no retry possible", getDbInstanceIdentifier()); //Database has been deleted while operating, hence we can not retry return false; } if (describeDBInstancesResult.getDBInstances().size() == 1) { DBInstance dbInstance = describeDBInstancesResult.getDBInstances().get(0); InstanceStatus instanceStatus = InstanceStatus.fromDatabaseStatus(dbInstance.getDBInstanceStatus()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Status of database to be retried is {}", instanceStatus); } return instanceStatus.isRetryable(); } else { throw new IllegalStateException("Multiple databases found for same identifier, this is likely an incompatibility with the Amazon SDK"); } }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getMarker() != null) sb.append("Marker: ").append(getMarker()).append(","); if (getDBInstances() != null) sb.append("DBInstances: ").append(getDBInstances()); sb.append("}"); return sb.toString(); }
private boolean isDatabaseAvailable(RetryContext context) { DescribeDBInstancesResult describeDBInstancesResult; try { describeDBInstancesResult = this.amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier((String) context.getAttribute(DB_INSTANCE_ATTRIBUTE_NAME))); } catch (DBInstanceNotFoundException e) { LOGGER.warn("Database Instance with name {} has been removed or is not configured correctly, no retry possible", getDbInstanceIdentifier()); //Database has been deleted while operating, hence we can not retry return false; } if (describeDBInstancesResult.getDBInstances().size() == 1) { DBInstance dbInstance = describeDBInstancesResult.getDBInstances().get(0); InstanceStatus instanceStatus = InstanceStatus.fromDatabaseStatus(dbInstance.getDBInstanceStatus()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Status of database to be retried is {}", instanceStatus); } return instanceStatus.isRetryable(); } else { throw new IllegalStateException("Multiple databases found for same identifier, this is likely an incompatibility with the Amazon SDK"); } }