use of org.apache.samza.Partition in project samza by apache.
the class TestJoinOperator method createStreamOperatorTask.
private StreamOperatorTask createStreamOperatorTask(Clock clock, StreamApplication app) throws Exception {
ApplicationRunner runner = mock(ApplicationRunner.class);
when(runner.getStreamSpec("instream")).thenReturn(new StreamSpec("instream", "instream", "insystem"));
when(runner.getStreamSpec("instream2")).thenReturn(new StreamSpec("instream2", "instream2", "insystem2"));
TaskContext taskContext = mock(TaskContext.class);
when(taskContext.getSystemStreamPartitions()).thenReturn(ImmutableSet.of(new SystemStreamPartition("insystem", "instream", new Partition(0)), new SystemStreamPartition("insystem2", "instream2", new Partition(0))));
when(taskContext.getMetricsRegistry()).thenReturn(new MetricsRegistryMap());
Config config = mock(Config.class);
StreamOperatorTask sot = new StreamOperatorTask(app, runner, clock);
sot.init(config, taskContext);
return sot;
}
use of org.apache.samza.Partition in project samza by apache.
the class TestWindowOperator method setup.
@Before
public void setup() throws Exception {
config = mock(Config.class);
taskContext = mock(TaskContext.class);
runner = mock(ApplicationRunner.class);
when(taskContext.getSystemStreamPartitions()).thenReturn(ImmutableSet.of(new SystemStreamPartition("kafka", "integers", new Partition(0))));
when(taskContext.getMetricsRegistry()).thenReturn(new MetricsRegistryMap());
when(runner.getStreamSpec("integers")).thenReturn(new StreamSpec("integers", "integers", "kafka"));
}
use of org.apache.samza.Partition in project samza by apache.
the class TestSamzaObjectMapper method setup.
@Before
public void setup() throws IOException {
Map<String, String> configMap = new HashMap<String, String>();
Set<SystemStreamPartition> ssp = new HashSet<>();
configMap.put("a", "b");
Config config = new MapConfig(configMap);
TaskName taskName = new TaskName("test");
ssp.add(new SystemStreamPartition("foo", "bar", new Partition(1)));
TaskModel taskModel = new TaskModel(taskName, ssp, new Partition(2));
Map<TaskName, TaskModel> tasks = new HashMap<TaskName, TaskModel>();
tasks.put(taskName, taskModel);
ContainerModel containerModel = new ContainerModel("1", 1, tasks);
Map<String, ContainerModel> containerMap = new HashMap<String, ContainerModel>();
containerMap.put("1", containerModel);
jobModel = new JobModel(config, containerMap);
}
use of org.apache.samza.Partition in project samza by apache.
the class TestSinglePartitionWithoutOffsetsSystemAdmin method testShouldGetASinglePartition.
@Test
public void testShouldGetASinglePartition() {
SinglePartitionWithoutOffsetsSystemAdmin admin = new SinglePartitionWithoutOffsetsSystemAdmin();
Set<String> streamNames = new HashSet<String>();
streamNames.add("a");
streamNames.add("b");
Map<String, SystemStreamMetadata> metadata = admin.getSystemStreamMetadata(streamNames);
assertEquals(2, metadata.size());
SystemStreamMetadata metadata1 = metadata.get("a");
SystemStreamMetadata metadata2 = metadata.get("b");
assertEquals(1, metadata1.getSystemStreamPartitionMetadata().size());
assertEquals(1, metadata2.getSystemStreamPartitionMetadata().size());
assertNull(metadata.get(new SystemStreamPartition("test-system", "c", new Partition(0))));
}
use of org.apache.samza.Partition in project samza by apache.
the class TestExecutionPlanner method createSystemAdmin.
static SystemAdmin createSystemAdmin(Map<String, Integer> streamToPartitions) {
return new SystemAdmin() {
@Override
public Map<SystemStreamPartition, String> getOffsetsAfter(Map<SystemStreamPartition, String> offsets) {
return null;
}
@Override
public Map<String, SystemStreamMetadata> getSystemStreamMetadata(Set<String> streamNames) {
Map<String, SystemStreamMetadata> map = new HashMap<>();
for (String stream : streamNames) {
Map<Partition, SystemStreamMetadata.SystemStreamPartitionMetadata> m = new HashMap<>();
for (int i = 0; i < streamToPartitions.get(stream); i++) {
m.put(new Partition(i), new SystemStreamMetadata.SystemStreamPartitionMetadata("", "", ""));
}
map.put(stream, new SystemStreamMetadata(stream, m));
}
return map;
}
@Override
public void createChangelogStream(String streamName, int numOfPartitions) {
}
@Override
public void validateChangelogStream(String streamName, int numOfPartitions) {
}
@Override
public void createCoordinatorStream(String streamName) {
}
@Override
public Integer offsetComparator(String offset1, String offset2) {
return null;
}
};
}
Aggregations