Java Code Examples for org.apache.nifi.remote.TransferDirection#SEND
The following examples show how to use
org.apache.nifi.remote.TransferDirection#SEND .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SiteToSiteCliMain.java From localization_nifi with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // Make IO redirection useful PrintStream output = System.out; System.setOut(System.err); Options options = new Options(); try { CliParse cliParse = parseCli(options, args); try (SiteToSiteClient siteToSiteClient = cliParse.getBuilder().build()) { if (cliParse.getTransferDirection() == TransferDirection.SEND) { new SiteToSiteSender(siteToSiteClient, System.in).sendFiles(); } else { new SiteToSiteReceiver(siteToSiteClient, output).receiveFiles(); } } } catch (Exception e) { printUsage(e.getMessage(), options); e.printStackTrace(); } }
Example 2
Source File: SocketClient.java From localization_nifi with Apache License 2.0 | 6 votes |
private String getPortIdentifier(final TransferDirection direction) throws IOException { final String id = this.portIdentifier; if (id != null) { return id; } final String portId; if (direction == TransferDirection.SEND) { portId = siteInfoProvider.getInputPortIdentifier(this.portName); } else { portId = siteInfoProvider.getOutputPortIdentifier(this.portName); } if (portId == null) { logger.debug("Unable to resolve port [{}] to an identifier", portName); } else { logger.debug("Resolved port [{}] to identifier [{}]", portName, portId); this.portIdentifier = portId; } return portId; }
Example 3
Source File: SiteToSiteCliMain.java From nifi with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // Make IO redirection useful PrintStream output = System.out; System.setOut(System.err); Options options = new Options(); try { CliParse cliParse = parseCli(options, args); try (SiteToSiteClient siteToSiteClient = cliParse.getBuilder().build()) { if (cliParse.getTransferDirection() == TransferDirection.SEND) { new SiteToSiteSender(siteToSiteClient, System.in).sendFiles(); } else { new SiteToSiteReceiver(siteToSiteClient, output).receiveFiles(); } } } catch (Exception e) { printUsage(e.getMessage(), options); e.printStackTrace(); } }
Example 4
Source File: SocketClient.java From nifi with Apache License 2.0 | 6 votes |
private String getPortIdentifier(final TransferDirection direction) throws IOException { final String id = this.portIdentifier; if (id != null) { return id; } final String portId; if (direction == TransferDirection.SEND) { portId = siteInfoProvider.getInputPortIdentifier(this.portName); } else { portId = siteInfoProvider.getOutputPortIdentifier(this.portName); } if (portId == null) { logger.debug("Unable to resolve port [{}] to an identifier", portName); } else { logger.debug("Resolved port [{}] to identifier [{}]", portName, portId); this.portIdentifier = portId; } return portId; }
Example 5
Source File: PeerSelector.java From nifi with Apache License 2.0 | 6 votes |
/** * Returns the normalized weight for this ratio of peer flowfiles to total flowfiles and the given direction. The number will be * a Double between 0 and 100 indicating the percent of all flowfiles the peer * should send/receive. The transfer direction is <em>from the perspective of this node to the peer</em> * (i.e. how many flowfiles should <em>this node send</em> to the peer, or how many flowfiles * should <em>this node receive</em> from the peer). * * @param direction the transfer direction ({@code SEND} weights the destinations higher if they have fewer flowfiles, {@code RECEIVE} weights them higher if they have more) * @param totalFlowFileCount the total flowfile count in the remote instance (standalone or cluster) * @param flowFileCount the flowfile count for the given peer * @param peerCount the number of peers in the remote instance * @return the normalized weight of this peer */ private static double calculateNormalizedWeight(TransferDirection direction, long totalFlowFileCount, int flowFileCount, int peerCount) { // If there is only a single remote, send/receive all data to/from it if (peerCount == 1) { return 100; } double cappedPercent; // If no flowfiles exist in the remote instance, evenly weight each node with 1/N if (totalFlowFileCount == 0) { cappedPercent = 1.0 / peerCount; } else { final double percentageOfFlowFiles = ((double) flowFileCount / totalFlowFileCount); cappedPercent = percentageOfFlowFiles; // If sending to the remote, allocate more flowfiles to the less-stressed peers if (direction == TransferDirection.SEND) { cappedPercent = (1 - percentageOfFlowFiles) / (peerCount - 1); } } return new BigDecimal(cappedPercent * 100).setScale(2, RoundingMode.FLOOR).doubleValue(); }
Example 6
Source File: StandardFlowManager.java From nifi with Apache License 2.0 | 5 votes |
public Port createPublicOutputPort(String id, String name) { id = requireNonNull(id).intern(); name = requireNonNull(name).intern(); verifyPortIdDoesNotExist(id); return new StandardPublicPort(id, name, TransferDirection.SEND, ConnectableType.OUTPUT_PORT, authorizer, bulletinRepository, processScheduler, isSiteToSiteSecure, nifiProperties.getBoredYieldDuration(), IdentityMappingUtil.getIdentityMappings(nifiProperties)); }
Example 7
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 3 votes |
/** * Creates a Port to use as an Output Port for the root Process Group, which * is used for Site-to-Site communications and will queue flow files waiting * to be delivered to remote instances * * @param id port id * @param name port name * @return new port * @throws NullPointerException if the ID or name is not unique * @throws IllegalStateException if an Input Port already exists with the * same name or id. */ public Port createRemoteOutputPort(String id, String name) { id = requireNonNull(id).intern(); name = requireNonNull(name).intern(); verifyPortIdDoesNotExist(id); return new StandardRootGroupPort(id, name, null, TransferDirection.SEND, ConnectableType.OUTPUT_PORT, authorizer, getBulletinRepository(), processScheduler, Boolean.TRUE.equals(isSiteToSiteSecure), nifiProperties); }