Search in sources :

Example 1 with CommunicationsException

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();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CommunicationsException(org.apache.nifi.controller.exception.CommunicationsException)

Example 2 with CommunicationsException

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);
    }
}
Also used : RemoteProcessGroupCounts(org.apache.nifi.groups.RemoteProcessGroupCounts) SiteToSiteRestApiClient(org.apache.nifi.remote.util.SiteToSiteRestApiClient) ControllerDTO(org.apache.nifi.web.api.dto.ControllerDTO) IOException(java.io.IOException) CommunicationsException(org.apache.nifi.controller.exception.CommunicationsException)

Aggregations

CommunicationsException (org.apache.nifi.controller.exception.CommunicationsException)2 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 RemoteProcessGroupCounts (org.apache.nifi.groups.RemoteProcessGroupCounts)1 SiteToSiteRestApiClient (org.apache.nifi.remote.util.SiteToSiteRestApiClient)1 ControllerDTO (org.apache.nifi.web.api.dto.ControllerDTO)1