use of org.apache.nifi.controller.exception.CommunicationsException in project nifi by apache.
the class StandardRemoteProcessGroup method isSecure.
@Override
public boolean isSecure() throws CommunicationsException {
Boolean secure;
readLock.lock();
try {
secure = this.destinationSecure;
if (secure != null) {
return secure;
}
} finally {
readLock.unlock();
}
refreshFlowContents();
readLock.lock();
try {
secure = this.destinationSecure;
if (secure == null) {
throw new CommunicationsException("Unable to determine whether or not site-to-site communications with peer should be secure");
}
return secure;
} finally {
readLock.unlock();
}
}
use of org.apache.nifi.controller.exception.CommunicationsException in project nifi by apache.
the class StandardRemoteProcessGroup method refreshFlowContents.
@Override
public void refreshFlowContents() throws CommunicationsException {
if (!initialized) {
return;
}
try {
// perform the request
final ControllerDTO dto;
try (final SiteToSiteRestApiClient apiClient = getSiteToSiteRestApiClient()) {
dto = apiClient.getController(targetUris);
} catch (IOException e) {
throw new CommunicationsException("Unable to communicate with Remote NiFi at URI " + targetUris + " due to: " + e.getMessage());
}
writeLock.lock();
try {
if (dto.getInputPorts() != null) {
setInputPorts(convertRemotePort(dto.getInputPorts()), true);
}
if (dto.getOutputPorts() != null) {
setOutputPorts(convertRemotePort(dto.getOutputPorts()), true);
}
// set the controller details
setTargetId(dto.getId());
setName(dto.getName());
setComments(dto.getComments());
// get the component counts
int inputPortCount = 0;
if (dto.getInputPortCount() != null) {
inputPortCount = dto.getInputPortCount();
}
int outputPortCount = 0;
if (dto.getOutputPortCount() != null) {
outputPortCount = dto.getOutputPortCount();
}
this.listeningPort = dto.getRemoteSiteListeningPort();
this.listeningHttpPort = dto.getRemoteSiteHttpListeningPort();
this.destinationSecure = dto.isSiteToSiteSecure();
final RemoteProcessGroupCounts newCounts = new RemoteProcessGroupCounts(inputPortCount, outputPortCount);
setCounts(newCounts);
this.refreshContentsTimestamp = System.currentTimeMillis();
} finally {
writeLock.unlock();
}
} catch (final IOException e) {
throw new CommunicationsException(e);
}
}
Aggregations