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.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(); }
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)) { String hint = (streamHint == null || streamHint.trim().matches("(?i:string)?")) ? AbstractDao.PRIMARY_HINT : streamHint.trim().toLowerCase(); Actor consumerActor = populateActorStreamConfig(streamName, region, consumer.getActor(), OPERATION.UPDATE.name(), TOPIC_POST_FIXES, hint, ACTOR_TYPE, avroStream.get().getTopicConfig());
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)); }