Java Code Examples for org.apache.nifi.remote.client.SiteToSiteClient#Builder

The following examples show how to use org.apache.nifi.remote.client.SiteToSiteClient#Builder . 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: SiteToSiteCliMainTest.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    SiteToSiteClient.Builder builder = new SiteToSiteClient.Builder();
    expectedUrl = SiteToSiteCliMain.URL_OPTION_DEFAULT;
    expectedTransferDirection = TransferDirection.valueOf(SiteToSiteCliMain.DIRECTION_OPTION_DEFAULT);
    expectedSiteToSiteTransportProtocol = SiteToSiteTransportProtocol.valueOf(SiteToSiteCliMain.TRANSPORT_PROTOCOL_OPTION_DEFAULT);
    expectedPortName = builder.getPortName();
    expectedPortIdentifier = builder.getPortIdentifier();
    expectedTimeoutNs = builder.getTimeout(TimeUnit.NANOSECONDS);
    expectedPenalizationNs = builder.getPenalizationPeriod(TimeUnit.NANOSECONDS);
    expectedKeystoreFilename = builder.getKeystoreFilename();
    expectedKeystorePass = builder.getKeystorePass();
    expectedKeystoreType = builder.getKeystoreType();
    expectedTruststoreFilename = builder.getTruststoreFilename();
    expectedTruststorePass = builder.getTruststorePass();
    expectedTruststoreType = builder.getTruststoreType();
    expectedCompression = false;
    expectedPeerPersistenceFile = builder.getPeerPersistenceFile();
    SiteToSiteClientConfig siteToSiteClientConfig = builder.buildConfig();
    expectedBatchCount = siteToSiteClientConfig.getPreferredBatchCount();
    expectedBatchDuration = siteToSiteClientConfig.getPreferredBatchDuration(TimeUnit.NANOSECONDS);
    expectedBatchSize = siteToSiteClientConfig.getPreferredBatchSize();
    expectedHttpProxy = siteToSiteClientConfig.getHttpProxy();
}
 
Example 2
Source File: SiteToSiteCliMainTest.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    SiteToSiteClient.Builder builder = new SiteToSiteClient.Builder();
    expectedUrl = SiteToSiteCliMain.URL_OPTION_DEFAULT;
    expectedTransferDirection = TransferDirection.valueOf(SiteToSiteCliMain.DIRECTION_OPTION_DEFAULT);
    expectedSiteToSiteTransportProtocol = SiteToSiteTransportProtocol.valueOf(SiteToSiteCliMain.TRANSPORT_PROTOCOL_OPTION_DEFAULT);
    expectedPortName = builder.getPortName();
    expectedPortIdentifier = builder.getPortIdentifier();
    expectedTimeoutNs = builder.getTimeout(TimeUnit.NANOSECONDS);
    expectedPenalizationNs = builder.getPenalizationPeriod(TimeUnit.NANOSECONDS);
    expectedKeystoreFilename = builder.getKeystoreFilename();
    expectedKeystorePass = builder.getKeystorePass();
    expectedKeystoreType = builder.getKeystoreType();
    expectedTruststoreFilename = builder.getTruststoreFilename();
    expectedTruststorePass = builder.getTruststorePass();
    expectedTruststoreType = builder.getTruststoreType();
    expectedCompression = false;
    expectedPeerPersistenceFile = builder.getPeerPersistenceFile();
    SiteToSiteClientConfig siteToSiteClientConfig = builder.buildConfig();
    expectedBatchCount = siteToSiteClientConfig.getPreferredBatchCount();
    expectedBatchDuration = siteToSiteClientConfig.getPreferredBatchDuration(TimeUnit.NANOSECONDS);
    expectedBatchSize = siteToSiteClientConfig.getPreferredBatchSize();
    expectedHttpProxy = siteToSiteClientConfig.getHttpProxy();
}
 
Example 3
Source File: TestNiFiOutputApplication.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
@Override
public void populateDAG(DAG dag, Configuration conf)
{
  final SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder()
      .url("http://localhost:8080/nifi")
      .portName("Apex")
      .buildConfig();

  final int batchSize = 1;
  final SiteToSiteClient.Builder builder = new SiteToSiteClient.Builder().fromConfig(clientConfig);
  final NiFiDataPacketBuilder<String> dataPacketBuilder = new StringNiFiDataPacketBuilder();
  final WindowDataManager windowDataManager = new WindowDataManager.NoopWindowDataManager();

  RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());

  NiFiSinglePortOutputOperator nifi = dag.addOperator("nifi",
      new NiFiSinglePortOutputOperator(builder, dataPacketBuilder, windowDataManager, batchSize));

  dag.addStream("rand_nifi", rand.string_data, nifi.inputPort).setLocality(null);
}
 
Example 4
Source File: TestNiFiInputApplication.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
@Override
public void populateDAG(DAG dag, Configuration conf)
{
  final SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder()
      .url("http://localhost:8080/nifi")
      .portName("Apex")
      .requestBatchCount(5)
      .buildConfig();

  final SiteToSiteClient.Builder builder = new SiteToSiteClient.Builder().fromConfig(clientConfig);

  final WindowDataManager windowDataManager = new WindowDataManager.NoopWindowDataManager();

  NiFiSinglePortInputOperator nifi = dag.addOperator("nifi", new NiFiSinglePortInputOperator(builder, windowDataManager));
  ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
  dag.addStream("nifi_console", nifi.outputPort, console.input).setLocality(null);
}
 
Example 5
Source File: StandardRemoteGroupPort.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void onSchedulingStart() {
    super.onSchedulingStart();

    final long penalizationMillis = FormatUtils.getTimeDuration(remoteGroup.getYieldDuration(), TimeUnit.MILLISECONDS);

    final SiteToSiteClient.Builder clientBuilder = new SiteToSiteClient.Builder()
            .urls(SiteToSiteRestApiClient.parseClusterUrls(remoteGroup.getTargetUris()))
            .portIdentifier(getTargetIdentifier())
            .sslContext(sslContext)
            .useCompression(isUseCompression())
            .eventReporter(remoteGroup.getEventReporter())
            .stateManager(remoteGroup.getStateManager())
            .nodePenalizationPeriod(penalizationMillis, TimeUnit.MILLISECONDS)
            .timeout(remoteGroup.getCommunicationsTimeout(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
            .transportProtocol(remoteGroup.getTransportProtocol())
            .httpProxy(new HttpProxy(remoteGroup.getProxyHost(), remoteGroup.getProxyPort(), remoteGroup.getProxyUser(), remoteGroup.getProxyPassword()))
            .localAddress(remoteGroup.getLocalAddress());

    final Integer batchCount = getBatchCount();
    if (batchCount != null) {
        clientBuilder.requestBatchCount(batchCount);
    }

    final String batchSize = getBatchSize();
    if (batchSize != null && batchSize.length() > 0) {
        clientBuilder.requestBatchSize(DataUnit.parseDataSize(batchSize.trim(), DataUnit.B).intValue());
    }

    final String batchDuration = getBatchDuration();
    if (batchDuration != null && batchDuration.length() > 0) {
        clientBuilder.requestBatchDuration(FormatUtils.getTimeDuration(batchDuration.trim(), TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
    }

    clientRef.set(clientBuilder.build());
}
 
Example 6
Source File: TestHttpClient.java    From nifi with Apache License 2.0 5 votes vote down vote up
private SiteToSiteClient.Builder getDefaultBuilderHTTPS() {
    return new SiteToSiteClient.Builder().transportProtocol(SiteToSiteTransportProtocol.HTTP)
            .url("https://localhost:" + sslConnector.getLocalPort() + "/nifi")
            .timeout(3, TimeUnit.MINUTES)
            .keystoreFilename("src/test/resources/certs/keystore.jks")
            .keystorePass("passwordpassword")
            .keystoreType(KeystoreType.JKS)
            .truststoreFilename("src/test/resources/certs/truststore.jks")
            .truststorePass("passwordpassword")
            .truststoreType(KeystoreType.JKS)
            ;
}
 
Example 7
Source File: SiteToSiteCliMainTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void parseAndCheckExpected(String[] args) throws ParseException {
    SiteToSiteCliMain.CliParse cliParse = SiteToSiteCliMain.parseCli(new Options(), args);
    SiteToSiteClient.Builder builder = cliParse.getBuilder();
    assertEquals(expectedUrl, builder.getUrl());
    assertEquals(expectedSiteToSiteTransportProtocol, builder.getTransportProtocol());
    assertEquals(expectedPortName, builder.getPortName());
    assertEquals(expectedPortIdentifier, builder.getPortIdentifier());
    assertEquals(expectedTimeoutNs, builder.getTimeout(TimeUnit.NANOSECONDS));
    assertEquals(expectedPenalizationNs, builder.getPenalizationPeriod(TimeUnit.NANOSECONDS));
    assertEquals(expectedKeystoreFilename, builder.getKeystoreFilename());
    assertEquals(expectedKeystorePass, builder.getKeystorePass());
    assertEquals(expectedKeystoreType, builder.getKeystoreType());
    assertEquals(expectedTruststoreFilename, builder.getTruststoreFilename());
    assertEquals(expectedTruststorePass, builder.getTruststorePass());
    assertEquals(expectedTruststoreType, builder.getTruststoreType());
    assertEquals(expectedCompression, builder.isUseCompression());
    assertEquals(expectedPeerPersistenceFile, builder.getPeerPersistenceFile());
    if (expectedHttpProxy == null) {
        assertNull(builder.getHttpProxy());
    } else {
        HttpProxy httpProxy = builder.getHttpProxy();
        assertNotNull(httpProxy);
        assertEquals(expectedHttpProxy.getHttpHost(), httpProxy.getHttpHost());
        assertEquals(expectedHttpProxy.getUsername(), httpProxy.getUsername());
        assertEquals(expectedHttpProxy.getPassword(), httpProxy.getPassword());
    }
    SiteToSiteClientConfig siteToSiteClientConfig = builder.buildConfig();
    assertEquals(expectedBatchCount, siteToSiteClientConfig.getPreferredBatchCount());
    assertEquals(expectedBatchDuration, siteToSiteClientConfig.getPreferredBatchDuration(TimeUnit.NANOSECONDS));
    assertEquals(expectedBatchSize, siteToSiteClientConfig.getPreferredBatchSize());
    assertEquals(expectedTransferDirection, cliParse.getTransferDirection());
}
 
Example 8
Source File: NiFiSinglePortOutputOperator.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
/**
 * @param siteToSiteBuilder the builder for a NiFi SiteToSiteClient
 * @param dataPacketBuilder a builder to produce NiFiDataPackets from incoming data
 * @param windowDataManager  a WindowDataManager to save and load state for windows of tuples
 * @param batchSize the maximum number of tuples to send to NiFi in a single transaction
 */
public NiFiSinglePortOutputOperator(
    final SiteToSiteClient.Builder siteToSiteBuilder,
    final NiFiDataPacketBuilder<T> dataPacketBuilder,
    final WindowDataManager windowDataManager,
    final int batchSize)
{
  super(siteToSiteBuilder, dataPacketBuilder, windowDataManager);
  this.inputPort = new BufferingInputPort(batchSize);
}
 
Example 9
Source File: AbstractNiFiInputOperator.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
/**
 * @param siteToSiteBuilder the builder for a NiFi SiteToSiteClient
 * @param windowDataManager a WindowDataManager to save and load state for windows of tuples
 */
public AbstractNiFiInputOperator(final SiteToSiteClient.Builder siteToSiteBuilder,
    final WindowDataManager windowDataManager)
{
  this.siteToSiteBuilder = siteToSiteBuilder;
  this.windowDataManager = windowDataManager;
}
 
Example 10
Source File: AbstractNiFiOutputOperator.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
/**
 * @param siteToSiteBuilder the builder for a NiFi SiteToSiteClient
 * @param dataPacketBuilder a builder to produce NiFiDataPackets from incoming data
 * @param windowDataManager  a WindowDataManager to save and load state for windows of tuples
 */
public AbstractNiFiOutputOperator(final SiteToSiteClient.Builder siteToSiteBuilder,
    final NiFiDataPacketBuilder<T> dataPacketBuilder, final WindowDataManager windowDataManager)
{
  this.siteToSiteBuilder = siteToSiteBuilder;
  this.dataPacketBuilder = dataPacketBuilder;
  this.windowDataManager = windowDataManager;
}
 
Example 11
Source File: LogLevelApplication.java    From nifi-streaming-examples with Apache License 2.0 5 votes vote down vote up
private NiFiSinglePortOutputOperator getNiFiOutput(DAG dag, LogLevelProperties props, WindowDataManager windowDataManager) {
    final SiteToSiteClient.Builder outputConfig = new SiteToSiteClient.Builder()
            .url(props.getNifiUrl())
            .portName(props.getNifiOutputPort());

    final int batchSize = 1;
    final NiFiDataPacketBuilder<LogLevels> dataPacketBuilder = new DictionaryBuilder(
            props.getWindowMillis(), props.getLogLevelThreshold());

    return dag.addOperator("nifi-out", new NiFiSinglePortOutputOperator(
            outputConfig, dataPacketBuilder, windowDataManager ,batchSize));
}
 
Example 12
Source File: LogLevelApplication.java    From nifi-streaming-examples with Apache License 2.0 5 votes vote down vote up
private NiFiSinglePortInputOperator getNiFiInput(DAG dag, LogLevelProperties props, WindowDataManager windowDataManager) {
    final SiteToSiteClient.Builder inputConfig = new SiteToSiteClient.Builder()
            .url(props.getNifiUrl())
            .portName(props.getNifiInputPort())
            .requestBatchCount(props.getNifiRequestBatch());

    return dag.addOperator("nifi-in", new NiFiSinglePortInputOperator(inputConfig, windowDataManager));
}
 
Example 13
Source File: TestHttpClient.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private SiteToSiteClient.Builder getDefaultBuilderHTTPS() {
    return new SiteToSiteClient.Builder().transportProtocol(SiteToSiteTransportProtocol.HTTP)
            .url("https://localhost:" + sslConnector.getLocalPort() + "/nifi")
            .timeout(3, TimeUnit.MINUTES)
            .keystoreFilename("src/test/resources/certs/localhost-ks.jks")
            .keystorePass("localtest")
            .keystoreType(KeystoreType.JKS)
            .truststoreFilename("src/test/resources/certs/localhost-ts.jks")
            .truststorePass("localtest")
            .truststoreType(KeystoreType.JKS)
            ;
}
 
Example 14
Source File: SiteToSiteCliMainTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private void parseAndCheckExpected(String[] args) throws ParseException {
    SiteToSiteCliMain.CliParse cliParse = SiteToSiteCliMain.parseCli(new Options(), args);
    SiteToSiteClient.Builder builder = cliParse.getBuilder();
    assertEquals(expectedUrl, builder.getUrl());
    assertEquals(expectedSiteToSiteTransportProtocol, builder.getTransportProtocol());
    assertEquals(expectedPortName, builder.getPortName());
    assertEquals(expectedPortIdentifier, builder.getPortIdentifier());
    assertEquals(expectedTimeoutNs, builder.getTimeout(TimeUnit.NANOSECONDS));
    assertEquals(expectedPenalizationNs, builder.getPenalizationPeriod(TimeUnit.NANOSECONDS));
    assertEquals(expectedKeystoreFilename, builder.getKeystoreFilename());
    assertEquals(expectedKeystorePass, builder.getKeystorePass());
    assertEquals(expectedKeystoreType, builder.getKeystoreType());
    assertEquals(expectedTruststoreFilename, builder.getTruststoreFilename());
    assertEquals(expectedTruststorePass, builder.getTruststorePass());
    assertEquals(expectedTruststoreType, builder.getTruststoreType());
    assertEquals(expectedCompression, builder.isUseCompression());
    assertEquals(expectedPeerPersistenceFile, builder.getPeerPersistenceFile());
    if (expectedHttpProxy == null) {
        assertNull(builder.getHttpProxy());
    } else {
        HttpProxy httpProxy = builder.getHttpProxy();
        assertNotNull(httpProxy);
        assertEquals(expectedHttpProxy.getHttpHost(), httpProxy.getHttpHost());
        assertEquals(expectedHttpProxy.getUsername(), httpProxy.getUsername());
        assertEquals(expectedHttpProxy.getPassword(), httpProxy.getPassword());
    }
    SiteToSiteClientConfig siteToSiteClientConfig = builder.buildConfig();
    assertEquals(expectedBatchCount, siteToSiteClientConfig.getPreferredBatchCount());
    assertEquals(expectedBatchDuration, siteToSiteClientConfig.getPreferredBatchDuration(TimeUnit.NANOSECONDS));
    assertEquals(expectedBatchSize, siteToSiteClientConfig.getPreferredBatchSize());
    assertEquals(expectedTransferDirection, cliParse.getTransferDirection());
}
 
Example 15
Source File: NiFiSinglePortInputOperator.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param siteToSiteBuilder the builder for a NiFi SiteToSiteClient
 * @param windowDataManager a WindowDataManager to save and load state for windows of tuples
 */
public NiFiSinglePortInputOperator(final SiteToSiteClient.Builder siteToSiteBuilder,
    final WindowDataManager windowDataManager)
{
  super(siteToSiteBuilder, windowDataManager);
}
 
Example 16
Source File: AbstractNiFiSinglePortInputOperator.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param siteToSiteBuilder the builder for a NiFi SiteToSiteClient
 * @param windowDataManager a WindowDataManager to save and load state for windows of tuples
 */
public AbstractNiFiSinglePortInputOperator(final SiteToSiteClient.Builder siteToSiteBuilder,
    final WindowDataManager windowDataManager)
{
  super(siteToSiteBuilder, windowDataManager);
}
 
Example 17
Source File: TestHttpClient.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
private SiteToSiteClient.Builder getDefaultBuilder() {
    return new SiteToSiteClient.Builder().transportProtocol(SiteToSiteTransportProtocol.HTTP)
            .url("http://localhost:" + httpConnector.getLocalPort() + "/nifi")
            .timeout(3, TimeUnit.MINUTES)
            ;
}
 
Example 18
Source File: TestHttpClient.java    From nifi with Apache License 2.0 4 votes vote down vote up
private SiteToSiteClient.Builder getDefaultBuilder() {
    return new SiteToSiteClient.Builder().transportProtocol(SiteToSiteTransportProtocol.HTTP)
            .url("http://localhost:" + httpConnector.getLocalPort() + "/nifi")
            .timeout(3, TimeUnit.MINUTES)
            ;
}
 
Example 19
Source File: SiteToSiteCliMain.java    From nifi with Apache License 2.0 votes vote down vote up
SiteToSiteClient.Builder getBuilder(); 
Example 20
Source File: SiteToSiteCliMain.java    From localization_nifi with Apache License 2.0 votes vote down vote up
SiteToSiteClient.Builder getBuilder();