/** * This method binds a service config to this unit service panel. * Make sure the remote unit was initialized before and the service config is compatible with this unit. * * @param serviceConfig the new service config to bind to this unit remote. * @throws CouldNotPerformException is thrown if any error occurs during the binding process. * @throws InterruptedException */ public void bindServiceConfig(final ServiceConfig serviceConfig) throws CouldNotPerformException, InterruptedException { try { if (unitRemote == null) { throw new InvalidStateException("The unit remote is unknown!!"); } setServiceConfig(serviceConfig); // updateDynamicComponents(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not bind ServiceConfig[" + serviceConfig.getServiceDescription().getType() + "] on UnitRemote[" + unitRemote.getScope() + "]!", ex); } }
resourceAllocation.addResourceIds(ScopeGenerator.generateStringRep(getScope()));
private ActionDescription updateActionDescriptionForUnit(ActionDescription actionDescription, UnitRemote unitRemote) throws CouldNotPerformException { // create new builder and copy fields ActionDescription.Builder unitActionDescription = ActionDescription.newBuilder(actionDescription); // get a new resource allocation id ActionDescriptionProcessor.updateResourceAllocationId(unitActionDescription); // update the action chain ActionDescriptionProcessor.updateActionChain(unitActionDescription, actionDescription); // resource ids should only contain that unit ResourceAllocation.Builder unitResourceAllocation = unitActionDescription.getResourceAllocationBuilder(); unitResourceAllocation.clearResourceIds(); unitResourceAllocation.addResourceIds(ScopeGenerator.generateStringRep(unitRemote.getScope())); // update the id in the serviceStateDescription to that of the unit ServiceStateDescription.Builder serviceStateDescription = unitActionDescription.getServiceStateDescriptionBuilder(); serviceStateDescription.setUnitId((String) unitRemote.getId()); return unitActionDescription.build(); }
Collection<UnitRemote> units = (Collection<UnitRemote>) multiUnitServiceFusion.getServiceRemote(serviceType).getInternalUnits(actionDescription.getServiceStateDescription().getUnitType()); for (UnitRemote unit : units) { scopeUnitMap.put(ScopeGenerator.generateStringRep(unit.getScope()), unit); scopeUnitMap.put(ScopeGenerator.generateStringRep(unitRemote.getScope()), unitRemote);
resourceAllocation.setPolicy(policy); resourceAllocation.setPriority(priority); resourceAllocation.addResourceIds(ScopeGenerator.generateStringRep(unitRemote.getScope()));