use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestKafkaSystemAdminJava method testValidateStreamWrongName.
@Test(expected = StreamValidationException.class)
public void testValidateStreamWrongName() {
SystemAdmin admin = this.basicSystemAdmin;
StreamSpec spec1 = new StreamSpec("testId", "testStreamName1", "testSystem", 8);
StreamSpec spec2 = new StreamSpec("testId", "testStreamName2", "testSystem", 8);
assertTrue("createStream should return true if the stream does not exist and then is created.", admin.createStream(spec1));
admin.validateStream(spec2);
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestKafkaSystemAdminJava method testValidateStreamWrongPartitionCount.
@Test(expected = StreamValidationException.class)
public void testValidateStreamWrongPartitionCount() {
SystemAdmin admin = this.basicSystemAdmin;
StreamSpec spec1 = new StreamSpec("testId", "testStreamPartition", "testSystem", 8);
StreamSpec spec2 = new StreamSpec("testId", "testStreamPartition", "testSystem", 4);
assertTrue("createStream should return true if the stream does not exist and then is created.", admin.createStream(spec1));
admin.validateStream(spec2);
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestKafkaSystemAdminJava method testValidateChangelogStreamDelegatesToValidateStream.
@Test
public void testValidateChangelogStreamDelegatesToValidateStream() {
final String STREAM = "testChangeLogValidate";
Properties coordProps = new Properties();
Map<String, ChangelogInfo> changeLogMap = new HashMap<>();
changeLogMap.put(STREAM, new ChangelogInfo(3, new Properties()));
KafkaSystemAdmin systemAdmin = createSystemAdmin(coordProps, 3, Util.javaMapAsScalaMap(changeLogMap));
SystemAdmin admin = Mockito.spy(systemAdmin);
StreamSpec spec = new StreamSpec("testId", STREAM, "testSystem", 12);
admin.createChangelogStream(spec.getPhysicalName(), spec.getPartitionCount());
admin.validateStream(spec);
admin.validateChangelogStream(spec.getPhysicalName(), spec.getPartitionCount());
Mockito.verify(admin).createStream(Mockito.any());
Mockito.verify(admin, Mockito.times(3)).validateStream(Mockito.any());
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestKafkaSystemAdminJava method testCreateCoordinatorStreamDelegatesToCreateStream.
@Test
public void testCreateCoordinatorStreamDelegatesToCreateStream() {
//coordProps, 3, new scala.collection.immutable.HashMap<>(), 1000);
KafkaSystemAdmin systemAdmin = createSystemAdmin();
SystemAdmin admin = Mockito.spy(systemAdmin);
StreamSpec spec = new StreamSpec("testId", "testCoordinatorStream", "testSystem");
admin.createCoordinatorStream(spec.getPhysicalName());
admin.validateStream(spec);
Mockito.verify(admin).createStream(Mockito.any());
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class StreamManager method createStreams.
public void createStreams(List<StreamSpec> streams) {
Multimap<String, StreamSpec> streamsGroupedBySystem = HashMultimap.create();
streams.forEach(streamSpec -> streamsGroupedBySystem.put(streamSpec.getSystemName(), streamSpec));
for (Map.Entry<String, Collection<StreamSpec>> entry : streamsGroupedBySystem.asMap().entrySet()) {
String systemName = entry.getKey();
SystemAdmin systemAdmin = sysAdmins.get(systemName);
for (StreamSpec stream : entry.getValue()) {
LOGGER.info("Creating stream {} with partitions {} on system {}", new Object[] { stream.getPhysicalName(), stream.getPartitionCount(), systemName });
systemAdmin.createStream(stream);
}
}
}
Aggregations