-
Notifications
You must be signed in to change notification settings - Fork 863
TINKERPOP-3282 TinkerStorageGraph #3639
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
base: master
Are you sure you want to change the base?
Changes from all commits
da0cf3b
28133e8
a6ec2e3
a78173f
a81ffc2
8ad03c9
0031b95
af52382
d32b022
445c08b
eb1bfbd
3e758c8
2cf5617
e076479
2de68bf
ed59853
8c8abc5
18da908
895b9c2
473094c
827213e
dde128b
47fdd13
ceec627
d5dd32e
719e2e4
5e2d2f9
0561b83
ffaeff1
3e15f63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # Sample configuration for a durable, transactional TinkerStorageGraph on Gremlin Server. Reference it from the | ||
| # server's "graphs" block, for example in gremlin-server-transaction.yaml: | ||
| # graphs: { graph: conf/tinkerstoragegraph-persistent.properties } | ||
| gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerStorageGraph | ||
|
|
||
| # Enables durable persistence. "graphbinary" is the built-in storage engine; the fully qualified class name of a | ||
| # custom TinkerStorage implementation may be used instead. Without this key the graph is transactional but in-memory. | ||
| gremlin.tinkergraph.storage=graphbinary | ||
| # Directory holding the durable data. Required when a storage engine is set. It is created if absent and may be | ||
| # opened by only one graph at a time (single writer, whether in this JVM or another process). | ||
| gremlin.tinkergraph.storage.directory=/tmp/tinkerstoragegraph | ||
|
|
||
| gremlin.tinkergraph.vertexIdManager=LONG | ||
| gremlin.tinkergraph.edgeIdManager=LONG | ||
| gremlin.tinkergraph.vertexPropertyIdManager=LONG | ||
|
|
||
| # Optional storage tuning (defaults shown, uncomment to change): | ||
| # "commit" forces each transaction to disk (survives OS crash/power loss); "os" is faster but survives only a JVM crash | ||
| #gremlin.tinkergraph.storage.sync=commit | ||
| # auto-compact the append log once it grows past this many bytes (default 67108864 = 64MB; 0 disables) | ||
| #gremlin.tinkergraph.storage.compactThreshold=67108864 | ||
| # persist auto-generated vertex-property ids across a reopen (default false) | ||
| #gremlin.tinkergraph.storage.preserveVertexPropertyIds=false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,14 +21,17 @@ | |
| import org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialTraversal; | ||
| import org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialTraversalDsl; | ||
| import org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialTraversalSource; | ||
| import org.apache.commons.configuration2.Configuration; | ||
| import org.apache.tinkerpop.gremlin.structure.Graph; | ||
| import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
| import org.apache.tinkerpop.gremlin.structure.io.IoCore; | ||
| import org.apache.tinkerpop.gremlin.structure.util.GraphFactory; | ||
| import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; | ||
| import org.mindrot.jbcrypt.BCrypt; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.File; | ||
| import java.net.InetAddress; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.Arrays; | ||
|
|
@@ -80,12 +83,63 @@ public void setup(final Map<String,Object> config) { | |
| // have to create the indices because they are not stored in gryo | ||
| final TinkerGraph tinkerGraph = (TinkerGraph) graph; | ||
| tinkerGraph.createIndex(PROPERTY_USERNAME, Vertex.class); | ||
|
|
||
| // TinkerGraph no longer auto-loads from graphLocation on open, so read the credential store here from | ||
| // the configured location/format. TinkerStorageGraph (which persists via its own storage engine) manages | ||
| // its own data and is left untouched. | ||
| loadCredentialStore(tinkerGraph); | ||
| } | ||
|
|
||
| credentialStore = graph.traversal(CredentialTraversalSource.class); | ||
| logger.info("CredentialGraph initialized at {}", credentialStore); | ||
| } | ||
|
|
||
| /** | ||
| * Reads the credential store into the supplied in-memory {@link TinkerGraph} from the | ||
| * {@code gremlin.tinkergraph.graphLocation} and {@code gremlin.tinkergraph.graphFormat} entries of its | ||
| * configuration, if present. Earlier versions of TinkerGraph read those keys themselves on open, so the | ||
| * credential store loaded as a side effect of {@code GraphFactory.open}; that automatic behaviour was removed | ||
| * and this method preserves it for the credential store alone. | ||
| * <p/> | ||
| * No TinkerGraph reads either key any more, which is why they are named here as literals rather than through | ||
| * constants. Despite the {@code gremlin.tinkergraph} prefix they are in effect settings of this authenticator, | ||
| * and belong in its own {@code config} block beside {@code credentialsDb} rather than in the graph's properties | ||
| * file. They are left in place here only to keep existing credential configurations working. A graph with a | ||
| * storage engine manages its own data and is skipped. | ||
| */ | ||
| private static void loadCredentialStore(final TinkerGraph graph) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of scope for this PR, but I feel like SimpleAuthenticator should be completely reworked for TinkerPop 4. It was already feeling dated, but stitching it to removed Graph config options really emphasizes that further.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah.........i noticed that and figured we'd be coming for that issue someday, so i just left the settings as they were. |
||
| final Configuration conf = graph.configuration(); | ||
| final String location = conf.getString("gremlin.tinkergraph.graphLocation", null); | ||
| // a storage engine manages its own persistence and is not an interchange-format load | ||
| final String storage = conf.getString(TinkerGraph.GREMLIN_TINKERGRAPH_STORAGE, null); | ||
| if (null == location || storage != null) | ||
| return; | ||
|
|
||
| final File f = new File(location); | ||
| if (!f.exists() || !f.isFile()) | ||
| return; | ||
|
|
||
| final String format = conf.getString("gremlin.tinkergraph.graphFormat", "gryo"); | ||
| try { | ||
| switch (format) { | ||
| case "graphml": | ||
| graph.io(IoCore.graphml()).readGraph(location); | ||
| break; | ||
| case "graphson": | ||
| graph.io(IoCore.graphson()).readGraph(location); | ||
| break; | ||
| case "gryo": | ||
| graph.io(IoCore.gryo()).readGraph(location); | ||
| break; | ||
| default: | ||
| graph.io(IoCore.createIoBuilder(format)).readGraph(location); | ||
| break; | ||
| } | ||
| } catch (Exception ex) { | ||
| throw new IllegalStateException(String.format("Could not load credential store at %s with format %s", location, format), ex); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public SaslNegotiator newSaslNegotiator(final InetAddress remoteAddress) { | ||
| return new PlainTextSaslAuthenticator(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the extra reference creates a maintenance chore without adding much value. Also it's referencing how
gremlin-server-transaction.yamlreferences this file, yet the server config yamls are unchanged in this PR.