@Override public Optional<ClusterValue> getClusterByKey(ClusterKey clusterKey) { ClusterValue clusterValue; Validate.validState(store != null, "Infra Manager should be configured"); try { log.debug("Approximate Num. of Entries in Infra Table-{}", store.approximateNumEntries()); clusterValue = store.get(clusterKey); } catch (Exception e) { throw new IllegalStateException("Error while retrieving the cluster Value using cluster key:" + clusterKey, e); } if (clusterValue == null) { log.error("Cluster Not Found, key: {}", clusterKey); } else { log.info("Cluster Name - {}", clusterValue.getClusterProperties()); } return Optional.ofNullable(clusterValue); } }
@Override @SuppressWarnings("unchecked") public ClusterValue build() { try { ClusterValue record = new ClusterValue(); record.clusterProperties = fieldSetFlags()[0] ? this.clusterProperties : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[0]); return record; } catch (java.lang.Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
private void upsertTopics(Stream stream, String vpc, boolean isNewStream) { ClusterValue clusterValue = getClusterDetails(vpc, env, stream.getTags().getHint(), "producer"); Properties topicConfig = new Properties(); if (stream.getTopicConfig() != null) { topicConfig.putAll(stream.getTopicConfig()); } String bootstrapServer = clusterValue.getClusterProperties().get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG); String zkConnect = clusterValue.getClusterProperties().get(KafkaProducerConfig.ZOOKEEPER_QUORUM); topicConfig.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer); topicConfig.put(KafkaProducerConfig.ZOOKEEPER_QUORUM, zkConnect); kafkaManager.upsertTopics(Collections.singleton(stream.getName()), stream.getPartitions(), stream.getReplicationFactor(), topicConfig, isNewStream); log.info("Topic {} created/updated at {}", stream.getName(), bootstrapServer); }
Optional<String> bootstrapServers = Optional.ofNullable(clusterValue.getClusterProperties().get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)); Optional<String> schemaRegistryURL = Optional.ofNullable(clusterValue.getClusterProperties().get(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG)); Optional<String> clusterName = Optional.ofNullable(clusterValue.getClusterProperties().get(CLUSTER_NAME));