public RemoteProcessGroup createRemoteProcessGroup(final String id, final String uris) { return new StandardRemoteProcessGroup(requireNonNull(id), uris, null, processScheduler, bulletinRepository, sslContext, nifiProperties); }
@Override public void verifyCanStopTransmitting() { if (!isTransmitting()) { throw new IllegalStateException(this.getIdentifier() + " is not transmitting"); } }
@Override public void setProcessGroup(final ProcessGroup group) { this.processGroup.set(group); for (final RemoteGroupPort port : getInputPorts()) { port.setProcessGroup(group); } for (final RemoteGroupPort port : getOutputPorts()) { port.setProcessGroup(group); } }
@Override public Resource getResource() { return ResourceFactory.getComponentResource(ResourceType.RemoteProcessGroup, getIdentifier(), getName()); }
try (final SiteToSiteRestApiClient apiClient = getSiteToSiteRestApiClient()) { dto = apiClient.getController(targetUris); } catch (IOException e) { try { if (dto.getInputPorts() != null) { setInputPorts(convertRemotePort(dto.getInputPorts()), true); setOutputPorts(convertRemotePort(dto.getOutputPorts()), true); setTargetId(dto.getId()); setName(dto.getName()); setComments(dto.getComments()); setCounts(newCounts); this.refreshContentsTimestamp = System.currentTimeMillis(); } finally {
@Override public void reportEvent(final Severity severity, final String category, final String message) { final String groupId = StandardRemoteProcessGroup.this.getProcessGroup().getIdentifier(); final String groupName = StandardRemoteProcessGroup.this.getProcessGroup().getName(); final String sourceId = StandardRemoteProcessGroup.this.getIdentifier(); final String sourceName = StandardRemoteProcessGroup.this.getName(); bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, groupName, sourceId, ComponentType.REMOTE_PROCESS_GROUP, sourceName, category, severity.name(), message)); } };
private SiteToSiteRestApiClient getSiteToSiteRestApiClient() { SiteToSiteRestApiClient apiClient = new SiteToSiteRestApiClient(sslContext, new HttpProxy(proxyHost, proxyPort, proxyUser, proxyPassword), getEventReporter()); apiClient.setConnectTimeoutMillis(getCommunicationsTimeout(TimeUnit.MILLISECONDS)); apiClient.setReadTimeoutMillis(getCommunicationsTimeout(TimeUnit.MILLISECONDS)); apiClient.setLocalAddress(getLocalAddress()); apiClient.setCacheExpirationMillis(remoteContentsCacheExpiration); return apiClient; }
writeLock.lock(); try { verifyCanStopTransmitting(); for (final RemoteGroupPort port : getInputPorts()) { scheduler.stopPort(port); for (final RemoteGroupPort port : getOutputPorts()) { scheduler.stopPort(port); for (final RemoteGroupPort port : getInputPorts()) { while (port.isRunning()) { try { for (final RemoteGroupPort port : getOutputPorts()) { while (port.isRunning()) { try {
@Override public void startTransmitting() { writeLock.lock(); try { verifyCanStartTransmitting(); for (final Port port : getInputPorts()) { // if port is not valid, don't start it because it will never become valid. // Validation is based on connections and whether or not the remote target exists. if (port.isValid() && port.hasIncomingConnection()) { scheduler.startPort(port); } } for (final Port port : getOutputPorts()) { if (port.isValid() && !port.getConnections().isEmpty()) { scheduler.startPort(port); } } transmitting.set(true); } finally { writeLock.unlock(); } }
getEventReporter().reportEvent(Severity.WARNING, "Site to Site", String.format("Unable to connect to %s due to %s", StandardRemoteProcessGroup.this.getTargetUris(), e));
private String generatePortId(final String targetId) { return UUID.nameUUIDFromBytes((this.getIdentifier() + targetId).getBytes(StandardCharsets.UTF_8)).toString(); }
sendPort = inputPortByName.get(descriptor.getName()); if (sendPort == null) { sendPort = addInputPort(descriptor); } else { sendPort.setTargetIdentifier(descriptor.getTargetId());
receivePort = outputPortByName.get(descriptor.getName()); if (receivePort == null) { receivePort = addOutputPort(descriptor); } else { receivePort.setTargetIdentifier(descriptor.getTargetId());
/** * Converts a set of ports into a set of remote process group ports. * * @param ports to convert * @return descriptors of ports */ private Set<RemoteProcessGroupPortDescriptor> convertRemotePort(final Set<PortDTO> ports) { Set<RemoteProcessGroupPortDescriptor> remotePorts = null; if (ports != null) { remotePorts = new LinkedHashSet<>(ports.size()); for (final PortDTO port : ports) { final StandardRemoteProcessGroupPortDescriptor descriptor = new StandardRemoteProcessGroupPortDescriptor(); final ScheduledState scheduledState = ScheduledState.valueOf(port.getState()); descriptor.setId(generatePortId(port.getId())); descriptor.setTargetId(port.getId()); descriptor.setName(port.getName()); descriptor.setComments(port.getComments()); descriptor.setTargetRunning(ScheduledState.RUNNING.equals(scheduledState)); remotePorts.add(descriptor); } } return remotePorts; }
private File getPeerPersistenceFile() { final File stateDir = nifiProperties.getPersistentStateDirectory(); return new File(stateDir, getIdentifier() + ".peers"); }
@Override public void verifyCanUpdate() { readLock.lock(); try { if (isTransmitting()) { throw new IllegalStateException(this.getIdentifier() + " is currently transmitting"); } for (final Port port : inputPorts.values()) { if (port.isRunning()) { throw new IllegalStateException(this.getIdentifier() + " has running Port: " + port.getIdentifier()); } } for (final Port port : outputPorts.values()) { if (port.isRunning()) { throw new IllegalStateException(this.getIdentifier() + " has running Port: " + port.getIdentifier()); } } } finally { readLock.unlock(); } }
for (final Port inputPort : getInputPorts()) { if (inputPort.isRunning()) { stillTransmitting = true; for (final Port outputPort : getOutputPorts()) { if (outputPort.isRunning()) { stillTransmitting = true;
@Override public void verifyCanDelete(final boolean ignoreConnections) { readLock.lock(); try { if (isTransmitting()) { throw new IllegalStateException(this.getIdentifier() + " is transmitting"); } for (final Port port : inputPorts.values()) { if (!ignoreConnections && port.hasIncomingConnection()) { throw new IllegalStateException(this.getIdentifier() + " is the destination of another component"); } if (port.isRunning()) { throw new IllegalStateException(this.getIdentifier() + " has running Port: " + port.getIdentifier()); } } for (final Port port : outputPorts.values()) { if (!ignoreConnections) { for (final Connection connection : port.getConnections()) { connection.verifyCanDelete(); } } if (port.isRunning()) { throw new IllegalStateException(this.getIdentifier() + " has running Port: " + port.getIdentifier()); } } } finally { readLock.unlock(); } }
readLock.lock(); try { if (isTransmitting()) { throw new IllegalStateException(this.getIdentifier() + " is already transmitting"); throw new IllegalStateException(this.getIdentifier() + " has running Port: " + port.getIdentifier()); throw new IllegalStateException(this.getIdentifier() + " has a Connection to Port " + port.getIdentifier() + ", but that Port no longer exists on the remote system"); throw new IllegalStateException(this.getIdentifier() + " has running Port: " + port.getIdentifier()); throw new IllegalStateException(this.getIdentifier() + " has a Connection to Port " + port.getIdentifier() + ", but that Port no longer exists on the remote system");