You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/05/10 16:56:41 UTC
incubator-tinkerpop git commit: Updated the gephi plugin to work on
Gephi 0.9.x
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1297 [created] d96f6312b
Updated the gephi plugin to work on Gephi 0.9.x
Improved output of HTTP request errors to gephi. It is likely that this change will not allow Gephi to work with 0.8.x anymore.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d96f6312
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d96f6312
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d96f6312
Branch: refs/heads/TINKERPOP-1297
Commit: d96f6312ba2e33e207576fd3692945cb6cf6a800
Parents: 9159fe7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 10 12:55:32 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 10 12:55:32 2016 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../src/reference/gremlin-applications.asciidoc | 16 +++++-----
.../upgrade/release-3.2.x-incubating.asciidoc | 8 +++++
.../console/plugin/GephiRemoteAcceptor.groovy | 31 +++++++++++++-------
.../GephiRemoteAcceptorIntegrateTest.java | 26 ++++++++--------
5 files changed, 51 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d96f6312/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a230df1..b3d7b12 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
TinkerPop 3.2.1 (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Updated the Gephi Plugin to support Gephi 0.9.x.
* Increased the testing and scope of `TraversalHelper.isLocalStarGraph()`.
* Added `VertexProgramInterceptor` interface as a general pattern for `GraphComputer` providers to use for bypassing `GraphComputer` semantics where appropriate.
* Added `SparkStarBarrierInterceptor` that uses Spark DSL for local star graph traversals that end with a `ReducingBarrierStep`.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d96f6312/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index ea79621..befb0f5 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -1630,14 +1630,14 @@ This plugin imports the appropriate classes for managing the credentials graph.
Gephi Plugin
~~~~~~~~~~~~
-image:gephi-logo.png[width=200, float=left] link:http://gephi.github.io/[Gephi] is an interactive visualization,
-exploration, and analysis platform for graphs. The link:https://marketplace.gephi.org/plugin/graph-streaming/[Graph Streaming]
-plugin for Gephi provides an link:https://wiki.gephi.org/index.php/Graph_Streaming[API] that can be leveraged to
-stream graphs and visualize traversals interactively through the Gremlin Gephi Plugin.
-
-The following instructions assume that Gephi has been download and installed. It further assumes that the Graph
-Streaming plugin has been installed (`Tools > Plugins`). The following instructions explain how to visualize a `Graph`
-and `Traversal`.
+image:gephi-logo.png[width=200, float=left] link:http://gephi.org/[Gephi] is an interactive visualization,
+exploration, and analysis platform for graphs. The link:https://gephi.org/plugins/#/plugin/graphstreaming[Graph Streaming]
+plugin for Gephi provides an API that can be leveraged to stream graph data to a running Gephi application. The Gephi
+plugin for Gremlin Console utilizes this API to allow for graph and traversal visualization.
+
+The Gephi plugin for Gremlin Console is compatible with Gephi 0.9.x. The following instructions assume that Gephi
+has been download and installed. It further assumes that the Graph Streaming plugin has been installed
+(`Tools > Plugins`). The following instructions explain how to visualize a `Graph` and `Traversal`.
In Gephi, create a new project with `File > New Project`. In the lower left view, click the "Streaming" tab, open the
Master drop down, and right click `Master Server > Start` which starts the Graph Streaming server in Gephi and by
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d96f6312/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 83c655c..d289f23 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -32,6 +32,14 @@ Please see the link:https://github.com/apache/incubator-tinkerpop/blob/3.2.1-inc
Upgrading for Users
~~~~~~~~~~~~~~~~~~~
+Gephi Plugin
+^^^^^^^^^^^^
+
+The Gephi Plugin has been updated to support Gephi 0.9.x. Please upgrade to this latest version to use the Gephi Plugin
+for Gremlin Console.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1297[TINKERPOP-1297]
+
TraversalVertexProgram
^^^^^^^^^^^^^^^^^^^^^^
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d96f6312/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
index 1cd3584..e9ea1da 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
@@ -20,6 +20,8 @@ package org.apache.tinkerpop.gremlin.console.plugin
import groovy.json.JsonOutput
import groovy.transform.CompileStatic
+import org.apache.http.client.methods.CloseableHttpResponse
+import org.apache.http.client.methods.HttpUriRequest
import org.apache.http.client.methods.RequestBuilder
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.CloseableHttpClient
@@ -27,19 +29,13 @@ import org.apache.http.impl.client.HttpClients
import org.apache.http.util.EntityUtils
import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor
import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException
-import org.apache.tinkerpop.gremlin.process.traversal.Path
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.structure.Direction
import org.apache.tinkerpop.gremlin.structure.Edge
import org.apache.tinkerpop.gremlin.structure.Graph
import org.apache.tinkerpop.gremlin.structure.Vertex
import groovy.json.JsonSlurper
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils
import org.codehaus.groovy.tools.shell.Groovysh
import org.codehaus.groovy.tools.shell.IO
-import org.javatuples.Pair
-
-import java.util.stream.Collectors
/**
* @author Stephen Mallette (http://stephen.genoprime.com)
@@ -49,11 +45,12 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
private String host = "localhost"
private int port = 8080
- private String workspace = "workspace0"
+ private String workspace = "workspace1"
private final Groovysh shell
private final IO io
+ private final Random rand = new Random();
boolean traversalSubmittedForViz = false
long vizStepDelay
private float[] vizStartRGBColor
@@ -76,7 +73,7 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
vizDefaultRGBColor = [0.6f, 0.6f, 0.6f] // light grey
vizColorToFade = 'g' // will fade so blue is strongest
vizColorFadeRate = 0.7 // the multiplicative rate to fade visited vertices
- vizStartSize = 20
+ vizStartSize = 3
vizSizeDecrementRate = 0.33f
}
@@ -273,6 +270,9 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
props.put('r', vizDefaultRGBColor[0])
props.put('g', vizDefaultRGBColor[1])
props.put('b', vizDefaultRGBColor[2])
+ props.put('x', rand.nextFloat())
+ props.put('y', rand.nextFloat())
+ props.put('size', 1)
props.put('visited', 0)
// only add if it does not exist in graph already
@@ -318,7 +318,8 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
def requestBuilder = RequestBuilder.get("http://$host:$port/$workspace")
queryArgs.each { requestBuilder = requestBuilder.addParameter(it.key, it.value) }
- def resp = EntityUtils.toString(httpclient.execute(requestBuilder.build()).entity)
+ def httpResp = makeRequest(requestBuilder.build())
+ def resp = EntityUtils.toString(httpResp.entity)
// gephi streaming plugin does not set the content type or respect the Accept header - treat as text
if (resp.isEmpty())
@@ -332,7 +333,17 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
.addParameter("format", "JSON")
.addParameter("operation", "updateGraph")
.setEntity(new StringEntity(JsonOutput.toJson(postBody)))
- EntityUtils.consume(httpclient.execute(requestBuilder.build()).entity)
+ EntityUtils.consume(makeRequest(requestBuilder.build()).entity)
+ }
+
+ private CloseableHttpResponse makeRequest(HttpUriRequest request) {
+ def httpResp = httpclient.execute(request)
+ if (httpResp.getStatusLine().getStatusCode() == 200) {
+ return httpResp
+ } else {
+ def resp = EntityUtils.toString(httpResp.entity)
+ throw new RuntimeException("Unsuccessful request to Gephi - [${httpResp.getStatusLine().getStatusCode()}] ${httpResp.getStatusLine().getReasonPhrase()} - $resp")
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d96f6312/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
index 6af1641..afda528 100644
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
@@ -82,31 +82,31 @@ public class GephiRemoteAcceptorIntegrateTest {
@Test
public void shouldConnectWithDefaults() throws RemoteException {
- assertThat(acceptor.connect(Collections.emptyList()).toString(), startsWith("Connection to Gephi - http://localhost:" + port + "/workspace0"));
+ assertThat(acceptor.connect(Collections.emptyList()).toString(), startsWith("Connection to Gephi - http://localhost:" + port + "/workspace1"));
}
@Test
public void shouldSubmitGraph() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace0"))
+ stubFor(post(urlPathEqualTo("/workspace1"))
.withQueryParam("format", equalTo("JSON"))
.withQueryParam("operation", equalTo("updateGraph"))
.willReturn(aResponse()
.withStatus(200)));
- stubFor(get(urlPathEqualTo("/workspace0"))
+ stubFor(get(urlPathEqualTo("/workspace1"))
.withQueryParam("operation", equalTo("getNode"))
.willReturn(aResponse()
.withStatus(200)));
acceptor.submit(Arrays.asList("g = org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.open();g.addVertex();g"));
- wireMockRule.verify(4, postRequestedFor(urlPathEqualTo("/workspace0")));
- wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/workspace0")));
+ wireMockRule.verify(4, postRequestedFor(urlPathEqualTo("/workspace1")));
+ wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/workspace1")));
}
@Test
public void shouldSubmitTraversalAfterConfigWithDefaultG() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace0"))
+ stubFor(post(urlPathEqualTo("/workspace1"))
.withQueryParam("format", equalTo("JSON"))
.withQueryParam("operation", equalTo("updateGraph"))
.willReturn(aResponse()
@@ -118,12 +118,12 @@ public class GephiRemoteAcceptorIntegrateTest {
acceptor.submit(Arrays.asList(
"vg.V(2).in('knows').out('knows').has('age',org.apache.tinkerpop.gremlin.process.traversal.P.gt(30)).outE('created').has('weight',org.apache.tinkerpop.gremlin.process.traversal.P.gt(0.5d)).inV().iterate()"));
- wireMockRule.verify(18, postRequestedFor(urlPathEqualTo("/workspace0")));
+ wireMockRule.verify(18, postRequestedFor(urlPathEqualTo("/workspace1")));
}
@Test
public void shouldSubmitTraversalAfterConfigWithDefinedG() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace0"))
+ stubFor(post(urlPathEqualTo("/workspace1"))
.withQueryParam("format", equalTo("JSON"))
.withQueryParam("operation", equalTo("updateGraph"))
.willReturn(aResponse()
@@ -135,12 +135,12 @@ public class GephiRemoteAcceptorIntegrateTest {
acceptor.submit(Arrays.asList(
"x.V(2).in('knows').out('knows').has('age',org.apache.tinkerpop.gremlin.process.traversal.P.gt(30)).outE('created').has('weight',org.apache.tinkerpop.gremlin.process.traversal.P.gt(0.5d)).inV().iterate()"));
- wireMockRule.verify(18, postRequestedFor(urlPathEqualTo("/workspace0")));
+ wireMockRule.verify(18, postRequestedFor(urlPathEqualTo("/workspace1")));
}
@Test
public void shouldSubmitTraversalOverRepeat() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace0"))
+ stubFor(post(urlPathEqualTo("/workspace1"))
.withQueryParam("format", equalTo("JSON"))
.withQueryParam("operation", equalTo("updateGraph"))
.willReturn(aResponse()
@@ -152,12 +152,12 @@ public class GephiRemoteAcceptorIntegrateTest {
acceptor.submit(Arrays.asList(
"vg.V(1).repeat(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.__().out()).times(2).iterate()"));
- wireMockRule.verify(13, postRequestedFor(urlPathEqualTo("/workspace0")));
+ wireMockRule.verify(13, postRequestedFor(urlPathEqualTo("/workspace1")));
}
@Test
public void shouldClearGraph() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace0"))
+ stubFor(post(urlPathEqualTo("/workspace1"))
.withQueryParam("format", equalTo("JSON"))
.withQueryParam("operation", equalTo("updateGraph"))
.withRequestBody(equalToJson("{\"dn\":{\"filter\":\"ALL\"}}"))
@@ -166,7 +166,7 @@ public class GephiRemoteAcceptorIntegrateTest {
acceptor.submit(Arrays.asList("clear"));
- wireMockRule.verify(1, postRequestedFor(urlPathEqualTo("/workspace0")));
+ wireMockRule.verify(1, postRequestedFor(urlPathEqualTo("/workspace1")));
}
private static int pickOpenPort() {