private void addVariables(Map<String, String> map, String prefix, PeerDescription peer) { map.put(format("%s.hostname", prefix), peer.getHostname()); map.put(format("%s.port", prefix), String.valueOf(peer.getPort())); map.put(format("%s.secure", prefix), String.valueOf(peer.isSecure())); }
@Override public String toString() { return "PeerStatus[hostname=" + description.getHostname() + ",port=" + description.getPort() + ",secure=" + description.isSecure() + ",flowFileCount=" + numFlowFiles + "]"; }
private String resolveNodeApiUrl(final PeerDescription description) { return (description.isSecure() ? "https" : "http") + "://" + description.getHostname() + ":" + description.getPort() + "/nifi-api"; }
private void persistPeerStatuses(final Set<PeerStatus> statuses) { if (persistenceFile == null) { return; } try (final OutputStream fos = new FileOutputStream(persistenceFile); final OutputStream out = new BufferedOutputStream(fos)) { for (final PeerStatus status : statuses) { final PeerDescription description = status.getPeerDescription(); final String line = description.getHostname() + ":" + description.getPort() + ":" + description.isSecure() + ":" + status.isQueryForPeers() + "\n"; out.write(line.getBytes(StandardCharsets.UTF_8)); } } catch (final IOException e) { error(logger, eventReporter, "Failed to persist list of Peers due to {}; if restarted and peer's NCM is down," + " may be unable to transfer data until communications with NCM are restored", e.toString()); logger.error("", e); } }
if (peerDescription.isSecure()) { final NiFiUser nifiUser = NiFiUserUtils.getNiFiUser(); logger.debug("initiating peer, nifiUser={}", nifiUser);
dos.writeBoolean(modifiedTarget.isSecure());
SiteToSiteTransportProtocol.HTTP, PeerDescriptionModifier.RequestType.SiteToSiteDetail, new HashMap<>(httpHeaders)); controller.setRemoteSiteHttpListeningPort(modifiedHttpTarget.getPort()); if (!controller.isSiteToSiteSecure() && modifiedHttpTarget.isSecure()) {
@Override public Set<PeerStatus> fetchRemotePeerStatuses(PeerDescription peerDescription) throws IOException { // Each node should has the same URL structure and network reach-ability with the proxy configuration. try (final SiteToSiteRestApiClient apiClient = new SiteToSiteRestApiClient(config.getSslContext(), config.getHttpProxy(), config.getEventReporter())) { final String scheme = peerDescription.isSecure() ? "https" : "http"; apiClient.setBaseUrl(scheme, peerDescription.getHostname(), peerDescription.getPort()); final int timeoutMillis = (int) config.getTimeout(TimeUnit.MILLISECONDS); apiClient.setConnectTimeoutMillis(timeoutMillis); apiClient.setReadTimeoutMillis(timeoutMillis); apiClient.setCacheExpirationMillis(config.getCacheExpiration(TimeUnit.MILLISECONDS)); apiClient.setLocalAddress(config.getLocalAddress()); final Collection<PeerDTO> peers = apiClient.getPeers(); if(peers == null || peers.size() == 0){ throw new IOException("Couldn't get any peer to communicate with. " + apiClient.getBaseUrl() + " returned zero peers."); } // Convert the PeerDTO's to PeerStatus objects. Use 'true' for the query-peer-for-peers flag because Site-to-Site over HTTP // was added in NiFi 1.0.0, which means that peer-to-peer queries are always allowed. return peers.stream().map(p -> new PeerStatus(new PeerDescription(p.getHostname(), p.getPort(), p.isSecure()), p.getFlowFileCount(), true)) .collect(Collectors.toSet()); } }
peer.setHostname(target.getHostname()); peer.setPort(target.getPort()); peer.setSecure(target.isSecure()); peer.setFlowFileCount(workload.getFlowFileCount()); peers.add(peer); peer.setSecure(target.isSecure()); peer.setFlowFileCount(0); // doesn't matter how many FlowFiles we have, because we're the only host.
private void addVariables(Map<String, String> map, String prefix, PeerDescription peer) { map.put(format("%s.hostname", prefix), peer.getHostname()); map.put(format("%s.port", prefix), String.valueOf(peer.getPort())); map.put(format("%s.secure", prefix), String.valueOf(peer.isSecure())); }
dos.writeBoolean(modifiedTarget.isSecure());