Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gremlin-console can't work #1027

Merged
merged 2 commits into from
Jun 17, 2020
Merged

Fix gremlin-console can't work #1027

merged 2 commits into from
Jun 17, 2020

Conversation

Linary
Copy link
Contributor

@Linary Linary commented Jun 10, 2020

Fix #1026

Change-Id: Ice222d809e4161f1d4d1f04822bef1c5af380a10

Change-Id: Ice222d809e4161f1d4d1f04822bef1c5af380a10
@codecov
Copy link

codecov bot commented Jun 10, 2020

Codecov Report

Merging #1027 into master will decrease coverage by 0.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1027      +/-   ##
============================================
- Coverage     69.35%   69.11%   -0.24%     
- Complexity     5314     5428     +114     
============================================
  Files           325      329       +4     
  Lines         25978    26570     +592     
  Branches       3687     3818     +131     
============================================
+ Hits          18017    18365     +348     
- Misses         6220     6413     +193     
- Partials       1741     1792      +51     
Impacted Files Coverage Δ Complexity Δ
...ava/com/baidu/hugegraph/io/HugeGraphSONModule.java 77.66% <100.00%> (-2.46%) 11.00 <0.00> (+1.00) ⬇️
...baidu/hugegraph/plugin/HugeGraphGremlinPlugin.java 86.66% <100.00%> (+0.95%) 4.00 <0.00> (ø)
...a/com/baidu/hugegraph/traversal/optimize/Text.java 66.66% <0.00%> (-33.34%) 2.00% <0.00%> (-1.00%)
...gegraph/backend/serializer/BinaryBackendEntry.java 69.64% <0.00%> (-13.08%) 31.00% <0.00%> (+2.00%) ⬇️
.../java/com/baidu/hugegraph/auth/HugePermission.java 70.00% <0.00%> (-10.00%) 6.00% <0.00%> (-1.00%)
...n/java/com/baidu/hugegraph/schema/VertexLabel.java 85.00% <0.00%> (-9.12%) 11.00% <0.00%> (+1.00%) ⬇️
...in/java/com/baidu/hugegraph/auth/SchemaDefine.java 69.91% <0.00%> (-9.09%) 10.00% <0.00%> (ø%)
...n/java/com/baidu/hugegraph/schema/SchemaLabel.java 70.96% <0.00%> (-7.88%) 23.00% <0.00%> (+2.00%) ⬇️
...ain/java/com/baidu/hugegraph/schema/EdgeLabel.java 73.68% <0.00%> (-6.97%) 19.00% <0.00%> (+3.00%) ⬇️
... and 62 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af75b51...cdcd2df. Read the comment docs.

@javeme
Copy link
Contributor

javeme commented Jun 10, 2020

$ hugegraph-0.11.1/bin/gremlin-console.sh 
objc[2884]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
Exception in thread "main" java.lang.NullPointerException: Cannot invoke method activate() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
at org.codehaus.groovy.vmplugin.v7.IndyGuardsFiltersAndSignatures.invokeGroovyObjectInvoker(IndyGuardsFiltersAndSignatures.java:163)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
at org.apache.tinkerpop.gremlin.console.Console$_closure18.doCall(Console.groovy:147)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:405)
at groovy.lang.Closure.call(Closure.java:421)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2330)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2315)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2356)
at org.codehaus.groovy.runtime.dgm$186.doMethodInvoke(Unknown Source)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:145)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:502)

javeme
javeme previously approved these changes Jun 10, 2020
@javeme
Copy link
Contributor

javeme commented Jun 15, 2020

run with memory backend:

$ hugegraph-0.11.1/bin/gremlin-console.sh 
objc[8740]: Class JavaLaunchHelper is implemented in both /bin/java and  /jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: HugeGraph
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> graph = HugeFactory.open("hugegraph-0.11.1/conf/hugegraph.properties")
==>standardhugegraph[hugegraph]
gremlin> g=graph.traversal()
==>graphtraversalsource[standardhugegraph[hugegraph], standard]
gremlin> g.V()
main dict load finished, time elapsed 1268 ms
model load finished, time elapsed 73 ms.
gremlin> graph.schema().vertexLabel('person').useCustomizeStringId().create();graph.schema().edgeLabel('next').sourceLabel('person').targetLabel('person').create(); g.addV('person').property(id,'A').as('a').addV('person').property(id,'B').as('b').addV('person').property(id,'C').as('c').addV('person').property(id,'D').as('d').addV('person').property(id,'E').as('e').addV('person').property(id,'F').as('f').addE('next').from('a').to('b').addE('next').from('b').to('c').addE('next').from('b').to('d').addE('next').from('c').to('d').addE('next').from('c').to('e').addE('next').from('d').to('e').addE('next').from('e').to('f').addE('next').from('f').to('d')
==>e[SF>1>>SD][F-next->D]
gremlin> g.V()
==>v[A]
==>v[B]
==>v[C]
==>v[D]
==>v[E]
==>v[F]

register with com.baidu.hugegraph.dist.RegisterUtil.registerRocksDB() for rocksdb backend.

@javeme
Copy link
Contributor

javeme commented Jun 15, 2020

run remote with error:

gremlin> :remote connect tinkerpop.server hugegraph-0.11.1/conf/remote.yaml 
==>Configured localhost/127.0.0.1:8182
gremlin> :> g.V().count()
Index: 121, Size: 0

image

@Linary
Copy link
Contributor Author

Linary commented Jun 15, 2020

start tinkerpop gremlin server

gremlin-server-3.4.3 > bin/gremlin-server.sh conf/gremlin-server-modern.yaml
[INFO] GremlinServer - 3.4.3
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----

[INFO] GremlinServer - Configuring Gremlin Server from conf/gremlin-server-modern.yaml
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] DefaultGraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties].
[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool.  Threads in pool named with pattern gremlin-*
[INFO] ServerGremlinExecutor - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
[INFO] ServerGremlinExecutor - Initialized gremlin-groovy GremlinScriptEngine and registered metrics
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms
[INFO] GremlinServer - Executing start up LifeCycleHook
[INFO] Logger$info - Loading 'modern' graph data.
[INFO] GremlinServer - idleConnectionTimeout was set to 0 which resolves to 0 seconds when configuring this value - this feature will be disabled
[INFO] GremlinServer - keepAliveInterval was set to 0 which resolves to 0 seconds when configuring this value - this feature will be disabled
[WARN] AbstractChannelizer - The org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0 serialization class is deprecated.
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+gryo with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0
[WARN] AbstractChannelizer - The org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0 serialization class is deprecated.
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+gryo-stringd with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
[INFO] AbstractChannelizer - Configured application/vnd.graphbinary-v1.0 with org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1
[INFO] AbstractChannelizer - Configured application/vnd.graphbinary-v1.0-stringd with org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1
[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 4 and boss thread pool of 1.
[INFO] GremlinServer$1 - Channel started at port 8182.

remote.yaml

hosts: [localhost]
port: 8182
serializer: {
  className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
  config: {
    serializeResultToString: true,
    ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
  }
}
gremlin>  :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :> g.V()
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
gremlin> :> g.V().count()
==>6

@Linary
Copy link
Contributor Author

Linary commented Jun 15, 2020

start HugeGraphServer

remote.yaml

hosts: [localhost]
port: 8182
serializer: {
  className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
  config: {
    serializeResultToString: false,
    ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
  }
}
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :> hugegraph.traversal().V()
==>[id:1:1,label:person,type:vertex,properties:[name:1,city:H]]
==>[id:1:2,label:person,type:vertex,properties:[name:2,city:H]]
==>[id:2:lop,label:software,type:vertex,properties:[name:lop,lang:java,price:328]]
==>[id:1:josh,label:person,type:vertex,properties:[name:josh,age:32,city:Beijing]]
==>[id:1:marko,label:person,type:vertex,properties:[name:marko,age:29,city:Beijing]]
==>[id:1:peter,label:person,type:vertex,properties:[name:peter,age:35,city:Shanghai]]
==>[id:1:vadas,label:person,type:vertex,properties:[name:vadas,age:27,city:Hongkong]]
==>[id:2:ripple,label:software,type:vertex,properties:[name:ripple,lang:java,price:199]]

Change-Id: I97603e8c8e4c3f806e782cdea375a7a85594889b
@1436516871
Copy link

1436516871 commented Jun 16, 2020

连接远程的server,提交gremlin语句

启动HugeGraphServer

进入gremlin控制台

[~]$ ./bin/gremlin-console.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: HugeGraph
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph

配置remote.yaml

hosts: [localhost]
port: 8182
serializer: {
  className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
  config: {
    serializeResultToString: false,
    ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
  }
}

连接到服务:

gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182

创建数据:

gremlin> :> hugegraph.schema().vertexLabel('person').useCustomizeStringId().create();hugegraph.schema().edgeLabel('next').sourceLabel('person').targetLabel('person').create();hugegraph.traversal().addV('person').property(id,'A').as('a').addV('person').property(id,'B').as('b').addV('person').property(id,'C').as('c').addV('person').property(id,'D').as('d').addV('person').property(id,'E').as('e').addV('person').property(id,'F').as('f').addE('next').from('a').to('b').addE('next').from('b').to('c').addE('next').from('b').to('d').addE('next').from('c').to('d').addE('next').from('c').to('e').addE('next').from('d').to('e').addE('next').from('e').to('f').addE('next').from('f').to('d')
==>[id:SF>1>>SD,label:next,type:edge,outV:F,outVLabel:person,inV:D,inVLabel:person,properties:[]]

执行查询语句:

gremlin> :> hugegraph.traversal().V()
==>[id:A,label:person,type:vertex,properties:[]]
==>[id:B,label:person,type:vertex,properties:[]]
==>[id:C,label:person,type:vertex,properties:[]]
==>[id:D,label:person,type:vertex,properties:[]]
==>[id:E,label:person,type:vertex,properties:[]]
==>[id:F,label:person,type:vertex,properties:[]]
gremlin> :> hugegraph.traversal().E()
==>[id:SA>1>>SB,label:next,type:edge,outV:A,outVLabel:person,inV:B,inVLabel:person,properties:[]]
==>[id:SB>1>>SC,label:next,type:edge,outV:B,outVLabel:person,inV:C,inVLabel:person,properties:[]]
==>[id:SB>1>>SD,label:next,type:edge,outV:B,outVLabel:person,inV:D,inVLabel:person,properties:[]]
==>[id:SC>1>>SD,label:next,type:edge,outV:C,outVLabel:person,inV:D,inVLabel:person,properties:[]]
==>[id:SC>1>>SE,label:next,type:edge,outV:C,outVLabel:person,inV:E,inVLabel:person,properties:[]]
==>[id:SD>1>>SE,label:next,type:edge,outV:D,outVLabel:person,inV:E,inVLabel:person,properties:[]]
==>[id:SE>1>>SF,label:next,type:edge,outV:E,outVLabel:person,inV:F,inVLabel:person,properties:[]]
==>[id:SF>1>>SD,label:next,type:edge,outV:F,outVLabel:person,inV:D,inVLabel:person,properties:[]]
gremlin> :> hugegraph.traversal().E().count()
==>8
gremlin> :> hugegraph.traversal().V().count()
==>6

@1436516871
Copy link

Accessing local data in console

Enter the gremlin console

[~]$ ./bin/gremlin-console.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: HugeGraph
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph

Register the backend and serializer of rocksdb

gremlin> com.baidu.hugegraph.dist.RegisterUtil.registerRocksDB()
==>null

Create graph instance

gremlin> graph = HugeFactory.open("conf/hugegraph.properties")
==>standardhugegraph[hugegraph]
gremlin> g=graph.traversal()
==>graphtraversalsource[standardhugegraph[hugegraph], standard]
Execute statement
gremlin> g.V()
main dict load finished, time elapsed 959 ms
model load finished, time elapsed 58 ms.
==>v[A]
==>v[B]
==>v[C]
==>v[D]
==>v[E]
==>v[F]

@zhoney zhoney merged commit 2b47775 into master Jun 17, 2020
@zhoney zhoney deleted the fix-gremlin-plugin-bug branch June 17, 2020 02:32
javeme pushed a commit that referenced this pull request Jun 18, 2020
* Fix gremlin-console can't work
* Let gremlin console can remote connect to HugeGremlinServer

Change-Id: Ice222d809e4161f1d4d1f04822bef1c5af380a10
Linary added a commit that referenced this pull request Jun 19, 2020
* Fix mysql backend openWithoutDB ssl-mode not work (#842)
* fix bug of missing offset with index query (#866)
* allow system async task in gremlin context (#892)
* sm allow cassandra backend creating thread as needed while execute cql (#896)
* fix: Invalid limit 10000000, must be <= capacity (#950)
* Fix gremlin-console can't work (#1027)

Change-Id: Ice222d809e4161f1d4d1f04822bef1c5af380a10

Co-authored-by: Linary <liningrui@vip.qq.com>
Co-authored-by: zhoney <zhangyi51@baidu.com>
@javeme
Copy link
Contributor

javeme commented Sep 14, 2020

image

gremlin> g.V().has('name','marko').out('knows').values('name')
org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.testAll(Lorg/apache/tinkerpop/gremlin/structure/Element;Ljava/util/List;)Z

maybe related to: apache/tinkerpop@134d745#diff-1ae6d5b30eaffe6d49a30d5eeef2dec3

@1436516871
Copy link

It can be used normally but not reproduced
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

有没有功能支持,输入gremlin语句的文本,解析后操作hugegraph,返回结果
4 participants