Search in sources :

Example 31 with StreamConfig

use of org.apache.samza.config.StreamConfig in project samza by apache.

the class TestStreamUtil method testGetStreamSystemNameArgValid.

// When the system name is provided explicitly, it should be used, regardless of whether it's also in the config
@Test
public void testGetStreamSystemNameArgValid() {
    Config config = buildStreamConfig(STREAM_ID, // This should be ignored because of the explicit arg
    StreamConfig.PHYSICAL_NAME, // This should be ignored because of the explicit arg
    TEST_PHYSICAL_NAME, StreamConfig.SYSTEM, // This too
    TEST_SYSTEM);
    StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config));
    assertEquals(STREAM_ID, spec.getId());
    assertEquals(TEST_PHYSICAL_NAME, spec.getPhysicalName());
    assertEquals(TEST_SYSTEM, spec.getSystemName());
}
Also used : StreamSpec(org.apache.samza.system.StreamSpec) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) StreamConfig(org.apache.samza.config.StreamConfig) StreamConfig(org.apache.samza.config.StreamConfig) Test(org.junit.Test)

Example 32 with StreamConfig

use of org.apache.samza.config.StreamConfig in project samza by apache.

the class TestStreamUtil method testGetStreamStreamIdInvalid.

// Special characters are NOT allowed for streamId, because it's used as an identifier in the config.
@Test(expected = IllegalArgumentException.class)
public void testGetStreamStreamIdInvalid() {
    Config config = buildStreamConfig(STREAM_ID_INVALID, StreamConfig.SYSTEM, TEST_SYSTEM);
    StreamUtil.getStreamSpec(STREAM_ID_INVALID, new StreamConfig(config));
}
Also used : JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) StreamConfig(org.apache.samza.config.StreamConfig) StreamConfig(org.apache.samza.config.StreamConfig) Test(org.junit.Test)

Example 33 with StreamConfig

use of org.apache.samza.config.StreamConfig in project samza by apache.

the class TestStreamUtil method testGetStreamSystemNameArgEmpty.

// Empty strings are NOT allowed for system name, because it's used as an identifier in the config.
@Test(expected = IllegalArgumentException.class)
public void testGetStreamSystemNameArgEmpty() {
    Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME, TEST_PHYSICAL_NAME, StreamConfig.SYSTEM, "");
    StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config));
}
Also used : StreamSpec(org.apache.samza.system.StreamSpec) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) StreamConfig(org.apache.samza.config.StreamConfig) StreamConfig(org.apache.samza.config.StreamConfig) Test(org.junit.Test)

Example 34 with StreamConfig

use of org.apache.samza.config.StreamConfig in project samza by apache.

the class TestStreamUtil method testStreamConfigOverridesWithSystemDefaults.

// Verify that we use a default specified with systems.x.default.stream.*, if specified
@Test
public void testStreamConfigOverridesWithSystemDefaults() {
    Config config = addConfigs(buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME, TEST_PHYSICAL_NAME, StreamConfig.SYSTEM, TEST_SYSTEM, "segment.bytes", "5309"), // System default property
    String.format("systems.%s.default.stream.replication.factor", TEST_SYSTEM), // System default property
    "4", String.format("systems.%s.default.stream.segment.bytest", TEST_SYSTEM), "867");
    StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config));
    Map<String, String> properties = spec.getConfig();
    assertEquals(3, properties.size());
    // Uses system default
    assertEquals("4", properties.get("replication.factor"));
    // Overrides system default
    assertEquals("5309", properties.get("segment.bytes"));
}
Also used : StreamSpec(org.apache.samza.system.StreamSpec) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) StreamConfig(org.apache.samza.config.StreamConfig) StreamConfig(org.apache.samza.config.StreamConfig) Test(org.junit.Test)

Example 35 with StreamConfig

use of org.apache.samza.config.StreamConfig in project samza by apache.

the class OperatorImplGraph method computeOutputToInput.

private static void computeOutputToInput(SystemStream input, OperatorSpec opSpec, Multimap<SystemStream, SystemStream> outputToInputStreams, StreamConfig streamConfig) {
    if (opSpec instanceof PartitionByOperatorSpec) {
        PartitionByOperatorSpec spec = (PartitionByOperatorSpec) opSpec;
        SystemStream systemStream = streamConfig.streamIdToSystemStream(spec.getOutputStream().getStreamId());
        outputToInputStreams.put(systemStream, input);
    } else if (opSpec instanceof BroadcastOperatorSpec) {
        BroadcastOperatorSpec spec = (BroadcastOperatorSpec) opSpec;
        SystemStream systemStream = streamConfig.streamIdToSystemStream(spec.getOutputStream().getStreamId());
        outputToInputStreams.put(systemStream, input);
    } else {
        Collection<OperatorSpec> nextOperators = opSpec.getRegisteredOperatorSpecs();
        nextOperators.forEach(spec -> computeOutputToInput(input, spec, outputToInputStreams, streamConfig));
    }
}
Also used : StreamOperatorSpec(org.apache.samza.operators.spec.StreamOperatorSpec) BroadcastOperatorSpec(org.apache.samza.operators.spec.BroadcastOperatorSpec) PartialJoinFunction(org.apache.samza.operators.functions.PartialJoinFunction) PartitionByOperatorSpec(org.apache.samza.operators.spec.PartitionByOperatorSpec) SendToTableWithUpdateOperatorSpec(org.apache.samza.operators.spec.SendToTableWithUpdateOperatorSpec) LoggerFactory(org.slf4j.LoggerFactory) JoinOperatorSpec(org.apache.samza.operators.spec.JoinOperatorSpec) HashMap(java.util.HashMap) TimestampedValue(org.apache.samza.util.TimestampedValue) Multimap(com.google.common.collect.Multimap) OperatorSpecGraph(org.apache.samza.operators.OperatorSpecGraph) StreamConfig(org.apache.samza.config.StreamConfig) SendToTableOperatorSpec(org.apache.samza.operators.spec.SendToTableOperatorSpec) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) OperatorSpec(org.apache.samza.operators.spec.OperatorSpec) SinkOperatorSpec(org.apache.samza.operators.spec.SinkOperatorSpec) SystemStream(org.apache.samza.system.SystemStream) AsyncFlatMapOperatorSpec(org.apache.samza.operators.spec.AsyncFlatMapOperatorSpec) Map(java.util.Map) KV(org.apache.samza.operators.KV) JobModel(org.apache.samza.job.model.JobModel) Logger(org.slf4j.Logger) OutputOperatorSpec(org.apache.samza.operators.spec.OutputOperatorSpec) Collection(java.util.Collection) WindowOperatorSpec(org.apache.samza.operators.spec.WindowOperatorSpec) Scheduler(org.apache.samza.operators.Scheduler) Clock(org.apache.samza.util.Clock) JoinFunction(org.apache.samza.operators.functions.JoinFunction) Collectors(java.util.stream.Collectors) Context(org.apache.samza.context.Context) List(java.util.List) StreamTableJoinOperatorSpec(org.apache.samza.operators.spec.StreamTableJoinOperatorSpec) Config(org.apache.samza.config.Config) KeyValueStore(org.apache.samza.storage.kv.KeyValueStore) Collections(java.util.Collections) InternalTaskContext(org.apache.samza.context.InternalTaskContext) InputOperatorSpec(org.apache.samza.operators.spec.InputOperatorSpec) SystemStream(org.apache.samza.system.SystemStream) PartitionByOperatorSpec(org.apache.samza.operators.spec.PartitionByOperatorSpec) Collection(java.util.Collection) BroadcastOperatorSpec(org.apache.samza.operators.spec.BroadcastOperatorSpec)

Aggregations

StreamConfig (org.apache.samza.config.StreamConfig)39 Config (org.apache.samza.config.Config)33 MapConfig (org.apache.samza.config.MapConfig)32 Test (org.junit.Test)31 JobConfig (org.apache.samza.config.JobConfig)23 StreamSpec (org.apache.samza.system.StreamSpec)17 Collection (java.util.Collection)11 StreamApplicationDescriptorImpl (org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl)10 OperatorSpecGraph (org.apache.samza.operators.OperatorSpecGraph)10 SamzaSqlApplicationConfig (org.apache.samza.sql.runner.SamzaSqlApplicationConfig)9 SamzaSqlQueryParser (org.apache.samza.sql.util.SamzaSqlQueryParser)9 SamzaSqlTestConfig (org.apache.samza.sql.util.SamzaSqlTestConfig)9 SystemStream (org.apache.samza.system.SystemStream)6 HashMap (java.util.HashMap)3 ApplicationConfig (org.apache.samza.config.ApplicationConfig)3 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2