How to set protocol using async java driver for ArangoDB? - arangodb

I am trying to connect ArangoDB from my java program. I have used the official async java driver for arangodb. The document mentions that we can set the protocol using useProtocol() method. But, this method is not present in code and in javadoc as well. Can somebody tell me how can I set the protocol to HTTP?
The github document mentions this following code.
ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().useProtocol(Protocol.VST).build();
But object returned by Builder() method do not have any useProtocol() method.

This was a mistake in the documentation. The async java driver only supports VelocyStream while the sync driver supports different network protocols.

Related

How do I verify the consistency level configured on the Java driver?

We are currently upgrading from 3.x to 4.x. We are using the programaticBuilder for the DriverConfigLoader. Below is the code for same.
DriverConfigLoader driverConfigLoader = DriverConfigLoader.programmaticBuilder()
.withDuration(DefaultDriverOption.HEARTBEAT_INTERVAL, Duration.ofSeconds(60))
.withString(DefaultDriverOption.REQUEST_CONSISTENCY, ConsistencyLevel.LOCAL_QUORUM.name())
.withString(DefaultDriverOption.RETRY_POLICY_CLASS, "DefaultRetryPolicy")
.withString(DefaultDriverOption.RECONNECTION_POLICY_CLASS, "ConstantReconnectionPolicy")
.withDuration(DefaultDriverOption.RECONNECTION_BASE_DELAY, Duration.ofSeconds(5))
.withString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, "DcInferringLoadBalancingPolicy")
.build();
Wanted to check how to verify this correct setting of ConsistencyLevel when the write/read happens. is there a debug log print mechanism available for this purpose.
Your question suggests that you don't trust that the configured consistency level is not being honoured by the driver so you're looking for proof that it does. To me it doesn't make sense. Perhaps you ran into another problem related to request consistency and you should post information about that instead.
In any case, the DriverConfigLoader is provided for convenience but we discourage its use because it means that you are hard-coding configuration within your app which is bad practice. If you need to make a change, you are forced to have to recompile your app again by virtue that the configuration is hardcoded. Only use the programmatic loader if you have a very specific reason.
The recommended method for configuring the driver options is to use an application configuration file (application.conf). The advantages include:
driver options is configured in a central location,
hot-reload support, and
changes do not require recompiling the app.
To set the basic request consistency to LOCAL_QUORUM:
datastax-java-driver {
basic {
request {
consistency = LOCAL_QUORUM
}
}
}
For details, see Configuring the Java driver. Cheers!
For DataStax Java Driver 4.x version you can do something like this:
CqlSession session = CqlSession.builder().withConfigLoader(driverConfigLoader).build();
DriverConfig config = session.getContext().getConfig();
config.getProfiles().forEach(
(name, profile) -> {
System.out.println("Profile: " + name);
profile.entrySet().forEach(System.out::println);
System.out.println();
});
This will print the values for every defined option in every defined profile. It won't print undefined options though.

OpenAPI Generator issue with Destination service API specification

I want to get all destinations on subaccount and instance level. In SAP API business Hub, I found the API information and "SAP Cloud SDK" tab to generate code by OpenAPI generator.
https://api.sap.com/api/SAP_CP_CF_Connectivity_Destination/overview
I downloaded the API specification and added dependencies into Cloud SDK for Java project. The code is generated successfully with some errors (unknown models)in generated api classes.
For example in DestinationsOnSubaccountLevelApi.class, model OneOfDestinationNameOnly is imported and used in method but it is not generated in model package.
I looked into API specification and found that there were two types of response entity. That is the reason why the code could not be generated properly. I can modify the API specification to make it work but it should not be the long term solution. Is there any other way to fix this issue?
Unfortunately the SAP Cloud SDK Generator for Open API services is not yet able to understand oneOf relationship that is modeled in the specification.
As an alternative, would you consider using the DestinationAccessor API for resolving single destinations?
You can also directly instantiate an ScpCfDestinationLoader, which allows for querying all destinations:
ScpCfDestinationLoader loader = new ScpCfDestinationLoader();
DestinationOptions options = DestinationOptions
.builder()
.augmentBuilder(ScpCfDestinationOptionsAugmenter.augmenter().retrievalStrategy(ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER))
.build();
Try<Iterable<ScpCfDestination>> destinations = loader.tryGetAllDestinations(options);
Similar to the default behavior of DestinationAccessor API, in the code above only the subscriber account will be considered. Other options are:
ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER
ScpCfDestinationRetrievalStrategy.ALWAYS_PROVIDER
ScpCfDestinationRetrievalStrategy.SUBSCRIBER_THEN_PROVIDER

Groovy Couchbase help needed

I am beginner in Groovy and Couchbase. Used Groovy-console to script some basic Groovy. Used couchbase console tool with UI to meddle with documents on couchbase. Now I wanna combine them. I want to meddle with documents in couchbase using Groovy script.
Where can I find an apt tutorial? Or an example code of Groovy-couchbase connection and operation will also help a lot.
(I couldn't find on Google searches, so had to turn to my fellow experts on stackoverflow)
Thank you so much! :-)
All you need is the Java client.
#Grab('com.couchbase.client:java-client:2.2.6')
import com.couchbase.client.java.CouchbaseCluster
// Connect to localhost
def cluster = CouchbaseCluster.create()
// Open the default bucket and the "beer-sample" one
def defaultBucket = cluster.openBucket()
def beerSampleBucket = cluster.openBucket("beer-sample")
// Disconnect and clear all allocated resources
cluster.disconnect()
The Java client documentation is here: http://developer.couchbase.com/documentation/server/4.0/sdks/java-2.2/java-intro.html

Baffled by all this Node -> Titan stuff

I'm new to Java, Gremlin, Nodejs, Tickerpop, Maven and just about everything else. What does this code do? In particular what is 'java.import' doing? Is it a Java class? What has this got to do with Titan?
var Titan = require('titan-node');
var gremlin = new Titan.Gremlin({ loglevel: 'OFF' });
var TinkerGraphFactory = gremlin.java.import('com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory');
var graph = TinkerGraphFactory.createTinkerGraphSync();
var g = gremlin.wrap(graph);
g.V('name', 'marko').next(function (err, v) {
v.getProperty('name', function (err, value) {
console.log(value);
});
});
Why when I use the Rexster can I not see the database being queried here?
To add to #mscdex valid answer.
This is JavaScript-flavored Gremlin code in Node.js using direct Java bindings via node-java.
Gremlin is not a language per se but a DSL. It is most of the time written in Groovy (because of its shortened syntax over Java), but it also exists in any JVM-compliant languages (ie. Java, Groovy, Scala, JavaScript via rhino and now nashorn with Java 8, to name a few). The full Groovy/Java API is accessible when typing Gremlin queries/scripts, which makes it a turing-complete "language".
I recommend reading http://gremlindocs.com/ and http://sql2gremlin.com for interesting beginner resources on Gremlin. http://www.tinkerpop.com/docs/3.0.0.M1/ will give you detailed information on TinkerPop and Gremlin (note: link will break as official v3.0 doc is released).
Because of the way node-java works and exposes Java methods (sync/async), you're required to use callbacks here in order to not block the event loop. This is a JavaScript concern and has nothing to do with Gremlin strictly speaking.
There a couple other clients which do not bind to the JVM directly but uses HTTP for TinkerPop 2.x (https://github.com/gulthor/grex for Node.js) or WebSocket for TinkerPop 3.0+ (https://github.com/gulthor/gremlin-client, for Node.JS/browsers, which will become the official TP3 JavaScript driver). Note: TinkerPop member / lib author here.
gremlin (a dependency of titan-node) uses node-java, which is a module that provides a bridge between node and Java. node-java allows you to import Java classes, instantiate Java data types, etc.
So what you're seeing is node-java importing a particular Java class because Gremlin is a Java/JVM thing.

SBT SDK Blogs and Activities API error

I setup the Social Business Toolkit against our development system. All APIs are working correct, except for the Blog and Activities API.
For both i recieve within the Java APIs the following error:
org.apache.http.conn.EofSensorInputStream cannot be cast to org.w3c.dom.Document
The blog request url from the sbt is:
http://example.com/service/proxy/connections/blogs/homepage/feed/blogs/atom?ps=5&dojo.preventCache=13
But correct would be:
http://example.com/service/proxy/connections/blogs/atom?ps=5&dojo.preventCache=13
Any idea why that happens?
The blog path is customizable per each IBM Connection installation: to support different blogs homepages, there is a parameter exposed on the BlogService API.
To change the default, try:
BlogService svc = ...
svc.defaultHomepageHandle = "";
Lorenzo's answer is correct, most installations use homepage as the blog handle, but you can configure it using the defaultHomepageHandle member variable in the BlogService.
Just a brief comment, maybe it's better to use the setHomepageHandle() method instead.

Resources