if (dto.getInputPorts() != null) { setInputPorts(convertRemotePort(dto.getInputPorts()), true); if (dto.getOutputPorts() != null) { setOutputPorts(convertRemotePort(dto.getOutputPorts()), true); setTargetId(dto.getId()); setName(dto.getName()); setComments(dto.getComments()); if (dto.getInputPortCount() != null) { inputPortCount = dto.getInputPortCount(); if (dto.getOutputPortCount() != null) { outputPortCount = dto.getOutputPortCount(); this.listeningPort = dto.getRemoteSiteListeningPort(); this.listeningHttpPort = dto.getRemoteSiteHttpListeningPort(); this.destinationSecure = dto.isSiteToSiteSecure();
nodeController.getInputPorts().stream().forEach(inputPort -> inputPortMap.computeIfAbsent(inputPort.getId(), nodeIdToInputPort -> new HashMap<>()).put(nodeId, inputPort)); nodeController.getOutputPorts().stream().forEach(outputPort -> outputPortMap.computeIfAbsent(outputPort.getId(), nodeIdToOutputPort -> new HashMap<>()).put(nodeId, outputPort)); if (!nodeInputPorts.isEmpty()) { final PortDTO inputPort = nodeInputPorts.iterator().next(); final PortDTO clientInputPort = clientDto.getInputPorts().stream().filter(p -> p.getId().equals(inputPort.getId())).findFirst().orElse(null); if (clientInputPort != null) { PortEntityMerger.mergeDtos(clientInputPort, inputPortByNodeId); if (!nodeOutputPorts.isEmpty()) { final PortDTO outputPort = nodeOutputPorts.iterator().next(); final PortDTO clientOutputPort = clientDto.getInputPorts().stream().filter(p -> p.getId().equals(outputPort.getId())).findFirst().orElse(null); if (clientOutputPort != null) { PortEntityMerger.mergeDtos(clientOutputPort, outputPortByNodeId); final Set<PortDTO> clientInputPorts = Sets.newHashSet(clientDto.getInputPorts()); final Set<PortDTO> clientOutputPorts = Sets.newHashSet(clientDto.getOutputPorts()); dtoMap.values().forEach(controller -> { clientInputPorts.retainAll(controller.getInputPorts()); clientOutputPorts.retainAll(controller.getOutputPorts()); }); clientDto.setInputPorts(clientInputPorts); clientDto.setInputPortCount(clientInputPorts.size()); clientDto.setOutputPorts(clientOutputPorts); clientDto.setOutputPortCount(clientOutputPorts.size());
this.siteToSitePort = controller.getRemoteSiteListeningPort(); this.siteToSiteHttpPort = controller.getRemoteSiteHttpListeningPort(); this.siteToSiteSecure = controller.isSiteToSiteSecure(); this.activeClusterUrl = connectedClusterUrl; for (final PortDTO inputPort : controller.getInputPorts()) { inputPortMap.put(inputPort.getName(), inputPort.getId()); for (final PortDTO outputPort : controller.getOutputPorts()) { outputPortMap.put(outputPort.getName(), outputPort.getId());
final ControllerDTO controllerDTO = new ControllerDTO(); controllerDTO.setId(controllerFacade.getRootGroupId()); controllerDTO.setInstanceId(controllerFacade.getInstanceId()); controllerDTO.setName(controllerFacade.getName()); controllerDTO.setComments(controllerFacade.getComments()); controllerDTO.setInputPorts(inputPortDtos); controllerDTO.setOutputPorts(outputPortDtos); controllerDTO.setInputPortCount(inputPortDtos.size()); controllerDTO.setOutputPortCount(outputPortDtos.size()); controllerDTO.setRunningCount(counts.getRunningCount()); controllerDTO.setStoppedCount(counts.getStoppedCount()); controllerDTO.setInvalidCount(counts.getInvalidCount()); controllerDTO.setDisabledCount(counts.getDisabledCount()); controllerDTO.setRemoteSiteListeningPort(controllerFacade.getRemoteSiteListeningPort()); controllerDTO.setRemoteSiteHttpListeningPort(controllerFacade.getRemoteSiteListeningHttpPort()); controllerDTO.setSiteToSiteSecure(controllerFacade.isRemoteSiteCommsSecure());
if (modificationNeededRaw || modificationNeededHttp) { final PeerDescription source = getSourcePeerDescription(req); final Boolean isSiteToSiteSecure = controller.isSiteToSiteSecure(); final String siteToSiteHostname = getSiteToSiteHostname(req); final Map<String, String> httpHeaders = getHttpHeaders(req); final PeerDescription rawTarget = new PeerDescription(siteToSiteHostname, controller.getRemoteSiteListeningPort(), isSiteToSiteSecure); final PeerDescription modifiedRawTarget = peerDescriptionModifier.modify(source, rawTarget, SiteToSiteTransportProtocol.RAW, PeerDescriptionModifier.RequestType.SiteToSiteDetail, new HashMap<>(httpHeaders)); controller.setRemoteSiteListeningPort(modifiedRawTarget.getPort()); final PeerDescription httpTarget = new PeerDescription(siteToSiteHostname, controller.getRemoteSiteHttpListeningPort(), isSiteToSiteSecure); final PeerDescription modifiedHttpTarget = peerDescriptionModifier.modify(source, httpTarget, SiteToSiteTransportProtocol.HTTP, PeerDescriptionModifier.RequestType.SiteToSiteDetail, new HashMap<>(httpHeaders)); controller.setRemoteSiteHttpListeningPort(modifiedHttpTarget.getPort()); if (!controller.isSiteToSiteSecure() && modifiedHttpTarget.isSecure()) { controller.setSiteToSiteSecure(true); controller.setRemoteSiteHttpListeningPort(null);
final ControllerDTO dto = apiClient.getController(targetUris); if (dto.getRemoteSiteListeningPort() == null && SiteToSiteTransportProtocol.RAW.equals(transportProtocol)) { authorizationIssue = "Remote instance is not configured to allow RAW Site-to-Site communications at this time."; } else if (dto.getRemoteSiteHttpListeningPort() == null && SiteToSiteTransportProtocol.HTTP.equals(transportProtocol)) { authorizationIssue = "Remote instance is not configured to allow HTTP Site-to-Site communications at this time."; } else { listeningPort = dto.getRemoteSiteListeningPort(); listeningHttpPort = dto.getRemoteSiteHttpListeningPort(); destinationSecure = dto.isSiteToSiteSecure(); } finally { writeLock.unlock();
/** * @return the port that the remote instance is listening on for * RAW Socket site-to-site communication, or <code>null</code> if the remote instance * is not configured to allow site-to-site communications. * * @throws IOException if unable to communicate with the remote instance */ public Integer getSiteToSitePort() throws IOException { Integer listeningPort; remoteInfoReadLock.lock(); try { listeningPort = this.siteToSitePort; if (listeningPort != null && this.remoteRefreshTime > System.currentTimeMillis() - REMOTE_REFRESH_MILLIS) { return listeningPort; } } finally { remoteInfoReadLock.unlock(); } final ControllerDTO controller = refreshRemoteInfo(); listeningPort = controller.getRemoteSiteListeningPort(); return listeningPort; }
/** * @return the port that the remote instance is listening on for * HTTP(S) site-to-site communication, or <code>null</code> if the remote instance * is not configured to allow site-to-site communications. * * @throws IOException if unable to communicate with the remote instance */ public Integer getSiteToSiteHttpPort() throws IOException { Integer listeningHttpPort; remoteInfoReadLock.lock(); try { listeningHttpPort = this.siteToSiteHttpPort; if (listeningHttpPort != null && this.remoteRefreshTime > System.currentTimeMillis() - REMOTE_REFRESH_MILLIS) { return listeningHttpPort; } } finally { remoteInfoReadLock.unlock(); } final ControllerDTO controller = refreshRemoteInfo(); listeningHttpPort = controller.getRemoteSiteHttpListeningPort(); return listeningHttpPort; }
/** * @return {@code true} if the remote instance is configured for secure * site-to-site communications, {@code false} otherwise * @throws IOException if unable to check if secure */ public boolean isSecure() throws IOException { remoteInfoReadLock.lock(); try { final Boolean secure = this.siteToSiteSecure; if (secure != null && this.remoteRefreshTime > System.currentTimeMillis() - REMOTE_REFRESH_MILLIS) { return secure; } } finally { remoteInfoReadLock.unlock(); } final ControllerDTO controller = refreshRemoteInfo(); final Boolean isSecure = controller.isSiteToSiteSecure(); if (isSecure == null) { throw new IOException("Remote NiFi instance " + clusterUrls + " is not currently configured to accept site-to-site connections"); } return isSecure; }