Java Code Examples for com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthResult#getTargetHealthDescriptions()
The following examples show how to use
com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthResult#getTargetHealthDescriptions() .
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: ELBIsInstanceRegisteredStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected Boolean run() throws Exception { TaskListener listener = this.getContext().get(TaskListener.class); listener.getLogger().println("elbIsInstanceRegistered instanceID: " + this.step.instanceID + " port: " + this.step.port + " from targetGroupARN: " + this.step.targetGroupARN); Boolean rval = false; AmazonElasticLoadBalancing client = AWSClientFactory.create(AmazonElasticLoadBalancingClientBuilder.standard(), this.getEnvVars()); DescribeTargetHealthRequest req = new DescribeTargetHealthRequest().withTargetGroupArn(this.step.targetGroupARN); DescribeTargetHealthResult res = client.describeTargetHealth(req); List<TargetHealthDescription> targets = res.getTargetHealthDescriptions(); for (TargetHealthDescription target : targets) { if (target.getTarget().getId().equals(this.step.instanceID) && target.getTargetHealth().getState().equals("healthy") ) { rval = true; break; } } listener.getLogger().println(res.toString()); return rval; }
Example 2
Source File: ELBIsInstanceDeregisteredStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected Boolean run() throws Exception { TaskListener listener = this.getContext().get(TaskListener.class); listener.getLogger().println("elbIsInstanceDeregistered instanceID: " + this.step.instanceID + " port: " + this.step.port + " from targetGroupARN: " + this.step.targetGroupARN); Boolean rval = true; AmazonElasticLoadBalancing client = AWSClientFactory.create(AmazonElasticLoadBalancingClientBuilder.standard(), this.getEnvVars()); DescribeTargetHealthRequest req = new DescribeTargetHealthRequest().withTargetGroupArn(this.step.targetGroupARN); DescribeTargetHealthResult res = client.describeTargetHealth(req); List<TargetHealthDescription> targets = res.getTargetHealthDescriptions(); for (TargetHealthDescription target : targets) { if (target.getTarget().getId().equals(this.step.instanceID) ) { rval = false; break; } } listener.getLogger().println(res.toString()); return rval; }
Example 3
Source File: ApplicationLoadBalancer.java From Baragon with Apache License 2.0 | 5 votes |
@Override public boolean isInstanceHealthy(String instanceId, String elbName) { DescribeTargetHealthRequest healthRequest = new DescribeTargetHealthRequest() .withTargets(new TargetDescription().withId(instanceId)); DescribeTargetHealthResult result = elbClient.describeTargetHealth(healthRequest); for (TargetHealthDescription health: result.getTargetHealthDescriptions()) { if (health.getTargetHealth().getState().equals(TargetHealthStateEnum.Healthy.toString()) && health.getTarget().getId().equals(instanceId)) { return true; } } return false; }