org.apache.nifi.remote.client.SiteToSiteClientConfig Java Examples
The following examples show how to use
org.apache.nifi.remote.client.SiteToSiteClientConfig.
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: NiFiSinkTopologyExample.java From flink with Apache License 2.0 | 7 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data from Flink") .buildConfig(); DataStreamSink<String> dataStream = env.fromElements("one", "two", "three", "four", "five", "q") .addSink(new NiFiSink<>(clientConfig, new NiFiDataPacketBuilder<String>() { @Override public NiFiDataPacket createNiFiDataPacket(String s, RuntimeContext ctx) { return new StandardNiFiDataPacket(s.getBytes(ConfigConstants.DEFAULT_CHARSET), new HashMap<String, String>()); } })); env.execute(); }
Example #2
Source File: HttpClient.java From localization_nifi with Apache License 2.0 | 6 votes |
public HttpClient(final SiteToSiteClientConfig config) { super(config); peerSelector = new PeerSelector(this, config.getPeerPersistenceFile()); peerSelector.setEventReporter(config.getEventReporter()); taskExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() { private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); @Override public Thread newThread(final Runnable r) { final Thread thread = defaultFactory.newThread(r); thread.setName("Http Site-to-Site PeerSelector"); thread.setDaemon(true); return thread; } }); taskExecutor.scheduleWithFixedDelay(new Runnable() { @Override public void run() { peerSelector.refreshPeers(); } }, 0, 5, TimeUnit.SECONDS); }
Example #3
Source File: TestNiFiInputApplication.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
@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 #4
Source File: TestNiFiOutputApplication.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
@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 #5
Source File: NiFiSourceTopologyExample.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data for Flink") .requestBatchCount(5) .buildConfig(); SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig); DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2); DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() { @Override public String map(NiFiDataPacket value) throws Exception { return new String(value.getContent(), Charset.defaultCharset()); } }); dataStream.print(); env.execute(); }
Example #6
Source File: NiFiSinkTopologyExample.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data from Flink") .buildConfig(); DataStreamSink<String> dataStream = env.fromElements("one", "two", "three", "four", "five", "q") .addSink(new NiFiSink<>(clientConfig, new NiFiDataPacketBuilder<String>() { @Override public NiFiDataPacket createNiFiDataPacket(String s, RuntimeContext ctx) { return new StandardNiFiDataPacket(s.getBytes(ConfigConstants.DEFAULT_CHARSET), new HashMap<String, String>()); } })); env.execute(); }
Example #7
Source File: NiFiSourceMain.java From flink-learning with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data for Flink") .requestBatchCount(5) .buildConfig(); SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig); DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2); DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() { @Override public String map(NiFiDataPacket value) throws Exception { return new String(value.getContent(), Charset.defaultCharset()); } }); dataStream.print(); env.execute(); }
Example #8
Source File: NiFiSinkMain.java From flink-learning with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data from Flink") .buildConfig(); DataStreamSink<String> dataStream = env.fromElements("one", "two", "three", "four", "five", "q") .addSink(new NiFiSink<>(clientConfig, new NiFiDataPacketBuilder<String>() { @Override public NiFiDataPacket createNiFiDataPacket(String s, RuntimeContext ctx) { return new StandardNiFiDataPacket(s.getBytes(ConfigConstants.DEFAULT_CHARSET), new HashMap<String, String>()); } })); env.execute(); }
Example #9
Source File: SiteToSiteCliMainTest.java From nifi with Apache License 2.0 | 6 votes |
@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 #10
Source File: TestNiFiBolt.java From localization_nifi with Apache License 2.0 | 6 votes |
@Before public void setup() { tickFrequency = 30; siteToSiteClientConfig = mock(SiteToSiteClientConfig.class); niFiDataPacketBuilder = mock(NiFiDataPacketBuilder.class); // setup the builder to return empty data packets for testing when(niFiDataPacketBuilder.createNiFiDataPacket(any(Tuple.class))).thenReturn(new NiFiDataPacket() { @Override public byte[] getContent() { return new byte[0]; } @Override public Map<String, String> getAttributes() { return new HashMap<>(); } }); }
Example #11
Source File: SocketClient.java From nifi with Apache License 2.0 | 6 votes |
public SocketClient(final SiteToSiteClientConfig config) { super(config); final int commsTimeout = (int) config.getTimeout(TimeUnit.MILLISECONDS); pool = new EndpointConnectionPool( createRemoteDestination(config.getPortIdentifier(), config.getPortName()), commsTimeout, (int) config.getIdleConnectionExpiration(TimeUnit.MILLISECONDS), config.getSslContext(), config.getEventReporter(), config.getPeerPersistence(), siteInfoProvider, config.getLocalAddress() ); this.compress = config.isUseCompression(); this.portIdentifier = config.getPortIdentifier(); this.portName = config.getPortName(); this.penalizationNanos = config.getPenalizationPeriod(TimeUnit.NANOSECONDS); }
Example #12
Source File: HttpClient.java From nifi with Apache License 2.0 | 6 votes |
public HttpClient(final SiteToSiteClientConfig config) { super(config); peerSelector = new PeerSelector(this, config.getPeerPersistence()); peerSelector.setEventReporter(config.getEventReporter()); taskExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() { private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); @Override public Thread newThread(final Runnable r) { final Thread thread = defaultFactory.newThread(r); thread.setName("Http Site-to-Site PeerSelector"); thread.setDaemon(true); return thread; } }); taskExecutor.scheduleWithFixedDelay(new Runnable() { @Override public void run() { peerSelector.refresh(); } }, 0, 5, TimeUnit.SECONDS); }
Example #13
Source File: SocketClient.java From localization_nifi with Apache License 2.0 | 6 votes |
public SocketClient(final SiteToSiteClientConfig config) { super(config); final int commsTimeout = (int) config.getTimeout(TimeUnit.MILLISECONDS); pool = new EndpointConnectionPool( createRemoteDestination(config.getPortIdentifier(), config.getPortName()), commsTimeout, (int) config.getIdleConnectionExpiration(TimeUnit.MILLISECONDS), config.getSslContext(), config.getEventReporter(), config.getPeerPersistenceFile(), siteInfoProvider, config.getLocalAddress() ); this.compress = config.isUseCompression(); this.portIdentifier = config.getPortIdentifier(); this.portName = config.getPortName(); this.penalizationNanos = config.getPenalizationPeriod(TimeUnit.NANOSECONDS); }
Example #14
Source File: SiteToSiteCliMainTest.java From localization_nifi with Apache License 2.0 | 6 votes |
@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 #15
Source File: NiFiSourceTopologyExample.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data for Flink") .requestBatchCount(5) .buildConfig(); SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig); DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2); DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() { @Override public String map(NiFiDataPacket value) throws Exception { return new String(value.getContent(), Charset.defaultCharset()); } }); dataStream.print(); env.execute(); }
Example #16
Source File: NiFiSinkTopologyExample.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data from Flink") .buildConfig(); DataStreamSink<String> dataStream = env.fromElements("one", "two", "three", "four", "five", "q") .addSink(new NiFiSink<>(clientConfig, new NiFiDataPacketBuilder<String>() { @Override public NiFiDataPacket createNiFiDataPacket(String s, RuntimeContext ctx) { return new StandardNiFiDataPacket(s.getBytes(ConfigConstants.DEFAULT_CHARSET), new HashMap<String, String>()); } })); env.execute(); }
Example #17
Source File: NiFiSinkMain.java From flink-learning with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data from Flink") .buildConfig(); DataStreamSink<String> dataStream = env.fromElements("one", "two", "three", "four", "five", "q") .addSink(new NiFiSink<>(clientConfig, new NiFiDataPacketBuilder<String>() { @Override public NiFiDataPacket createNiFiDataPacket(String s, RuntimeContext ctx) { return new StandardNiFiDataPacket(s.getBytes(ConfigConstants.DEFAULT_CHARSET), new HashMap<String, String>()); } })); env.execute(); }
Example #18
Source File: NiFiSourceTopologyExample.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data for Flink") .requestBatchCount(5) .buildConfig(); SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig); DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2); DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() { @Override public String map(NiFiDataPacket value) throws Exception { return new String(value.getContent(), Charset.defaultCharset()); } }); dataStream.print(); env.execute(); }
Example #19
Source File: TestNiFiBolt.java From nifi with Apache License 2.0 | 6 votes |
@Before public void setup() { tickFrequency = 30; siteToSiteClientConfig = mock(SiteToSiteClientConfig.class); niFiDataPacketBuilder = mock(NiFiDataPacketBuilder.class); // setup the builder to return empty data packets for testing when(niFiDataPacketBuilder.createNiFiDataPacket(any(Tuple.class))).thenReturn(new NiFiDataPacket() { @Override public byte[] getContent() { return new byte[0]; } @Override public Map<String, String> getAttributes() { return new HashMap<>(); } }); }
Example #20
Source File: NiFiSourceMain.java From flink-learning with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data for Flink") .requestBatchCount(5) .buildConfig(); SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig); DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2); DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() { @Override public String map(NiFiDataPacket value) throws Exception { return new String(value.getContent(), Charset.defaultCharset()); } }); dataStream.print(); env.execute(); }
Example #21
Source File: TestStandardRemoteGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testSendBatchByDuration() throws Exception { final SiteToSiteClientConfig siteToSiteClientConfig = new SiteToSiteClient.Builder() .requestBatchDuration(1, TimeUnit.NANOSECONDS) .buildConfig(); setupMock(SiteToSiteTransportProtocol.HTTP, TransferDirection.SEND, siteToSiteClientConfig); // t1 = {1}, t2 = {2} .. and so on. final int[] expectedNumberOfPackets = {1, 1, 1, 1, 1}; testSendBatch(expectedNumberOfPackets); }
Example #22
Source File: NiFiStormTopology.java From nifi with Apache License 2.0 | 5 votes |
public static void main( String[] args ) { // Build a Site-To-Site client config for pulling data final SiteToSiteClientConfig inputConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data for Storm") .buildConfig(); // Build a Site-To-Site client config for pushing data final SiteToSiteClientConfig outputConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("Data from Storm") .buildConfig(); final int tickFrequencySeconds = 5; final NiFiDataPacketBuilder niFiDataPacketBuilder = new SimpleNiFiDataPacketBuilder(); final NiFiBolt niFiBolt = new NiFiBolt(outputConfig, niFiDataPacketBuilder, tickFrequencySeconds) //.withBatchSize(1) ; TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("nifiInput", new NiFiSpout(inputConfig)); builder.setBolt("nifiOutput", niFiBolt).shuffleGrouping("nifiInput"); // Submit the topology running in local mode Config conf = new Config(); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("test", conf, builder.createTopology()); Utils.sleep(90000); cluster.shutdown(); }
Example #23
Source File: TestStandardRemoteGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testSendBatchBySize() throws Exception { final SiteToSiteClientConfig siteToSiteClientConfig = new SiteToSiteClient.Builder() .requestBatchSize(30) .buildConfig(); setupMock(SiteToSiteTransportProtocol.HTTP, TransferDirection.SEND, siteToSiteClientConfig); // t1 = {10, 11, 12}, t2 = {13, 14} final int[] expectedNumberOfPackets = {3, 2}; testSendBatch(expectedNumberOfPackets); }
Example #24
Source File: TestStandardRemoteGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testSendBatchByCount() throws Exception { final SiteToSiteClientConfig siteToSiteClientConfig = new SiteToSiteClient.Builder() .requestBatchCount(2) .buildConfig(); setupMock(SiteToSiteTransportProtocol.HTTP, TransferDirection.SEND, siteToSiteClientConfig); // t1 = {0, 1}, t2 = {2, 3}, t3 = {4} final int[] expectedNumberOfPackets = {2, 2, 1}; testSendBatch(expectedNumberOfPackets); }
Example #25
Source File: SiteToSiteCliMainTest.java From nifi with Apache License 2.0 | 5 votes |
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 #26
Source File: TestStandardRemoteGroupPort.java From nifi with Apache License 2.0 | 5 votes |
private void setupMock(final SiteToSiteTransportProtocol protocol, final TransferDirection direction, final SiteToSiteClientConfig siteToSiteClientConfig) throws Exception { processGroup = null; remoteGroup = mock(RemoteProcessGroup.class); scheduler = null; siteToSiteClient = mock(SiteToSiteClient.class); this.transaction = mock(Transaction.class); eventReporter = mock(EventReporter.class); final ConnectableType connectableType; switch (direction) { case SEND: connectableType = ConnectableType.REMOTE_INPUT_PORT; break; case RECEIVE: connectableType = ConnectableType.OUTPUT_PORT; break; default: connectableType = null; break; } port = spy(new StandardRemoteGroupPort(ID, ID, NAME, remoteGroup, direction, connectableType, null, scheduler, new StandardNiFiProperties())); doReturn(true).when(remoteGroup).isTransmitting(); doReturn(protocol).when(remoteGroup).getTransportProtocol(); doReturn(REMOTE_CLUSTER_URL).when(remoteGroup).getTargetUri(); doReturn(siteToSiteClient).when(port).getSiteToSiteClient(); doReturn(transaction).when(siteToSiteClient).createTransaction(eq(direction)); doReturn(siteToSiteClientConfig).when(siteToSiteClient).getConfig(); doReturn(eventReporter).when(remoteGroup).getEventReporter(); }
Example #27
Source File: TestSiteToSiteClient.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testSerialization() { final SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("input") .buildConfig(); final Kryo kryo = new Kryo(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final Output output = new Output(out); try { kryo.writeObject(output, clientConfig); } finally { output.close(); } final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); final Input input = new Input(in); try { SiteToSiteClientConfig clientConfig2 = kryo.readObject(input, SiteToSiteClient.StandardSiteToSiteClientConfig.class); Assert.assertEquals(clientConfig.getUrls(), clientConfig2.getUrls()); } finally { input.close(); } }
Example #28
Source File: TestSiteToSiteClient.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testSerializationWithStateManager() { final StateManager stateManager = Mockito.mock(StateManager.class); final SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder() .url("http://localhost:8080/nifi") .portName("input") .stateManager(stateManager) .buildConfig(); final Kryo kryo = new Kryo(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final Output output = new Output(out); try { kryo.writeObject(output, clientConfig); } finally { output.close(); } final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); final Input input = new Input(in); try { SiteToSiteClientConfig clientConfig2 = kryo.readObject(input, SiteToSiteClient.StandardSiteToSiteClientConfig.class); Assert.assertEquals(clientConfig.getUrls(), clientConfig2.getUrls()); // Serialization works, but the state manager is not serialized. Assert.assertNotNull(clientConfig.getStateManager()); Assert.assertNull(clientConfig2.getStateManager()); } finally { input.close(); } }
Example #29
Source File: TestSiteToSiteClient.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testGetUrlBackwardCompatibility() { final Set<String> urls = new LinkedHashSet<>(); urls.add("http://node1:8080/nifi"); urls.add("http://node2:8080/nifi"); final SiteToSiteClientConfig config = new SiteToSiteClient.Builder() .urls(urls) .buildConfig(); Assert.assertEquals("http://node1:8080/nifi", config.getUrl()); Assert.assertEquals(urls, config.getUrls()); }
Example #30
Source File: NiFiBolt.java From nifi with Apache License 2.0 | 5 votes |
public NiFiBolt(final SiteToSiteClientConfig clientConfig, final NiFiDataPacketBuilder builder, final int tickFrequencySeconds) { Validate.notNull(clientConfig); Validate.notNull(builder); Validate.isTrue(tickFrequencySeconds > 0); this.clientConfig = clientConfig; this.builder = builder; this.tickFrequencySeconds = tickFrequencySeconds; }