You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »


General SDK questions

Where can I find Java Doc API description?

JavaDoc JAR package is published together with compiled classes to the ONAP Nexus repository. You can download JavaDoc in your IDE so you will get documentation hints. Alternatively you can use Maven Dependency plugin (classifier=javadoc).

Which Java version is supported?

For now we are compiling SDK using JDK 8. Hence we advice to use SDK on JRE 8. However, we are using parts of it on JRE 11 and it still works.

Are you sure Java 8 is supported? I can see a debug log from Netty.

If you have enabled a debug log level for Netty packages you might have seen the following log:


[main] DEBUG i.n.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9

Background: this is a result of  moving sun.misc.Unsafe to jdk.internal.misc.Unsafe in JDK 9, so if Netty wants to support both pre and post Java 9 it has to check the JDK version and use the class from available package.

It does not have any impact on SDK. SDK still works with this log. You might want to change log level for io.netty package to INFO.

Are native epoll bindings required?

Before first call to a remote API you can get the following exception, logged on DEBUG level:

9:27:09.888 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - netty_transport_native_epoll_x86_64 cannot be loaded from java.libary.path,
now trying export to -Dio.netty.native.workdir: /tmpjava.lang.UnsatisfiedLinkError:
no netty_transport_native_epoll_x86_64 in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
    at java.base/java.lang.System.loadLibrary(System.java:1867)
    at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:349)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)

As in the latter case this is only a DEBUG log. The library will fall back to Java NIO. In order to get rid of this log you may either change log level or add dependency on native transports.

CBS Client

When cbsClient.updates() will yield an event?

updates will emit changes to the configuration, ie. it will yield an event only when newJsonObject != lastJsonObject (using standard Java equals for comparison). Every check is performed at the specified interval (= it's poll-based).

What does a single JsonObject returned from CbsClient contain?

It will consist of the complete JSON representing what CBS/Consul keeps for microservice (and not only the changes).

Note

We have started an implementation for listening to changes in a subtree of JsonObject based on Merkle Tree data structure. But we are still unsure if we will continue this or not. Please let me know if you find it useful. For now we are recommending to first convert the JsonObject to domain classes and then subscribe to changes in these objects if you want to have a fine-grained control over update handling. It's an experimental API so it can change or be removed in future releases.

An issue arises when the Flux stream terminates with an error. In that case, since error is a terminal event, stream that updates from Consul is finished. In order to restart periodic CBS fetches, it must be re-subscribed. What is the suggestion about it?

Please use one of retry operators as described in Handling errors in reactive streams section of DCAE SDK main page. You should probably use a retry operator with a back-off so you won't be retrying immediately (which can result in DDoS attack on CBS).

There is a StreamParser::unsafeParse method. Why is it unsafe? Should I avoid using it?

Firstly: you SHOULD NOT avoid using it. The name indicates that it's not a pure function. If you are OK with a function throwing exception in case of any problems then you can safely use unsafeParse method (pun intended), given you properly handle StreamParsingExceptions. Otherwise, you should probably use pure parse function which will return either a StreamParsingError or a result by means of vavr Either data type. In other words: you can use any of these methods - it depends on your preferred style.

  • No labels