Java Code Examples for org.apache.nifi.remote.TransferDirection#RECEIVE

The following examples show how to use org.apache.nifi.remote.TransferDirection#RECEIVE . 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: SocketClientTransaction.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private void initialize() throws IOException {
    try {
        if (direction == TransferDirection.RECEIVE) {
            // Indicate that we would like to have some data
            RequestType.RECEIVE_FLOWFILES.writeRequestType(dos);
            dos.flush();

            final Response dataAvailableCode = Response.read(dis);
            switch (dataAvailableCode.getCode()) {
                case MORE_DATA:
                    logger.debug("{} {} Indicates that data is available", this, peer);
                    this.dataAvailable = true;
                    break;
                case NO_MORE_DATA:
                    logger.debug("{} No data available from {}", peer);
                    this.dataAvailable = false;
                    return;
                default:
                    throw new ProtocolException("Got unexpected response when asking for data: " + dataAvailableCode);
            }

        } else {
            // Indicate that we would like to have some data
            RequestType.SEND_FLOWFILES.writeRequestType(dos);
            dos.flush();
        }
    } catch (final Exception e) {
        error();
        throw e;
    }
}
 
Example 2
Source File: SiteInfoProvider.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public String getPortIdentifier(final String portName, final TransferDirection transferDirection) throws  IOException {
    if (transferDirection == TransferDirection.RECEIVE) {
        return getOutputPortIdentifier(portName);
    } else {
        return getInputPortIdentifier(portName);
    }
}
 
Example 3
Source File: SocketClientTransaction.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void initialize() throws IOException {
    try {
        if (direction == TransferDirection.RECEIVE) {
            // Indicate that we would like to have some data
            RequestType.RECEIVE_FLOWFILES.writeRequestType(dos);
            dos.flush();

            final Response dataAvailableCode = Response.read(dis);
            switch (dataAvailableCode.getCode()) {
                case MORE_DATA:
                    logger.debug("{} {} Indicates that data is available", this, peer);
                    this.dataAvailable = true;
                    break;
                case NO_MORE_DATA:
                    logger.debug("{} No data available from {}", this, peer);
                    this.dataAvailable = false;
                    return;
                default:
                    throw new ProtocolException("Got unexpected response when asking for data: " + dataAvailableCode);
            }

        } else {
            // Indicate that we would like to have some data
            RequestType.SEND_FLOWFILES.writeRequestType(dos);
            dos.flush();
        }
    } catch (final Exception e) {
        error();
        throw e;
    }
}
 
Example 4
Source File: SiteInfoProvider.java    From nifi with Apache License 2.0 5 votes vote down vote up
public String getPortIdentifier(final String portName, final TransferDirection transferDirection) throws  IOException {
    if (transferDirection == TransferDirection.RECEIVE) {
        return getOutputPortIdentifier(portName);
    } else {
        return getInputPortIdentifier(portName);
    }
}
 
Example 5
Source File: StandardFlowManager.java    From nifi with Apache License 2.0 5 votes vote down vote up
public Port createPublicInputPort(String id, String name) {
    id = requireNonNull(id).intern();
    name = requireNonNull(name).intern();
    verifyPortIdDoesNotExist(id);
    return new StandardPublicPort(id, name,
        TransferDirection.RECEIVE, ConnectableType.INPUT_PORT, authorizer, bulletinRepository,
        processScheduler, isSiteToSiteSecure, nifiProperties.getBoredYieldDuration(),
        IdentityMappingUtil.getIdentityMappings(nifiProperties));
}
 
Example 6
Source File: SiteToSiteCliMainTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testParseTransferDirection() throws ParseException {
    expectedTransferDirection = TransferDirection.RECEIVE;
    parseAndCheckExpected("d", SiteToSiteCliMain.DIRECTION_OPTION, expectedTransferDirection.toString());
}
 
Example 7
Source File: SiteToSiteCliMainTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testParseTransferDirection() throws ParseException {
    expectedTransferDirection = TransferDirection.RECEIVE;
    parseAndCheckExpected("d", SiteToSiteCliMain.DIRECTION_OPTION, expectedTransferDirection.toString());
}
 
Example 8
Source File: FlowController.java    From localization_nifi with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a Port to use as an Input Port for the root Process Group, which
 * is used for Site-to-Site communications
 *
 * @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 createRemoteInputPort(String id, String name) {
    id = requireNonNull(id).intern();
    name = requireNonNull(name).intern();
    verifyPortIdDoesNotExist(id);
    return new StandardRootGroupPort(id, name, null, TransferDirection.RECEIVE, ConnectableType.INPUT_PORT,
            authorizer, getBulletinRepository(), processScheduler, Boolean.TRUE.equals(isSiteToSiteSecure), nifiProperties);
}