public void merge(final VersionControlInformationEntity clientEntity, final Map<NodeIdentifier, VersionControlInformationEntity> entityMap) { final VersionControlInformationDTO clientDto = clientEntity.getVersionControlInformation(); // We need to merge the 'current' and 'modified' flags because these are updated by nodes in the background. Since // the nodes can synchronize with the Flow Registry at different intervals, we have to determine how to handle these // flags if different nodes report different values for them. entityMap.values().stream() .filter(entity -> entity != clientEntity) .forEach(entity -> { final VersionControlInformationDTO dto = entity.getVersionControlInformation(); updateFlowState(clientDto, dto); }); }
public VersionControlInformationEntity createVersionControlInformationEntity(final VersionControlInformationDTO dto, final RevisionDTO processGroupRevision) { final VersionControlInformationEntity entity = new VersionControlInformationEntity(); entity.setVersionControlInformation(dto); entity.setProcessGroupRevision(processGroupRevision); return entity; }
if (entity == null) { final ProcessGroupEntity processGroup = serviceFacade.getProcessGroup(groupId); entity = new VersionControlInformationEntity(); entity.setProcessGroupRevision(processGroup.getRevision());
final RevisionDTO revisionDto = requestEntity.getProcessGroupRevision(); if (revisionDto == null) { throw new IllegalArgumentException("Process Group Revision must be specified"); final VersionControlInformationDTO requestVersionControlInfoDto = requestEntity.getVersionControlInformation(); if (requestVersionControlInfoDto == null) { throw new IllegalArgumentException("Version Control Information must be supplied."); verifyDisconnectedNodeModification(requestEntity.isDisconnectedNodeAcknowledged()); final VersionedFlowSnapshot flowSnapshot = serviceFacade.getVersionedFlowSnapshot(requestEntity.getVersionControlInformation(), true); replicateRequest, flowSnapshot); final Revision requestRevision = getRevision(requestEntity.getProcessGroupRevision(), groupId); return withWriteLock( serviceFacade, (revision, wrapper) -> { final VersionControlInformationEntity versionControlInformationEntity = wrapper.getVersionControlInformationEntity(); final VersionControlInformationDTO versionControlInformationDTO = versionControlInformationEntity.getVersionControlInformation(); final VersionControlInformationDTO currentVersion = currentVersionEntity.getVersionControlInformation(); if (!currentVersion.getBucketId().equals(versionControlInformationDTO.getBucketId())) { throw new IllegalArgumentException("The Version Control Information provided does not match the flow that the Process Group is currently synchronized with.");
final RevisionDTO revisionDto = requestEntity.getProcessGroupRevision(); if (revisionDto == null) { throw new IllegalArgumentException("Process Group Revision must be specified"); final VersionControlInformationDTO requestVersionControlInfoDto = requestEntity.getVersionControlInformation(); if (requestVersionControlInfoDto == null) { throw new IllegalArgumentException("Version Control Information must be supplied."); verifyDisconnectedNodeModification(requestEntity.isDisconnectedNodeAcknowledged()); final VersionedFlowSnapshot flowSnapshot = serviceFacade.getVersionedFlowSnapshot(requestEntity.getVersionControlInformation(), true); replicateRequest, flowSnapshot); final Revision requestRevision = getRevision(requestEntity.getProcessGroupRevision(), groupId); return withWriteLock( serviceFacade,
@Override public VersionControlInfoResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException, MissingOptionException, CommandException { final String pgId = getRequiredArg(properties, CommandOption.PG_ID); final VersionControlInformationEntity entity = client.getVersionsClient().getVersionControlInfo(pgId); if (entity.getVersionControlInformation() == null) { throw new NiFiClientException("Process group is not under version control"); } return new VersionControlInfoResult(getResultType(properties), entity); }
final VersionControlInformationDTO updatedVci = updatedGroup.getComponent().getVersionControlInformation(); final VersionControlInformationEntity responseEntity = new VersionControlInformationEntity(); responseEntity.setProcessGroupRevision(updatedGroup.getRevision()); responseEntity.setVersionControlInformation(updatedVci);
snapshotEntity.setRegistryId(requestEntity.getVersionControlInformation().getRegistryId()); snapshotEntity.setVersionedFlow(flowSnapshot); snapshotEntity.setUpdateDescendantVersionedFlows(updateDescendantVersionedFlows); final VersionControlInformationDTO requestVci = requestEntity.getVersionControlInformation();
@Override protected void writeSimpleResult(final PrintStream output) { final VersionControlInformationDTO dto = versionControlInformationEntity.getVersionControlInformation(); if (dto == null) { return; } final Table table = new Table.Builder() .column("Registry", 20, 30, true) .column("Bucket", 20, 30, true) .column("Flow", 20, 30, true) .column("Ver", 3, 3, false) .build(); table.addRow( dto.getRegistryName(), dto.getBucketName(), dto.getFlowName(), String.valueOf(dto.getVersion()) ); final TableWriter tableWriter = new DynamicTableWriter(); tableWriter.write(table, output); }
@Override public VersionedFlowSnapshotMetadataSetResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException, MissingOptionException { final String pgId = getRequiredArg(properties, CommandOption.PG_ID); final VersionsClient versionsClient = client.getVersionsClient(); final VersionControlInformationEntity existingVersionControlInfo = versionsClient.getVersionControlInfo(pgId); final VersionControlInformationDTO existingVersionControlDTO = existingVersionControlInfo.getVersionControlInformation(); if (existingVersionControlDTO == null) { throw new NiFiClientException("Process group is not under version control"); } final String registryId = existingVersionControlDTO.getRegistryId(); final String bucketId = existingVersionControlDTO.getBucketId(); final String flowId = existingVersionControlDTO.getFlowId(); final FlowClient flowClient = client.getFlowClient(); final VersionedFlowSnapshotMetadataSetEntity versions = flowClient.getVersions(registryId, bucketId, flowId); if (versions.getVersionedFlowSnapshotMetadataSet() == null || versions.getVersionedFlowSnapshotMetadataSet().isEmpty()) { throw new NiFiClientException("No versions available"); } return new VersionedFlowSnapshotMetadataSetResult(getResultType(properties), versions); }
final VersionControlInformationDTO existingVersionControlDTO = existingVersionControlInfo.getVersionControlInformation();
private Response retrieveRequest(final String requestType, final String requestId) { if (requestId == null) { throw new IllegalArgumentException("Request ID must be specified."); } final NiFiUser user = NiFiUserUtils.getNiFiUser(); // request manager will ensure that the current is the user that submitted this request final AsynchronousWebRequest<VersionControlInformationEntity> asyncRequest = requestManager.getRequest(requestType, requestId, user); final VersionedFlowUpdateRequestDTO updateRequestDto = new VersionedFlowUpdateRequestDTO(); updateRequestDto.setComplete(asyncRequest.isComplete()); updateRequestDto.setFailureReason(asyncRequest.getFailureReason()); updateRequestDto.setLastUpdated(asyncRequest.getLastUpdated()); updateRequestDto.setProcessGroupId(asyncRequest.getProcessGroupId()); updateRequestDto.setRequestId(requestId); updateRequestDto.setUri(generateResourceUri("versions", requestType, requestId)); updateRequestDto.setState(asyncRequest.getState()); updateRequestDto.setPercentCompleted(asyncRequest.getPercentComplete()); if (updateRequestDto.isComplete()) { final VersionControlInformationEntity vciEntity = serviceFacade.getVersionControlInformation(asyncRequest.getProcessGroupId()); updateRequestDto.setVersionControlInformation(vciEntity == null ? null : vciEntity.getVersionControlInformation()); } final RevisionDTO groupRevision = serviceFacade.getProcessGroup(asyncRequest.getProcessGroupId()).getRevision(); final VersionedFlowUpdateRequestEntity updateRequestEntity = new VersionedFlowUpdateRequestEntity(); updateRequestEntity.setProcessGroupRevision(groupRevision); updateRequestEntity.setRequest(updateRequestDto); return generateOkResponse(updateRequestEntity).build(); }
updateRequestDto.setVersionControlInformation(vciEntity == null ? null : vciEntity.getVersionControlInformation());