use of com.amazonaws.services.ec2.model.Monitoring in project camel by apache.
the class AmazonEC2ClientMock method monitorInstances.
@Override
public MonitorInstancesResult monitorInstances(MonitorInstancesRequest monitorInstancesRequest) {
MonitorInstancesResult result = new MonitorInstancesResult();
if (!monitorInstancesRequest.getInstanceIds().isEmpty()) {
Collection<InstanceMonitoring> coll = new ArrayList();
Iterator it = monitorInstancesRequest.getInstanceIds().iterator();
while (it.hasNext()) {
String id = (String) it.next();
InstanceMonitoring mon = new InstanceMonitoring();
mon.setInstanceId(id);
Monitoring monitoring = new Monitoring();
monitoring.setState(MonitoringState.Enabled);
mon.setMonitoring(monitoring);
coll.add(mon);
}
result.setInstanceMonitorings(coll);
}
return result;
}
use of com.amazonaws.services.ec2.model.Monitoring in project camel by apache.
the class AmazonEC2ClientMock method unmonitorInstances.
@Override
public UnmonitorInstancesResult unmonitorInstances(UnmonitorInstancesRequest unmonitorInstancesRequest) {
UnmonitorInstancesResult result = new UnmonitorInstancesResult();
if (!unmonitorInstancesRequest.getInstanceIds().isEmpty()) {
Collection<InstanceMonitoring> coll = new ArrayList();
Iterator it = unmonitorInstancesRequest.getInstanceIds().iterator();
while (it.hasNext()) {
String id = (String) it.next();
InstanceMonitoring mon = new InstanceMonitoring();
mon.setInstanceId(id);
Monitoring monitoring = new Monitoring();
monitoring.setState(MonitoringState.Disabled);
mon.setMonitoring(monitoring);
coll.add(mon);
}
result.setInstanceMonitorings(coll);
}
return result;
}
use of com.amazonaws.services.ec2.model.Monitoring in project aws-doc-sdk-examples by awsdocs.
the class MonitorInstance method monitorInstance.
public static void monitorInstance(String instance_id) {
final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
DryRunSupportedRequest<MonitorInstancesRequest> dry_request = () -> {
MonitorInstancesRequest request = new MonitorInstancesRequest().withInstanceIds(instance_id);
return request.getDryRunRequest();
};
DryRunResult dry_response = ec2.dryRun(dry_request);
if (!dry_response.isSuccessful()) {
System.out.printf("Failed dry run to enable monitoring on instance %s", instance_id);
throw dry_response.getDryRunResponse();
}
MonitorInstancesRequest request = new MonitorInstancesRequest().withInstanceIds(instance_id);
ec2.monitorInstances(request);
System.out.printf("Successfully enabled monitoring for instance %s", instance_id);
}
Aggregations