/** * Converts a StreamSpec into a KafakStreamSpec. Special handling for coordinator and changelog stream. * @param spec a StreamSpec object * @return KafkaStreamSpec object */ public KafkaStreamSpec toKafkaSpec(StreamSpec spec) { KafkaStreamSpec kafkaSpec; if (spec.isChangeLogStream()) { String topicName = spec.getPhysicalName(); ChangelogInfo topicMeta = changelogTopicMetaInformation.get(topicName); if (topicMeta == null) { throw new StreamValidationException("Unable to find topic information for topic " + topicName); } kafkaSpec = new KafkaStreamSpec(spec.getId(), topicName, systemName, spec.getPartitionCount(), topicMeta.replicationFactor(), topicMeta.kafkaProps()); } else if (spec.isCoordinatorStream()) { kafkaSpec = new KafkaStreamSpec(spec.getId(), spec.getPhysicalName(), systemName, 1, coordinatorStreamReplicationFactor, coordinatorStreamProperties); } else if (intermediateStreamProperties.containsKey(spec.getId())) { kafkaSpec = KafkaStreamSpec.fromSpec(spec).copyWithProperties(intermediateStreamProperties.get(spec.getId())); } else { kafkaSpec = KafkaStreamSpec.fromSpec(spec); } return kafkaSpec; }
/** * Converts a StreamSpec into a KafakStreamSpec. Special handling for coordinator and changelog stream. * @param spec a StreamSpec object * @return KafkaStreamSpec object */ public KafkaStreamSpec toKafkaSpec(StreamSpec spec) { KafkaStreamSpec kafkaSpec; if (spec.isChangeLogStream()) { String topicName = spec.getPhysicalName(); ChangelogInfo topicMeta = changelogTopicMetaInformation.get(topicName); if (topicMeta == null) { throw new StreamValidationException("Unable to find topic information for topic " + topicName); } kafkaSpec = new KafkaStreamSpec(spec.getId(), topicName, systemName, spec.getPartitionCount(), topicMeta.replicationFactor(), topicMeta.kafkaProps()); } else if (spec.isCoordinatorStream()) { kafkaSpec = new KafkaStreamSpec(spec.getId(), spec.getPhysicalName(), systemName, 1, coordinatorStreamReplicationFactor, coordinatorStreamProperties); } else if (intermediateStreamProperties.containsKey(spec.getId())) { kafkaSpec = KafkaStreamSpec.fromSpec(spec).copyWithProperties(intermediateStreamProperties.get(spec.getId())); } else { kafkaSpec = KafkaStreamSpec.fromSpec(spec); } return kafkaSpec; }
/** * Converts a StreamSpec into a KafakStreamSpec. Special handling for coordinator and changelog stream. * @param spec a StreamSpec object * @return KafkaStreamSpec object */ public KafkaStreamSpec toKafkaSpec(StreamSpec spec) { KafkaStreamSpec kafkaSpec; if (spec.isChangeLogStream()) { String topicName = spec.getPhysicalName(); ChangelogInfo topicMeta = changelogTopicMetaInformation.get(topicName); if (topicMeta == null) { throw new StreamValidationException("Unable to find topic information for topic " + topicName); } kafkaSpec = new KafkaStreamSpec(spec.getId(), topicName, systemName, spec.getPartitionCount(), topicMeta.replicationFactor(), topicMeta.kafkaProps()); } else if (spec.isCoordinatorStream()) { kafkaSpec = new KafkaStreamSpec(spec.getId(), spec.getPhysicalName(), systemName, 1, coordinatorStreamReplicationFactor, coordinatorStreamProperties); } else if (intermediateStreamProperties.containsKey(spec.getId())) { kafkaSpec = KafkaStreamSpec.fromSpec(spec).copyWithProperties(intermediateStreamProperties.get(spec.getId())); } else { kafkaSpec = KafkaStreamSpec.fromSpec(spec); } return kafkaSpec; }
@Test public void testUnsupportedConfigStrippedFromProperties() { StreamSpec original = new StreamSpec("dummyId","dummyPhysicalName", "dummySystemName", ImmutableMap.of("segment.bytes", "4", "replication.factor", "7")); // First verify the original assertEquals("7", original.get("replication.factor")); assertEquals("4", original.get("segment.bytes")); Map<String, String> config = original.getConfig(); assertEquals("7", config.get("replication.factor")); assertEquals("4", config.get("segment.bytes")); // Now verify the Kafka spec KafkaStreamSpec spec = KafkaStreamSpec.fromSpec(original); assertNull(spec.get("replication.factor")); assertEquals("4", spec.get("segment.bytes")); Properties kafkaProperties = spec.getProperties(); Map<String, String> kafkaConfig = spec.getConfig(); assertNull(kafkaProperties.get("replication.factor")); assertEquals("4", kafkaProperties.get("segment.bytes")); assertNull(kafkaConfig.get("replication.factor")); assertEquals("4", kafkaConfig.get("segment.bytes")); }