use of org.apache.nifi.web.api.entity.CreateActiveRequestEntity in project nifi by apache.
the class VersionsResource method lockVersionControl.
private String lockVersionControl(final URI originalUri, final String groupId) throws URISyntaxException {
final URI createRequestUri = new URI(originalUri.getScheme(), originalUri.getUserInfo(), originalUri.getHost(), originalUri.getPort(), "/nifi-api/versions/active-requests", null, originalUri.getFragment());
final NodeResponse clusterResponse;
try {
// create an active request entity to indicate the group id
final CreateActiveRequestEntity activeRequestEntity = new CreateActiveRequestEntity();
activeRequestEntity.setProcessGroupId(groupId);
final Map<String, String> headers = new HashMap<>();
headers.put("content-type", MediaType.APPLICATION_JSON);
if (getReplicationTarget() == ReplicationTarget.CLUSTER_NODES) {
clusterResponse = getRequestReplicator().replicate(HttpMethod.POST, createRequestUri, activeRequestEntity, headers).awaitMergedResponse();
} else {
clusterResponse = getRequestReplicator().forwardToCoordinator(getClusterCoordinatorNode(), HttpMethod.POST, createRequestUri, activeRequestEntity, headers).awaitMergedResponse();
}
} catch (final InterruptedException ie) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted while updating Version Control Information for Process Group with ID " + groupId + ".", ie);
}
if (clusterResponse.getStatus() != Status.OK.getStatusCode()) {
final String errorResponse = getResponseEntity(clusterResponse, String.class);
throw new IllegalStateException("Failed to create a Version Control Request across all nodes in the cluster. Received response code " + clusterResponse.getStatus() + " with content: " + errorResponse);
}
final String requestId = getResponseEntity(clusterResponse, String.class);
return requestId;
}
Aggregations