Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: HV VES Client section

...

Code Block
languagexml
<dependencies>
  <dependency>
    <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
    <artifactId>cbs-client</artifactId>
    <version>${sdk.version}</version>
  </dependency>

  <dependency>
    <groupId>org.onap.dcaegen2.services.sdk.security.crypt</groupId>
    <artifactId>crypt-password</artifactId>
    <version>${sdk.version}</version>
  </dependency>

 <!-- more to go -->

</dependencies>

Available APIs

cbs-client - a Config Binding Service client

You can use CbsClientFactory to lookup for CBS in your application. Returned CbsClient can then be used to get a configuration, poll for configuration or poll for configuration changes.

The following CBS endpoints are supported by means of different CbsRequests:

  • get-configuration created by CbsRequests.getConfiguration method - returns the service configuration
  • get-by-key created by CbsRequests.getByKey method - returns componentName:key entry from Consul
  • get-all created by CbsRequests.getAll method - returns everything which relates to the service (configuration, policies, etc.)

Sample usage:

Code Block
languagejava
linenumbers
  <dependency>
    <groupId>org.onap.dcaegen2.services.sdk</groupId>
    <artifactId>hvvesclient-producer-api</artifactId>
    <version>${sdk.version}</version>
  </dependency>
  <dependency>
    <groupId>org.onap.dcaegen2.services.sdk</groupId>
    <artifactId>hvvesclient-producer-impl</artifactId>
    <version>${sdk.version}</version>
    <scope>runtime</scope>
  </dependency>

 <!-- more to go -->

</dependencies>


Available APIs

...

cbs-client - a Config Binding Service client

You can use CbsClientFactory to lookup for CBS in your application. Returned CbsClient can then be used to get a configuration, poll for configuration or poll for configuration changes.

The following CBS endpoints are supported by means of different CbsRequests:

  • get-configuration created by CbsRequests.getConfiguration method - returns the service configuration
  • get-by-key created by CbsRequests.getByKey method - returns componentName:key entry from Consul
  • get-all created by CbsRequests.getAll method - returns everything which relates to the service (configuration, policies, etc.)

Sample usage:

Code Block
languagejava
linenumberstrue
// Generate RequestID and InvocationID which will be used when logging and in HTTP requests
final RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create();
final CbsRequest request = CbsRequests.getConfiguration(diagnosticContext);

// Read necessary properties from the environment
final EnvProperties env = EnvProperties.fromEnvironment();

// Create the client and use it to get the configuration
CbsClientFactory.createCbsClient(env)
        .flatMap(cbsClient -> cbsClient.get(request))
        .subscribe(
                jsonObject -> {
                    // do a stuff with your JSON configuration using GSON API
                    final int port = Integer.parseInt(jsonObject.get("collector.listen_port").getAsString());
                    // ...
                },
                throwable -> {
                    logger.warn("Ooops", throwable);
                });

...

Code Block
languagejava
linenumberstrue
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
final StreamFromGsonParser<MessageRouterSink> mrSinkParser = StreamFromGsonParsers.messageRouterSinkParser();

CbsClientFactory.createCbsClient(EnvProperties.fromEnvironment())
    .flatMapMany(cbsClient -> cbsClient.updates(request, Duration.ofSeconds(5), Duration.ofMinutes(1)))
    .map(DataStreams::namedSinks)
    .map(sinks -> sinks.filter(StreamPredicates.streamOfType(MESSAGE_ROUTER)).map(mrSinkParser::unsafeParse).toList())
    .subscribe(
        mrSinks -> mrSinks.forEach(mrSink -> {
            logger.info(mrSink.name()); // name = the configuration key
            logger.info(mrSink.aafCredentials().username()); // = aaf_username
            logger.info(mrSink.topicUrl());
            // ...
        }),
        throwable -> logger.warn("Ooops", throwable)
 );

For details and sample usage please refer to JavaDoc and unit and integration tests. Especially CbsClientImplIT, MessageRouterSinksIT and  MixedDmaapStreamsIT might be useful.

INFO

  • We also provide a working stream parser for DMaaP native Kafka streams. Please note that the configuration structure is not standardized yet (it's in draft status).
  • In one of future releases of DCAE SDK we plan on aligning the SDK dmaap-client with the results of these parsers (MessageRouterSink, MessageRouterSource, etc.). For now there is an experimental (read: untested) API in org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api package of dmaap-client.


...

crypt-password - an utility for BCrypt passwords

Library to generate and match cryptography password using BCrypt algorithm

Code Block
java -jar crypt-password-${sdk.version}.jar     logger.info(mrSink.aafCredentials().username()); // = aaf_username
            logger.info(mrSink.topicUrl());
            // ...
        }),
        throwable -> logger.warn("Ooops", throwable)
 );

For details and sample usage please refer to JavaDoc and unit and integration tests. Especially CbsClientImplIT, MessageRouterSinksIT and  MixedDmaapStreamsIT might be useful.

INFO

  • We also provide a working stream parser for DMaaP native Kafka streams. Please note that the configuration structure is not standardized yet (it's in draft status).
  • In one of future releases of DCAE SDK we plan on aligning the SDK dmaap-client with the results of these parsers (MessageRouterSink, MessageRouterSource, etc.). For now there is an experimental (read: untested) API in org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api package of dmaap-client.

crypt-password - an utility for BCrypt passwords

Library to generate and match cryptography password using BCrypt algorithm

Code Block
java -jar crypt-password-${sdk.version}.jar password_to_crypt

$2a$10$iDEKdKknakPqH5XZb6wEmeBP2SMRwwiWHy8RNioUTNycIomjIqCAO

Can be used like maven dependency to match generated password.

<ExperimentalApi> dmaap-client - a DMaaP MR client

TODO

Code Block
languagejava
linenumberstrue
final MessageRouterPublisher publisher = DmaapClientFactory.createMessageRouterPublisher();
final MessageRouterSink sinkDefinition; //... Sink definition obtained by parsing CBS response
final MessageRouterPublishRequest request = ImmutableMessageRouterPublishRequest.builder()password_to_crypt

$2a$10$iDEKdKknakPqH5XZb6wEmeBP2SMRwwiWHy8RNioUTNycIomjIqCAO

Can be used like maven dependency to match generated password.


...

<ExperimentalApi> dmaap-client - a DMaaP MR client

TODO

Code Block
languagejava
linenumberstrue
final MessageRouterPublisher publisher = DmaapClientFactory.createMessageRouterPublisher();
final MessageRouterSink sinkDefinition; //... Sink definition obtained by parsing CBS response
final MessageRouterPublishRequest request = ImmutableMessageRouterPublishRequest.builder()
        .sinkDefinition(sinkDefinition)
        .build();

Flux.just(1, 2, 3)
        .map(JsonPrimitive::new)
        .transform(input -> cut.put(request, input))
        .subscribe(resp -> {
                    if (resp.successful()) {
                        logger.debug("Sent a batch of messages to the MR");
                .sinkDefinition(sinkDefinition)    } else {
  .build();  Flux.just(1, 2, 3)         .map(JsonPrimitive::new)         logger.transform(input -> cut.put(request, input))warn("Message sending has failed: {}", resp.failReason());
        .subscribe(resp -> {          }
          if (resp.successful()) {    },
                ex -> {
 logger.debug("Sent a batch of messages to the MR");            logger.warn("An unexpected error while sending messages to DMaaP", ex);
} else {                         logger.warn("Message sending has failed: {}", resp.failReason());});


...

hvvesclient-producer - a reference Java implementation of High Volume VES Collector client

This library is used in xNF simulator which helps us test HV VES Collector in CSIT tests. You may use it as a reference when implementing your code in non-JVM language or directly when using Java/Kotlin/etc.

Sample usage:

Code Block
languagejava
linenumberstrue
final ProducerOptions producerOptions = ImmutableProducerOptions.builder()
        .collectorAddresses(HashSet.of(
            }    InetSocketAddress.createUnresolved("dcae-hv-ves-collector", 32222)))
        .build();
final HvVesProducer },hvVesProducer = HvVesProducerFactory.create(producerOptions);

Flux<VesEvent> events; // ...
Mono.from(hvVesProducer.send(events))
        ex.doOnSuccess(() -> {
   logger.info("All events has been sent"))
                .doOnError(ex -> logger.warn("AnFailed unexpectedto errorsend whileone sendingor messagesmore to DMaaPevents", ex);)
                }.subscribe();