/** * Copies this StreamSpec, but applies a new partitionCount. * * This method is not static s.t. subclasses can override it. * * @param partitionCount The partitionCount for the returned StreamSpec. * @return A copy of this StreamSpec with the specified partitionCount. */ public StreamSpec copyWithPartitionCount(int partitionCount) { return new StreamSpec(id, physicalName, systemName, partitionCount, config); }
/** * Copies this StreamSpec, but applies a new partitionCount. * * This method is not static s.t. subclasses can override it. * * @param partitionCount The partitionCount for the returned StreamSpec. * @return A copy of this StreamSpec with the specified partitionCount. */ public StreamSpec copyWithPartitionCount(int partitionCount) { return new StreamSpec(id, physicalName, systemName, partitionCount, config); }
public static StreamSpec createCheckpointStreamSpec(String physicalName, String systemName) { return new StreamSpec(CHECKPOINT_STREAM_ID, physicalName, systemName, 1); }
public static StreamSpec createCoordinatorStreamSpec(String physicalName, String systemName) { return new StreamSpec(COORDINATOR_STREAM_ID, physicalName, systemName, 1); }
private StreamSpec genStream() { ++streamSeq; return new StreamSpec(String.valueOf(streamSeq), "test-stream", "test-system"); }
@Test(expected = IllegalArgumentException.class) public void testInvalidSystemName() { new StreamSpec("dummyId", "dummyPhysicalName", "dummy.System.Name", 0); } }
public static StreamSpec getStreamSpec(String streamId, StreamConfig streamConfig) { String physicalName = streamConfig.getPhysicalName(streamId); String system = streamConfig.getSystem(streamId); Map<String, String> streamProperties = streamConfig.getStreamProperties(streamId); return new StreamSpec(streamId, physicalName, system, streamProperties); } }
public static StreamSpec getStreamSpec(String streamId, StreamConfig streamConfig) { String physicalName = streamConfig.getPhysicalName(streamId); String system = streamConfig.getSystem(streamId); Map<String, String> streamProperties = streamConfig.getStreamProperties(streamId); return new StreamSpec(streamId, physicalName, system, streamProperties); } }
@Test(expected = IllegalArgumentException.class) public void testInvalidPartitionCount() { new StreamSpec("dummyId", "dummyPhysicalName", "dummySystemName", -1); }
@Test(expected = IllegalArgumentException.class) public void testInvalidStreamId() { new StreamSpec("dummy.Id", "dummyPhysicalName", "dummySystemName", 0); }
public static StreamSpec getStreamSpec(String streamId, StreamConfig streamConfig) { String physicalName = streamConfig.getPhysicalName(streamId); String system = streamConfig.getSystem(streamId); Map<String, String> streamProperties = streamConfig.getStreamProperties(streamId); return new StreamSpec(streamId, physicalName, system, streamProperties); } }
public static StreamSpec getStreamSpec(String streamId, StreamConfig streamConfig) { String physicalName = streamConfig.getPhysicalName(streamId); String system = streamConfig.getSystem(streamId); Map<String, String> streamProperties = streamConfig.getStreamProperties(streamId); return new StreamSpec(streamId, physicalName, system, streamProperties); } }
public static StreamSpec getStreamSpec(String streamId, StreamConfig streamConfig) { String physicalName = streamConfig.getPhysicalName(streamId); String system = streamConfig.getSystem(streamId); Map<String, String> streamProperties = streamConfig.getStreamProperties(streamId); return new StreamSpec(streamId, physicalName, system, streamProperties); } }
/** * A test case to verify if the plan results in same hash in case of same plan. * Note: the overall JOB PLAN remains the same outside the scope of intermediate streams the sake of these test cases. */ @Test public void testGeneratePlanIdWithSameStreamSpecs() { List<StreamSpec> streamSpecs = ImmutableList.of(new StreamSpec("test-stream-1", "stream-1", "testStream"), new StreamSpec("test-stream-2", "stream-2", "testStream"), new StreamSpec("test-stream-3", "stream-3", "testStream")); String planIdForFirstAttempt = getExecutionPlanId(streamSpecs); String planIdForSecondAttempt = getExecutionPlanId(streamSpecs); assertEquals("Expected latch ids to match!", "1447946713", planIdForFirstAttempt); assertEquals("Expected latch ids to match for the second attempt!", planIdForFirstAttempt, planIdForSecondAttempt); }
@Test(expected = StreamValidationException.class) public void testValidateStreamDoesNotExist() { StreamSpec spec = new StreamSpec("testId", "testStreamNameExist", "testSystem", 8); systemAdmin().validateStream(spec); }
@Test(expected = StreamValidationException.class) public void testValidateStreamWrongName() { 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.", systemAdmin().createStream(spec1)); systemAdmin().validateStream(spec2); }
@Test(expected = StreamValidationException.class) public void testValidateStreamWrongPartitionCount() { 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.", systemAdmin().createStream(spec1)); systemAdmin().validateStream(spec2); }
public TestInMemorySystem() { Config config = new MapConfig(); systemFactory = new InMemorySystemFactory(); systemAdmin = systemFactory.getAdmin(SYSTEM_NAME, config); systemAdmin.createStream(new StreamSpec(STREAM_NAME, STREAM_NAME, SYSTEM_NAME, PARTITION_COUNT)); }
@Test public void testCreateStream() { StreamSpec spec = new StreamSpec("testId", "testStream", "testSystem", 8); KafkaSystemAdmin admin = systemAdmin(); assertTrue("createStream should return true if the stream does not exist and then is created.", admin.createStream(spec)); admin.validateStream(spec); assertFalse("createStream should return false if the stream already exists.", systemAdmin().createStream(spec)); }
@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()); }