protected TransportProtocol protocol(SpDataStream stream) { return stream .getEventGrounding() .getTransportProtocol(); }
public static EventGrounding getSupportedGrounding() { EventGrounding grounding = new EventGrounding(); grounding.setTransportFormats(standardFormat()); grounding.setTransportProtocols(standardProtocols()); return grounding; } }
public static EventGrounding makeDummyGrounding() { EventGrounding grounding = new EventGrounding(); grounding.setTransportFormats(Arrays.asList(new TransportFormat())); grounding.setTransportProtocol(ProtocolGenerator.makeDummyProtocol()); return grounding; } }
@Override public boolean match(EventGrounding offer, EventGrounding requirement, List<MatchingResultMessage> errorLog) { boolean match = MatchingUtils.nullCheckRightNullDisallowed(offer, requirement) || (matchProtocols(offer.getTransportProtocols(), requirement.getTransportProtocols(), errorLog) && matchFormats(offer.getTransportFormats(), requirement.getTransportFormats(), errorLog)); return match; }
if (adapterDescription instanceof AdapterSetDescription) { ds = ((AdapterSetDescription) adapterDescription).getDataSet(); EventGrounding eg = new EventGrounding(); eg.setTransportProtocol(SupportedProtocols.kafka()); eg.setTransportFormats(Arrays.asList(SupportedFormats.jsonFormat())); ((SpDataSet) ds).setSupportedGrounding(eg); } else { String topic = adapterDescription.getEventGrounding().getTransportProtocol().getTopicDefinition().getActualTopicName(); EventGrounding eg = new EventGrounding(); eg.setTransportFormats(Arrays.asList(Formats.jsonFormat())); eg.setTransportProtocol(tp);
public DataSetModificationMessage selectGrounding() { // TODO grounding negotiation TransportProtocol protocol = new KafkaTransportProtocol(BackendConfig.INSTANCE.getKafkaHost(), BackendConfig.INSTANCE.getKafkaPort(), TopicGenerator.generateRandomTopic(), BackendConfig.INSTANCE.getZookeeperHost(), BackendConfig.INSTANCE.getZookeeperPort()); TransportFormat format = spDataSet.getSupportedGrounding().getTransportFormats().get(0); EventGrounding outputGrounding = new EventGrounding(); outputGrounding.setTransportProtocol(protocol); outputGrounding.setTransportFormats(Arrays.asList(format)); return new DataSetModificationMessage(outputGrounding,RandomStringUtils.randomAlphanumeric(10)); } }
@Override public List<SpInputCollector> getInputCollectors() throws SpRuntimeException { List<SpInputCollector> inputCollectors = new ArrayList<>(); for (SpDataStream is : bindingParams.getGraph().getInputStreams()) { inputCollectors.add(ProtocolManager.findInputCollector(is.getEventGrounding() .getTransportProtocol(), is.getEventGrounding().getTransportFormats().get(0), singletonEngine)); } return inputCollectors; }
public AdapterDescription() { super(); this.rules = new ArrayList<>(); this.eventGrounding = new EventGrounding(); this.config = new ArrayList<>(); // TODO move to another place TransportProtocol tp = new KafkaTransportProtocol(); tp.setTopicDefinition(new SimpleTopicDefinition("bb")); this.eventGrounding.setTransportProtocol(tp); // this.eventGrounding.setTransportFormats(Arrays.asList(Formats.jsonFormat())); }
protected AbstractProcessingElementBuilder(String id, String label, String description, T element) { super(id, label, description, element); this.streamRequirements = new ArrayList<>(); this.stream1Properties = new ArrayList<>(); this.stream2Properties = new ArrayList<>(); this.supportedGrounding = new EventGrounding(); }
/** * Assigns a new {@link org.streampipes.model.grounding.TransportFormat} to the stream definition. * @param format The transport format of the stream at runtime (e.g., JSON or Thrift). Use * {@link org.streampipes.sdk.helpers.Formats} to use some pre-defined formats (or create a new format as * described in the developer guide). * @return this */ public DataStreamBuilder format(TransportFormat format) { this.eventGrounding.setTransportFormats(Collections.singletonList(format)); return this; }
/** * Assigns a new {@link org.streampipes.model.grounding.TransportProtocol} to the stream definition. * @param protocol The transport protocol of the stream at runtime (e.g., Kafka or MQTT). Use * {@link org.streampipes.sdk.helpers.Protocols} to use some pre-defined protocols (or create a new protocol as * described in the developer guide). * @return this */ public DataStreamBuilder protocol(TransportProtocol protocol) { this.eventGrounding.setTransportProtocol(protocol); return this; }
public <T extends TransportFormat> boolean supportsFormat(String format) { List<InvocableStreamPipesEntity> elements = buildInvocables(); return elements .stream() .allMatch(e -> e .getSupportedGrounding() .getTransportFormats() .stream() .anyMatch(s -> s.getRdfType().contains(format))); } }
/** * Assigns supported communication/transport protocols to the pipeline elements that can be handled at runtime (e.g., * Kafka or JMS). * @param protocols A list of supported {@link org.streampipes.model.grounding.TransportProtocol}s. Use * {@link org.streampipes.sdk.helpers.SupportedProtocols} to assign protocols from some pre-defined * ones or create your own by following the developer guide. * @return this */ public BU supportedProtocols(List<TransportProtocol> protocols) { this.supportedGrounding.setTransportProtocols(protocols); return me(); }
public DataSetModificationMessage selectGrounding() { // TODO grounding negotiation TransportProtocol protocol = new KafkaTransportProtocol(BackendConfig.INSTANCE.getKafkaHost(), BackendConfig.INSTANCE.getKafkaPort(), TopicGenerator.generateRandomTopic(), BackendConfig.INSTANCE.getZookeeperHost(), BackendConfig.INSTANCE.getZookeeperPort()); TransportFormat format = spDataSet.getSupportedGrounding().getTransportFormats().get(0); EventGrounding outputGrounding = new EventGrounding(); outputGrounding.setTransportProtocol(protocol); outputGrounding.setTransportFormats(Arrays.asList(format)); return new DataSetModificationMessage(outputGrounding,RandomStringUtils.randomAlphanumeric(10)); } }
@Override public List<SpInputCollector> getInputCollectors() throws SpRuntimeException { List<SpInputCollector> inputCollectors = new ArrayList<>(); for (SpDataStream is : bindingParams.getGraph().getInputStreams()) { inputCollectors.add(ProtocolManager.findInputCollector(is.getEventGrounding() .getTransportProtocol(), is.getEventGrounding().getTransportFormats().get(0), singletonEngine)); } return inputCollectors; }
public static EventGrounding createEventGrounding(String kafkaHost, int kafkaPort, EventSchema eventSchema) { EventGrounding eventGrounding = new EventGrounding(); KafkaTransportProtocol transportProtocol = new KafkaTransportProtocol(); transportProtocol.setBrokerHostname(kafkaHost); transportProtocol.setKafkaPort(kafkaPort); String topic = "org.streampipes.connect." + UUID.randomUUID(); System.out.println("Topic: " + topic); TopicDefinition topicDefinition = new SimpleTopicDefinition(topic); transportProtocol.setTopicDefinition(topicDefinition); eventGrounding.setTransportProtocol(transportProtocol); return eventGrounding; } }
protected DataSetBuilder(String id, String label, String description) { super(id, label, description, new SpDataSet()); this.eventProperties = new ArrayList<>(); this.supportedGrounding = new EventGrounding(); }
@Override public boolean match(EventGrounding offer, EventGrounding requirement, List<MatchingResultMessage> errorLog) { boolean match = MatchingUtils.nullCheckRightNullDisallowed(offer, requirement) || (matchProtocols(offer.getTransportProtocols(), requirement.getTransportProtocols(), errorLog) && matchFormats(offer.getTransportFormats(), requirement.getTransportFormats(), errorLog)); return match; }
public DataSetBuilder supportedFormat(TransportFormat format) { this.supportedGrounding.setTransportFormats(Collections.singletonList(format)); return this; }
public DataSetBuilder supportedProtocol(TransportProtocol protocol) { this.supportedGrounding.setTransportProtocol(protocol); return this; }