public SystemStream toSystemStream() { return new SystemStream(systemName, physicalName); }
public SystemStream getSystemStream() { return new SystemStream(system, stream); }
@Override public Set<SystemStream> getAllSystemStreams() { return ((Set<String>) this.metadataConsumer.listTopics().keySet()).stream() .map(x -> new SystemStream(systemName, x)) .collect(Collectors.toSet()); }
@Override public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException { int idx = sspString.indexOf('.'); int lastIdx = sspString.lastIndexOf('.'); if (idx < 0 || lastIdx < 0) { throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition"); } return new SystemStreamPartition( new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)), new Partition(Integer.parseInt(sspString.substring(lastIdx + 1)))); } }
@Override public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException { int idx = sspString.indexOf('.'); int lastIdx = sspString.lastIndexOf('.'); if (idx < 0 || lastIdx < 0) { throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition"); } return new SystemStreamPartition( new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)), new Partition(Integer.parseInt(sspString.substring(lastIdx + 1)))); } }
@Override public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException { int idx = sspString.indexOf('.'); int lastIdx = sspString.lastIndexOf('.'); if (idx < 0 || lastIdx < 0) { throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition"); } return new SystemStreamPartition( new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)), new Partition(Integer.parseInt(sspString.substring(lastIdx + 1)))); } }
@Override public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException { int idx = sspString.indexOf('.'); int lastIdx = sspString.lastIndexOf('.'); if (idx < 0 || lastIdx < 0) { throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition"); } return new SystemStreamPartition( new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)), new Partition(Integer.parseInt(sspString.substring(lastIdx + 1)))); } }
@Override public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException { int idx = sspString.indexOf('.'); int lastIdx = sspString.lastIndexOf('.'); if (idx < 0 || lastIdx < 0) { throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition"); } return new SystemStreamPartition( new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)), new Partition(Integer.parseInt(sspString.substring(lastIdx + 1)))); } }
public String getStreamSerdeName(String systemName, String streamName) { StreamConfig streamConfig = new StreamConfig(this); scala.Option<String> option = streamConfig.getStreamMsgSerde(new SystemStream(systemName, streamName)); return option.isEmpty() ? null : option.get(); } }
public String getStreamSerdeName(String systemName, String streamName) { StreamConfig streamConfig = new StreamConfig(this); scala.Option<String> option = streamConfig.getStreamMsgSerde(new SystemStream(systemName, streamName)); return option.isEmpty() ? null : option.get(); } }
private OutgoingMessageEnvelope createMessageEnvelope(String streamName) { return new OutgoingMessageEnvelope(new SystemStream(SYSTEM_NAME, streamName), "key1".getBytes(), "value".getBytes()); }
private OutgoingMessageEnvelope createMessageEnvelope(String streamName, int partition) { return new OutgoingMessageEnvelope(new SystemStream(SYSTEM_NAME, streamName), partition, "key1".getBytes(), "value0".getBytes()); }
@Test(expected = IllegalArgumentException.class) public void testContainsSamzaPropertyThrowsIfInvalidPropertyName() { StreamConfig config = buildConfig("key1", "value1", "key2", "value2"); config.containsSamzaProperty(new SystemStream("SysX", "StrX"), "key1"); }
@Before public void setup() { mockCoordinatorStreamSystemFactory = new MockCoordinatorStreamSystemFactory(); MockCoordinatorStreamSystemFactory.enableMockConsumerCache(); PowerMockito.mockStatic(CoordinatorStreamUtil.class); when(CoordinatorStreamUtil.getCoordinatorSystemFactory(anyObject())).thenReturn(mockCoordinatorStreamSystemFactory); when(CoordinatorStreamUtil.getCoordinatorSystemStream(anyObject())).thenReturn(new SystemStream("test-kafka", "test")); when(CoordinatorStreamUtil.getCoordinatorStreamName(anyObject(), anyObject())).thenReturn("test"); }
private MetricsSnapshotReporter getMetricsSnapshotReporter(String blacklist) { return new MetricsSnapshotReporter(new InMemorySystemProducer("test system", null), new SystemStream("test system", "test stream"), 60000, "test job", "test jobID", "samza-container-0", "test version", "test samza version", "test host", new MetricsSnapshotSerdeV2(), new Some<>(blacklist), new AbstractFunction0<Object>() { @Override public Object apply() { return System.currentTimeMillis(); } }); } }
@Before public void setup() { MockCoordinatorStreamSystemFactory.enableMockConsumerCache(); mockCoordinatorStreamSystemFactory = new MockCoordinatorStreamSystemFactory(); PowerMockito.mockStatic(CoordinatorStreamUtil.class); when(CoordinatorStreamUtil.getCoordinatorSystemFactory(anyObject())).thenReturn(mockCoordinatorStreamSystemFactory); when(CoordinatorStreamUtil.getCoordinatorSystemStream(anyObject())).thenReturn(new SystemStream("test-kafka", "test")); when(CoordinatorStreamUtil.getCoordinatorStreamName(anyObject(), anyObject())).thenReturn("test"); }
@Before public void setUp() { MockCoordinatorStreamSystemFactory.enableMockConsumerCache(); Map<String, String> configMap = ImmutableMap.of("job.name", "test-job", "job.coordinator.system", "test-kafka"); MockCoordinatorStreamSystemFactory systemFactory = new MockCoordinatorStreamSystemFactory(); PowerMockito.mockStatic(CoordinatorStreamUtil.class); when(CoordinatorStreamUtil.getCoordinatorSystemFactory(anyObject())).thenReturn(systemFactory); when(CoordinatorStreamUtil.getCoordinatorSystemStream(anyObject())).thenReturn(new SystemStream("test-kafka", "test")); when(CoordinatorStreamUtil.getCoordinatorStreamName(anyObject(), anyObject())).thenReturn("test"); coordinatorStreamStore = new CoordinatorStreamStore(SetTaskContainerMapping.TYPE, new MapConfig(configMap), new MetricsRegistryMap()); coordinatorStreamStore.init(); }
private SystemStream getCoordinatorSystemStream(Config config) { assertNotNull(config.get("job.coordinator.system")); assertNotNull(config.get("job.name")); return new SystemStream(config.get("job.coordinator.system"), CoordinatorStreamUtil.getCoordinatorStreamName(config.get("job.name"), config.get("job.id") == null ? "1" : config.get("job.id"))); }
@Test public void testBasicConstructor() { StreamSpec streamSpec = new StreamSpec("dummyId", "dummyPhysicalName", "dummySystemName", 1); assertEquals("dummyId", streamSpec.getId()); assertEquals("dummyPhysicalName", streamSpec.getPhysicalName()); assertEquals("dummySystemName", streamSpec.getSystemName()); assertEquals(1, streamSpec.getPartitionCount()); // SystemStream should use the physical name, not the streamId. SystemStream systemStream = new SystemStream("dummySystemName", "dummyPhysicalName"); assertEquals(systemStream, streamSpec.toSystemStream()); }
private StreamApplicationDescriptorImpl getKeyedSessionWindowStreamGraph(AccumulationMode mode, Duration duration) throws IOException { StreamApplication userApp = appDesc -> { KVSerde<Integer, Integer> kvSerde = KVSerde.of(new IntegerSerde(), new IntegerSerde()); GenericSystemDescriptor sd = new GenericSystemDescriptor("kafka", "mockFactoryClass"); GenericInputDescriptor<KV<Integer, Integer>> inputDescriptor = sd.getInputDescriptor("integers", kvSerde); appDesc.getInputStream(inputDescriptor) .window(Windows.keyedSessionWindow(KV::getKey, duration, new IntegerSerde(), kvSerde) .setAccumulationMode(mode), "w1") .sink((message, messageCollector, taskCoordinator) -> { SystemStream outputSystemStream = new SystemStream("outputSystem", "outputStream"); messageCollector.send(new OutgoingMessageEnvelope(outputSystemStream, message)); }); }; return new StreamApplicationDescriptorImpl(userApp, config); }