use of org.apache.samza.system.OutgoingMessageEnvelope in project samza by apache.
the class DefaultIndexRequestFactoryTest method testGetIndexRequestInvalidStreamName.
@Test(expected = SamzaException.class)
public void testGetIndexRequestInvalidStreamName() {
when(SYSTEM.getStream()).thenReturn(INDEX);
indexRequestFactory.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, EMPTY_MSG));
}
use of org.apache.samza.system.OutgoingMessageEnvelope in project samza by apache.
the class DefaultIndexRequestFactoryTest method testGetIndexRequestWithId.
@Test
public void testGetIndexRequestWithId() throws Exception {
IndexRequest indexRequest = indexRequestFactory.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, "id", EMPTY_MSG));
assertEquals("id", indexRequest.id());
}
use of org.apache.samza.system.OutgoingMessageEnvelope in project samza by apache.
the class DefaultIndexRequestFactoryTest method testGetIndexRequestWithPartitionKey.
@Test
public void testGetIndexRequestWithPartitionKey() throws Exception {
IndexRequest indexRequest = indexRequestFactory.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, "shardKey", "id", EMPTY_MSG));
assertEquals("shardKey", indexRequest.routing());
}
use of org.apache.samza.system.OutgoingMessageEnvelope in project samza by apache.
the class DefaultIndexRequestFactoryTest method testGetIndexRequestMessageMap.
@Test
public void testGetIndexRequestMessageMap() throws Exception {
IndexRequest indexRequest = indexRequestFactory.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, Collections.singletonMap("foo", "bar")));
assertEquals(Collections.singletonMap("foo", "bar"), indexRequest.sourceAsMap());
}
use of org.apache.samza.system.OutgoingMessageEnvelope in project samza by apache.
the class StreamAppender method append.
@Override
public void append(LoggingEvent event) {
if (!recursiveCall.get()) {
try {
recursiveCall.set(true);
if (!systemInitialized) {
if (JobModelManager.currentJobModelManager() != null) {
// JobCoordinator has been instantiated
setupSystem();
systemInitialized = true;
} else {
log.trace("Waiting for the JobCoordinator to be instantiated...");
}
} else {
OutgoingMessageEnvelope outgoingMessageEnvelope = new OutgoingMessageEnvelope(systemStream, key.getBytes("UTF-8"), serde.toBytes(subLog(event)));
systemProducer.send(SOURCE, outgoingMessageEnvelope);
}
} catch (Exception e) {
System.err.println("[StreamAppender] Error sending log message:");
e.printStackTrace();
} finally {
recursiveCall.set(false);
}
}
}
Aggregations