String actorType, Map<String, String> topicConfigMap) { Actor.Builder actorBuilder = Actor.newBuilder(); actorBuilder.setName(actor.getName()); actorBuilder.setRegionStreamConfigurations(actor.getRegionStreamConfigurations()); for (RegionStreamConfiguration regionStreamConfiguration : actor.getRegionStreamConfigurations()) { if (regionStreamConfiguration.getRegion().equals(region)) { Map<String, String> configMap = regionStreamConfiguration.getStreamConfiguration(); "Populated Cluster information into the Stream AvroObject. actorName={} ; region={} ; BootstrapServer={} ; " + "schemaRegistryURL={} ; hint={} ; clusterName={}", actor.getName(), region, bootstrapServers, schemaRegistryURL, hint, clusterName);
public static Producer getJsonProducer(com.homeaway.digitalplatform.streamregistry.Producer avroProducer) { Producer.ProducerBuilder builder = Producer.builder(); if (avroProducer.getActor().getName() != null) { builder.name(avroProducer.getActor().getName()); } if (avroProducer.getActor().getRegionStreamConfigurations() != null) { List<RegionStreamConfiguration> regionConfigAvroList = avroProducer.getActor().getRegionStreamConfigurations(); List<RegionStreamConfig> regionConfigJsonList = buildRegionStreamConfig(regionConfigAvroList); builder.regionStreamConfigList(regionConfigJsonList); } return builder.build(); }
/** * Gets the Builder instance for the 'actor' field and creates one if it doesn't exist yet. * * Actor configuration for the consumer * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Actor.Builder getActorBuilder() { if (actorBuilder == null) { if (hasActor()) { setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.newBuilder(actor)); } else { setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.newBuilder()); } } return actorBuilder; }
private Optional<com.homeaway.streamplatform.streamregistry.model.Consumer> getConsumer(String streamName, String consumerName) { // pull data from state store of this instance. log.info("Pulling stream information from local instance's state-store for streamName={} ; consumerName={}", streamName, consumerName); Optional<AvroStream> streamValue = kStreams.getAvroStreamForKey( AvroStreamKey.newBuilder().setStreamName(streamName).build()); if (streamValue.isPresent()) { streamValue.get().setOperationType(OperationType.GET); for (com.homeaway.digitalplatform.streamregistry.Consumer consumer : streamValue.get().getConsumers()) { if (consumer.getActor().getName().equals(consumerName)) return Optional.of(AvroToJsonDTO.getJsonConsumer(consumer)); } } return Optional.empty(); }
@Override @SuppressWarnings("unchecked") public Actor build() { try { Actor record = new Actor(); record.name = fieldSetFlags()[0] ? this.name : (java.lang.String) defaultValue(fields()[0]); record.regionStreamConfigurations = fieldSetFlags()[1] ? this.regionStreamConfigurations : (java.util.List<com.homeaway.digitalplatform.streamregistry.RegionStreamConfiguration>) defaultValue(fields()[1]); return record; } catch (java.lang.Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
/** * Gets the Builder instance for the 'actor' field and creates one if it doesn't exist yet. * * Actor configuration for the producer * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Actor.Builder getActorBuilder() { if (actorBuilder == null) { if (hasActor()) { setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.newBuilder(actor)); } else { setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.newBuilder()); } } return actorBuilder; }
public static Consumer getJsonConsumer(com.homeaway.digitalplatform.streamregistry.Consumer avroConsumer) { Consumer.ConsumerBuilder builder = Consumer.builder(); if (avroConsumer.getActor().getName() != null) { builder.name(avroConsumer.getActor().getName()); } if (avroConsumer.getActor().getRegionStreamConfigurations() != null) { List<RegionStreamConfiguration> regionConfigAvroList = avroConsumer.getActor().getRegionStreamConfigurations(); List<RegionStreamConfig> regionConfigJsonList = buildRegionStreamConfig(regionConfigAvroList); builder.regionStreamConfigList(regionConfigJsonList); } return builder.build(); }
private Optional<com.homeaway.streamplatform.streamregistry.model.Producer> getProducer(String streamName, String producerName) { // pull data from state store of this instance. log.info("Pulling stream information from local instance's state-store for streamName={} ; producerName={}", streamName, producerName); Optional<AvroStream> streamValue = kStreams.getAvroStreamForKey(AvroStreamKey.newBuilder().setStreamName(streamName).build()); if (streamValue.isPresent() && streamValue.get().getProducers() != null) { streamValue.get().setOperationType(OperationType.GET); for (com.homeaway.digitalplatform.streamregistry.Producer producer : streamValue.get().getProducers()) { if (producer.getActor().getName().equals(producerName)) return Optional.of(AvroToJsonDTO.getJsonProducer(producer)); } } return Optional.empty(); }
/** * Creates a Builder by copying an existing Builder. * @param other The existing Builder to copy. */ private Builder(com.homeaway.digitalplatform.streamregistry.Producer.Builder other) { super(other); if (isValidValue(fields()[0], other.actor)) { this.actor = data().deepCopy(fields()[0].schema(), other.actor); fieldSetFlags()[0] = true; } if (other.hasActorBuilder()) { this.actorBuilder = com.homeaway.digitalplatform.streamregistry.Actor.newBuilder(other.getActorBuilder()); } }
if (producers != null) { for (com.homeaway.digitalplatform.streamregistry.Producer producer : producers) { if (producer.getActor().getName().equalsIgnoreCase(producerName)) { for (RegionStreamConfiguration config : producer.getActor().getRegionStreamConfigurations()) { if (config.getRegion().equals(region)) {
/** * Creates a Builder by copying an existing Builder. * @param other The existing Builder to copy. */ private Builder(com.homeaway.digitalplatform.streamregistry.Consumer.Builder other) { super(other); if (isValidValue(fields()[0], other.actor)) { this.actor = data().deepCopy(fields()[0].schema(), other.actor); fieldSetFlags()[0] = true; } if (other.hasActorBuilder()) { this.actorBuilder = com.homeaway.digitalplatform.streamregistry.Actor.newBuilder(other.getActorBuilder()); } }
if (consumers != null) { for (com.homeaway.digitalplatform.streamregistry.Consumer consumer : consumers) { if (consumer.getActor().getName().equalsIgnoreCase(consumerName)) { for (RegionStreamConfiguration streamConfiguration : consumer.getActor().getRegionStreamConfigurations()) { if (streamConfiguration.getRegion().equals(region)) {
private Optional<com.homeaway.streamplatform.streamregistry.model.Producer> registerProducer(AvroStream avroStream, String producerName, String region) { if (!regionDao.getSupportedRegions(avroStream.getTags().getHint()).contains(region)) throw new UnknownRegionException(region); List<com.homeaway.digitalplatform.streamregistry.Producer> listProducers = avroStream.getProducers(); if (listProducers == null) { listProducers = new ArrayList<>(); } com.homeaway.digitalplatform.streamregistry.Producer producer = com.homeaway.digitalplatform.streamregistry.Producer.newBuilder() .setActor(Actor.newBuilder() .setName(producerName) .build()) .build(); String streamHint = avroStream.getTags().getHint(); String hint = (streamHint == null || streamHint.trim().matches("(?i:string)?")) ? AbstractDao.PRIMARY_HINT : streamHint.trim().toLowerCase(); Actor actor = populateActorStreamConfig(avroStream.getName(), region, producer.getActor(), OPERATION.CREATE.name(), topicPostFixes, hint, ACTOR_TYPE, avroStream.getTopicConfig()); Producer newProducer = com.homeaway.digitalplatform.streamregistry.Producer.newBuilder() .setActor(actor) .build(); listProducers.add(newProducer); avroStream.setProducers(listProducers); updateAvroStream(avroStream); return Optional.of(AvroToJsonDTO.getJsonProducer(newProducer)); }
private Optional<com.homeaway.streamplatform.streamregistry.model.Consumer> createConsumer(AvroStream avroStream, String consumerName, String region) { log.info("==>>> getting into creating consumer. Initial Stream: {}", avroStream.toString()); if (!regionDao.getSupportedRegions(avroStream.getTags().getHint()).contains(region)) throw new UnknownRegionException(region); List<com.homeaway.digitalplatform.streamregistry.Consumer> listConsumers = avroStream.getConsumers(); if (listConsumers == null) { listConsumers = new ArrayList<>(); } com.homeaway.digitalplatform.streamregistry.Consumer consumer = com.homeaway.digitalplatform.streamregistry.Consumer .newBuilder() .setActor(Actor.newBuilder() .setName(consumerName) .build()) .build(); String streamHint = avroStream.getTags().getHint(); String hint = (streamHint == null || streamHint.trim().matches("(?i:string)?")) ? AbstractDao.PRIMARY_HINT : streamHint.trim().toLowerCase(); Actor actor = populateActorStreamConfig(avroStream.getName(), region, consumer.getActor(), OPERATION.CREATE.name(), TOPIC_POST_FIXES, hint, ACTOR_TYPE, avroStream.getTopicConfig()); consumer = Consumer.newBuilder() .setActor(actor) .build(); listConsumers.add(consumer); avroStream.setConsumers(listConsumers); updateAvroStream(avroStream); return Optional.of(AvroToJsonDTO.getJsonConsumer(consumer)); }