/** * Simplified method form for invoking the DescribeDBInstances operation with an AsyncHandler. * * @see #describeDBInstancesAsync(DescribeDBInstancesRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<DescribeDBInstancesResult> describeDBInstancesAsync( com.amazonaws.handlers.AsyncHandler<DescribeDBInstancesRequest, DescribeDBInstancesResult> asyncHandler) { return describeDBInstancesAsync(new DescribeDBInstancesRequest(), asyncHandler); }
/** * <p> * An optional pagination token provided by a previous <code>DescribeDBInstances</code> request. If this parameter * is specified, the response includes only records beyond the marker, up to the value specified by * <code>MaxRecords</code>. * </p> * * @param marker * An optional pagination token provided by a previous <code>DescribeDBInstances</code> request. If this * parameter is specified, the response includes only records beyond the marker, up to the value specified by * <code>MaxRecords</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeDBInstancesRequest withMarker(String marker) { setMarker(marker); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDBInstanceIdentifier() == null) ? 0 : getDBInstanceIdentifier().hashCode()); hashCode = prime * hashCode + ((getFilters() == null) ? 0 : getFilters().hashCode()); hashCode = prime * hashCode + ((getMaxRecords() == null) ? 0 : getMaxRecords().hashCode()); hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); return hashCode; }
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"); } }
@TaskAction public void describeDBInstances() { // NOPMD // to enable conventionMappings feature String dbInstanceIdentifier = getDbInstanceIdentifier(); AmazonRDSPluginExtension ext = getProject().getExtensions().getByType(AmazonRDSPluginExtension.class); AmazonRDS rds = ext.getClient(); try { DescribeDBInstancesRequest request = new DescribeDBInstancesRequest() .withMaxRecords(getMaxRecords()); if (getDbInstanceIdentifier() != null && getDbInstanceIdentifier().length() > 0) { request.withDBInstanceIdentifier(getDbInstanceIdentifier()); } if (getFilters() != null) { request.withFilters(getFilters().entrySet().stream() .map(it -> new Filter() .withName(it.getKey().toString()) .withValues(it.getValue())) .collect(Collectors.toList())); } DescribeDBInstancesResult dir = rds.describeDBInstances(request); dbInstances = dir.getDBInstances(); } catch (AmazonServiceException e) { throw new GradleException("Fail to describe instance: " + dbInstanceIdentifier, e); } } }
} while (clustersResult.getMarker() != null); DescribeDBInstancesRequest rdsRequest = new DescribeDBInstancesRequest(); DescribeDBInstancesResult result; rdsRequest.setMarker(result.getMarker()); } while (result.getMarker() != null);
List<DBInstanceVH> dbInstList = new ArrayList<>(); do{ rslt = rdsClient.describeDBInstances(new DescribeDBInstancesRequest().withMarker(nextMarker)); List<DBInstance> dbInstListTemp = rslt.getDBInstances(); for(DBInstance db : dbInstListTemp){
/** * 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; }
/** * 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; }
@Override public DescribeDBInstancesResult describeDBInstances() { return describeDBInstances(new DescribeDBInstancesRequest()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeDBInstancesRequest == false) return false; DescribeDBInstancesRequest other = (DescribeDBInstancesRequest) obj; if (other.getDBInstanceIdentifier() == null ^ this.getDBInstanceIdentifier() == null) return false; if (other.getDBInstanceIdentifier() != null && other.getDBInstanceIdentifier().equals(this.getDBInstanceIdentifier()) == false) return false; if (other.getFilters() == null ^ this.getFilters() == null) return false; if (other.getFilters() != null && other.getFilters().equals(this.getFilters()) == false) return false; if (other.getMaxRecords() == null ^ this.getMaxRecords() == null) return false; if (other.getMaxRecords() != null && other.getMaxRecords().equals(this.getMaxRecords()) == false) return false; if (other.getMarker() == null ^ this.getMarker() == null) return false; if (other.getMarker() != null && other.getMarker().equals(this.getMarker()) == false) return false; return true; }
/** * <p> * An optional pagination token provided by a previous <code>DescribeDBInstances</code> request. If this parameter * is specified, the response includes only records beyond the marker, up to the value specified by * <code>MaxRecords</code>. * </p> * * @param marker * An optional pagination token provided by a previous <code>DescribeDBInstances</code> request. If this * parameter is specified, the response includes only records beyond the marker, up to the value specified by * <code>MaxRecords</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeDBInstancesRequest withMarker(String marker) { setMarker(marker); return this; }
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 ""; }
/** * Simplified method form for invoking the DescribeDBInstances operation. * * @see #describeDBInstancesAsync(DescribeDBInstancesRequest) */ @Override public java.util.concurrent.Future<DescribeDBInstancesResult> describeDBInstancesAsync() { return describeDBInstancesAsync(new DescribeDBInstancesRequest()); }
/** * 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 (getDBInstanceIdentifier() != null) sb.append("DBInstanceIdentifier: ").append(getDBInstanceIdentifier()).append(","); if (getFilters() != null) sb.append("Filters: ").append(getFilters()).append(","); if (getMaxRecords() != null) sb.append("MaxRecords: ").append(getMaxRecords()).append(","); if (getMarker() != null) sb.append("Marker: ").append(getMarker()); 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"); } }
/** * Simplified method form for invoking the DescribeDBInstances operation with an AsyncHandler. * * @see #describeDBInstancesAsync(DescribeDBInstancesRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<DescribeDBInstancesResult> describeDBInstancesAsync( com.amazonaws.handlers.AsyncHandler<DescribeDBInstancesRequest, DescribeDBInstancesResult> asyncHandler) { return describeDBInstancesAsync(new DescribeDBInstancesRequest(), asyncHandler); }
request.setHttpMethod(HttpMethodName.POST); if (describeDBInstancesRequest.getDBInstanceIdentifier() != null) { request.addParameter("DBInstanceIdentifier", StringUtils.fromString(describeDBInstancesRequest.getDBInstanceIdentifier())); if (!describeDBInstancesRequest.getFilters().isEmpty() || !((com.amazonaws.internal.SdkInternalList<Filter>) describeDBInstancesRequest.getFilters()).isAutoConstruct()) { com.amazonaws.internal.SdkInternalList<Filter> filtersList = (com.amazonaws.internal.SdkInternalList<Filter>) describeDBInstancesRequest .getFilters(); int filtersListIndex = 1; if (describeDBInstancesRequest.getMaxRecords() != null) { request.addParameter("MaxRecords", StringUtils.fromInteger(describeDBInstancesRequest.getMaxRecords())); if (describeDBInstancesRequest.getMarker() != null) { request.addParameter("Marker", StringUtils.fromString(describeDBInstancesRequest.getMarker()));
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"); } }
/** * Simplified method form for invoking the DescribeDBInstances operation. * * @see #describeDBInstancesAsync(DescribeDBInstancesRequest) */ @Override public java.util.concurrent.Future<DescribeDBInstancesResult> describeDBInstancesAsync() { return describeDBInstancesAsync(new DescribeDBInstancesRequest()); }