protected String getCommandName(ProcessState state, ProcessInstance process, Object eventResource, Object dataResource, Object agentResource) { if (commandName != null) { return commandName; } else { return process.getName(); } }
@Override protected Object getDataResource(ProcessState state, ProcessInstance process) { if (process.getName().equalsIgnoreCase(VolumeConstants.PROCESS_REVERT)) { Snapshot snapshot = objectManager.loadResource(Snapshot.class, state.getData().get("snapshotId").toString()); return snapshot; } else if (process.getName().equalsIgnoreCase(VolumeConstants.PROCESS_RESTORE_FROM_BACKUP)) { Backup backup = objectManager.loadResource(Backup .class, state.getData().get("backupId").toString()); return backup; } throw new IllegalStateException("Unsupported process: " + process.getName()); } }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { Service service = (Service)state.getResource(); sdService.registerServiceLinks(service); registerInstances(service); if (process.getName().equalsIgnoreCase(ServiceConstants.PROCESS_SERVICE_UPDATE)) { cleanupOldSelectorLinks(state, service); } return null; }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { Volume volume = (Volume)state.getResource(); List<Snapshot> snapshots = null; if (VolumeConstants.PROCESS_RESTORE_FROM_BACKUP.equalsIgnoreCase(process.getName())) { snapshots = objectManager.children(volume, Snapshot.class); } else if (VolumeConstants.PROCESS_REVERT.equalsIgnoreCase(process.getName())) { Snapshot snapshot = objectManager.loadResource(Snapshot.class, state.getData().get("snapshotId").toString()); Map<Object, Object> criteria = new HashMap<Object, Object>(); criteria.put(SNAPSHOT.VOLUME_ID, volume.getId()); criteria.put(SNAPSHOT.REMOVED, null); criteria.put(SNAPSHOT.ID, new Condition(ConditionType.GT, snapshot.getId())); snapshots = objectManager.find(Snapshot.class, criteria); } else { throw new IllegalStateException("Unknown process: " + process.getName()); } for (Snapshot s : snapshots) { if (s.getRemoved() == null) { objectProcessManager.scheduleStandardProcess(StandardProcess.REMOVE, s, null); } } return null; }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { final Service service = (Service) state.getResource(); // on inactive service update, do nothing if (process.getName().equalsIgnoreCase(ServiceConstants.PROCESS_SERVICE_UPDATE) && service.getState().equalsIgnoreCase(CommonStatesConstants.UPDATING_INACTIVE)) { return null; } activity.run(service, process.getName(), getMessage(process.getName()), new Runnable() { @Override public void run() { waitForConsumedServicesActivate(state, service); deploymentMgr.activate(service); } }); objectManager.reload(state.getResource()); return new HandlerResult(ServiceConstants.FIELD_CURRENT_SCALE, exposeDao.getCurrentScale(service.getId())); }
counters.get(e.getExitReason()).inc(); if (e.getExitReason().isError()) { log.error("Process [{}:{}] on [{}] failed, exit [{}] : {}", instance.getName(), processId, instance.getResourceId(), e .getExitReason(), e.getMessage()); log.info("Timeout on process [{}:{}] on [{}] : {}", instance.getName(), processId, instance.getResourceId(), e .getMessage()); } catch (ProcessCancelException e) { CANCELED.inc(); runRemaining = true; log.debug("Process canceled [{}:{}] on [{}] : {}", instance.getName(), processId, instance.getResourceId(), e.getMessage()); } catch (Throwable e) { if (e instanceof LoggableException) { CANCELED.inc(); log.error("Unknown exception running process [{}:{}] on [{}], canceled by [{}]", instance == null ? null : instance.getName(), processId, instance == null ? null : instance.getResourceId(), cause.getMessage()); } else { EXCEPTION.inc(); log.error("Unknown exception running process [{}:{}] on [{}]", instance == null ? null : instance.getName(), processId, instance == null ? null : instance.getResourceId(), e);
if (process.getName().equalsIgnoreCase(ServiceConstants.PROCESS_SERVICE_UPDATE)) { Object oldObj = state.getData().get("old"); if (oldObj != null) {
EventVO<Object> event = EventVO.newEvent(getCommandName() == null ? process.getName() : getCommandName()) .withData(data) .withResourceType(getObjectManager().getType(eventResource))
String eventName = getEventName() == null ? process.getName() : getEventName();