I don't find avaliabel java client version?

Posted by lxwithgod:

please tell me which branch is avaiable ?
I use feature/first_implement and master ,i met some error
feature/first_implement:
io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown service graph.Dgraph
at io.grpc.Status.asRuntimeException(Status.java:503)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:207)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:140)
at io.dgraph.client.DgraphGrpc$DgraphBlockingStub.query(DgraphGrpc.java:150)
at io.dgraph.client.GrpcDgraphClient.query(GrpcDgraphClient.java:54)
at io.dgraph.client.GrpcDgraphClient.query(GrpcDgraphClient.java:32)
master have simaliar error.

lxwithgod commented :

I use maven,

io.dgraph
dgraph4j
0.0.1

deepakjois commented :

  • Can you post your code?
  • Are you sure you are running the latest server from dgraph master?

lxwithgod commented :

thanks ,I install dgraph server:
curl https://get.dgraph.io -sSf | bash
so,server is 0.8.3,
but,i get your master,build jar,I get dgraph4j-all-0.8.1.jar.
package com.dataPlatform.dgraphConnector;

import com.dataPlatform.DBConnector;
import com.dataPlatform.commonAddress.CommonAddress;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.dgraph.DgraphClient;
import io.dgraph.DgraphGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**

  • Created by lx on 17-11-10.
    */
    public class DgraphConnector extends DBConnector {
    private static DgraphClient dgraphClient;
    static {
    ManagedChannel channel = ManagedChannelBuilder.
    forAddress(CommonAddress.getDgraph_connection_host(),
    CommonAddress.getDgraph_connection_port()).usePlaintext(true).build();
    DgraphGrpc.DgraphBlockingStub blockingStub = DgraphGrpc.newBlockingStub(channel);
    dgraphClient = new DgraphClient(Collections.singletonList(blockingStub));
    }

    public static DgraphConnector newInstance(){
    return new DgraphConnector();
    }

    @Override
    public String query(Object… where) throws Exception {
    String js =null;
    if(where.length==1) {
    Map<String,String> vars=new HashMap<>();
    js=dgraphClient.newTransaction().query(where[0].toString(),vars).getJson().toStringUtf8();
    }else if (where.length==2){
    js = dgraphClient.newTransaction().query(where[0].toString(),
    (Map<String, String>) where[1]).getJson().toStringUtf8();
    }
    return js;
    }

    @Override
    public Object insert(Object data) throws Exception {
    return null;
    }

    @Override
    public Object update(Object data) throws Exception {
    return null;
    }

    @Override
    public Object delete(Object data) throws Exception {
    return null;
    }

    @Override
    public void close() {

    }

    @Override
    public Object getConnector() {
    return null;
    }

    @Override
    public Object result2Json(Object e) {
    return null;
    }

    public static void main(String args) {
    String js = “{\n” +
    " everyone(func: eq(name, “Michael”)) {\n" +
    " \tage\n" +
    " name\n" +
    " friend {\n" +
    " \n" +
    " }\n" +
    " }\n" +
    “}\n”;
    try {
    js=DgraphConnector.newInstance().query(js);
    System.out.println(js);

     } catch (Exception e) {
         e.printStackTrace();
     }
    

    }
    }

lxwithgod commented :

please tell me if server’version must be equal cilent’version.
and,i git master,when ./gradlew test,there are error about

textTxnQueryVariables

io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown method Alter
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:227)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:208)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:141)
at io.dgraph.DgraphGrpc$DgraphBlockingStub.alter(DgraphGrpc.java:285)
at io.dgraph.DgraphClient.alter(DgraphClient.java:61)
at io.dgraph.DgraphClientTest.textTxnQueryVariables(DgraphClientTest.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)

deepakjois commented :

The server and client version must match. Things are in development right now and the README is out of date, but I will update the README soon with the latest instructions.

In the meanwhile you can get a Dgraph server going by installing Go and running the following commands in two different directories (make sure $GOPATH/bin is added to your $PATH):

rm -r zw; go install github.com/dgraph-io/dgraph/dgraph && dgraph zero
rm -r p w; go install github.com/dgraph-io/dgraph/dgraph && dgraph server --memory_mb=1024

After this, ./gradlew test should run successfully.

lxwithgod commented :

but i use v0.8.1 from https://github.com/dgraph-io/dgraph/releases/download/v0.8.1/dgraph-linux-amd64-v0.8.1.tar.gz
and .i use your client code ,I get dgraph4j-all-0.8.1.jar,but ,same error,io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown method query

deepakjois commented :

v0.8.1 will not work with latest code in this repo. We will be releasing Dgraph v0.9 soon. Before that, you will need to build the latest code from dgraph repo yourself, using the commands I provided above.

lxwithgod commented :

ok

deepakjois commented :

Sorry about the confusion. I will update the README shortly, so that it is clearer.

lxwithgod commented :

thanks

deepakjois commented :

README has been updated. Let me know if you are still having issues.