@Override @SuppressWarnings("unchecked") public AvroStreamKey build() { try { AvroStreamKey record = new AvroStreamKey(); record.streamName = fieldSetFlags()[0] ? this.streamName : (java.lang.String) defaultValue(fields()[0]); return record; } catch (java.lang.Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
@Override public Optional<Stream> getStream(String streamName) { log.info("Pulling stream information from global state-store for streamName={}", streamName); Optional<AvroStream> streamValue = kStreams.getAvroStreamForKey(AvroStreamKey.newBuilder().setStreamName(streamName).build()); return streamValue.map(AvroToJsonDTO::convertAvroToJson); }
protected Pair<AvroStreamKey, Optional<AvroStream>> getAvroStreamKeyValue(String streamName) { AvroStreamKey key = AvroStreamKey.newBuilder().setStreamName(streamName).build(); Optional<AvroStream> value = kStreams.getAvroStreamForKey(key); return new ImmutablePair<>(key, value); }
private List<com.homeaway.streamplatform.streamregistry.model.Consumer> getAllConsumers(String streamName) { List<com.homeaway.streamplatform.streamregistry.model.Consumer> consumers = new ArrayList<>(); // pull data from state store of this instance. log.info("Pulling stream information from local instance's state-store for stream={} ; consumers=all", streamName); Optional<AvroStream> streamValue = kStreams.getAvroStreamForKey(AvroStreamKey.newBuilder().setStreamName(streamName).build()); if (streamValue.isPresent() && streamValue.get().getConsumers() != null) { streamValue.get().setOperationType(OperationType.GET); for (com.homeaway.digitalplatform.streamregistry.Consumer consumer : streamValue.get().getConsumers()) { consumers.add(AvroToJsonDTO.getJsonConsumer(consumer)); } } return consumers; }
private List<com.homeaway.streamplatform.streamregistry.model.Producer> getProducers(String streamName) { List<com.homeaway.streamplatform.streamregistry.model.Producer> producers = new ArrayList<>(); // pull data from state store of this instance. log.info("Pulling stream information from local instance's state-store for streamName={} ; managedKafkaProducer=all", streamName); 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()) { producers.add(AvroToJsonDTO.getJsonProducer(producer)); } } return producers; }
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(); }
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(); }
private void validateStateStore() { try { AvroStreamKey avroStreamKey = AvroStreamKey.newBuilder().setStreamName(HEALTH_CHECK_STREAM_NAME).build(); Optional<AvroStream> avroStreamValue = managedKStreams.getAvroStreamForKey(avroStreamKey); if(!avroStreamValue.isPresent() || ! avroStreamValue.get().getName().equals(HEALTH_CHECK_STREAM_NAME)) { setStateStoreHealthy(false); throw new IllegalStateException("HealthCheck Failed: StreamRegistryHealthCheck Stream not available in StateStore."); } } catch (Exception e) { setStateStoreHealthy(false); throw e; } setStateStoreHealthy(true); }
public void updateAvroStream(AvroStream stream) { AvroStreamKey key = AvroStreamKey.newBuilder().setStreamName(stream.getName()).build(); stream.setOperationType(OperationType.UPSERT); try { kafkaProducer.log(key, stream); } catch (Exception e) { log.error("Error logging stream - {}", stream, e); } } }
public void updateAvroStream(AvroStream stream) { AvroStreamKey key = AvroStreamKey.newBuilder().setStreamName(stream.getName()).build(); stream.setOperationType(OperationType.UPSERT); try { kafkaProducer.log(key, stream); } catch (Exception e) { log.error("Error logging stream - {}", stream.toString()); } }
isNewStream = true; avroStream.setCreated(System.currentTimeMillis()); key = AvroStreamKey.newBuilder().setStreamName(avroStream.getName()).build();