@Override public RevisionUpdate<ActivateControllerServicesEntity> update() { // schedule the components processGroupDAO.activateControllerServices(processGroupId, state, serviceRevisions.keySet()); // update the revisions final Map<String, Revision> updatedRevisions = new HashMap<>(); for (final Revision revision : serviceRevisions.values()) { final Revision currentRevision = revisionManager.getRevision(revision.getComponentId()); updatedRevisions.put(revision.getComponentId(), currentRevision.incrementRevision(revision.getClientId())); } // save controllerFacade.save(); // gather details for response final ActivateControllerServicesEntity entity = new ActivateControllerServicesEntity(); entity.setId(processGroupId); entity.setState(state.name()); return new StandardRevisionUpdate<>(entity, null, new HashSet<>(updatedRevisions.values())); } });
if (!id.equals(requestEntity.getId())) { throw new IllegalArgumentException(String.format("The process group id (%s) in the request body does " + "not equal the process group id of the requested resource (%s).", requestEntity.getId(), id)); if (requestEntity.getState() == null) { throw new IllegalArgumentException("The controller service state must be specified."); } else { try { desiredState = ControllerServiceState.valueOf(requestEntity.getState()); } catch (final IllegalArgumentException iae) { throw new IllegalArgumentException(String.format("The controller service state must be one of [%s].", if (requestEntity.getComponents() == null) { requestEntity.setComponents(componentsToSchedule); return replicate(HttpMethod.PUT, requestEntity); } else if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestEntity.isDisconnectedNodeAcknowledged()); final Map<String, RevisionDTO> requestComponentsToSchedule = requestEntity.getComponents(); final Map<String, Revision> requestComponentRevisions = requestComponentsToSchedule.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> getRevision(e.getValue(), e.getKey()))); () -> serviceFacade.verifyActivateControllerServices(id, desiredState, requestComponentRevisions.keySet()), (revisions, scheduleComponentsEntity) -> { final ControllerServiceState serviceState = ControllerServiceState.valueOf(scheduleComponentsEntity.getState()); final Map<String, RevisionDTO> componentsToSchedule = scheduleComponentsEntity.getComponents();
Collectors.toMap(Map.Entry::getKey, entry -> dtoFactory.createRevisionDTO(entry.getValue()))); final ActivateControllerServicesEntity activateServicesEntity = new ActivateControllerServicesEntity(); activateServicesEntity.setComponents(serviceRevisionDtoMap); activateServicesEntity.setId(groupId); activateServicesEntity.setState(desiredState.name());
@Override public ActivateControllerServicesEntity activateControllerServices(final ActivateControllerServicesEntity activateControllerServicesEntity) throws NiFiClientException, IOException { if (activateControllerServicesEntity == null) { throw new IllegalArgumentException("Entity cannot be null"); } if (StringUtils.isBlank(activateControllerServicesEntity.getId())) { throw new IllegalArgumentException("Entity must contain a process group id"); } return executeAction("Error enabling or disabling controlling services", () -> { final WebTarget target = flowTarget .path("process-groups/{id}/controller-services") .resolveTemplate("id", activateControllerServicesEntity.getId()); return getRequestBuilder(target).put( Entity.entity(activateControllerServicesEntity, MediaType.APPLICATION_JSON_TYPE), ActivateControllerServicesEntity.class); }); }
Collectors.toMap(Map.Entry::getKey, entry -> dtoFactory.createRevisionDTO(entry.getValue()))); final ActivateControllerServicesEntity activateServicesEntity = new ActivateControllerServicesEntity(); activateServicesEntity.setComponents(serviceRevisionDtoMap); activateServicesEntity.setId(groupId); activateServicesEntity.setState(desiredState.name());
final ActivateControllerServicesEntity enableEntity = new ActivateControllerServicesEntity(); enableEntity.setId(pgId); enableEntity.setState(ActivateControllerServicesEntity.STATE_ENABLED);
final ActivateControllerServicesEntity disableEntity = new ActivateControllerServicesEntity(); disableEntity.setId(pgId); disableEntity.setState(ActivateControllerServicesEntity.STATE_DISABLED);