private void monitorInstances(AmazonEC2Client ec2Client, Exchange exchange) { Collection instanceIds; MonitorInstancesRequest request = new MonitorInstancesRequest(); if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS))) { instanceIds = exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS, Collection.class); request.withInstanceIds(instanceIds); } else { throw new IllegalArgumentException("Instances Ids must be specified"); } MonitorInstancesResult result; try { result = ec2Client.monitorInstances(request); } catch (AmazonServiceException ase) { LOG.trace("Monitor Instances command returned the error code {}", ase.getErrorCode()); throw ase; } LOG.trace("Start Monitoring instances with Ids [{}] ", Arrays.toString(instanceIds.toArray())); Message message = getMessageForResponse(exchange); message.setBody(result); }
@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; }
@Override public MonitorInstancesResult monitor(MonitorInstancesRequest request, ResultCapture<MonitorInstancesResult> extractor) { ActionResult result = resource.performAction("Monitor", request, extractor); if (result == null) return null; return (MonitorInstancesResult) result.getData(); }
@Override public MonitorInstancesResult monitor(ResultCapture<MonitorInstancesResult> extractor) { MonitorInstancesRequest request = new MonitorInstancesRequest(); return monitor(request, extractor); }
@Override public MonitorInstancesResult monitorInstances(MonitorInstancesRequest monitorInstancesRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public MonitorInstancesResult monitor(MonitorInstancesRequest request) { return monitor(request, null); }
@Override public MonitorInstancesResult monitor() { return monitor((ResultCapture<MonitorInstancesResult>)null); }
/** * Performs the <code>Monitor</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Instance</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>InstanceIds.0</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The response of the low-level client operation associated with * this resource action. * @see MonitorInstancesRequest */ MonitorInstancesResult monitor(MonitorInstancesRequest request);
/** * Performs the <code>Monitor</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Instance</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>InstanceIds.0</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The response of the low-level client operation associated with * this resource action. * @see MonitorInstancesRequest */ MonitorInstancesResult monitor(MonitorInstancesRequest request, ResultCapture<MonitorInstancesResult> extractor);
/** * The convenient method form for the <code>Monitor</code> action. * * @see #monitor(MonitorInstancesRequest) */ MonitorInstancesResult monitor();
/** * The convenient method form for the <code>Monitor</code> action. * * @see #monitor(MonitorInstancesRequest, ResultCapture) */ MonitorInstancesResult monitor(ResultCapture<MonitorInstancesResult> extractor);