List of usage examples for java.rmi RemoteException RemoteException
public RemoteException(String s)
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.defaults.DefaultDescribeSI.java
public DescribeSpotInstanceRequestsResponseType describeSIRequests(DescribeSpotInstanceRequestsType req, Caller caller, Manager manager) throws RemoteException { if (manager == null) { throw new IllegalArgumentException("manager may not be null"); }/* w ww . j ava 2s .com*/ if (caller == null) { throw new IllegalArgumentException("caller may not be null"); } if (req == null) { throw new IllegalArgumentException("req may not be null"); } SpotInstanceRequestIdSetItemType[] sirisi = req.getSpotInstanceRequestIdSet().getItem(); SpotRequestInfo[] spotRequests = null; if (sirisi != null) { String[] reqIds = new String[sirisi.length]; for (int i = 0; i < sirisi.length; i++) { reqIds[i] = sirisi[i].getSpotInstanceRequestId().trim(); } try { if (reqIds.length > 0) { spotRequests = manager.getSpotRequests(reqIds, caller); } else { spotRequests = manager.getSpotRequestsByCaller(caller); } } catch (ManageException e) { final String msg = "Problem retrieving SI request: " + Arrays.toString(reqIds) + ": "; if (logger.isDebugEnabled()) { logger.error(msg + e.getMessage(), e); } else { logger.error(msg + e.getMessage()); } } catch (Exception e) { logger.warn(e.getMessage(), e); throw new RemoteException("Invalid request ID."); } } DescribeSpotInstanceRequestsResponseType dsirrt = new DescribeSpotInstanceRequestsResponseType(); if (spotRequests != null) { SpotInstanceRequestSetItemType[] sirsti = new SpotInstanceRequestSetItemType[spotRequests.length]; for (int i = 0; i < spotRequests.length; i++) { try { sirsti[i] = translateSpotInfo(spotRequests[i]); } catch (Exception e) { final String err = "Problem translating valid spot instance " + "request into elastic protocol." + " Error: " + e.getMessage(); logger.warn(err, e); } } SpotInstanceRequestSetType sirst = new SpotInstanceRequestSetType(); sirst.setItem(sirsti); dsirrt.setSpotInstanceRequestSet(sirst); } return dsirrt; }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.defaults.DefaultDescribeSpotPriceHistory.java
public DescribeSpotPriceHistoryResponseType describeSpotPriceHistory(DescribeSpotPriceHistoryType req, Manager manager) throws RemoteException { String supportedType = RAs.getSpotInstanceType(); InstanceTypeSetItemType[] instanceType = req.getInstanceTypeSet().getItem(); if (instanceType != null && instanceType.length > 0 && !supportedType.equals(instanceType[0].getInstanceType())) { throw new RemoteException("Unsupported spot instance type: '" + instanceType[0] + "'." + " Currently supported SI type: " + supportedType); }/*from w w w . j a v a2 s . co m*/ SpotPriceEntry[] spotPriceHistory = null; try { spotPriceHistory = manager.getSpotPriceHistory(req.getStartTime(), req.getEndTime()); } catch (ManageException e) { final String msg = "Problem retrieving spot price history : "; if (logger.isDebugEnabled()) { logger.error(msg + e.getMessage(), e); } else { logger.error(msg + e.getMessage()); } } DescribeSpotPriceHistoryResponseType result = new DescribeSpotPriceHistoryResponseType(); if (spotPriceHistory != null) { SpotPriceHistorySetItemType[] items = new SpotPriceHistorySetItemType[spotPriceHistory.length]; for (int i = 0; i < spotPriceHistory.length; i++) { SpotPriceEntry spotPriceEntry = spotPriceHistory[i]; SpotPriceHistorySetItemType item = new SpotPriceHistorySetItemType(); item.setInstanceType(supportedType); item.setTimestamp(spotPriceEntry.getTimeStamp()); item.setSpotPrice(spotPriceHistory[i].getSpotPrice().toString()); items[i] = item; } SpotPriceHistorySetType spotPriceHistorySet = new SpotPriceHistorySetType(); spotPriceHistorySet.setItem(items); result.setSpotPriceHistorySet(spotPriceHistorySet); } return result; }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.defaults.DefaultTerminate.java
public TerminateInstancesResponseType terminate(TerminateInstancesType req, Caller caller, Manager manager) throws RemoteException { if (manager == null) { throw new IllegalArgumentException("manager may not be null"); }// w w w. j a va 2 s . c o m if (caller == null) { throw new IllegalArgumentException("caller may not be null"); } if (req == null) { throw new IllegalArgumentException("req may not be null"); } final String[] elasticInstIDs = this.getElasticIDs(req); if (elasticInstIDs.length == 0) { throw new RemoteException("No instance IDs in termination request"); } final String[] managerInstances = this.translateIDs(elasticInstIDs); // currentStates array needs to be same length as managerInstances and // elasticInstanceIDs, used to correlate later final InstanceStateType[] currentStates = new InstanceStateType[managerInstances.length]; for (int i = 0; i < managerInstances.length; i++) { final String mgrInstanceID = managerInstances[i]; try { final VM vm = manager.getInstance(mgrInstanceID); if (vm != null) { final State state = vm.getState(); if (state != null) { final String mgrState = state.getState(); final InstanceStateType ist = new InstanceStateType(); ist.setName(StateMap.managerStringToElasticString(mgrState)); ist.setCode(StateMap.managerStringToElasticInt(mgrState)); currentStates[i] = ist; } } } catch (DoesNotExistException e) { currentStates[i] = null; } catch (ManageException e) { currentStates[i] = null; logger.error(e.getMessage()); } } for (int i = 0; i < managerInstances.length; i++) { if (currentStates[i] == null) { continue; } final String mgrID = managerInstances[i]; try { manager.trash(mgrID, Manager.INSTANCE, caller); } catch (DoesNotExistException e) { // do nothing, already accomplished } catch (ManageException e) { if (logger.isDebugEnabled()) { logger.error(e.getMessage(), e); } else { logger.error(e.getMessage()); } } } final InstanceStateType terminated = new InstanceStateType(); terminated.setCode(StateMap.STATE_TERMINATED.intValue()); terminated.setName(StateMap.STATE_TERMINATED_STR); final InstanceStateType[] newStates = new InstanceStateType[managerInstances.length]; for (int i = 0; i < managerInstances.length; i++) { if (currentStates[i] == null) { continue; } final String mgrInstanceID = managerInstances[i]; try { final VM vm = manager.getInstance(mgrInstanceID); if (vm != null) { final State state = vm.getState(); if (state != null) { final String mgrState = state.getState(); final InstanceStateType ist = new InstanceStateType(); ist.setName(StateMap.managerStringToElasticString(mgrState)); ist.setCode(StateMap.managerStringToElasticInt(mgrState)); newStates[i] = ist; } } } catch (DoesNotExistException e) { newStates[i] = terminated; } catch (ManageException e) { newStates[i] = terminated; logger.error(e.getMessage()); } } final List<InstanceStateChangeType> retList = new LinkedList<InstanceStateChangeType>(); for (int i = 0; i < newStates.length; i++) { if (currentStates[i] == null) { continue; } retList.add(new InstanceStateChangeType(currentStates[i], elasticInstIDs[i], newStates[i])); } final InstanceStateChangeType[] tirits = retList.toArray(new InstanceStateChangeType[retList.size()]); final InstanceStateChangeSetType tirtSet = new InstanceStateChangeSetType(); tirtSet.setItem(tirits); final TerminateInstancesResponseType tirt = new TerminateInstancesResponseType(); tirt.setInstancesSet(tirtSet); return tirt; }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public RunInstancesResponseType runInstances(RunInstancesType req) throws RemoteException { if (req == null) { throw new RemoteException("RunInstancesType request is missing"); }/*from ww w. ja v a 2 s.c o m*/ final Caller caller = this.container.getCaller(); final CreateResult result; try { CreateRequest creq = this.run.translateRunInstances(req, caller); AddCustomizations.addAll((_CreateRequest) creq, this.repr, this.mdServer); result = this.manager.create(creq, caller); } catch (IdempotentCreationMismatchException e) { // need to expose this error specifically in query responses. // would be better to have a more general way of handling EC2 // server error responses for both SOAP and Query throw new IdempotentCreationMismatchRemoteException(e.getMessage(), e); } catch (ResourceRequestDeniedException e) { throw new ResourceRequestDeniedRemoteException(e.getMessage(), e); } catch (Exception e) { throw new RemoteException(e.getMessage(), e); } final String keyname = req.getKeyName(); try { return this.run.translateCreateResult(result, caller, keyname); } catch (Exception e) { final String err = "Problem translating valid creation " + "result into elastic protocol. Backout required. " + " Error: " + e.getMessage(); logger.error(err, e); this.terminate.backOutCreateResult(result, caller, this.manager); // gets caught by Throwable hook: throw new RuntimeException(err, e); } }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public RebootInstancesResponseType rebootInstances(RebootInstancesType req) throws RemoteException { if (req == null) { throw new RemoteException("DescribeInstancesType request is missing"); }//from ww w . j av a 2 s .com final Caller caller = this.container.getCaller(); final boolean result = this.reboot.reboot(req, caller, this.manager); return new RebootInstancesResponseType(result, ""); // TODO do something real with requestId }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public DescribeInstancesResponseType describeInstances(DescribeInstancesType req) throws RemoteException { if (req == null) { throw new RemoteException("DescribeInstancesType request is missing"); }//from w w w. j a v a 2s . co m final Caller caller = this.container.getCaller(); try { final String[] instanceIDs = this.describe.findQueryIDs(req); final VM[] vms = this.manager.getAllByCaller(caller); final String ownerID = this.container.getOwnerID(caller); return this.describe.translate(vms, instanceIDs, ownerID); } catch (ManageException e) { throw new RemoteException(e.getMessage(), e); } catch (CannotTranslateException e) { throw new RemoteException(e.getMessage(), e); } }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public TerminateInstancesResponseType terminateInstances(TerminateInstancesType req) throws RemoteException { if (req == null) { throw new RemoteException("TerminateInstancesType request is missing"); }//from ww w . jav a2s . co m final Caller caller = this.container.getCaller(); return this.terminate.terminate(req, caller, this.manager); }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public RequestSpotInstancesResponseType requestSpotInstances(RequestSpotInstancesType req) throws RemoteException { if (req == null) { throw new RemoteException("requestSpotInstances request is missing"); }//from w ww .j a va 2 s .co m final Caller caller = this.container.getCaller(); return this.reqSI.requestSpotInstances(req, caller, this.manager); }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public CancelSpotInstanceRequestsResponseType cancelSpotInstanceRequests(CancelSpotInstanceRequestsType req) throws RemoteException { if (req == null) { throw new RemoteException("CancelSpotInstanceRequestsType request is missing"); }//from w ww .j a v a 2 s . c o m final Caller caller = this.container.getCaller(); return this.cancelSI.cancelSIRequests(req, caller, this.manager); }
From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.rm.ServiceRMImpl.java
public DescribeSpotInstanceRequestsResponseType describeSpotInstanceRequests( DescribeSpotInstanceRequestsType req) throws RemoteException { if (req == null) { throw new RemoteException("CancelSpotInstanceRequestsType request is missing"); }/* www. jav a2 s . com*/ final Caller caller = this.container.getCaller(); return this.describeSI.describeSIRequests(req, caller, manager); }