@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAddress() == null) ? 0 : getAddress().hashCode()); hashCode = prime * hashCode + ((getPort() == null) ? 0 : getPort().hashCode()); hashCode = prime * hashCode + ((getHostedZoneId() == null) ? 0 : getHostedZoneId().hashCode()); return hashCode; }
public Endpoint unmarshall(StaxUnmarshallerContext context) throws Exception { Endpoint endpoint = new Endpoint(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return endpoint; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Address", targetDepth)) { endpoint.setAddress(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Port", targetDepth)) { endpoint.setPort(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("HostedZoneId", targetDepth)) { endpoint.setHostedZoneId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return endpoint; } } } }
private DataSourceInformation fromRdsInstance(DBInstance dbInstance) { Assert.notNull(dbInstance, "DbInstance must not be null"); Assert.notNull(dbInstance.getEndpoint(), "The database instance has no endpoint available!"); return new DataSourceInformation(DatabaseType.fromEngine(dbInstance.getEngine()), dbInstance.getEndpoint().getAddress(), dbInstance.getEndpoint().getPort(), StringUtils.hasText(this.databaseName) ? this.databaseName : dbInstance.getDBName(), StringUtils.hasText(this.username) ? this.username : dbInstance.getMasterUsername(), this.password); } }
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 ""; }
.forEach(dbInstance -> { final Map<String, Object> metadata = newHashMap(); metadata.put("unsecuredDatabase", dbInstance.getEndpoint().getAddress()); metadata.put("errorMessages", "Unsecured Database! Your DB can be reached from outside"); writeViolation(accountId, region, metadata, dbInstance.getEndpoint().getAddress());
hashCode = prime * hashCode + ((getMasterUsername() == null) ? 0 : getMasterUsername().hashCode()); hashCode = prime * hashCode + ((getDBName() == null) ? 0 : getDBName().hashCode()); hashCode = prime * hashCode + ((getEndpoint() == null) ? 0 : getEndpoint().hashCode()); hashCode = prime * hashCode + ((getAllocatedStorage() == null) ? 0 : getAllocatedStorage().hashCode()); hashCode = prime * hashCode + ((getInstanceCreateTime() == null) ? 0 : getInstanceCreateTime().hashCode()); hashCode = prime * hashCode + ((getDeletionProtection() == null) ? 0 : getDeletionProtection().hashCode()); hashCode = prime * hashCode + ((getAssociatedRoles() == null) ? 0 : getAssociatedRoles().hashCode()); hashCode = prime * hashCode + ((getListenerEndpoint() == null) ? 0 : getListenerEndpoint().hashCode()); return hashCode;
if (other.getEndpoint() == null ^ this.getEndpoint() == null) return false; if (other.getEndpoint() != null && other.getEndpoint().equals(this.getEndpoint()) == false) return false; if (other.getAllocatedStorage() == null ^ this.getAllocatedStorage() == null) if (other.getListenerEndpoint() == null ^ this.getListenerEndpoint() == null) return false; if (other.getListenerEndpoint() != null && other.getListenerEndpoint().equals(this.getListenerEndpoint()) == false) return false; return true;
private DataSourceInformation fromRdsInstance(DBInstance dbInstance) { Assert.notNull(dbInstance, "DbInstance must not be null"); Assert.notNull(dbInstance.getEndpoint(), "The database instance has no endpoint available!"); return new DataSourceInformation(DatabaseType.fromEngine(dbInstance.getEngine()), dbInstance.getEndpoint().getAddress(), dbInstance.getEndpoint().getPort(), StringUtils.hasText(this.databaseName) ? this.databaseName : dbInstance.getDBName(), StringUtils.hasText(this.username) ? this.username : dbInstance.getMasterUsername(), this.password); } }
this.endpoint = instance.getEndpoint(); if(this.endpoint != null) { this.hostname = endpoint.getAddress(); this.privateIP = getPrivateIp(hostname); } else {
hashCode = prime * hashCode + ((getMasterUsername() == null) ? 0 : getMasterUsername().hashCode()); hashCode = prime * hashCode + ((getDBName() == null) ? 0 : getDBName().hashCode()); hashCode = prime * hashCode + ((getEndpoint() == null) ? 0 : getEndpoint().hashCode()); hashCode = prime * hashCode + ((getAllocatedStorage() == null) ? 0 : getAllocatedStorage().hashCode()); hashCode = prime * hashCode + ((getInstanceCreateTime() == null) ? 0 : getInstanceCreateTime().hashCode()); hashCode = prime * hashCode + ((getDeletionProtection() == null) ? 0 : getDeletionProtection().hashCode()); hashCode = prime * hashCode + ((getAssociatedRoles() == null) ? 0 : getAssociatedRoles().hashCode()); hashCode = prime * hashCode + ((getListenerEndpoint() == null) ? 0 : getListenerEndpoint().hashCode()); return hashCode;
if (other.getEndpoint() == null ^ this.getEndpoint() == null) return false; if (other.getEndpoint() != null && other.getEndpoint().equals(this.getEndpoint()) == false) return false; if (other.getAllocatedStorage() == null ^ this.getAllocatedStorage() == null) if (other.getListenerEndpoint() == null ^ this.getListenerEndpoint() == null) return false; if (other.getListenerEndpoint() != null && other.getListenerEndpoint().equals(this.getListenerEndpoint()) == false) return false; return true;
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Endpoint == false) return false; Endpoint other = (Endpoint) obj; if (other.getAddress() == null ^ this.getAddress() == null) return false; if (other.getAddress() != null && other.getAddress().equals(this.getAddress()) == false) return false; if (other.getPort() == null ^ this.getPort() == null) return false; if (other.getPort() != null && other.getPort().equals(this.getPort()) == false) return false; if (other.getHostedZoneId() == null ^ this.getHostedZoneId() == null) return false; if (other.getHostedZoneId() != null && other.getHostedZoneId().equals(this.getHostedZoneId()) == false) return false; return true; }
private void describe(String dbInstanceIdentifier) throws Exception { while (true) { DescribeDBInstancesRequest request = new DescribeDBInstancesRequest() .withDBInstanceIdentifier(dbInstanceIdentifier); DescribeDBInstancesResult response = client.describeDBInstances(request); DBInstance dbInstance = response.getDBInstances().get(0); if (!dbInstance.getDBInstanceStatus().equalsIgnoreCase("creating")) { System.out.println("Done! " + response); System.out.println(dbInstance.getEndpoint().getAddress()); System.out.println(dbInstance.getEndpoint().getPort()); break; } System.out.println("Not done - will wait 10s: " + response); Thread.sleep(10000L); } }
public Endpoint unmarshall(StaxUnmarshallerContext context) throws Exception { Endpoint endpoint = new Endpoint(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return endpoint; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Address", targetDepth)) { endpoint.setAddress(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Port", targetDepth)) { endpoint.setPort(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("HostedZoneId", targetDepth)) { endpoint.setHostedZoneId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return endpoint; } } } }
/** * 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 (getAddress() != null) sb.append("Address: ").append(getAddress()).append(","); if (getPort() != null) sb.append("Port: ").append(getPort()).append(","); if (getHostedZoneId() != null) sb.append("HostedZoneId: ").append(getHostedZoneId()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAddress() == null) ? 0 : getAddress().hashCode()); hashCode = prime * hashCode + ((getPort() == null) ? 0 : getPort().hashCode()); hashCode = prime * hashCode + ((getHostedZoneId() == null) ? 0 : getHostedZoneId().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Endpoint == false) return false; Endpoint other = (Endpoint) obj; if (other.getAddress() == null ^ this.getAddress() == null) return false; if (other.getAddress() != null && other.getAddress().equals(this.getAddress()) == false) return false; if (other.getPort() == null ^ this.getPort() == null) return false; if (other.getPort() != null && other.getPort().equals(this.getPort()) == false) return false; if (other.getHostedZoneId() == null ^ this.getHostedZoneId() == null) return false; if (other.getHostedZoneId() != null && other.getHostedZoneId().equals(this.getHostedZoneId()) == false) return false; return true; }
/** * 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 (getAddress() != null) sb.append("Address: ").append(getAddress()).append(","); if (getPort() != null) sb.append("Port: ").append(getPort()).append(","); if (getHostedZoneId() != null) sb.append("HostedZoneId: ").append(getHostedZoneId()); sb.append("}"); return sb.toString(); }