/** * Registers a source with the underlying SystemProducer. * * @param source * The source to register. */ public void register(String source) { systemProducer.register(source); }
/** * Registers a source with the underlying SystemProducer. * * @param source * The source to register. */ public void register(String source) { systemProducer.register(source); }
/** * Registers a source with the underlying SystemProducer. * * @param source * The source to register. */ public void register(String source) { systemProducer.register(source); }
/** * Registers a source with the underlying SystemProducer. * * @param source * The source to register. */ public void register(String source) { systemProducer.register(source); }
/** * Registers a source with the underlying SystemProducer. * * @param source * The source to register. */ public void register(String source) { systemProducer.register(source); }
@Override public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); bootstrapMessagesFromStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }
@Override public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); bootstrapMessagesFromStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }
@Override public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); bootstrapMessagesFromStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }
@Override public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); bootstrapMessagesFromStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }
@Override public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); bootstrapMessagesFromStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }
@Test(expected=SamzaException.class) public void testFlushFailedSendFromException() throws Exception { ArgumentCaptor<BulkProcessor.Listener> listenerCaptor = ArgumentCaptor.forClass(BulkProcessor.Listener.class); when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), listenerCaptor.capture())) .thenReturn(processorOne); producer.register(SOURCE_ONE); listenerCaptor.getValue().afterBulk(0, null, new Throwable()); producer.flush(SOURCE_ONE); }
@Test(expected=SamzaException.class) public void testFlushFailedSendFromFailedDocument() throws Exception { ArgumentCaptor<BulkProcessor.Listener> listenerCaptor = ArgumentCaptor.forClass(BulkProcessor.Listener.class); when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), listenerCaptor.capture())) .thenReturn(processorOne); producer.register(SOURCE_ONE); BulkResponse response = getRespWithFailedDocument(RestStatus.BAD_REQUEST); listenerCaptor.getValue().afterBulk(0, null, response); producer.flush(SOURCE_ONE); }
@Before public void setUp() throws Exception { metrics = new ElasticsearchSystemProducerMetrics("es", new MetricsRegistryMap()); producer = new ElasticsearchSystemProducer(SYSTEM_NAME, BULK_PROCESSOR_FACTORY, CLIENT, INDEX_REQUEST_FACTORY, metrics); processorOne = mock(BulkProcessor.class); processorTwo = mock(BulkProcessor.class); when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), any(BulkProcessor.Listener.class))) .thenReturn(processorOne); producer.register(SOURCE_ONE); when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), any(BulkProcessor.Listener.class))) .thenReturn(processorTwo); producer.register(SOURCE_TWO); }
@Test public void testIgnoreVersionConficts() throws Exception { ArgumentCaptor<BulkProcessor.Listener> listenerCaptor = ArgumentCaptor.forClass(BulkProcessor.Listener.class); when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), listenerCaptor.capture())) .thenReturn(processorOne); producer.register(SOURCE_ONE); BulkResponse response = getRespWithFailedDocument(RestStatus.CONFLICT); listenerCaptor.getValue().afterBulk(0, null, response); assertEquals(1, metrics.conflicts.getCount()); producer.flush(SOURCE_ONE); }
@Test public void testSystemFactoryCreateAndStartProducer() { Config eventHubConfig = createEventHubConfig(); EventHubSystemFactory systemFactory = new EventHubSystemFactory(); SystemProducer systemProducer = systemFactory.getProducer(SYSTEM_NAME, eventHubConfig, new NoOpMetricsRegistry()); Assert.assertNotNull(systemProducer); systemProducer.register(STREAM_NAME1); systemProducer.register(STREAM_NAME2); systemProducer.start(); systemProducer.stop(); }
systemProducer.register(SOURCE); systemProducer.start();
systemProducer.register(SOURCE); systemProducer.start();
@Test public void testSendToSpecificPartition() { Config eventHubConfig = MockEventHubConfigFactory.getEventHubConfig(EventHubSystemProducer.PartitioningMethod.PARTITION_KEY_AS_PARTITION); EventHubSystemFactory systemFactory = new EventHubSystemFactory(); SystemProducer systemProducer = systemFactory.getProducer(SYSTEM_NAME, eventHubConfig, new NoOpMetricsRegistry()); systemProducer.register(STREAM_NAME1); systemProducer.start(); for (int i = 0; i < 100; i++) { systemProducer.send(STREAM_NAME1, createMessageEnvelope(STREAM_NAME1, 0)); } systemProducer.flush(STREAM_NAME1); systemProducer.stop(); }
@Test public void testSend() { Config eventHubConfig = createEventHubConfig(); EventHubSystemFactory systemFactory = new EventHubSystemFactory(); SystemProducer systemProducer = systemFactory.getProducer(SYSTEM_NAME, eventHubConfig, new NoOpMetricsRegistry()); systemProducer.register(STREAM_NAME1); try { systemProducer.send(STREAM_NAME1, createMessageEnvelope(STREAM_NAME1)); Assert.fail("Sending event before starting producer should throw exception"); } catch (SamzaException e) { } systemProducer.start(); systemProducer.send(STREAM_NAME1, createMessageEnvelope(STREAM_NAME1)); try { systemProducer.send("unregistered_stream", createMessageEnvelope("unregistered_stream")); Assert.fail("Sending event to destination that is not registered should throw exception"); } catch (SamzaException e) { } try { systemProducer.register(STREAM_NAME2); Assert.fail("Trying to register after starting producer should throw exception"); } catch (SamzaException e) { } systemProducer.flush(STREAM_NAME1); systemProducer.stop(); }