question

Upvotes
Accepted
5 1 2 3

How to connect to Velocity Analytics 8 using API

I tried connecting to Velocity Analytics 8, but an error occurred in the middle process.

ClassCastException is output with the following method.
DeltaQRoundRobinConnectionFactory.loadHostListFromCurrentConnection ()

The processing flow is as follows.

Generate DefaultDeltaStream
Run InitialiseDeltaControl()
A log of DeltaCConnectorThread is output and a message of Connection thread completed is output.
It ends immediately with ClassCastException.

apijavavelocity-analytics
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
21 0 0 1

Hello Yokoyama Ryouta,

To connect to the GW process you can use Java driver from Kx Systems. It's an interface for kdb+, check link below:

https://code.kx.com/q/interfaces/java-client-for-q/

You need to use c.java class, create connection to your gateway and send query as sync message. Example:

c c=null; //connection object
c=new c("host",5010,"username:password"); //create connection
Object result=c.k("your query here"); //send a sync message and 
recieve resultc.Flip flip = c.td(result); //convert result object to 
c.Flip
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
21 0 0 1

Hello Yokoyama Ryouta,

As I understand you trying to pass incorrect object instance to DeltaStream.initialiseDeltaControl() method:

https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/ClassCastException.html

InitialiseDeltaControl signatures:

void initialiseDeltaControl(ConfigurationManager var1); 

void initialiseDeltaControl(ConfigurationManager var1, String var2); 

void initialiseDeltaControl(String var1, int var2, String var3, int var4, String var5, int var6, boolean var7, String var8, int var9, int var10, boolean var11) throws DeltaStreamException; 

void initialiseDeltaControl(String var1, Integer var2, String var3, Integer var4, String var5, Integer var6, Boolean var7, String var8, Integer var9, Integer var10, Boolean var11, Boolean var12) throws DeltaStreamException;

Example of InitialiseDeltaControl call:

deltaStream.initialiseDeltaControl(primaryHost, primaryPort.intValue(), secondaryHost, secondaryPort.intValue(),instanceName, instanceId.intValue(), exclusive.booleanValue(), loginString,retryMaxTimeOutPeriod.intValue(), retryTimeoutStep.intValue(), encrypted.booleanValue());

note that host parameters should be passed as String objects, port - as Int.

Hope this helps.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
5 1 2 3

Hello Hurynovich,

Thank you for your response.

I understood that an exception occurred in initialiseDeltaControl.
I reconfirmed the call of initialiseDeltaControl, but I have not found a problem.
I am coding as follows, but where is the problem?
Note: IP, ID and PW are masked.

private DeltaStream createStream() throws DeltaStreamException {
    DeltaStream stream = DeltaStreamFactory.newDeltaStream();
    stream.initialiseDeltaControl(
        "XX.XX.XX.XX.", //primaryhost
        1234,//primaryport
        null,//secondaryhost
        0,//secondaryport
        "Develop",//instancename
        0,//instanceId
        true,//exclusive
        "XXXXXXX:XXXX",//loginString
        10000,//retryMaxTimeOutPeriod
        1000,//retryTimeoutStep
        false //encrypted
    );
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
21 0 0 1

Hello Yokoyama Ryouta,

Code looks right, can you please recheck is "stream" object an instance of DefaultDeltaStream and all values passed into initialiseDeltaControl method have right types? Also which version of VA binaries you use? I've tested this code and it works

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
5 1 2 3

Hello Hurynovich,
thank you so much for your reply.
I may be making a misunderstanding.
When executing the q command using the Delta IDE, I am connected to the Gateway process.
For this reason, I thought that the VA8 Java API will connect to the Gateway process as well, but is this understanding wrong?
If you designate the destination Port as a DeltaControl process, ClassCastException no longer occurs.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
21 0 0 1

Hello Yokoyama Ryouta,

You are welcome! That's right - VA8 C#/Java API should be connected to main DC port (same port using for connection to your VA instance in DeltaControl application).

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
5 1 2 3

Hello Hurynovich,
Thanks to your answer, I was able to correct my wrong understanding.
By the way, do you know how to connect to the Gateway process using Java and get data?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
5 1 2 3

Hello Hurynovich,
I was able to connect to the Gateway process and retrieve the data.
I greatly appreciate your help.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea