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)) { Actor producerActor = populateActorStreamConfig(streamName, region, producer.getActor(), OPERATION.CREATE.name(), topicPostFixes, hint, ACTOR_TYPE, avroStream.get().getTopicConfig()); producer.setActor(producerActor); updateAvroStream(avroStream.get()); log.info("Producer updated in source-processor-topic. streamName={} ; producerName={} ; 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)); }
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(); }
@Override @SuppressWarnings("unchecked") public Producer build() { try { Producer record = new Producer(); if (actorBuilder != null) { record.actor = this.actorBuilder.build(); } else { record.actor = fieldSetFlags()[0] ? this.actor : (com.homeaway.digitalplatform.streamregistry.Actor) defaultValue(fields()[0]); } return record; } catch (java.lang.Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
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(); }