Search in sources :

Example 6 with OutgoingMessageEnvelope

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));
}
Also used : OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 7 with OutgoingMessageEnvelope

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());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 8 with OutgoingMessageEnvelope

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());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 9 with OutgoingMessageEnvelope

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());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 10 with OutgoingMessageEnvelope

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);
        }
    }
}
Also used : OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) IOException(java.io.IOException) SamzaException(org.apache.samza.SamzaException)

Aggregations

OutgoingMessageEnvelope (org.apache.samza.system.OutgoingMessageEnvelope)20 Test (org.junit.Test)12 IndexRequest (org.elasticsearch.action.index.IndexRequest)8 SystemStream (org.apache.samza.system.SystemStream)7 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 SamzaException (org.apache.samza.SamzaException)2 MessageType (org.apache.samza.operators.data.MessageType)2 TestMessageEnvelope (org.apache.samza.operators.data.TestMessageEnvelope)2 MessageCollector (org.apache.samza.task.MessageCollector)2 TaskCoordinator (org.apache.samza.task.TaskCoordinator)2 TypeReference (org.codehaus.jackson.type.TypeReference)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 CoordinatorStreamMessage (org.apache.samza.coordinator.stream.messages.CoordinatorStreamMessage)1 Delete (org.apache.samza.coordinator.stream.messages.Delete)1 SetConfig (org.apache.samza.coordinator.stream.messages.SetConfig)1 OperatorSpec (org.apache.samza.operators.spec.OperatorSpec)1 PartialJoinOperatorSpec (org.apache.samza.operators.spec.PartialJoinOperatorSpec)1