From 9a60e5762c56920b5bd387a6a26c25e31fadf72c Mon Sep 17 00:00:00 2001 From: Ken Hu <106191785+kenhuuu@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:26:39 -0700 Subject: [PATCH] Remove v4 suffix --- .../reference/gremlin-applications.asciidoc | 2 +- .../src/main/java/examples/Connections.java | 5 +- .../tinkerpop/gremlin/driver/Channelizer.java | 6 +- .../tinkerpop/gremlin/driver/Client.java | 26 ++- .../tinkerpop/gremlin/driver/Cluster.java | 38 ++-- .../tinkerpop/gremlin/driver/Connection.java | 4 +- .../gremlin/driver/ConnectionPool.java | 4 +- .../gremlin/driver/LoadBalancingStrategy.java | 10 +- .../gremlin/driver/RequestOptions.java | 14 +- .../tinkerpop/gremlin/driver/Result.java | 4 +- .../tinkerpop/gremlin/driver/ResultSet.java | 8 +- .../tinkerpop/gremlin/driver/Settings.java | 8 +- .../handler/GremlinResponseHandler.java | 8 +- .../handler/HttpGremlinRequestEncoder.java | 15 +- .../HttpGremlinResponseStreamDecoder.java | 19 +- .../gremlin/driver/simple/AbstractClient.java | 19 +- .../gremlin/driver/simple/SimpleClient.java | 22 +-- .../driver/simple/SimpleHttpClient.java | 18 +- .../driver/util/ProfilingApplication.java | 7 +- .../gremlin/driver/ResultSetTest.java | 4 +- .../tinkerpop/gremlin/driver/TokensTest.java | 6 +- .../remote/DriverRemoteConnectionTest.java | 12 +- .../gremlin/server/AbstractChannelizer.java | 24 +-- .../tinkerpop/gremlin/server/Context.java | 32 ++-- .../gremlin/server/GraphManager.java | 1 - .../tinkerpop/gremlin/server/Settings.java | 12 +- .../gremlin/server/auth/Authenticator.java | 8 +- .../gremlin/server/authz/Authorizer.java | 8 +- .../HttpBasicAuthorizationHandler.java | 12 +- .../handler/HttpGremlinEndpointHandler.java | 63 +++--- .../server/handler/HttpHandlerUtil.java | 21 +- .../handler/HttpRequestMessageDecoder.java | 52 ++--- .../gremlin/server/handler/StateKey.java | 4 +- .../gremlin/server/util/GremlinError.java | 14 +- ...4.java => TextPlainMessageSerializer.java} | 25 ++- .../driver/ClientConnectionIntegrateTest.java | 7 +- .../remote/AbstractRemoteGraphProvider.java | 4 +- .../GraphBinaryGroovyRemoteGraphProvider.java | 4 +- .../GraphBinaryLangRemoteGraphProvider.java | 4 +- ...raphBinaryRemoteGraphComputerProvider.java | 4 +- .../gremlin/driver/remote/RemoteWorld.java | 10 +- .../tinkerpop/gremlin/server/ContextTest.java | 10 +- .../server/GremlinDriverIntegrateTest.java | 8 +- .../server/GremlinResultSetIntegrateTest.java | 16 +- .../GremlinServerHttpIntegrateTest.java | 62 +++--- .../server/GremlinServerIntegrateTest.java | 50 ++--- ...emlinServerSerializationIntegrateTest.java | 7 +- .../server/GremlinServerSslIntegrateTest.java | 5 +- .../server/authz/AllowListAuthorizer.java | 8 +- .../gremlin/server/authz/AuthorizerTest.java | 6 +- .../HttpRequestMessageDecoderTest.java | 80 ++++---- ...va => TextPlainMessageSerializerTest.java} | 8 +- .../driver/SerializationBenchmark.java | 20 +- ...rializerV4.java => MessageSerializer.java} | 38 ++-- .../util/{TokensV4.java => Tokens.java} | 4 +- ...uestMessageV4.java => RequestMessage.java} | 46 ++--- ...nseMessageV4.java => ResponseMessage.java} | 38 ++-- ...ponseResultV4.java => ResponseResult.java} | 6 +- ...ponseStatusV4.java => ResponseStatus.java} | 7 +- .../AbstractGraphSONMessageSerializerV4.java | 180 +++++++++--------- ...V4.java => AbstractMessageSerializer.java} | 6 +- .../ser/GraphBinaryMessageSerializerV4.java | 46 ++--- .../util/ser/GraphSONMessageSerializerV4.java | 4 +- .../GraphSONUntypedMessageSerializerV4.java | 4 +- .../ser/{SerTokensV4.java => SerTokens.java} | 4 +- .../{SerializersV4.java => Serializers.java} | 24 +-- ...rV4.java => RequestMessageSerializer.java} | 38 ++-- .../io/AbstractCompatibilityTest.java | 34 ++-- .../io/AbstractTypedCompatibilityTest.java | 29 ++- .../io/AbstractUntypedCompatibilityTest.java | 28 +-- .../tinkerpop/gremlin/structure/io/Model.java | 18 +- ...ageV4Test.java => RequestMessageTest.java} | 62 +++--- ...phSONMessageSerializerV4RoundTripTest.java | 4 +- .../ser/GraphSONMessageSerializerV4Test.java | 38 ++-- ...raphSONUntypedMessageSerializerV4Test.java | 24 +-- .../GraphBinaryMessageSerializerV4Test.java | 36 ++-- ...V4Test.java => MessageSerializerTest.java} | 48 ++--- .../sample/SamplePersonSerializerTest.java | 8 +- 78 files changed, 797 insertions(+), 825 deletions(-) rename gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/{TextPlainMessageSerializerV4.java => TextPlainMessageSerializer.java} (82%) rename gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/{TextPlainMessageSerializerV4Test.java => TextPlainMessageSerializerTest.java} (89%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/{MessageSerializerV4.java => MessageSerializer.java} (75%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/{TokensV4.java => Tokens.java} (98%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/{RequestMessageV4.java => RequestMessage.java} (76%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/{ResponseMessageV4.java => ResponseMessage.java} (72%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/{ResponseResultV4.java => ResponseResult.java} (92%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/{ResponseStatusV4.java => ResponseStatus.java} (90%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/{AbstractMessageSerializerV4.java => AbstractMessageSerializer.java} (93%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/{SerTokensV4.java => SerTokens.java} (96%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/{SerializersV4.java => Serializers.java} (74%) rename gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/{RequestMessageSerializerV4.java => RequestMessageSerializer.java} (68%) rename gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/{RequestMessageV4Test.java => RequestMessageTest.java} (56%) rename gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/{MessageSerializerV4Test.java => MessageSerializerTest.java} (75%) diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc index d4a4e1d4d06..c0ab64a342e 100644 --- a/docs/src/reference/gremlin-applications.asciidoc +++ b/docs/src/reference/gremlin-applications.asciidoc @@ -1823,7 +1823,7 @@ public class AllowListAuthorizer implements Authorizer { * {@link AuthorizationException} if this is not the case. * * @param user {@link AuthenticatedUser} that needs authorization. - * @param msg {@link RequestMessage} in which the {@link org.apache.tinkerpop.gremlin.util.TokensV4}.ARGS_GREMLIN argument can contain an arbitrary succession of script statements. + * @param msg {@link RequestMessage} in which the {@link org.apache.tinkerpop.gremlin.util.Tokens}.ARGS_GREMLIN argument can contain an arbitrary succession of script statements. */ public void authorize(final AuthenticatedUser user, final RequestMessage msg) throws AuthorizationException { if (!usernamesSandbox.contains(user.getName())) { diff --git a/gremlin-driver/src/main/java/examples/Connections.java b/gremlin-driver/src/main/java/examples/Connections.java index 7707c468e2b..0c6eb5176b1 100644 --- a/gremlin-driver/src/main/java/examples/Connections.java +++ b/gremlin-driver/src/main/java/examples/Connections.java @@ -19,7 +19,6 @@ Licensed to the Apache Software Foundation (ASF) under one package examples; -import org.apache.tinkerpop.gremlin.driver.Channelizer; import org.apache.tinkerpop.gremlin.driver.Client; import org.apache.tinkerpop.gremlin.driver.Cluster; import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection; @@ -29,7 +28,7 @@ Licensed to the Apache Software Foundation (ASF) under one import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; @@ -95,7 +94,7 @@ private static void withCluster() throws Exception { private static void withSerializer() throws Exception { IoRegistry registry = new FakeIoRegistry(); // an IoRegistry instance exposed by a specific graph provider TypeSerializerRegistry typeSerializerRegistry = TypeSerializerRegistry.build().addRegistry(registry).create(); - MessageSerializerV4 serializer = new GraphBinaryMessageSerializerV4(typeSerializerRegistry); + MessageSerializer serializer = new GraphBinaryMessageSerializerV4(typeSerializerRegistry); Cluster cluster = Cluster.build("localhost"). serializer(serializer). create(); diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Channelizer.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Channelizer.java index 5961545d5a8..fb37f01306e 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Channelizer.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Channelizer.java @@ -32,7 +32,7 @@ import org.apache.tinkerpop.gremlin.driver.handler.HttpGremlinRequestEncoder; import org.apache.tinkerpop.gremlin.driver.handler.HttpGremlinResponseStreamDecoder; import org.apache.tinkerpop.gremlin.driver.handler.SslCheckHandler; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import java.util.Collections; import java.util.Optional; @@ -160,8 +160,8 @@ final class HttpChannelizer extends AbstractChannelizer { /** * This response is used as a signal for determining if all content of the response has been read. */ - public static final ResponseMessageV4 LAST_CONTENT_READ_RESPONSE = - ResponseMessageV4.build().code(HttpResponseStatus.NO_CONTENT).result(Collections.emptyList()).create(); + public static final ResponseMessage LAST_CONTENT_READ_RESPONSE = + ResponseMessage.build().code(HttpResponseStatus.NO_CONTENT).result(Collections.emptyList()).create(); private HttpGremlinRequestEncoder gremlinRequestEncoder; private HttpGremlinResponseStreamDecoder gremlinResponseDecoder; diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java index d9cfa722978..15cb93f570b 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java @@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException; import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,8 +44,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import static org.apache.tinkerpop.gremlin.driver.RequestOptions.getRequestOptions; - /** * A {@code Client} is constructed from a {@link Cluster} and represents a way to send messages to Gremlin Server. * This class itself is a base class as there are different implementations that provide differing kinds of @@ -71,11 +69,11 @@ public abstract class Client { } /** - * Makes any initial changes to the builder and returns the constructed {@link RequestMessageV4}. Implementers + * Makes any initial changes to the builder and returns the constructed {@link RequestMessage}. Implementers * may choose to override this message to append data to the request before sending. By default, this method * will simply return the {@code builder} passed in by the caller. */ - public RequestMessageV4.Builder buildMessage(final RequestMessageV4.Builder builder) { + public RequestMessage.Builder buildMessage(final RequestMessage.Builder builder) { return builder; } @@ -87,7 +85,7 @@ public RequestMessageV4.Builder buildMessage(final RequestMessageV4.Builder buil /** * Chooses a {@link Connection} to write the message to. */ - protected abstract Connection chooseConnection(final RequestMessageV4 msg) throws TimeoutException, ConnectionException; + protected abstract Connection chooseConnection(final RequestMessage msg) throws TimeoutException, ConnectionException; /** * Asynchronous close of the {@code Client}. @@ -231,7 +229,7 @@ public CompletableFuture submitAsync(final String gremlin, final Requ // need to call buildMessage() right away to get client specific configurations, that way request specific // ones can override as needed - final RequestMessageV4.Builder request = buildMessage(RequestMessageV4.build(gremlin)) + final RequestMessage.Builder request = buildMessage(RequestMessage.build(gremlin)) .addChunkSize(batchSize); // apply settings if they were made available @@ -245,9 +243,9 @@ public CompletableFuture submitAsync(final String gremlin, final Requ } /** - * A low-level method that allows the submission of a manually constructed {@link RequestMessageV4}. + * A low-level method that allows the submission of a manually constructed {@link RequestMessage}. */ - public CompletableFuture submitAsync(final RequestMessageV4 msg) { + public CompletableFuture submitAsync(final RequestMessage msg) { if (isClosing()) throw new IllegalStateException("Client is closed"); if (!initialized) @@ -349,7 +347,7 @@ public Client alias(final String graphOrTraversalSource) { * from that host's connection pool. */ @Override - protected Connection chooseConnection(final RequestMessageV4 msg) throws TimeoutException, ConnectionException { + protected Connection chooseConnection(final RequestMessage msg) throws TimeoutException, ConnectionException { final Iterator possibleHosts = this.cluster.loadBalancingStrategy().select(msg); // try a random host if none are marked available. maybe it will reconnect in the meantime. better than @@ -483,8 +481,8 @@ public static class AliasClusteredClient extends Client { } @Override - public CompletableFuture submitAsync(final RequestMessageV4 msg) { - final RequestMessageV4.Builder builder = RequestMessageV4.from(msg); + public CompletableFuture submitAsync(final RequestMessage msg) { + final RequestMessage.Builder builder = RequestMessage.from(msg); builder.addG(graphOrTraversalSource); @@ -502,7 +500,7 @@ public synchronized Client init() { } @Override - public RequestMessageV4.Builder buildMessage(final RequestMessageV4.Builder builder) { + public RequestMessage.Builder buildMessage(final RequestMessage.Builder builder) { if (close.isDone()) throw new IllegalStateException("Client is closed"); builder.addG(graphOrTraversalSource); @@ -523,7 +521,7 @@ protected void initializeImplementation() { * Delegates to the underlying {@link Client.ClusteredClient}. */ @Override - protected Connection chooseConnection(final RequestMessageV4 msg) throws TimeoutException, ConnectionException { + protected Connection chooseConnection(final RequestMessage msg) throws TimeoutException, ConnectionException { if (close.isDone()) throw new IllegalStateException("Client is closed"); return client.chooseConnection(msg); } diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java index d4fda9c6ea0..4453297c674 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java @@ -30,9 +30,9 @@ import org.apache.commons.configuration2.Configuration; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.tinkerpop.gremlin.driver.auth.Auth; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -279,7 +279,7 @@ public String getPath() { } /** - * Get the {@link MessageSerializerV4} MIME types supported. + * Get the {@link MessageSerializer} MIME types supported. */ public String[] getSerializers() { return getSerializer().mimeTypesSupported(); @@ -359,7 +359,7 @@ Factory getFactory() { return manager.factory; } - MessageSerializerV4 getSerializer() { + MessageSerializer getSerializer() { return manager.serializer; } @@ -387,7 +387,7 @@ LoadBalancingStrategy loadBalancingStrategy() { return manager.loadBalancingStrategy; } - RequestMessageV4.Builder validationRequest() { + RequestMessage.Builder validationRequest() { return manager.validationRequest.get(); } @@ -468,7 +468,7 @@ public final static class Builder { private final List addresses = new ArrayList<>(); private int port = 8182; private String path = "/gremlin"; - private MessageSerializerV4 serializer = null; + private MessageSerializer serializer = null; private int nioPoolSize = Runtime.getRuntime().availableProcessors(); private int workerPoolSize = Runtime.getRuntime().availableProcessors() * 2; private int minConnectionPoolSize = ConnectionPool.MIN_POOL_SIZE; @@ -529,28 +529,28 @@ public Builder path(final String path) { } /** - * Set the {@link MessageSerializerV4} to use given the exact name of a {@link SerializersV4} enum. Note that + * Set the {@link MessageSerializer} to use given the exact name of a {@link Serializers} enum. Note that * setting this value this way will not allow specific configuration of the serializer itself. If specific - * configuration is required * please use {@link #serializer(MessageSerializerV4)}. + * configuration is required * please use {@link #serializer(MessageSerializer)}. */ public Builder serializer(final String mimeType) { - serializer = SerializersV4.valueOf(mimeType).simpleInstance(); + serializer = Serializers.valueOf(mimeType).simpleInstance(); return this; } /** - * Set the {@link MessageSerializerV4} to use via the {@link SerializersV4} enum. If specific configuration is - * required please use {@link #serializer(MessageSerializerV4)}. + * Set the {@link MessageSerializer} to use via the {@link Serializers} enum. If specific configuration is + * required please use {@link #serializer(MessageSerializer)}. */ - public Builder serializer(final SerializersV4 mimeType) { + public Builder serializer(final Serializers mimeType) { serializer = mimeType.simpleInstance(); return this; } /** - * Sets the {@link MessageSerializerV4} to use. + * Sets the {@link MessageSerializer} to use. */ - public Builder serializer(final MessageSerializerV4 serializer) { + public Builder serializer(final MessageSerializer serializer) { this.serializer = serializer; return this; } @@ -804,7 +804,7 @@ List getContactPoints() { public Cluster create() { if (addresses.isEmpty()) addContactPoint("localhost"); - if (null == serializer) serializer = SerializersV4.GRAPHBINARY_V4.simpleInstance(); + if (null == serializer) serializer = Serializers.GRAPHBINARY_V4.simpleInstance(); return new Cluster(this); } } @@ -839,11 +839,11 @@ class Manager { private boolean initialized; private final List contactPoints; private final Factory factory; - private final MessageSerializerV4 serializer; + private final MessageSerializer serializer; private final Settings.ConnectionPoolSettings connectionPoolSettings; private final LoadBalancingStrategy loadBalancingStrategy; private final Optional sslContextOptional; - private final Supplier validationRequest; + private final Supplier validationRequest; private final List interceptor; /** @@ -926,7 +926,7 @@ private Manager(final Builder builder) { this.connectionScheduler = new ScheduledThreadPoolExecutor(contactPoints.size() + 1, new BasicThreadFactory.Builder().namingPattern("gremlin-driver-conn-scheduler-%d").build()); - validationRequest = () -> RequestMessageV4.build(builder.validationRequest); + validationRequest = () -> RequestMessage.build(builder.validationRequest); } private void validateBuilder(final Builder builder) { diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java index 87ca7c7ce0a..3809af6f5d9 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java @@ -21,7 +21,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import io.netty.bootstrap.Bootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; @@ -180,7 +180,7 @@ public synchronized CompletableFuture closeAsync() { return future; } - public ChannelPromise write(final RequestMessageV4 requestMessage, final CompletableFuture resultQueueSetup) { + public ChannelPromise write(final RequestMessage requestMessage, final CompletableFuture resultQueueSetup) { // once there is a completed write, then create a traverser for the result set and complete // the promise so that the client knows that that it can start checking for results. final Connection thisConnection = this; diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java index e26af4f9c2c..6187c6e0964 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java @@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory; import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException; import org.apache.tinkerpop.gremlin.util.ExceptionHelper; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.apache.tinkerpop.gremlin.util.TimeUtil; import java.util.ArrayList; @@ -500,7 +500,7 @@ private boolean tryReconnect(final Host h) { // pool needs it. for now that seems like an unnecessary added bit of complexity for dealing with this // error state connection = connectionFactory.create(this); - final RequestMessageV4 ping = client.buildMessage(cluster.validationRequest()).create(); + final RequestMessage ping = client.buildMessage(cluster.validationRequest()).create(); final CompletableFuture f = new CompletableFuture<>(); connection.write(ping, f); f.get().all().get(); diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/LoadBalancingStrategy.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/LoadBalancingStrategy.java index 153ac65fd7e..4455a4ed6e2 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/LoadBalancingStrategy.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/LoadBalancingStrategy.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.driver; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.ArrayList; import java.util.Collection; @@ -41,13 +41,13 @@ public interface LoadBalancingStrategy extends Host.Listener { public void initialize(final Cluster cluster, final Collection hosts); /** - * Provide an ordered list of hosts to send the given {@link RequestMessageV4} to. + * Provide an ordered list of hosts to send the given {@link RequestMessage} to. */ - public Iterator select(final RequestMessageV4 msg); + public Iterator select(final RequestMessage msg); /** * A simple round-robin strategy that simply selects the next host in the {@link Cluster} to send the - * {@link RequestMessageV4} to. + * {@link RequestMessage} to. */ public static class RoundRobin implements LoadBalancingStrategy { @@ -61,7 +61,7 @@ public void initialize(final Cluster cluster, final Collection hosts) { } @Override - public Iterator select(final RequestMessageV4 msg) { + public Iterator select(final RequestMessage msg) { final List hosts = new ArrayList<>(); // a host could be marked as dead in which case we dont need to send messages to it - just skip it for diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java index 180614423e9..ef32af2d002 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java @@ -20,18 +20,18 @@ import org.apache.tinkerpop.gremlin.process.traversal.GremlinLang; import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Optional; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_BATCH_SIZE; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_EVAL_TIMEOUT; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_G; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_LANGUAGE; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_MATERIALIZE_PROPERTIES; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_BATCH_SIZE; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_EVAL_TIMEOUT; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_G; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_LANGUAGE; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_MATERIALIZE_PROPERTIES; /** * Options that can be supplied on a per request basis. @@ -145,7 +145,7 @@ public Builder addParameter(final String name, final Object value) { /** * The per client request override for the client and server configured {@code resultIterationBatchSize}. If * this value is not set, then the configuration for the {@link Cluster} is used unless the - * {@link RequestMessageV4} is configured completely by the user. + * {@link RequestMessage} is configured completely by the user. */ public Builder batchSize(final int batchSize) { this.batchSize = batchSize; diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java index 6b1545b05e1..0d55e52a199 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java @@ -24,7 +24,7 @@ import org.apache.tinkerpop.gremlin.structure.Property; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.apache.tinkerpop.gremlin.util.message.ResponseResultV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseResult; import java.util.Iterator; @@ -39,7 +39,7 @@ public final class Result { final Object resultObject; /** - * Constructs a "result" from data found in {@link ResponseResultV4#getData()}. + * Constructs a "result" from data found in {@link ResponseResult#getData()}. */ public Result(final Object responseData) { this.resultObject = responseData; diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java index 22de4fe7e8c..d74eb6ec76e 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.driver; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.ArrayList; import java.util.Iterator; @@ -50,13 +50,13 @@ public final class ResultSet implements Iterable { private final ResultQueue resultQueue; private final ExecutorService executor; - private final RequestMessageV4 originalRequestMessage; + private final RequestMessage originalRequestMessage; private final Host host; private final CompletableFuture readCompleted; public ResultSet(final ResultQueue resultQueue, final ExecutorService executor, - final CompletableFuture readCompleted, final RequestMessageV4 originalRequestMessage, + final CompletableFuture readCompleted, final RequestMessage originalRequestMessage, final Host host) { this.executor = executor; this.host = host; @@ -65,7 +65,7 @@ public ResultSet(final ResultQueue resultQueue, final ExecutorService executor, this.originalRequestMessage = originalRequestMessage; } - public RequestMessageV4 getOriginalRequestMessage() { + public RequestMessage getOriginalRequestMessage() { return originalRequestMessage; } diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java index 39eb0e96113..267cc7f9f68 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java @@ -19,7 +19,7 @@ package org.apache.tinkerpop.gremlin.driver; import org.apache.commons.configuration2.Configuration; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import org.yaml.snakeyaml.LoaderOptions; @@ -348,7 +348,7 @@ static class ConnectionPoolSettings { public static class SerializerSettings { /** - * The fully qualified class name of the {@link MessageSerializerV4} that will be used to communicate with the + * The fully qualified class name of the {@link MessageSerializer} that will be used to communicate with the * server. Note that the serializer configured on the client should be supported by the server configuration. * By default the setting is configured to {@link GraphBinaryMessageSerializerV4}. */ @@ -359,9 +359,9 @@ public static class SerializerSettings { */ public Map config = null; - public MessageSerializerV4 create() throws Exception { + public MessageSerializer create() throws Exception { final Class clazz = Class.forName(className); - final MessageSerializerV4 serializer = (MessageSerializerV4) clazz.newInstance(); + final MessageSerializer serializer = (MessageSerializer) clazz.newInstance(); Optional.ofNullable(config).ifPresent(c -> serializer.configure(c, null)); return serializer; } diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/GremlinResponseHandler.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/GremlinResponseHandler.java index 4c6735cb852..ed0df978c91 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/GremlinResponseHandler.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/GremlinResponseHandler.java @@ -27,7 +27,7 @@ import org.apache.tinkerpop.gremlin.driver.ResultQueue; import org.apache.tinkerpop.gremlin.driver.exception.ResponseException; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,9 +39,9 @@ /** * Takes a map of requests pending responses and writes responses to the {@link ResultQueue} of a request - * as the {@link ResponseMessageV4} objects are deserialized. + * as the {@link ResponseMessage} objects are deserialized. */ -public class GremlinResponseHandler extends SimpleChannelInboundHandler { +public class GremlinResponseHandler extends SimpleChannelInboundHandler { private static final Logger logger = LoggerFactory.getLogger(GremlinResponseHandler.class); private static final AttributeKey CAUGHT_EXCEPTION = AttributeKey.valueOf("caughtException"); private final AtomicReference pending; @@ -63,7 +63,7 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { } @Override - protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessageV4 response) { + protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessage response) { final HttpResponseStatus statusCode = response.getStatus() == null ? null : response.getStatus().getCode(); final ResultQueue queue = pending.get(); diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinRequestEncoder.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinRequestEncoder.java index cbffb47ea1a..95b95506151 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinRequestEncoder.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinRequestEncoder.java @@ -34,9 +34,8 @@ import org.apache.tinkerpop.gremlin.driver.auth.Auth.AuthenticationException; import org.apache.tinkerpop.gremlin.driver.exception.ResponseException; import org.apache.tinkerpop.gremlin.process.traversal.GremlinLang; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import java.net.InetSocketAddress; @@ -45,23 +44,23 @@ import static org.apache.tinkerpop.gremlin.driver.handler.SslCheckHandler.REQUEST_SENT; /** - * Converts {@link RequestMessageV4} to a {@code HttpRequest}. + * Converts {@link RequestMessage} to a {@code HttpRequest}. */ @ChannelHandler.Sharable -public final class HttpGremlinRequestEncoder extends MessageToMessageEncoder { +public final class HttpGremlinRequestEncoder extends MessageToMessageEncoder { - private final MessageSerializerV4 serializer; + private final MessageSerializer serializer; private final boolean userAgentEnabled; private final List interceptors; - public HttpGremlinRequestEncoder(final MessageSerializerV4 serializer, final List interceptors, boolean userAgentEnabled) { + public HttpGremlinRequestEncoder(final MessageSerializer serializer, final List interceptors, boolean userAgentEnabled) { this.serializer = serializer; this.interceptors = interceptors; this.userAgentEnabled = userAgentEnabled; } @Override - protected void encode(final ChannelHandlerContext channelHandlerContext, final RequestMessageV4 requestMessage, final List objects) throws Exception { + protected void encode(final ChannelHandlerContext channelHandlerContext, final RequestMessage requestMessage, final List objects) throws Exception { final String mimeType = serializer.mimeTypesSupported()[0]; if (requestMessage.getField("gremlin") instanceof GremlinLang) { throw new ResponseException(HttpResponseStatus.BAD_REQUEST, String.format( diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinResponseStreamDecoder.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinResponseStreamDecoder.java index 799dcc8f1a2..9e6b6e79acb 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinResponseStreamDecoder.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpGremlinResponseStreamDecoder.java @@ -25,7 +25,6 @@ import io.netty.handler.codec.http.DefaultHttpObject; import io.netty.handler.codec.http.HttpContent; import io.netty.handler.codec.http.HttpHeaderNames; -import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.LastHttpContent; @@ -33,16 +32,14 @@ import io.netty.util.AttributeKey; import io.netty.util.AttributeMap; import io.netty.util.CharsetUtil; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; +import org.apache.tinkerpop.gremlin.util.ser.SerTokens; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; import org.apache.tinkerpop.shaded.jackson.databind.JsonNode; import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; import java.util.List; -import java.util.Objects; import static org.apache.tinkerpop.gremlin.driver.Channelizer.HttpChannelizer.LAST_CONTENT_READ_RESPONSE; @@ -53,11 +50,11 @@ public class HttpGremlinResponseStreamDecoder extends MessageToMessageDecoder RESPONSE_ENCODING = AttributeKey.valueOf("responseSerializer"); private static final AttributeKey BYTES_READ = AttributeKey.valueOf("bytesRead"); - private final MessageSerializerV4 serializer; + private final MessageSerializer serializer; private final int maxContentLength; private final ObjectMapper mapper = new ObjectMapper(); - public HttpGremlinResponseStreamDecoder(final MessageSerializerV4 serializer, final int maxContentLength) { + public HttpGremlinResponseStreamDecoder(final MessageSerializer serializer, final int maxContentLength) { this.serializer = serializer; this.maxContentLength = maxContentLength; } @@ -88,16 +85,16 @@ protected void decode(ChannelHandlerContext ctx, DefaultHttpObject msg, List callback) throws Exception { + public void submit(final RequestMessage requestMessage, final Consumer callback) throws Exception { callbackResponseHandler.callback = callback; writeAndFlush(requestMessage); } @Override - public List submit(final RequestMessageV4 requestMessage) throws Exception { + public List submit(final RequestMessage requestMessage) throws Exception { // this is just a test client to force certain behaviors of the server. hanging tests are a pain to deal with // especially in travis as it's not always clear where the hang is. a few reasonable timeouts might help // make debugging easier when we look at logs return submitAsync(requestMessage).get(180, TimeUnit.SECONDS); } - static class CallbackResponseHandler extends SimpleChannelInboundHandler { - public Consumer callback; + static class CallbackResponseHandler extends SimpleChannelInboundHandler { + public Consumer callback; @Override - protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessageV4 response) throws Exception { + protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessage response) throws Exception { callback.accept(response); } } diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleClient.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleClient.java index 3f767997aee..779a0fd5281 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleClient.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleClient.java @@ -18,8 +18,8 @@ */ package org.apache.tinkerpop.gremlin.driver.simple; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import java.io.Closeable; import java.util.List; @@ -31,21 +31,21 @@ */ public interface SimpleClient extends Closeable { - public default void submit(final String gremlin, final Consumer callback) throws Exception { - submit(RequestMessageV4.build(gremlin).create(), callback); + public default void submit(final String gremlin, final Consumer callback) throws Exception { + submit(RequestMessage.build(gremlin).create(), callback); } - public void submit(final RequestMessageV4 requestMessage, final Consumer callback) throws Exception; + public void submit(final RequestMessage requestMessage, final Consumer callback) throws Exception; - public default List submit(final String gremlin) throws Exception { - return submit(RequestMessageV4.build(gremlin).create()); + public default List submit(final String gremlin) throws Exception { + return submit(RequestMessage.build(gremlin).create()); } - public List submit(final RequestMessageV4 requestMessage) throws Exception; + public List submit(final RequestMessage requestMessage) throws Exception; - public default CompletableFuture> submitAsync(final String gremlin) throws Exception { - return submitAsync(RequestMessageV4.build(gremlin).create()); + public default CompletableFuture> submitAsync(final String gremlin) throws Exception { + return submitAsync(RequestMessage.build(gremlin).create()); } - public CompletableFuture> submitAsync(final RequestMessageV4 requestMessage) throws Exception; + public CompletableFuture> submitAsync(final RequestMessage requestMessage) throws Exception; } diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleHttpClient.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleHttpClient.java index 5042d48e3ca..fc1d622eb39 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleHttpClient.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/simple/SimpleHttpClient.java @@ -20,17 +20,15 @@ import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.ChannelOption; -import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.util.InsecureTrustManagerFactory; import org.apache.tinkerpop.gremlin.driver.Channelizer; -import org.apache.tinkerpop.gremlin.driver.RequestInterceptor; import org.apache.tinkerpop.gremlin.driver.handler.HttpContentDecompressionHandler; import org.apache.tinkerpop.gremlin.driver.handler.HttpGremlinResponseStreamDecoder; import org.apache.tinkerpop.gremlin.driver.handler.HttpGremlinRequestEncoder; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import io.netty.bootstrap.Bootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; @@ -38,7 +36,7 @@ import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.codec.http.HttpClientCodec; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryMapper; import org.slf4j.Logger; @@ -94,7 +92,7 @@ public SimpleHttpClient(final URI uri) { sslCtx = null; } - final MessageSerializerV4 serializer = new GraphBinaryMessageSerializerV4(); + final MessageSerializer serializer = new GraphBinaryMessageSerializerV4(); b.channel(NioSocketChannel.class) .handler(new ChannelInitializer() { @Override @@ -119,9 +117,9 @@ protected void initChannel(final SocketChannel ch) { } @Override - public CompletableFuture> submitAsync(final RequestMessageV4 requestMessage) throws Exception { - final List results = new ArrayList<>(); - final CompletableFuture> f = new CompletableFuture<>(); + public CompletableFuture> submitAsync(final RequestMessage requestMessage) throws Exception { + final List results = new ArrayList<>(); + final CompletableFuture> f = new CompletableFuture<>(); callbackResponseHandler.callback = response -> { // message with trailers if (f.isDone()) @@ -141,7 +139,7 @@ public CompletableFuture> submitAsync(final RequestMessa } @Override - public void writeAndFlush(final RequestMessageV4 requestMessage) throws Exception { + public void writeAndFlush(final RequestMessage requestMessage) throws Exception { channel.writeAndFlush(requestMessage); } diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java index 57851811852..1d718f430a2 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java @@ -20,11 +20,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import org.apache.tinkerpop.gremlin.driver.Channelizer; import org.apache.tinkerpop.gremlin.driver.Client; import org.apache.tinkerpop.gremlin.driver.Cluster; import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import java.io.BufferedWriter; import java.io.File; @@ -190,7 +189,7 @@ public static void main(final String[] args) { final int maxWaitForConnection = Integer.parseInt(options.getOrDefault("maxWaitForConnection", "3000").toString()); final int workerPoolSize = Integer.parseInt(options.getOrDefault("workerPoolSize", Runtime.getRuntime().availableProcessors() * 2).toString()); final int tooSlowThreshold = Integer.parseInt(options.getOrDefault("tooSlowThreshold", "125").toString()); - final String serializer = options.getOrDefault("serializer", SerializersV4.GRAPHBINARY_V4.name()).toString(); + final String serializer = options.getOrDefault("serializer", Serializers.GRAPHBINARY_V4.name()).toString(); final boolean exercise = Boolean.parseBoolean(options.getOrDefault("exercise", "false").toString()); final String script = options.getOrDefault("script", "1+1").toString(); @@ -200,7 +199,7 @@ public static void main(final String[] args) { .maxConnectionPoolSize(maxConnectionPoolSize) .nioPoolSize(nioPoolSize) .maxWaitForConnection(maxWaitForConnection) - .serializer(SerializersV4.valueOf(serializer)) + .serializer(Serializers.valueOf(serializer)) .workerPoolSize(workerPoolSize).create(); try { diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java index 343b7c5f0a3..f32ee281285 100644 --- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java +++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.driver; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.junit.Before; import org.junit.Test; @@ -45,7 +45,7 @@ public class ResultSetTest extends AbstractResultQueueTest { @Before public void setupThis() { - resultSet = new ResultSet(resultQueue, pool, readCompleted, RequestMessageV4.build("traversal").create(), null); + resultSet = new ResultSet(resultQueue, pool, readCompleted, RequestMessage.build("traversal").create(), null); } @Test diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/TokensTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/TokensTest.java index cc7e80bd9ac..cbbb2d6cbe0 100644 --- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/TokensTest.java +++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/TokensTest.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.driver; -import org.apache.tinkerpop.gremlin.util.TokensV4; +import org.apache.tinkerpop.gremlin.util.Tokens; import org.junit.Test; import java.lang.reflect.Constructor; @@ -32,8 +32,8 @@ public class TokensTest { @Test public void shouldBeUtilityClass() throws Exception { - final Constructor constructor = TokensV4.class.getDeclaredConstructor(); - assertTrue(Modifier.isFinal(TokensV4.class.getModifiers())); + final Constructor constructor = Tokens.class.getDeclaredConstructor(); + assertTrue(Modifier.isFinal(Tokens.class.getModifiers())); assertTrue(Modifier.isPrivate(constructor.getModifiers())); constructor.setAccessible(true); constructor.newInstance(); diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnectionTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnectionTest.java index 1f77bf6ebb0..5d9c7a6933e 100644 --- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnectionTest.java +++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnectionTest.java @@ -19,7 +19,7 @@ package org.apache.tinkerpop.gremlin.driver.remote; import org.apache.tinkerpop.gremlin.driver.RequestOptions; -import org.apache.tinkerpop.gremlin.util.TokensV4; +import org.apache.tinkerpop.gremlin.util.Tokens; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; import org.junit.Test; @@ -38,9 +38,9 @@ public void shouldBuildRequestOptions() { final RequestOptions options = getRequestOptions( g.with("x"). with("y", 100). - with(TokensV4.ARGS_BATCH_SIZE, 1000). - with(TokensV4.ARGS_EVAL_TIMEOUT, 100000L). - with(TokensV4.ARGS_USER_AGENT, "test"). + with(Tokens.ARGS_BATCH_SIZE, 1000). + with(Tokens.ARGS_EVAL_TIMEOUT, 100000L). + with(Tokens.ARGS_USER_AGENT, "test"). V().asAdmin().getGremlinLang()); assertEquals(1000, options.getBatchSize().get().intValue()); assertEquals(100000L, options.getTimeout().get().longValue()); @@ -49,8 +49,8 @@ public void shouldBuildRequestOptions() { @Test public void shouldBuildRequestOptionsWithNumerics() { final RequestOptions options = getRequestOptions( - g.with(TokensV4.ARGS_BATCH_SIZE, 100). - with(TokensV4.ARGS_EVAL_TIMEOUT, 1000). + g.with(Tokens.ARGS_BATCH_SIZE, 100). + with(Tokens.ARGS_EVAL_TIMEOUT, 1000). V().asAdmin().getGremlinLang()); assertEquals(Integer.valueOf(100), options.getBatchSize().get()); assertEquals(Long.valueOf(1000), options.getTimeout().get()); diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java index 368800d6c43..8a9fd95e2c2 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java @@ -32,9 +32,9 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.socket.SocketChannel; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; import org.javatuples.Pair; @@ -70,7 +70,7 @@ * Gremlin scripts). *

* Implementers need only worry about determining how incoming data is converted to a - * {@link RequestMessageV4} and outgoing data is converted from a {@link ResponseMessageV4} to whatever expected format is + * {@link RequestMessage} and outgoing data is converted from a {@link ResponseMessage} to whatever expected format is * needed by the pipeline. * * @author Stephen Mallette (http://stephen.genoprime.com) @@ -101,7 +101,7 @@ public abstract class AbstractChannelizer extends ChannelInitializer> serializers = new HashMap<>(); + protected final Map> serializers = new HashMap<>(); protected Authenticator authenticator; protected Authorizer authorizer; @@ -204,15 +204,15 @@ private void configureSerializers() { serializerSettings.stream().map(config -> { try { final Class clazz = Class.forName(config.className); - if (!MessageSerializerV4.class.isAssignableFrom(clazz)) { - logger.warn("The {} serialization class does not implement {} - it will not be available.", config.className, MessageSerializerV4.class.getCanonicalName()); - return Optional.empty(); + if (!MessageSerializer.class.isAssignableFrom(clazz)) { + logger.warn("The {} serialization class does not implement {} - it will not be available.", config.className, MessageSerializer.class.getCanonicalName()); + return Optional.empty(); } if (clazz.getAnnotation(Deprecated.class) != null) logger.warn("The {} serialization class is deprecated.", config.className); - final MessageSerializerV4 serializer = (MessageSerializerV4) clazz.newInstance(); + final MessageSerializer serializer = (MessageSerializer) clazz.newInstance(); final Map graphsDefinedAtStartup = new HashMap<>(); for (String graphName : settings.graphs.keySet()) { graphsDefinedAtStartup.put(graphName, graphManager.getGraph(graphName)); @@ -224,16 +224,16 @@ private void configureSerializers() { return Optional.ofNullable(serializer); } catch (ClassNotFoundException cnfe) { logger.warn("Could not find configured serializer class - {} - it will not be available", config.className); - return Optional.empty(); + return Optional.empty(); } catch (Exception ex) { logger.warn("Could not instantiate configured serializer class - {} - it will not be available. {}", config.className, ex.getMessage()); - return Optional.empty(); + return Optional.empty(); } }).filter(Optional::isPresent).map(Optional::get).flatMap(serializer -> Stream.of(serializer.mimeTypesSupported()).map(mimeType -> Pair.with(mimeType, serializer)) ).forEach(pair -> { final String mimeType = pair.getValue0(); - final MessageSerializerV4 serializer = pair.getValue1(); + final MessageSerializer serializer = pair.getValue1(); if (serializers.containsKey(mimeType)) logger.info("{} already has {} configured - it will not be replaced by {}, change order of serialization configuration if this is not desired.", mimeType, serializers.get(mimeType).getClass().getName(), serializer.getClass().getName()); diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java index d2589e2df71..ef31042161d 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java @@ -26,8 +26,8 @@ import org.apache.tinkerpop.gremlin.structure.Element; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.List; import java.util.Optional; @@ -41,7 +41,7 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public class Context { - private final RequestMessageV4 requestMessage; + private final RequestMessage requestMessage; private final ChannelHandlerContext channelHandlerContext; private final Settings settings; private final GraphManager graphManager; @@ -56,14 +56,14 @@ public class Context { private boolean timeoutExecutorGrabbed = false; private final Object timeoutExecutorLock = new Object(); - public Context(final RequestMessageV4 requestMessage, final ChannelHandlerContext ctx, + public Context(final RequestMessage requestMessage, final ChannelHandlerContext ctx, final Settings settings, final GraphManager graphManager, final GremlinExecutor gremlinExecutor, final ScheduledExecutorService scheduledExecutorService) { this(requestMessage, ctx, settings, graphManager, gremlinExecutor, scheduledExecutorService, HttpGremlinEndpointHandler.RequestState.NOT_STARTED); } - public Context(final RequestMessageV4 requestMessage, final ChannelHandlerContext ctx, + public Context(final RequestMessage requestMessage, final ChannelHandlerContext ctx, final Settings settings, final GraphManager graphManager, final GremlinExecutor gremlinExecutor, final ScheduledExecutorService scheduledExecutorService, final HttpGremlinEndpointHandler.RequestState requestState) { @@ -103,7 +103,7 @@ public ScheduledFuture getTimeoutExecutor() { /** * The timeout for the request. If the request is a script it examines the script for a timeout setting using * {@code with()}. If that is not found then it examines the request itself to see if the timeout is provided by - * {@link TokensV4#TIMEOUT_MS}. If that is not provided then the {@link Settings#evaluationTimeout} is + * {@link Tokens#TIMEOUT_MS}. If that is not provided then the {@link Settings#evaluationTimeout} is * utilized as the default. */ public long getRequestTimeout() { @@ -121,7 +121,7 @@ public ScheduledExecutorService getScheduledExecutorService() { /** * Gets the current request to Gremlin Server. */ - public RequestMessageV4 getRequestMessage() { + public RequestMessage getRequestMessage() { return requestMessage; } @@ -167,7 +167,7 @@ public GremlinExecutor getGremlinExecutor() { private long determineTimeout() { // timeout override - handle both deprecated and newly named configuration. earlier logic should prevent // both configurations from being submitted at the same time - final Long timeoutMs = requestMessage.getField(TokensV4.TIMEOUT_MS); + final Long timeoutMs = requestMessage.getField(Tokens.TIMEOUT_MS); final long seto = (null != timeoutMs) ? timeoutMs : settings.getEvaluationTimeout(); // override the timeout if the lifecycle has a value assigned. if the script contains with(timeout) @@ -180,19 +180,19 @@ private long determineTimeout() { private String determineMaterializeProperties() { final Optional mp = GremlinScriptChecker.parse(gremlinArgument.toString()).getMaterializeProperties(); if (mp.isPresent()) - return mp.get().equals(TokensV4.MATERIALIZE_PROPERTIES_TOKENS) - ? TokensV4.MATERIALIZE_PROPERTIES_TOKENS - : TokensV4.MATERIALIZE_PROPERTIES_ALL; + return mp.get().equals(Tokens.MATERIALIZE_PROPERTIES_TOKENS) + ? Tokens.MATERIALIZE_PROPERTIES_TOKENS + : Tokens.MATERIALIZE_PROPERTIES_ALL; - final String materializeProperties = requestMessage.getField(TokensV4.ARGS_MATERIALIZE_PROPERTIES); + final String materializeProperties = requestMessage.getField(Tokens.ARGS_MATERIALIZE_PROPERTIES); // all options except MATERIALIZE_PROPERTIES_TOKENS treated as MATERIALIZE_PROPERTIES_ALL - return TokensV4.MATERIALIZE_PROPERTIES_TOKENS.equals(materializeProperties) - ? TokensV4.MATERIALIZE_PROPERTIES_TOKENS - : TokensV4.MATERIALIZE_PROPERTIES_ALL; + return Tokens.MATERIALIZE_PROPERTIES_TOKENS.equals(materializeProperties) + ? Tokens.MATERIALIZE_PROPERTIES_TOKENS + : Tokens.MATERIALIZE_PROPERTIES_ALL; } public void handleDetachment(final List aggregate) { - if (!aggregate.isEmpty() && !this.getMaterializeProperties().equals(TokensV4.MATERIALIZE_PROPERTIES_ALL)) { + if (!aggregate.isEmpty() && !this.getMaterializeProperties().equals(Tokens.MATERIALIZE_PROPERTIES_ALL)) { final Object firstElement = aggregate.get(0); if (firstElement instanceof Element) { diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java index 7a219b08b70..e8acaf2612c 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java @@ -20,7 +20,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; import javax.script.Bindings; import java.util.Map; diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java index 0692cdef232..b939bce20bf 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java @@ -32,7 +32,7 @@ import org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager; import org.apache.tinkerpop.gremlin.server.util.LifeCycleHook; import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.LoaderOptions; @@ -228,7 +228,7 @@ public Settings() { public Map scriptEngines; /** - * List of {@link MessageSerializerV4} to configure. If no serializers are specified then default serializers for + * List of {@link MessageSerializer} to configure. If no serializers are specified then default serializers for * the most current versions of "application/json" and "application/vnd.gremlin-v1.0+gryo" are applied. */ public List serializers = Collections.emptyList(); @@ -378,7 +378,7 @@ public static class ScriptEngineSettings { } /** - * Settings for the {@link MessageSerializerV4} implementations. + * Settings for the {@link MessageSerializer} implementations. */ public static class SerializerSettings { @@ -390,14 +390,14 @@ public SerializerSettings() {} } /** - * The fully qualified class name of the {@link MessageSerializerV4} implementation. This class name will be + * The fully qualified class name of the {@link MessageSerializer} implementation. This class name will be * used to load the implementation from the classpath. */ public String className; /** - * A {@link Map} containing {@link MessageSerializerV4} specific configurations. Consult the - * {@link MessageSerializerV4} implementation for specifics on what configurations are expected. + * A {@link Map} containing {@link MessageSerializer} specific configurations. Consult the + * {@link MessageSerializer} implementation for specifics on what configurations are expected. */ public Map config = Collections.emptyMap(); } diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/Authenticator.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/Authenticator.java index 09d0e59493d..d0ea194b46e 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/Authenticator.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/Authenticator.java @@ -20,8 +20,8 @@ import io.netty.handler.codec.http.HttpResponseStatus; import org.apache.tinkerpop.gremlin.server.Channelizer; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import java.net.InetAddress; import java.util.Map; @@ -74,12 +74,12 @@ public interface SaslNegotiator * Evaluates the client response data and generates a byte[] reply which may be a further challenge or purely * informational in the case that the negotiation is completed on this round. * - * This method is called each time a {@link RequestMessageV4} with an "op" code of "authenticate" is received + * This method is called each time a {@link RequestMessage} with an "op" code of "authenticate" is received * from a client. After it is called, {@link #isComplete()} is checked to determine whether the negotiation has * finished. If so, an {@link AuthenticatedUser} is obtained by calling {@link #getAuthenticatedUser()} and * that user associated with the active connection. If the negotiation is not yet complete, * the byte[] is returned to the client as a further challenge in an - * {@link ResponseMessageV4} with {@link HttpResponseStatus#PROXY_AUTHENTICATION_REQUIRED}. This continues until + * {@link ResponseMessage} with {@link HttpResponseStatus#PROXY_AUTHENTICATION_REQUIRED}. This continues until * the negotiation does complete or an error is encountered. */ public byte[] evaluateResponse(final byte[] clientResponse) throws AuthenticationException; diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/authz/Authorizer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/authz/Authorizer.java index 90de0c3e10e..32fdde7b9a5 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/authz/Authorizer.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/authz/Authorizer.java @@ -19,8 +19,8 @@ package org.apache.tinkerpop.gremlin.server.authz; import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.Map; @@ -46,8 +46,8 @@ public default String authorize(final AuthenticatedUser user, final String greml * {@link AuthorizationException} if this is not the case. * * @param user {@link AuthenticatedUser} that needs authorization. - * @param msg {@link RequestMessageV4} in which the {@link TokensV4}.ARGS_GREMLIN argument can contain an arbitrary succession of script statements. + * @param msg {@link RequestMessage} in which the {@link Tokens}.ARGS_GREMLIN argument can contain an arbitrary succession of script statements. */ - public void authorize(final AuthenticatedUser user, final RequestMessageV4 msg) throws AuthorizationException; + public void authorize(final AuthenticatedUser user, final RequestMessage msg) throws AuthorizationException; } diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthorizationHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthorizationHandler.java index 48fac5e2bd0..0df8003992f 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthorizationHandler.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthorizationHandler.java @@ -26,8 +26,8 @@ import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser; import org.apache.tinkerpop.gremlin.server.authz.AuthorizationException; import org.apache.tinkerpop.gremlin.server.authz.Authorizer; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,8 +57,8 @@ public HttpBasicAuthorizationHandler(Authorizer authorizer) { @Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) { - if (msg instanceof RequestMessageV4) { - final RequestMessageV4 requestMessage = (RequestMessageV4) msg; + if (msg instanceof RequestMessage) { + final RequestMessage requestMessage = (RequestMessage) msg; try { user = ctx.channel().attr(StateKey.AUTHENTICATED_USER).get(); @@ -68,9 +68,9 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) { final String gremlin = requestMessage.getGremlin(); final Map aliases = new HashMap<>(); - aliases.put(TokensV4.ARGS_G, requestMessage.getField(TokensV4.ARGS_G)); + aliases.put(Tokens.ARGS_G, requestMessage.getField(Tokens.ARGS_G)); final String restrictedGremlin = authorizer.authorize(user, gremlin, aliases); - final RequestMessageV4 restrictedMsg = RequestMessageV4.from(requestMessage, restrictedGremlin).create(); + final RequestMessage restrictedMsg = RequestMessage.from(requestMessage, restrictedGremlin).create(); ctx.fireChannelRead(restrictedMsg); } catch (AuthorizationException ex) { // Expected: users can alternate between allowed and disallowed requests diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java index e3b34379a24..622c979fe79 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java @@ -27,7 +27,6 @@ import io.netty.handler.codec.http.DefaultHttpContent; import io.netty.handler.codec.http.DefaultHttpResponse; import io.netty.handler.codec.http.HttpHeaderNames; -import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -56,11 +55,11 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.util.TemporaryException; import org.apache.tinkerpop.gremlin.util.ExceptionHelper; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.TokensV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.Tokens; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.codehaus.groovy.control.MultipleCompilationErrorsException; import org.javatuples.Pair; import org.slf4j.Logger; @@ -105,13 +104,13 @@ import static org.apache.tinkerpop.gremlin.server.handler.HttpHandlerUtil.writeError; /** - * Handler that processes RequestMessageV4. This handler will attempt to execute the query and stream the results back + * Handler that processes RequestMessage. This handler will attempt to execute the query and stream the results back * in HTTP chunks to the client. * * @author Stephen Mallette (http://stephen.genoprime.com) */ @ChannelHandler.Sharable -public class HttpGremlinEndpointHandler extends SimpleChannelInboundHandler { +public class HttpGremlinEndpointHandler extends SimpleChannelInboundHandler { private static final Logger logger = LoggerFactory.getLogger(HttpGremlinEndpointHandler.class); private static final Logger auditLogger = LoggerFactory.getLogger(GremlinServer.AUDIT_LOGGER_NAME); @@ -162,9 +161,9 @@ public HttpGremlinEndpointHandler(final GremlinExecutor gremlinExecutor, } @Override - public void channelRead0(final ChannelHandlerContext ctx, final RequestMessageV4 requestMessage) { + public void channelRead0(final ChannelHandlerContext ctx, final RequestMessage requestMessage) { ctx.channel().attr(StateKey.HTTP_RESPONSE_SENT).set(false); - final Pair> serializer = ctx.channel().attr(StateKey.SERIALIZER).get(); + final Pair> serializer = ctx.channel().attr(StateKey.SERIALIZER).get(); final Context requestCtx = new Context(requestMessage, ctx, settings, graphManager, gremlinExecutor, gremlinExecutor.getScheduledExecutorService(), NOT_STARTED); @@ -172,7 +171,7 @@ public void channelRead0(final ChannelHandlerContext ctx, final RequestMessageV4 final Timer.Context timerContext = evalOpTimer.time(); // timeout override - handle both deprecated and newly named configuration. earlier logic should prevent // both configurations from being submitted at the same time - final Long timeoutMs = requestMessage.getField(TokensV4.TIMEOUT_MS); + final Long timeoutMs = requestMessage.getField(Tokens.TIMEOUT_MS); final long seto = (null != timeoutMs) ? timeoutMs : requestCtx.getSettings().getEvaluationTimeout(); final FutureTask evalFuture = new FutureTask<>(() -> { @@ -180,8 +179,8 @@ public void channelRead0(final ChannelHandlerContext ctx, final RequestMessageV4 try { logger.debug("Processing request containing script [{}] and bindings of [{}] on {}", - requestMessage.getFieldOrDefault(TokensV4.ARGS_GREMLIN, ""), - requestMessage.getFieldOrDefault(TokensV4.ARGS_BINDINGS, Collections.emptyMap()), + requestMessage.getFieldOrDefault(Tokens.ARGS_GREMLIN, ""), + requestMessage.getFieldOrDefault(Tokens.ARGS_BINDINGS, Collections.emptyMap()), Thread.currentThread().getName()); if (settings.enableAuditLog) { AuthenticatedUser user = ctx.channel().attr(StateKey.AUTHENTICATED_USER).get(); @@ -239,7 +238,7 @@ public void channelRead0(final ChannelHandlerContext ctx, final RequestMessageV4 } } - private GremlinError formErrorResponseMessage(Throwable t, RequestMessageV4 requestMessage) { + private GremlinError formErrorResponseMessage(Throwable t, RequestMessage requestMessage) { if (t instanceof UndeclaredThrowableException) t = t.getCause(); // if any exception in the chain is TemporaryException or Failure then we should respond with the @@ -286,10 +285,10 @@ private GremlinError formErrorResponseMessage(Throwable t, RequestMessageV4 requ return GremlinError.general(t); } - private void iterateScriptEvalResult(final Context context, MessageSerializerV4 serializer, final RequestMessageV4 message) + private void iterateScriptEvalResult(final Context context, MessageSerializer serializer, final RequestMessage message) throws ProcessingException, InterruptedException, ScriptException { - if (message.optionalField(TokensV4.ARGS_BINDINGS).isPresent()) { - final Map bindings = (Map) message.getFields().get(TokensV4.ARGS_BINDINGS); + if (message.optionalField(Tokens.ARGS_BINDINGS).isPresent()) { + final Map bindings = (Map) message.getFields().get(Tokens.ARGS_BINDINGS); if (IteratorUtils.anyMatch(bindings.keySet().iterator(), k -> null == k || !(k instanceof String))) { throw new ProcessingException(GremlinError.binding()); } @@ -306,7 +305,7 @@ private void iterateScriptEvalResult(final Context context, MessageSerializerV4< } final Map args = message.getFields(); - final String language = args.containsKey(TokensV4.ARGS_LANGUAGE) ? (String) args.get(TokensV4.ARGS_LANGUAGE) : "gremlin-groovy"; + final String language = args.containsKey(Tokens.ARGS_LANGUAGE) ? (String) args.get(Tokens.ARGS_LANGUAGE) : "gremlin-groovy"; final GremlinScriptEngine scriptEngine = gremlinExecutor.getScriptEngineManager().getEngineByName(language); final Bindings mergedBindings = mergeBindingsFromRequest(context, new SimpleBindings(graphManager.getAsBindings())); @@ -326,19 +325,19 @@ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cau private Bindings mergeBindingsFromRequest(final Context ctx, final Bindings bindings) throws ProcessingException { // alias any global bindings to a different variable. - final RequestMessageV4 msg = ctx.getRequestMessage(); + final RequestMessage msg = ctx.getRequestMessage(); // add any bindings to override any other supplied - Optional.ofNullable((Map) msg.getFields().get(TokensV4.ARGS_BINDINGS)).ifPresent(bindings::putAll); + Optional.ofNullable((Map) msg.getFields().get(Tokens.ARGS_BINDINGS)).ifPresent(bindings::putAll); - if (msg.getFields().containsKey(TokensV4.ARGS_G)) { - final String aliased = msg.getField(TokensV4.ARGS_G); + if (msg.getFields().containsKey(Tokens.ARGS_G)) { + final String aliased = msg.getField(Tokens.ARGS_G); boolean found = false; // first check if the alias refers to a Graph instance final Graph graph = ctx.getGraphManager().getGraph(aliased); if (null != graph) { - bindings.put(TokensV4.ARGS_G, graph); + bindings.put(Tokens.ARGS_G, graph); found = true; } @@ -347,7 +346,7 @@ private Bindings mergeBindingsFromRequest(final Context ctx, final Bindings bind if (!found) { final TraversalSource ts = ctx.getGraphManager().getTraversalSource(aliased); if (null != ts) { - bindings.put(TokensV4.ARGS_G, ts); + bindings.put(Tokens.ARGS_G, ts); found = true; } } @@ -362,7 +361,7 @@ private Bindings mergeBindingsFromRequest(final Context ctx, final Bindings bind return bindings; } - private void iterateTraversal(final Context context, MessageSerializerV4 serializer, Traversal.Admin traversal) + private void iterateTraversal(final Context context, MessageSerializer serializer, Traversal.Admin traversal) throws InterruptedException { final UUID requestId = context.getChannelHandlerContext().attr(StateKey.REQUEST_ID).get(); logger.debug("Traversal request {} for in thread {}", requestId, Thread.currentThread().getName()); @@ -372,9 +371,9 @@ private void iterateTraversal(final Context context, MessageSerializerV4 seri handleIterator(context, new TraverserIterator(traversal), serializer); } - private void handleIterator(final Context context, final Iterator itty, final MessageSerializerV4 serializer) throws InterruptedException { + private void handleIterator(final Context context, final Iterator itty, final MessageSerializer serializer) throws InterruptedException { final ChannelHandlerContext nettyContext = context.getChannelHandlerContext(); - final RequestMessageV4 msg = context.getRequestMessage(); + final RequestMessage msg = context.getRequestMessage(); final Settings settings = context.getSettings(); boolean warnOnce = false; @@ -394,7 +393,7 @@ private void handleIterator(final Context context, final Iterator itty, final Me } // the batch size can be overridden by the request - final int resultIterationBatchSize = (Integer) msg.optionalField(TokensV4.ARGS_BATCH_SIZE) + final int resultIterationBatchSize = (Integer) msg.optionalField(Tokens.ARGS_BATCH_SIZE) .orElse(settings.resultIterationBatchSize); List aggregate = new ArrayList<>(resultIterationBatchSize); @@ -506,8 +505,8 @@ private boolean acceptsDeflateEncoding(List encodings) { return false; } - private static ByteBuf makeChunk(final Context ctx, final RequestMessageV4 msg, - final MessageSerializerV4 serializer, final List aggregate, + private static ByteBuf makeChunk(final Context ctx, final RequestMessage msg, + final MessageSerializer serializer, final List aggregate, final boolean hasMore) throws Exception { try { final ChannelHandlerContext nettyContext = ctx.getChannelHandlerContext(); @@ -518,11 +517,11 @@ private static ByteBuf makeChunk(final Context ctx, final RequestMessageV4 msg, ctx.setRequestState(FINISHING); } - ResponseMessageV4 responseMessage = null; + ResponseMessage responseMessage = null; // for this state no need to build full ResponseMessage if (ctx.getRequestState() != STREAMING) { - final ResponseMessageV4.Builder builder = ResponseMessageV4.build().result(aggregate); + final ResponseMessage.Builder builder = ResponseMessage.build().result(aggregate); // need to put status in last message if (ctx.getRequestState() == FINISHING) { @@ -540,7 +539,7 @@ private static ByteBuf makeChunk(final Context ctx, final RequestMessageV4 msg, } ctx.setRequestState(FINISHED); - return serializer.serializeResponseAsBinary(ResponseMessageV4.build() + return serializer.serializeResponseAsBinary(ResponseMessage.build() .result(aggregate) .code(HttpResponseStatus.OK) .create(), nettyContext.alloc()); diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpHandlerUtil.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpHandlerUtil.java index 8d729def988..a7360d625fa 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpHandlerUtil.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpHandlerUtil.java @@ -36,9 +36,9 @@ import org.apache.tinkerpop.gremlin.server.GremlinServer; import org.apache.tinkerpop.gremlin.server.util.GremlinError; import org.apache.tinkerpop.gremlin.server.util.MetricManager; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; +import org.apache.tinkerpop.gremlin.util.ser.SerTokens; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; import org.apache.tinkerpop.shaded.jackson.databind.node.ObjectNode; @@ -49,7 +49,6 @@ import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE; import static io.netty.handler.codec.http.HttpHeaderNames.TRANSFER_ENCODING; import static io.netty.handler.codec.http.HttpHeaderValues.CHUNKED; -import static io.netty.handler.codec.http.HttpResponseStatus.OK; import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; /** @@ -90,14 +89,14 @@ public static void sendError(final ChannelHandlerContext ctx, final HttpResponse } /** - * Writes and flushes a {@link ResponseMessageV4} that contains an error back to the client. Can be used to send + * Writes and flushes a {@link ResponseMessage} that contains an error back to the client. Can be used to send * errors while streaming or when no response chunk has been sent. This serves as the end of a response. * * @param context The netty context. * @param responseMessage The response to send back. * @param serializer The serializer to use to serialize the error response. */ - static void writeError(final Context context, final ResponseMessageV4 responseMessage, final MessageSerializerV4 serializer) { + static void writeError(final Context context, final ResponseMessage responseMessage, final MessageSerializer serializer) { try { final ChannelHandlerContext ctx = context.getChannelHandlerContext(); final ByteBuf ByteBuf = context.getRequestState() == HttpGremlinEndpointHandler.RequestState.STREAMING @@ -123,15 +122,15 @@ static void writeError(final Context context, final ResponseMessageV4 responseMe } /** - * Writes a {@link GremlinError} into the status object of a {@link ResponseMessageV4} and then flushes it. Used to + * Writes a {@link GremlinError} into the status object of a {@link ResponseMessage} and then flushes it. Used to * send specific errors back to the client. This serves as the end of a response. * * @param context The netty context. * @param error The GremlinError used to populate the status. * @param serializer The serializer to use to serialize the error response. */ - static void writeError(final Context context, final GremlinError error, final MessageSerializerV4 serializer) { - final ResponseMessageV4 responseMessage = ResponseMessageV4.build() + static void writeError(final Context context, final GremlinError error, final MessageSerializer serializer) { + final ResponseMessage responseMessage = ResponseMessage.build() .code(error.getCode()) .statusMessage(error.getMessage()) .exception(error.getException()) @@ -150,9 +149,9 @@ static void writeError(final Context context, final GremlinError error, final Me */ static void sendTrailingHeaders(final ChannelHandlerContext ctx, final HttpResponseStatus statusCode, final String exceptionType) { final DefaultLastHttpContent defaultLastHttpContent = new DefaultLastHttpContent(); - defaultLastHttpContent.trailingHeaders().add(SerTokensV4.TOKEN_CODE, statusCode.code()); + defaultLastHttpContent.trailingHeaders().add(SerTokens.TOKEN_CODE, statusCode.code()); if (exceptionType != null && !exceptionType.isEmpty()) { - defaultLastHttpContent.trailingHeaders().add(SerTokensV4.TOKEN_EXCEPTION, exceptionType); + defaultLastHttpContent.trailingHeaders().add(SerTokens.TOKEN_EXCEPTION, exceptionType); } ctx.writeAndFlush(defaultLastHttpContent); diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoder.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoder.java index 3980517cb96..919d8272481 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoder.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoder.java @@ -22,10 +22,10 @@ import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.util.CharsetUtil; -import org.apache.tinkerpop.gremlin.server.util.TextPlainMessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.server.util.TextPlainMessageSerializer; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -54,8 +54,8 @@ import static org.apache.tinkerpop.gremlin.server.handler.HttpHandlerUtil.sendError; /** - * Decodes the contents of a {@code FullHttpRequest}. This will extract the {@code RequestMessageV4} from the - * {@code FullHttpRequest} or, if unsuccessful, will flush an error back. + * Decodes the contents of a {@link FullHttpRequest}. This will extract the {@link RequestMessage} from the + * {@link FullHttpRequest} or, if unsuccessful, will flush an error back. */ @ChannelHandler.Sharable public class HttpRequestMessageDecoder extends MessageToMessageDecoder { @@ -64,9 +64,9 @@ public class HttpRequestMessageDecoder extends MessageToMessageDecoder> serializers; + private final Map> serializers; /** * A generic mapper to decode an application/json request. @@ -74,7 +74,7 @@ public class HttpRequestMessageDecoder extends MessageToMessageDecoder> serializers) { + public HttpRequestMessageDecoder(final Map> serializers) { this.serializers = serializers; } @@ -83,7 +83,7 @@ protected void decode(final ChannelHandlerContext ctx, final FullHttpRequest req ctx.channel().attr(StateKey.REQUEST_HEADERS).set(req.headers()); final String acceptMime = Optional.ofNullable(req.headers().get(HttpHeaderNames.ACCEPT)).orElse("application/json"); - final Pair> serializer = chooseSerializer(acceptMime); + final Pair> serializer = chooseSerializer(acceptMime); if (req.method() != POST) { sendError(ctx, METHOD_NOT_ALLOWED, METHOD_NOT_ALLOWED.toString()); @@ -95,7 +95,7 @@ protected void decode(final ChannelHandlerContext ctx, final FullHttpRequest req return; } - final RequestMessageV4 requestMessage; + final RequestMessage requestMessage; try { requestMessage = getRequestMessageFromHttpRequest(req, serializers); } catch (IllegalArgumentException | SerializationException | NullPointerException ex) { @@ -108,7 +108,7 @@ protected void decode(final ChannelHandlerContext ctx, final FullHttpRequest req objects.add(requestMessage); } - private Pair> chooseSerializer(final String mimeType) { + private Pair> chooseSerializer(final String mimeType) { final List> ordered = Stream.of(mimeType.split(",")).map(mediaType -> { // parse out each mediaType with its params - keeping it simple and just looking for "quality". if // that value isn't there, default it to 1.0. not really validating here so users better get their @@ -132,7 +132,7 @@ else if (accept.equals("text/plain")) { } /** - * Convert a http request into a {@link RequestMessageV4}. + * Convert a http request into a {@link RequestMessage}. * There are 2 payload types options here. * 1. * existing https://tinkerpop.apache.org/docs/current/reference/#connecting-via-http @@ -151,12 +151,12 @@ else if (accept.equals("text/plain")) { * Accept header can be any. * Request body contains serialized RequestMessage */ - public RequestMessageV4 getRequestMessageFromHttpRequest(final FullHttpRequest request, - Map> serializers) throws SerializationException { + public RequestMessage getRequestMessageFromHttpRequest(final FullHttpRequest request, + Map> serializers) throws SerializationException { final String contentType = request.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentType != null && !contentType.equals("application/json") && serializers.containsKey(contentType)) { - final MessageSerializerV4 serializer = serializers.get(contentType); + final MessageSerializer serializer = serializers.get(contentType); final ByteBuf buffer = request.content(); try { @@ -165,10 +165,10 @@ public RequestMessageV4 getRequestMessageFromHttpRequest(final FullHttpRequest r throw new SerializationException("Unable to deserialize request using: " + serializer.getClass().getSimpleName(), e); } } - return getRequestMessageV4FromHttpRequest(request); + return getRequestMessageFromHttpRequest(request); } - private RequestMessageV4 getRequestMessageV4FromHttpRequest(final FullHttpRequest request) { + private RequestMessage getRequestMessageFromHttpRequest(final FullHttpRequest request) { final JsonNode body; try { body = mapper.readTree(request.content().toString(CharsetUtil.UTF_8)); @@ -176,12 +176,12 @@ private RequestMessageV4 getRequestMessageV4FromHttpRequest(final FullHttpReques throw new IllegalArgumentException("body could not be parsed", ioe); } - final JsonNode scriptNode = body.get(TokensV4.ARGS_GREMLIN); + final JsonNode scriptNode = body.get(Tokens.ARGS_GREMLIN); if (null == scriptNode) throw new IllegalArgumentException("no gremlin script supplied"); - final RequestMessageV4.Builder builder = RequestMessageV4.build(scriptNode.asText()); + final RequestMessage.Builder builder = RequestMessage.build(scriptNode.asText()); - final JsonNode bindingsNode = body.get(TokensV4.ARGS_BINDINGS); + final JsonNode bindingsNode = body.get(Tokens.ARGS_BINDINGS); if (bindingsNode != null && !bindingsNode.isObject()) throw new IllegalArgumentException("bindings must be a Map"); @@ -190,19 +190,19 @@ private RequestMessageV4 getRequestMessageV4FromHttpRequest(final FullHttpReques bindingsNode.fields().forEachRemaining(kv -> bindings.put(kv.getKey(), fromJsonNode(kv.getValue()))); builder.addBindings(bindings); - final JsonNode gNode = body.get(TokensV4.ARGS_G); + final JsonNode gNode = body.get(Tokens.ARGS_G); if (null != gNode) builder.addG(gNode.asText()); - final JsonNode languageNode = body.get(TokensV4.ARGS_LANGUAGE); + final JsonNode languageNode = body.get(Tokens.ARGS_LANGUAGE); builder.addLanguage((null == languageNode) ? "gremlin-groovy" : languageNode.asText()); - final JsonNode chunkSizeNode = body.get(TokensV4.ARGS_BATCH_SIZE); + final JsonNode chunkSizeNode = body.get(Tokens.ARGS_BATCH_SIZE); if (null != chunkSizeNode) builder.addChunkSize(chunkSizeNode.asInt()); - final JsonNode timeoutMsNode = body.get(TokensV4.TIMEOUT_MS); + final JsonNode timeoutMsNode = body.get(Tokens.TIMEOUT_MS); if (null != timeoutMsNode) builder.addTimeoutMillis(timeoutMsNode.asLong()); - final JsonNode matPropsNode = body.get(TokensV4.ARGS_MATERIALIZE_PROPERTIES); + final JsonNode matPropsNode = body.get(Tokens.ARGS_MATERIALIZE_PROPERTIES); if (null != matPropsNode) builder.addMaterializeProperties(matPropsNode.asText()); return builder.create(); diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/StateKey.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/StateKey.java index 0478a6a6956..2e8cc752107 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/StateKey.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/StateKey.java @@ -20,7 +20,7 @@ import io.netty.handler.codec.http.HttpHeaders; import io.netty.util.AttributeKey; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser; import org.javatuples.Pair; @@ -38,7 +38,7 @@ private StateKey() {} /** * The key for the current serializer requested by the client. */ - public static final AttributeKey>> SERIALIZER = AttributeKey.valueOf("serializer"); + public static final AttributeKey>> SERIALIZER = AttributeKey.valueOf("serializer"); /** * The key for the current request headers. diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinError.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinError.java index bcd9ec40a88..f0f298aa1ba 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinError.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinError.java @@ -21,13 +21,13 @@ import io.netty.handler.codec.http.HttpResponseStatus; import org.apache.tinkerpop.gremlin.process.traversal.Failure; import org.apache.tinkerpop.gremlin.util.ExceptionHelper; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.Set; /** - * Exception utility class that generates exceptions in the form expected in a {@code ResponseStatusV4} for different + * Exception utility class that generates exceptions in the form expected in a {@code ResponseStatus} for different * issues that the server can encounter. */ public class GremlinError { @@ -56,7 +56,7 @@ public String getException() { // ------------ request validation errors // script type errors - public static GremlinError invalidGremlinType(final RequestMessageV4 requestMessage ) { + public static GremlinError invalidGremlinType(final RequestMessage requestMessage ) { final String message = String.format("Message could not be parsed. Check the format of the request. [%s]", requestMessage); return new GremlinError(HttpResponseStatus.BAD_REQUEST, message, "InvalidRequestException"); @@ -82,12 +82,12 @@ public static GremlinError binding(final int bindingsCount, final int allowedSiz public static GremlinError binding(final String aliased) { final String message = String.format("Could not alias [%s] to [%s] as [%s] not in the Graph or TraversalSource global bindings", - TokensV4.ARGS_G, aliased, aliased); + Tokens.ARGS_G, aliased, aliased); return new GremlinError(HttpResponseStatus.BAD_REQUEST, message, "InvalidRequestException"); } // execution errors - public static GremlinError timeout(final RequestMessageV4 requestMessage ) { + public static GremlinError timeout(final RequestMessage requestMessage ) { final String message = String.format("A timeout occurred during traversal evaluation of [%s] - consider increasing the limit given to evaluationTimeout", requestMessage); return new GremlinError(HttpResponseStatus.INTERNAL_SERVER_ERROR, message, "ServerTimeoutExceededException"); @@ -120,7 +120,7 @@ public static GremlinError longFrame(Throwable t) { return new GremlinError(HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE, message, "RequestEntityTooLargeException"); } - public static GremlinError longRequest(final RequestMessageV4 requestMessage ) { + public static GremlinError longRequest(final RequestMessage requestMessage ) { final String message = String.format("The Gremlin statement that was submitted exceeds the maximum compilation size allowed by the JVM, please split it into multiple smaller statements - %s", requestMessage.trimMessage(1021)); return new GremlinError(HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE, message, "RequestEntityTooLargeException"); } diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializer.java similarity index 82% rename from gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java rename to gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializer.java index dadd1eb4687..cf311379ad5 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializer.java @@ -22,10 +22,9 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.CharsetUtil; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; -import org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.ser.SerializationException; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; +import org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializer; import java.util.List; import java.util.Objects; @@ -35,7 +34,7 @@ * A highly use-case specific serializer that only has context for HTTP where results simply need to be converted * to string in a line by line fashion for text based returns. */ -public class TextPlainMessageSerializerV4 extends AbstractMessageSerializerV4> { +public class TextPlainMessageSerializer extends AbstractMessageSerializer> { @Override public Function getMapper() { @@ -43,14 +42,14 @@ public Function getMapper() { } @Override - public ByteBuf serializeResponseAsBinary(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) { + public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) { return (responseMessage.getStatus().getCode() == HttpResponseStatus.OK) ? convertStringData(responseMessage.getResult().getData(), false, allocator) : convertErrorString(responseMessage.getStatus().getMessage(), allocator); } @Override - public ByteBuf writeHeader(ResponseMessageV4 responseMessage, ByteBufAllocator allocator) { + public ByteBuf writeHeader(ResponseMessage responseMessage, ByteBufAllocator allocator) { return convertStringData(responseMessage.getResult().getData(), false, allocator); } @@ -60,32 +59,32 @@ public ByteBuf writeChunk(Object aggregate, ByteBufAllocator allocator) { } @Override - public ByteBuf writeFooter(ResponseMessageV4 responseMessage, ByteBufAllocator allocator) { + public ByteBuf writeFooter(ResponseMessage responseMessage, ByteBufAllocator allocator) { return convertStringData(responseMessage.getResult().getData(), true, allocator); } @Override - public ByteBuf writeErrorFooter(ResponseMessageV4 responseMessage, ByteBufAllocator allocator) { + public ByteBuf writeErrorFooter(ResponseMessage responseMessage, ByteBufAllocator allocator) { return convertErrorString(System.lineSeparator() + responseMessage.getStatus().getMessage(), allocator); } @Override - public ResponseMessageV4 readChunk(ByteBuf byteBuf, boolean isFirstChunk) { + public ResponseMessage readChunk(ByteBuf byteBuf, boolean isFirstChunk) { throw new UnsupportedOperationException("text/plain does not have deserialization functions"); } @Override - public ByteBuf serializeRequestAsBinary(final RequestMessageV4 requestMessage, final ByteBufAllocator allocator) { + public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, final ByteBufAllocator allocator) { throw new UnsupportedOperationException("text/plain does not produce binary"); } @Override - public RequestMessageV4 deserializeBinaryRequest(final ByteBuf msg) { + public RequestMessage deserializeBinaryRequest(final ByteBuf msg) { throw new UnsupportedOperationException("text/plain does not have deserialization functions"); } @Override - public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg) { + public ResponseMessage deserializeBinaryResponse(final ByteBuf msg) { throw new UnsupportedOperationException("text/plain does not have deserialization functions"); } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientConnectionIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientConnectionIntegrateTest.java index 523c9e6dd4f..39f89e877c9 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientConnectionIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientConnectionIntegrateTest.java @@ -20,10 +20,9 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; -import io.netty.handler.codec.CorruptedFrameException; import io.netty.handler.codec.TooLongFrameException; import nl.altindag.log.LogCaptor; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException; import org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException; import org.apache.tinkerpop.gremlin.server.AbstractGremlinServerIntegrationTest; @@ -149,7 +148,7 @@ public void shouldBalanceConcurrentRequestsAcrossConnections() throws Interrupte final ExecutorService executorServiceForTesting = cluster.executor(); try { - final RequestMessageV4.Builder request = client.buildMessage(RequestMessageV4.build("Thread.sleep(5000)")); + final RequestMessage.Builder request = client.buildMessage(RequestMessage.build("Thread.sleep(5000)")); final Callable sendQueryCallable = () -> client.chooseConnection(request.create()); final List> listOfTasks = new ArrayList<>(); for (int i = 0; i < connPoolSize; i++) { @@ -195,7 +194,7 @@ public void overLimitOperationsShouldCreateNewHttpConnectionPerRequestAsNeeded() final ExecutorService executorServiceForTesting = cluster.executor(); try { - final RequestMessageV4.Builder request = client.buildMessage(RequestMessageV4.build("Thread.sleep(5000)")); + final RequestMessage.Builder request = client.buildMessage(RequestMessage.build("Thread.sleep(5000)")); final Callable sendQueryCallable = () -> client.chooseConnection(request.create()); final List> listOfTasks = new ArrayList<>(); for (int i = 0; i < operations; i++) { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java index d80271af6cd..9d41d393d88 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java @@ -36,7 +36,7 @@ import org.apache.tinkerpop.gremlin.server.TestClientFactory; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import java.io.InputStream; import java.util.HashMap; @@ -332,7 +332,7 @@ public GraphTraversalSource traversal(final Graph graph) { return g; } - public static Cluster.Builder createClusterBuilder(final SerializersV4 serializer) { + public static Cluster.Builder createClusterBuilder(final Serializers serializer) { // bigger buffer for some tests return TestClientFactory.build().maxContentLength(10_000_000).serializer(serializer); } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryGroovyRemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryGroovyRemoteGraphProvider.java index 31102ff41ce..5e1f9f0466c 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryGroovyRemoteGraphProvider.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryGroovyRemoteGraphProvider.java @@ -19,7 +19,7 @@ package org.apache.tinkerpop.gremlin.driver.remote; import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; /** * @author Stephen Mallette (http://stephen.genoprime.com) @@ -30,6 +30,6 @@ reason = "MatchAlgorithmStrategy construction doesn't work for gremlin-groovy") public class GraphBinaryGroovyRemoteGraphProvider extends AbstractRemoteGraphProvider implements AutoCloseable { public GraphBinaryGroovyRemoteGraphProvider() { - super(createClusterBuilder(SerializersV4.GRAPHBINARY_V4).create(), false, "groovy-test"); + super(createClusterBuilder(Serializers.GRAPHBINARY_V4).create(), false, "groovy-test"); } } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryLangRemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryLangRemoteGraphProvider.java index fa45c9749a9..ab678ac96ea 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryLangRemoteGraphProvider.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryLangRemoteGraphProvider.java @@ -18,13 +18,13 @@ */ package org.apache.tinkerpop.gremlin.driver.remote; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; /** * @author Stephen Mallette (http://stephen.genoprime.com) */ public class GraphBinaryLangRemoteGraphProvider extends AbstractRemoteGraphProvider implements AutoCloseable { public GraphBinaryLangRemoteGraphProvider() { - super(createClusterBuilder(SerializersV4.GRAPHBINARY_V4).create(), false, "gremlin-lang"); + super(createClusterBuilder(Serializers.GRAPHBINARY_V4).create(), false, "gremlin-lang"); } } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryRemoteGraphComputerProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryRemoteGraphComputerProvider.java index 5530e34a06b..888fa915dad 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryRemoteGraphComputerProvider.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/GraphBinaryRemoteGraphComputerProvider.java @@ -22,7 +22,7 @@ import org.apache.tinkerpop.gremlin.GraphProvider; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; /** * @author Stephen Mallette (http://stephen.genoprime.com) @@ -151,6 +151,6 @@ public class GraphBinaryRemoteGraphComputerProvider extends AbstractRemoteGraphProvider { public GraphBinaryRemoteGraphComputerProvider() { - super(createClusterBuilder(SerializersV4.GRAPHBINARY_V4).create(), true, "groovy-test"); + super(createClusterBuilder(Serializers.GRAPHBINARY_V4).create(), true, "groovy-test"); } } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java index a0a2d527ba5..b1c66c1d39d 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java @@ -29,7 +29,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.server.TestClientFactory; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.junit.AssumptionViolatedException; import java.io.File; @@ -49,7 +49,7 @@ public abstract class RemoteWorld implements World { * Helper method to create a test cluster based on the type of serializer. Can be used by implementations to help * construct a RemoteWorld. */ - public static Cluster createTestCluster(final SerializersV4 serializer) { + public static Cluster createTestCluster(final Serializers serializer) { return TestClientFactory.build().serializer(serializer).create(); } @@ -160,7 +160,7 @@ public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphDat //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static class GraphBinaryLangRemoteWorld extends RemoteWorld { - public GraphBinaryLangRemoteWorld() { super(createTestCluster(SerializersV4.GRAPHBINARY_V4)); } + public GraphBinaryLangRemoteWorld() { super(createTestCluster(Serializers.GRAPHBINARY_V4)); } @Override public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphData graphData) { @@ -170,7 +170,7 @@ public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphDat } public static class GraphBinaryGroovyRemoteWorld extends RemoteWorld { - public GraphBinaryGroovyRemoteWorld() { super(createTestCluster(SerializersV4.GRAPHBINARY_V4)); } + public GraphBinaryGroovyRemoteWorld() { super(createTestCluster(Serializers.GRAPHBINARY_V4)); } @Override public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphData graphData) { @@ -182,7 +182,7 @@ public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphDat //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static class GraphBinaryRemoteComputerWorld extends RemoteComputerWorld { - public GraphBinaryRemoteComputerWorld() { super(createTestCluster(SerializersV4.GRAPHBINARY_V4)); } + public GraphBinaryRemoteComputerWorld() { super(createTestCluster(Serializers.GRAPHBINARY_V4)); } @Override public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphData graphData) { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ContextTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ContextTest.java index 96dacaa0c30..accdcc86ffb 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ContextTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ContextTest.java @@ -20,7 +20,7 @@ import io.netty.channel.ChannelHandlerContext; import nl.altindag.log.LogCaptor; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -52,8 +52,8 @@ public void setupForEachTest() { public void shouldParseParametersFromScriptRequest() { final ChannelHandlerContext ctx = Mockito.mock(ChannelHandlerContext.class); - final RequestMessageV4 request = - RequestMessageV4.build("g.with('evaluationTimeout', 1000).with(true).with('materializeProperties', 'tokens').V().out('knows')") + final RequestMessage request = + RequestMessage.build("g.with('evaluationTimeout', 1000).with(true).with('materializeProperties', 'tokens').V().out('knows')") .create(); final Settings settings = new Settings(); final Context context = new Context(request, ctx, settings, null, null, null); @@ -66,8 +66,8 @@ public void shouldParseParametersFromScriptRequest() public void shouldSkipInvalidMaterializePropertiesParameterFromScriptRequest() { final ChannelHandlerContext ctx = Mockito.mock(ChannelHandlerContext.class); - final RequestMessageV4 request = - RequestMessageV4.build("g.with('evaluationTimeout', 1000).with(true).with('materializeProperties', 'some-invalid-value').V().out('knows')") + final RequestMessage request = + RequestMessage.build("g.with('evaluationTimeout', 1000).with(true).with('materializeProperties', 'some-invalid-value').V().out('knows')") .create(); final Settings settings = new Settings(); final Context context = new Context(request, ctx, settings, null, null, null); diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java index 3f78b5fac48..904407a6d96 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java @@ -37,7 +37,7 @@ import org.apache.tinkerpop.gremlin.util.ExceptionHelper; import org.apache.tinkerpop.gremlin.util.TimeUtil; import org.apache.tinkerpop.gremlin.util.function.FunctionUtils; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -207,7 +207,7 @@ public void shouldInterceptRequestsWithHandshake() throws Exception { @Ignore("Reading for streaming GraphSON is not supported") @Test public void shouldReportErrorWhenRequestCantBeSerialized() throws Exception { - final Cluster cluster = TestClientFactory.build().serializer(SerializersV4.GRAPHSON_V4).create(); + final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V4).create(); try { final Client client = cluster.connect().alias("g"); @@ -731,7 +731,7 @@ public void shouldFailWithBadServerSideSerialization() throws Exception { @Test public void shouldWorkWithGraphBinaryV4Serialization() throws Exception { - final Cluster cluster = TestClientFactory.build().serializer(SerializersV4.GRAPHBINARY_V4).create(); + final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHBINARY_V4).create(); final Client client = cluster.connect(); try { @@ -973,7 +973,7 @@ public void shouldAliasGraphVariables() throws Exception { @Test public void shouldAliasTraversalSourceVariables() throws Exception { - final Cluster cluster = TestClientFactory.build().serializer(SerializersV4.GRAPHBINARY_V4).create(); + final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHBINARY_V4).create(); final Client client = cluster.connect(); try { try { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java index d1f0d4d00d2..b63bf18543a 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java @@ -23,8 +23,6 @@ import org.apache.tinkerpop.gremlin.driver.Result; import org.apache.tinkerpop.gremlin.driver.ResultSet; import org.apache.tinkerpop.gremlin.process.traversal.Path; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Property; @@ -38,13 +36,11 @@ import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath; import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; -import org.hamcrest.CoreMatchers; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -71,18 +67,18 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat @Parameterized.Parameters(name = "{0}") public static Iterable data() { - final MessageSerializerV4 graphBinaryMessageSerializerV4 = new GraphBinaryMessageSerializerV4(); + final MessageSerializer graphBinaryMessageSerializerV4 = new GraphBinaryMessageSerializerV4(); return Arrays.asList(new Object[][]{ - {SerializersV4.GRAPHBINARY_V4, graphBinaryMessageSerializerV4} + {Serializers.GRAPHBINARY_V4, graphBinaryMessageSerializerV4} }); } @Parameterized.Parameter(value = 0) - public SerializersV4 name; + public Serializers name; @Parameterized.Parameter(value = 1) - public MessageSerializerV4 messageSerializer; + public MessageSerializer messageSerializer; @Before public void beforeTest() { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java index 6c0d2cc9a60..bf3aa20adf9 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java @@ -45,13 +45,13 @@ import org.apache.tinkerpop.gremlin.server.handler.HttpBasicAuthenticationHandler; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.GraphSONUntypedMessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.SerTokens; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.apache.tinkerpop.shaded.jackson.databind.JsonNode; import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; import org.junit.Assert; @@ -74,10 +74,10 @@ import java.util.concurrent.TimeUnit; import static org.apache.tinkerpop.gremlin.server.handler.HttpRequestIdHandler.REQUEST_ID_HEADER_NAME; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_MATERIALIZE_PROPERTIES; -import static org.apache.tinkerpop.gremlin.util.TokensV4.MATERIALIZE_PROPERTIES_ALL; -import static org.apache.tinkerpop.gremlin.util.TokensV4.MATERIALIZE_PROPERTIES_TOKENS; -import static org.apache.tinkerpop.gremlin.util.TokensV4.TIMEOUT_MS; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_MATERIALIZE_PROPERTIES; +import static org.apache.tinkerpop.gremlin.util.Tokens.MATERIALIZE_PROPERTIES_ALL; +import static org.apache.tinkerpop.gremlin.util.Tokens.MATERIALIZE_PROPERTIES_TOKENS; +import static org.apache.tinkerpop.gremlin.util.Tokens.TIMEOUT_MS; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.StringRegularExpression.matchesRegex; @@ -817,7 +817,7 @@ public void should200OnPOSTWithGraphSON4d0AcceptHeaderDefaultResultToJson() thro try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals(SerTokensV4.MIME_JSON, response.getEntity().getContentType().getValue()); + assertEquals(SerTokens.MIME_JSON, response.getEntity().getContentType().getValue()); final String json = EntityUtils.toString(response.getEntity()); final JsonNode node = mapper.readTree(json); assertEquals(0, node.get("result").get(0).asInt()); @@ -832,7 +832,7 @@ public void should500WithResultThatCantBeSerialized() throws Exception { try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); // Temporarily 200 - assertEquals(SerTokensV4.MIME_JSON, response.getEntity().getContentType().getValue()); + assertEquals(SerTokens.MIME_JSON, response.getEntity().getContentType().getValue()); final String json = EntityUtils.toString(response.getEntity()); final JsonNode node = mapper.readTree(json); assertThat(node.get("status").get("message").asText(), startsWith("Error during serialization: Could not find a type identifier for the class")); @@ -936,19 +936,19 @@ public void should200OnPOSTWithChunkedResponseGraphBinary() throws Exception { final String gremlin = "inject(0,1,2,3,4,5,6,7,8,9,'ten',11,12,13,14,15,'new chunk')"; final GraphBinaryMessageSerializerV4 serializer = new GraphBinaryMessageSerializerV4(); final ByteBuf serializedRequest = serializer.serializeRequestAsBinary( - RequestMessageV4.build(gremlin).create(), new UnpooledByteBufAllocator(false)); + RequestMessage.build(gremlin).create(), new UnpooledByteBufAllocator(false)); final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); - httppost.addHeader(HttpHeaders.CONTENT_TYPE, SerializersV4.GRAPHBINARY_V4.getValue()); - httppost.addHeader(HttpHeaders.ACCEPT, SerializersV4.GRAPHBINARY_V4.getValue()); + httppost.addHeader(HttpHeaders.CONTENT_TYPE, Serializers.GRAPHBINARY_V4.getValue()); + httppost.addHeader(HttpHeaders.ACCEPT, Serializers.GRAPHBINARY_V4.getValue()); httppost.setEntity(new ByteArrayEntity(serializedRequest.array())); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); assertTrue(response.getEntity().isChunked()); - final ResponseMessageV4 responseMessage = serializer.readChunk(toByteBuf(response.getEntity()), true); + final ResponseMessage responseMessage = serializer.readChunk(toByteBuf(response.getEntity()), true); assertEquals(17, ((List)responseMessage.getResult().getData()).size()); final Header[] footers = getTrailingHeaders(response); @@ -963,19 +963,19 @@ public void should200OnPOSTWithEmptyChunkedResponseGraphBinary() throws Exceptio final String gremlin = "g.V().iterate()"; final GraphBinaryMessageSerializerV4 serializer = new GraphBinaryMessageSerializerV4(); final ByteBuf serializedRequest = serializer.serializeRequestAsBinary( - RequestMessageV4.build(gremlin).create(), new UnpooledByteBufAllocator(false)); + RequestMessage.build(gremlin).create(), new UnpooledByteBufAllocator(false)); final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); - httppost.addHeader(HttpHeaders.CONTENT_TYPE, SerializersV4.GRAPHBINARY_V4.getValue()); - httppost.addHeader(HttpHeaders.ACCEPT, SerializersV4.GRAPHBINARY_V4.getValue()); + httppost.addHeader(HttpHeaders.CONTENT_TYPE, Serializers.GRAPHBINARY_V4.getValue()); + httppost.addHeader(HttpHeaders.ACCEPT, Serializers.GRAPHBINARY_V4.getValue()); httppost.setEntity(new ByteArrayEntity(serializedRequest.array())); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); assertTrue(response.getEntity().isChunked()); - final ResponseMessageV4 responseMessage = serializer.readChunk(toByteBuf(response.getEntity()), true); + final ResponseMessage responseMessage = serializer.readChunk(toByteBuf(response.getEntity()), true); assertEquals(0, ((List)responseMessage.getResult().getData()).size()); final Header[] footers = getTrailingHeaders(response); @@ -1135,18 +1135,18 @@ public void should200OnPOSTWithGremlinGraphSONEndcodedBodyAndDoubleBindings() th final SimpleBindings bindings = new SimpleBindings(); bindings.put("x", 10.5d); final ByteBuf serializedRequest = serializer.serializeRequestAsBinary( - RequestMessageV4.build("x").addBindings(bindings).create(), + RequestMessage.build("x").addBindings(bindings).create(), new UnpooledByteBufAllocator(false)); final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); - httppost.addHeader(HttpHeaders.ACCEPT, SerializersV4.GRAPHSON_V4.getValue()); - httppost.addHeader("Content-Type", SerializersV4.GRAPHSON_V4.getValue()); + httppost.addHeader(HttpHeaders.ACCEPT, Serializers.GRAPHSON_V4.getValue()); + httppost.addHeader("Content-Type", Serializers.GRAPHSON_V4.getValue()); httppost.setEntity(new ByteArrayEntity(serializedRequest.array())); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals(SerializersV4.GRAPHSON_V4.getValue(), response.getEntity().getContentType().getValue()); + assertEquals(Serializers.GRAPHSON_V4.getValue(), response.getEntity().getContentType().getValue()); final String json = EntityUtils.toString(response.getEntity()); final JsonNode node = mapper.readTree(json); assertEquals(10.5d, node.get("result").get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).doubleValue(), 0.0001); @@ -1157,13 +1157,13 @@ public void should200OnPOSTWithGremlinGraphSONEndcodedBodyAndDoubleBindings() th public void should400OnPOSTWithInvalidRequestArgsWhenInvalidBindingsSupplied() throws Exception { final GraphSONMessageSerializerV4 serializer = new GraphSONMessageSerializerV4(); final ByteBuf serializedRequest = serializer.serializeRequestAsBinary( - RequestMessageV4.build("g.V(id)").addBinding("id", "1").create(), + RequestMessage.build("g.V(id)").addBinding("id", "1").create(), new UnpooledByteBufAllocator(false)); final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); - httppost.addHeader(HttpHeaders.ACCEPT, SerializersV4.GRAPHSON_V4.getValue()); - httppost.addHeader("Content-Type", SerializersV4.GRAPHSON_V4.getValue()); + httppost.addHeader(HttpHeaders.ACCEPT, Serializers.GRAPHSON_V4.getValue()); + httppost.addHeader("Content-Type", Serializers.GRAPHSON_V4.getValue()); httppost.setEntity(new ByteArrayEntity(serializedRequest.array())); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { @@ -1211,14 +1211,14 @@ public void shouldIgnoreRequestIdInPostRequest() throws Exception { public void should100onExpectContinueRequest() throws Exception { final GraphSONMessageSerializerV4 serializer = new GraphSONMessageSerializerV4(); final ByteBuf serializedRequest = serializer.serializeRequestAsBinary( - RequestMessageV4.build("gmodern.V()").create(), + RequestMessage.build("gmodern.V()").create(), new UnpooledByteBufAllocator(false)); final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); httppost.setConfig(RequestConfig.custom().setExpectContinueEnabled(true).build()); - httppost.addHeader(HttpHeaders.ACCEPT, SerializersV4.GRAPHSON_V4.getValue()); - httppost.addHeader("Content-Type", SerializersV4.GRAPHSON_V4.getValue()); + httppost.addHeader(HttpHeaders.ACCEPT, Serializers.GRAPHSON_V4.getValue()); + httppost.addHeader("Content-Type", Serializers.GRAPHSON_V4.getValue()); httppost.setEntity(new ByteArrayEntity(serializedRequest.array())); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { @@ -1285,13 +1285,13 @@ public void shouldAcceptMaterializePropertiesTokensInRequestBody() throws Except public void shouldNotContainStatusMessageOrExceptionWith200() throws Exception { final GraphSONMessageSerializerV4 serializer = new GraphSONMessageSerializerV4(); final ByteBuf serializedRequest = serializer.serializeRequestAsBinary( - RequestMessageV4.build("1+1").create(), + RequestMessage.build("1+1").create(), new UnpooledByteBufAllocator(false)); final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); - httppost.addHeader(HttpHeaders.ACCEPT, SerializersV4.GRAPHSON_V4.getValue()); - httppost.addHeader("Content-Type", SerializersV4.GRAPHSON_V4.getValue()); + httppost.addHeader(HttpHeaders.ACCEPT, Serializers.GRAPHSON_V4.getValue()); + httppost.addHeader("Content-Type", Serializers.GRAPHSON_V4.getValue()); httppost.setEntity(new ByteArrayEntity(serializedRequest.array())); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java index fac54aaf460..af5228945ee 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java @@ -48,8 +48,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.util.ExceptionHelper; import org.apache.tinkerpop.gremlin.util.function.Lambda; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.hamcrest.Matchers; import org.junit.After; import org.junit.AfterClass; @@ -76,7 +76,7 @@ import static org.apache.tinkerpop.gremlin.process.remote.RemoteConnection.GREMLIN_REMOTE; import static org.apache.tinkerpop.gremlin.process.remote.RemoteConnection.GREMLIN_REMOTE_CONNECTION_CLASS; import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; -import static org.apache.tinkerpop.gremlin.util.TokensV4.ARGS_EVAL_TIMEOUT; +import static org.apache.tinkerpop.gremlin.util.Tokens.ARGS_EVAL_TIMEOUT; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -472,7 +472,7 @@ public void shouldRespectHighWaterMarkSettingAndSucceed() { final CountDownLatch latch = new CountDownLatch(resultCountToGenerate); final AtomicBoolean expected = new AtomicBoolean(false); final AtomicBoolean faulty = new AtomicBoolean(false); - final RequestMessageV4 request = RequestMessageV4.build(fattyX) + final RequestMessage request = RequestMessage.build(fattyX) .addChunkSize(batchSize).create(); client.submitAsync(request).thenAcceptAsync(r -> { @@ -508,7 +508,7 @@ public void shouldReturnInvalidRequestArgsWhenInvalidReservedBindingKeyIsUsed() try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { final Map bindings = new HashMap<>(); bindings.put(T.id.getAccessor(), "123"); - final RequestMessageV4 request = RequestMessageV4.build("[1,2,3,4,5,6,7,8,9,0]") + final RequestMessage request = RequestMessage.build("[1,2,3,4,5,6,7,8,9,0]") .addBindings(bindings).create(); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean pass = new AtomicBoolean(false); @@ -527,7 +527,7 @@ public void shouldReturnInvalidRequestArgsWhenInvalidReservedBindingKeyIsUsed() try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { final Map bindings = new HashMap<>(); bindings.put("id", "123"); - final RequestMessageV4 request = RequestMessageV4.build("[1,2,3,4,5,6,7,8,9,0]") + final RequestMessage request = RequestMessage.build("[1,2,3,4,5,6,7,8,9,0]") .addBindings(bindings).create(); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean pass = new AtomicBoolean(false); @@ -550,7 +550,7 @@ public void shouldReturnInvalidRequestArgsWhenBindingCountExceedsAllowable() thr final Map bindings = new HashMap<>(); bindings.put("x", 123); bindings.put("y", 123); - final RequestMessageV4 request = RequestMessageV4.build("x+y") + final RequestMessage request = RequestMessage.build("x+y") .addBindings(bindings).create(); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean pass = new AtomicBoolean(false); @@ -569,7 +569,7 @@ public void shouldReturnInvalidRequestArgsWhenBindingCountExceedsAllowable() thr try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { final Map bindings = new HashMap<>(); bindings.put("x", 123); - final RequestMessageV4 request = RequestMessageV4.build("x+123") + final RequestMessage request = RequestMessage.build("x+123") .addBindings(bindings).create(); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean pass = new AtomicBoolean(false); @@ -591,7 +591,7 @@ public void shouldReturnInvalidRequestArgsWhenInvalidNullBindingKeyIsUsed() thro try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { final Map bindings = new HashMap<>(); bindings.put(null, "123"); - final RequestMessageV4 request = RequestMessageV4.build("[1,2,3,4,5,6,7,8,9,0]") + final RequestMessage request = RequestMessage.build("[1,2,3,4,5,6,7,8,9,0]") .addBindings(bindings).create(); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean pass = new AtomicBoolean(false); @@ -612,9 +612,9 @@ public void shouldReturnInvalidRequestArgsWhenInvalidNullBindingKeyIsUsed() thro @SuppressWarnings("unchecked") public void shouldBatchResultsByTwos() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { - final RequestMessageV4 request = RequestMessageV4.build("[0,1,2,3,4,5,6,7,8,9]").create(); + final RequestMessage request = RequestMessage.build("[0,1,2,3,4,5,6,7,8,9]").create(); - final List msgs = client.submit(request); + final List msgs = client.submit(request); assertEquals(0, (int) msgs.get(0).getResult().getData().get(0)); assertEquals(1, (int) msgs.get(0).getResult().getData().get(1)); assertEquals(2, (int) msgs.get(1).getResult().getData().get(0)); @@ -625,7 +625,7 @@ public void shouldBatchResultsByTwos() throws Exception { assertEquals(7, (int) msgs.get(3).getResult().getData().get(1)); assertEquals(8, (int) msgs.get(4).getResult().getData().get(0)); assertEquals(9, (int) msgs.get(4).getResult().getData().get(1)); - for (ResponseMessageV4 resp : msgs.subList(5, msgs.size())) { + for (ResponseMessage resp : msgs.subList(5, msgs.size())) { assertEquals(0, resp.getResult().getData().size()); } } @@ -650,7 +650,7 @@ public void shouldBatchResultsByTwosWithDriver() throws Exception { public void shouldNotThrowNoSuchElementException() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()){ // this should return "nothing" - there should be no exception - final List responses = client.submit("g.V().has('name','kadfjaldjfla')"); + final List responses = client.submit("g.V().has('name','kadfjaldjfla')"); assertTrue(((List) responses.get(0).getResult().getData()).isEmpty()); } } @@ -659,7 +659,7 @@ public void shouldNotThrowNoSuchElementException() throws Exception { @SuppressWarnings("unchecked") public void shouldReceiveFailureTimeOutOnScriptEval() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()){ - final List responses = client.submit("Thread.sleep(3000);'some-stuff-that-should not return'"); + final List responses = client.submit("Thread.sleep(3000);'some-stuff-that-should not return'"); assertTrue(responses.get(0).getStatus().getMessage().contains("timeout occurred")); // validate that we can still send messages to the server @@ -671,10 +671,10 @@ public void shouldReceiveFailureTimeOutOnScriptEval() throws Exception { @SuppressWarnings("unchecked") public void shouldReceiveFailureTimeOutOnEvalUsingOverride() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { - final RequestMessageV4 msg = RequestMessageV4.build("Thread.sleep(3000);'some-stuff-that-should not return'") + final RequestMessage msg = RequestMessage.build("Thread.sleep(3000);'some-stuff-that-should not return'") .addTimeoutMillis(100L) .create(); - final List responses = client.submit(msg); + final List responses = client.submit(msg); assertThat(responses.get(0).getStatus().getMessage(), containsString("A timeout occurred during traversal evaluation")); // validate that we can still send messages to the server @@ -687,7 +687,7 @@ public void shouldReceiveFailureTimeOutOnScriptEvalOfOutOfControlLoop() throws E try (SimpleClient client = TestClientFactory.createSimpleHttpClient()){ // timeout configured for 1 second so the timed interrupt should trigger prior to the // evaluationTimeout which is at 30 seconds by default - final List responses = client.submit("while(true){}"); + final List responses = client.submit("while(true){}"); assertThat(responses.get(0).getStatus().getMessage(), startsWith("Timeout during script evaluation triggered by TimedInterruptCustomizerProvider")); // validate that we can still send messages to the server @@ -810,10 +810,10 @@ public void shouldFailOnDeadHost() throws Exception { @Test public void shouldNotHavePartialContentWithOneResult() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { - final RequestMessageV4 request = RequestMessageV4.build("10").create(); - final List responses = client.submit(request); + final RequestMessage request = RequestMessage.build("10").create(); + final List responses = client.submit(request); assertEquals(10, responses.get(0).getResult().getData().get(0)); - for (ResponseMessageV4 resp : responses.subList(1, responses.size())) { + for (ResponseMessage resp : responses.subList(1, responses.size())) { assertEquals(0, resp.getResult().getData().size()); } } @@ -822,8 +822,8 @@ public void shouldNotHavePartialContentWithOneResult() throws Exception { @Test public void shouldHavePartialContentWithLongResultsCollection() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { - final RequestMessageV4 request = RequestMessageV4.build("new String[100]").create(); - final List responses = client.submit(request); + final RequestMessage request = RequestMessage.build("new String[100]").create(); + final List responses = client.submit(request); assertThat(responses.size(), Matchers.greaterThan(1)); // first message have no status @@ -836,10 +836,10 @@ public void shouldHavePartialContentWithLongResultsCollection() throws Exception @Test public void shouldFailWithBadScriptEval() throws Exception { try (SimpleClient client = TestClientFactory.createSimpleHttpClient()) { - final RequestMessageV4 request = RequestMessageV4.build("new String().doNothingAtAllBecauseThis is a syntax error").create(); - final List responses = client.submit(request); + final RequestMessage request = RequestMessage.build("new String().doNothingAtAllBecauseThis is a syntax error").create(); + final List responses = client.submit(request); assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, responses.get(0).getStatus().getCode()); - for (ResponseMessageV4 resp : responses.subList(1, responses.size())) { + for (ResponseMessage resp : responses.subList(1, responses.size())) { assertEquals(0, resp.getResult().getData().size()); } } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java index e8538ab8e33..caf4f1ef3c6 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java @@ -28,9 +28,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; -import org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializer; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,12 +45,12 @@ @RunWith(Parameterized.class) public class GremlinServerSerializationIntegrateTest extends AbstractGremlinServerIntegrationTest { - private AbstractMessageSerializerV4 serializer; + private AbstractMessageSerializer serializer; private Cluster cluster = null; private Client client = null; private GraphTraversalSource g = null; - public GremlinServerSerializationIntegrateTest(AbstractMessageSerializerV4 serializer) { + public GremlinServerSerializationIntegrateTest(AbstractMessageSerializer serializer) { this.serializer = serializer; } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSslIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSslIntegrateTest.java index dbf051ca77a..cf2444cb022 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSslIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSslIntegrateTest.java @@ -27,10 +27,9 @@ import io.netty.handler.ssl.util.SelfSignedCertificate; import org.apache.tinkerpop.gremlin.driver.Client; import org.apache.tinkerpop.gremlin.driver.Cluster; -import org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException; import org.apache.tinkerpop.gremlin.driver.simple.SimpleClient; import org.apache.tinkerpop.gremlin.util.ExceptionHelper; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.junit.Ignore; import org.junit.Test; @@ -169,7 +168,7 @@ public void shouldEnableWebSocketSsl() throws Exception { final Map bindings = new HashMap<>(); bindings.put("x", 123); bindings.put("y", 123); - final RequestMessageV4 request = RequestMessageV4.build("x+y") + final RequestMessage request = RequestMessage.build("x+y") .addBindings(bindings).create(); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean pass = new AtomicBoolean(false); diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AllowListAuthorizer.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AllowListAuthorizer.java index a6a19a3d1c9..ccbd54ab9a7 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AllowListAuthorizer.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AllowListAuthorizer.java @@ -21,8 +21,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource; import org.apache.tinkerpop.gremlin.server.Settings.AuthorizationSettings; import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import java.util.ArrayList; import java.util.HashMap; @@ -90,9 +90,9 @@ public void setup(final Map config) { * {@link AuthorizationException} if this is not the case. * * @param user {@link AuthenticatedUser} that needs authorization. - * @param msg {@link RequestMessageV4} in which the {@link TokensV4}.ARGS_GREMLIN argument can contain an arbitrary succession of script statements. + * @param msg {@link RequestMessage} in which the {@link Tokens}.ARGS_GREMLIN argument can contain an arbitrary succession of script statements. */ - public void authorize(final AuthenticatedUser user, final RequestMessageV4 msg) throws AuthorizationException { + public void authorize(final AuthenticatedUser user, final RequestMessage msg) throws AuthorizationException { if (!usernamesSandbox.contains(user.getName())) { throw new AuthorizationException(REJECT_STRING); } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AuthorizerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AuthorizerTest.java index e52b189b9e1..e345f1c9510 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AuthorizerTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/authz/AuthorizerTest.java @@ -24,7 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy; import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -89,9 +89,9 @@ private void negativeString(final String username, final String traversalSource) } } - private RequestMessageV4 buildRequestMessage(final String traversalSource) { + private RequestMessage buildRequestMessage(final String traversalSource) { final String script = String.format("1+1; %s.V().map{it.get()}", traversalSource); - return RequestMessageV4.build(script).create(); + return RequestMessage.build(script).create(); } private static class SubgraphTraversals implements Supplier { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoderTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoderTest.java index 7862ef9f198..4c0e15f2590 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoderTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoderTest.java @@ -31,14 +31,14 @@ import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.HttpVersion; import io.netty.util.CharsetUtil; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; +import org.apache.tinkerpop.gremlin.util.ser.SerTokens; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.junit.Test; import java.util.HashMap; @@ -59,12 +59,12 @@ public class HttpRequestMessageDecoderTest { private final GraphBinaryMessageSerializerV4 graphBinarySerializer = new GraphBinaryMessageSerializerV4(); public final GraphSONMessageSerializerV4 graphSONSerializer = new GraphSONMessageSerializerV4(); - private final static Map> serializers = new HashMap<>(); + private final static Map> serializers = new HashMap<>(); static { - serializers.put(SerializersV4.GRAPHSON_V4_UNTYPED.getValue(), SerializersV4.GRAPHSON_V4_UNTYPED.simpleInstance()); - serializers.put("application/json", SerializersV4.GRAPHSON_V4_UNTYPED.simpleInstance()); - serializers.put(SerializersV4.GRAPHSON_V4.getValue(), SerializersV4.GRAPHSON_V4.simpleInstance()); - serializers.put(SerializersV4.GRAPHBINARY_V4.getValue(), SerializersV4.GRAPHBINARY_V4.simpleInstance()); + serializers.put(Serializers.GRAPHSON_V4_UNTYPED.getValue(), Serializers.GRAPHSON_V4_UNTYPED.simpleInstance()); + serializers.put("application/json", Serializers.GRAPHSON_V4_UNTYPED.simpleInstance()); + serializers.put(Serializers.GRAPHSON_V4.getValue(), Serializers.GRAPHSON_V4.simpleInstance()); + serializers.put(Serializers.GRAPHBINARY_V4.getValue(), Serializers.GRAPHBINARY_V4.simpleInstance()); } @Test @@ -72,12 +72,12 @@ public void shouldFailWhenIncorrectSerializerUsed() throws SerializationExceptio final HttpRequestMessageDecoder requestMessageDecoder = new HttpRequestMessageDecoder(serializers); final EmbeddedChannel testChannel = new EmbeddedChannel(new HttpServerCodec(), new HttpObjectAggregator(Integer.MAX_VALUE), requestMessageDecoder); - final RequestMessageV4 request = RequestMessageV4.build("g.V()").create(); + final RequestMessage request = RequestMessage.build("g.V()").create(); final ByteBuf buffer = graphSONSerializer.serializeRequestAsBinary(request, allocator); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_GRAPHBINARY_V4); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_GRAPHBINARY_V4); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "some uri", buffer, headers, new DefaultHttpHeaders()); @@ -96,12 +96,12 @@ public void shouldCorrectlyDeserializeRequestMessage() throws SerializationExcep final HttpRequestMessageDecoder requestMessageDecoder = new HttpRequestMessageDecoder(serializers); final EmbeddedChannel testChannel = new EmbeddedChannel(new HttpServerCodec(), new HttpObjectAggregator(Integer.MAX_VALUE), requestMessageDecoder); - final RequestMessageV4 request = RequestMessageV4.build("g.V()").addLanguage("gremlin-lang").create(); + final RequestMessage request = RequestMessage.build("g.V()").addLanguage("gremlin-lang").create(); final ByteBuf buffer = graphBinarySerializer.serializeRequestAsBinary(request, allocator); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_GRAPHBINARY_V4); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_GRAPHBINARY_V4); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "some uri", buffer, headers, new DefaultHttpHeaders()); @@ -109,7 +109,7 @@ public void shouldCorrectlyDeserializeRequestMessage() throws SerializationExcep testChannel.writeInbound(httpRequest); testChannel.finish(); - final RequestMessageV4 decodedRequestMessage = testChannel.readInbound(); + final RequestMessage decodedRequestMessage = testChannel.readInbound(); assertThat(request.getFields(), samePropertyValuesAs(decodedRequestMessage.getFields())); assertEquals(request.getGremlin(), decodedRequestMessage.getGremlin()); } @@ -126,7 +126,7 @@ public void shouldCorrectlyDeserializeGremlinFromPostRequest() throws Serializat CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "some uri", buffer, headers, new DefaultHttpHeaders()); @@ -134,9 +134,9 @@ public void shouldCorrectlyDeserializeGremlinFromPostRequest() throws Serializat testChannel.writeInbound(httpRequest); testChannel.finish(); - final RequestMessageV4 decodedRequestMessage = testChannel.readInbound(); + final RequestMessage decodedRequestMessage = testChannel.readInbound(); assertEquals(gremlin, decodedRequestMessage.getGremlin()); - assertEquals("gremlin-groovy", decodedRequestMessage.getField(TokensV4.ARGS_LANGUAGE)); + assertEquals("gremlin-groovy", decodedRequestMessage.getField(Tokens.ARGS_LANGUAGE)); } @Test @@ -152,7 +152,7 @@ public void shouldCorrectlyDeserializeGremlinFromPostRequestWithAllScriptFieldsS CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buffer, headers, new DefaultHttpHeaders()); @@ -160,10 +160,10 @@ public void shouldCorrectlyDeserializeGremlinFromPostRequestWithAllScriptFieldsS testChannel.writeInbound(httpRequest); testChannel.finish(); - final RequestMessageV4 decodedRequestMessage = testChannel.readInbound(); + final RequestMessage decodedRequestMessage = testChannel.readInbound(); assertEquals(gremlin, decodedRequestMessage.getGremlin()); - assertEquals("gremlin-groovy", decodedRequestMessage.getField(TokensV4.ARGS_LANGUAGE)); - assertEquals("2", ((Map)decodedRequestMessage.getField(TokensV4.ARGS_BINDINGS)).get("x")); + assertEquals("gremlin-groovy", decodedRequestMessage.getField(Tokens.ARGS_LANGUAGE)); + assertEquals("2", ((Map)decodedRequestMessage.getField(Tokens.ARGS_BINDINGS)).get("x")); } @Test @@ -178,7 +178,7 @@ public void shouldErrorOnBadRequestWithMalformedJson() throws SerializationExcep CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buffer, headers, new DefaultHttpHeaders()); @@ -205,7 +205,7 @@ public void shouldIgnoreInvalidRequestMessageParameter() throws SerializationExc CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buffer, headers, new DefaultHttpHeaders()); @@ -213,8 +213,8 @@ public void shouldIgnoreInvalidRequestMessageParameter() throws SerializationExc testChannel.writeInbound(httpRequest); testChannel.finish(); - final RequestMessageV4 decodedRequestMessage = testChannel.readInbound(); - assertNotEquals("abc", decodedRequestMessage.getField(TokensV4.ARGS_LANGUAGE)); + final RequestMessage decodedRequestMessage = testChannel.readInbound(); + assertNotEquals("abc", decodedRequestMessage.getField(Tokens.ARGS_LANGUAGE)); } @Test @@ -226,7 +226,7 @@ public void shouldErrorOnBadRequestWithNoParameter() throws SerializationExcepti buffer.writeCharSequence("{ }", CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buffer, headers, new DefaultHttpHeaders()); @@ -257,7 +257,7 @@ public void shouldAttemptToParseRequestWithNonsenseContentType() throws Serializ testChannel.writeInbound(httpRequest); testChannel.finish(); - RequestMessageV4 decodedRequest = testChannel.readInbound(); + RequestMessage decodedRequest = testChannel.readInbound(); assertNotNull(decodedRequest); } @@ -293,7 +293,7 @@ public void shouldNotAddInvalidFieldToRequestMessage() throws SerializationExcep buffer.writeCharSequence("{\"gremlin\":\"g.V()\",\"nonfield\":\"shouldntgetadded\"}", CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buffer, headers, new DefaultHttpHeaders()); @@ -301,7 +301,7 @@ public void shouldNotAddInvalidFieldToRequestMessage() throws SerializationExcep testChannel.writeInbound(httpRequest); testChannel.finish(); - RequestMessageV4 decodedRequest = testChannel.readInbound(); + RequestMessage decodedRequest = testChannel.readInbound(); assertNull(decodedRequest.getField("nonfield")); assertEquals("g.V()", decodedRequest.getGremlin()); } @@ -315,10 +315,10 @@ public void shouldAddValidFieldsToRequestMessage() throws SerializationException final ByteBuf buffer = allocator.buffer(); buffer.writeCharSequence("{\"gremlin\":\"g.V().limit(2)\",\"batchSize\":\"10\",\"language\":\"gremlin-lang\"," + "\"g\":\"gmodern\",\"bindings\":{\"x\":\"1\"},\"timeoutMs\":\"12\"," + - "\"materializeProperties\":\"" + TokensV4.MATERIALIZE_PROPERTIES_TOKENS + "\"}", CharsetUtil.UTF_8); + "\"materializeProperties\":\"" + Tokens.MATERIALIZE_PROPERTIES_TOKENS + "\"}", CharsetUtil.UTF_8); final HttpHeaders headers = new DefaultHttpHeaders(); - headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokensV4.MIME_JSON); + headers.add(HttpHeaderNames.CONTENT_TYPE, SerTokens.MIME_JSON); final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buffer, headers, new DefaultHttpHeaders()); @@ -326,14 +326,14 @@ public void shouldAddValidFieldsToRequestMessage() throws SerializationException testChannel.writeInbound(httpRequest); testChannel.finish(); - RequestMessageV4 decodedRequest = testChannel.readInbound(); + RequestMessage decodedRequest = testChannel.readInbound(); assertEquals("g.V().limit(2)", decodedRequest.getGremlin()); - assertEquals(10, (int) decodedRequest.getField(TokensV4.ARGS_BATCH_SIZE)); - assertEquals("gremlin-lang", decodedRequest.getField(TokensV4.ARGS_LANGUAGE)); - assertEquals("gmodern", decodedRequest.getField(TokensV4.ARGS_G)); - assertEquals("1", ((Map) decodedRequest.getField(TokensV4.ARGS_BINDINGS)).get("x")); - assertEquals(1, ((Map) decodedRequest.getField(TokensV4.ARGS_BINDINGS)).size()); - assertEquals(12, (long) decodedRequest.getField(TokensV4.TIMEOUT_MS)); - assertEquals(TokensV4.MATERIALIZE_PROPERTIES_TOKENS, decodedRequest.getField(TokensV4.ARGS_MATERIALIZE_PROPERTIES)); + assertEquals(10, (int) decodedRequest.getField(Tokens.ARGS_BATCH_SIZE)); + assertEquals("gremlin-lang", decodedRequest.getField(Tokens.ARGS_LANGUAGE)); + assertEquals("gmodern", decodedRequest.getField(Tokens.ARGS_G)); + assertEquals("1", ((Map) decodedRequest.getField(Tokens.ARGS_BINDINGS)).get("x")); + assertEquals(1, ((Map) decodedRequest.getField(Tokens.ARGS_BINDINGS)).size()); + assertEquals(12, (long) decodedRequest.getField(Tokens.TIMEOUT_MS)); + assertEquals(Tokens.MATERIALIZE_PROPERTIES_TOKENS, decodedRequest.getField(Tokens.ARGS_MATERIALIZE_PROPERTIES)); } } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerTest.java similarity index 89% rename from gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java rename to gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerTest.java index 4fda9ae89d3..6772f9be307 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerTest.java @@ -23,7 +23,7 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.CharsetUtil; import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.junit.Test; import java.util.Arrays; @@ -32,15 +32,15 @@ import static org.junit.Assert.assertEquals; -public class TextPlainMessageSerializerV4Test { +public class TextPlainMessageSerializerTest { @Test public void shouldProducePlainText() throws Exception { final Map m = new HashMap<>(); - final ResponseMessageV4 msg = ResponseMessageV4.build(). + final ResponseMessage msg = ResponseMessage.build(). code(HttpResponseStatus.OK). result(Arrays.asList(1, new DetachedVertex(100, "person", m), java.awt.Color.RED)).create(); - final TextPlainMessageSerializerV4 messageSerializer = new TextPlainMessageSerializerV4(); + final TextPlainMessageSerializer messageSerializer = new TextPlainMessageSerializer(); final ByteBuf output = messageSerializer.serializeResponseAsBinary(msg, ByteBufAllocator.DEFAULT); final String exp = "==>1" + System.lineSeparator() + "==>v[100]" + System.lineSeparator() + diff --git a/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java b/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java index 4a12db7d3b5..ad3711b13a4 100644 --- a/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java +++ b/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java @@ -26,8 +26,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.GremlinLang; import org.apache.tinkerpop.gremlin.structure.io.binary.DataType; import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; @@ -100,12 +100,12 @@ public class SerializationBenchmark extends AbstractBenchmarkBase { private static final UUID id = UUID.randomUUID(); - private static final ResponseMessageV4 response = ResponseMessageV4 + private static final ResponseMessage response = ResponseMessage .build().code(HttpResponseStatus.OK).result(Collections.singletonList(new ReferenceVertex(1, "person"))) .create(); private static final GremlinLang gremlinLang = new GremlinLang(); - private static final RequestMessageV4 request = RequestMessageV4 + private static final RequestMessage request = RequestMessage .build(gremlinLang.getGremlin()) .create(); @@ -120,26 +120,26 @@ public class SerializationBenchmark extends AbstractBenchmarkBase { } @Benchmark - public RequestMessageV4 testReadMessage1Binary() throws SerializationException { + public RequestMessage testReadMessage1Binary() throws SerializationException { RequestMessageBinaryBuffer1.readerIndex(0); return binarySerializer.deserializeBinaryRequest(RequestMessageBinaryBuffer1); } @Benchmark - public RequestMessageV4 testReadMessage2Binary() throws SerializationException { + public RequestMessage testReadMessage2Binary() throws SerializationException { RequestMessageBinaryBuffer2.readerIndex(0); return binarySerializer.deserializeBinaryRequest(RequestMessageBinaryBuffer2); } @Benchmark - public RequestMessageV4 testReadMessage1GraphSON() throws SerializationException { + public RequestMessage testReadMessage1GraphSON() throws SerializationException { RequestMessageGraphSONBuffer1.readerIndex(0); return graphsonSerializer.deserializeBinaryRequest(RequestMessageGraphSONBuffer1); } @Benchmark - public RequestMessageV4 testReadMessage2GraphSON() throws SerializationException { + public RequestMessage testReadMessage2GraphSON() throws SerializationException { RequestMessageGraphSONBuffer2.readerIndex(0); return graphsonSerializer.deserializeBinaryRequest(RequestMessageGraphSONBuffer2); } @@ -169,7 +169,7 @@ public void testWriteBytecodeGraphSON() throws SerializationException { } @Benchmark - public RequestMessageV4 testInstanceCreation() { - return RequestMessageV4.build("a").addLanguage("gremlin-groovy").addG("g").create(); + public RequestMessage testInstanceCreation() { + return RequestMessage.build("a").addLanguage("gremlin-groovy").addG("g").create(); } } diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/MessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/MessageSerializer.java similarity index 75% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/MessageSerializerV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/MessageSerializer.java index 8f10a2849a7..522858e7347 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/MessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/MessageSerializer.java @@ -18,8 +18,8 @@ */ package org.apache.tinkerpop.gremlin.util; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import org.apache.tinkerpop.gremlin.structure.Graph; import io.netty.buffer.ByteBuf; @@ -34,18 +34,18 @@ /** * Serializes data to and from Gremlin Server. Typically, the object being serialized or deserialized will be an item - * from an {@link Iterator} as returned from the {@code ScriptEngine} or an incoming {@link RequestMessageV4}. - * {@link MessageSerializerV4} instances are instantiated to a cache via {@link ServiceLoader} and indexed based on - * the mime types they support. If a mime type is supported more than once, the first {@link MessageSerializerV4} + * from an {@link Iterator} as returned from the {@code ScriptEngine} or an incoming {@link RequestMessage}. + * {@link MessageSerializer} instances are instantiated to a cache via {@link ServiceLoader} and indexed based on + * the mime types they support. If a mime type is supported more than once, the first {@link MessageSerializer} * instance loaded for that mime type is assigned. If a mime type is not found the server default is chosen. The * default may change from version to version so it is best to not rely on it when developing applications and to * always be explicit in specifying the type you wish to bind to. * * @author Stephen Mallette (http://stephen.genoprime.com) */ -public interface MessageSerializerV4 { +public interface MessageSerializer { - static final Logger logger = LoggerFactory.getLogger(MessageSerializerV4.class); + static final Logger logger = LoggerFactory.getLogger(MessageSerializer.class); /** * Gets the "mapper" that performs the underlying serialization work. @@ -53,30 +53,30 @@ public interface MessageSerializerV4 { M getMapper(); /** - * Serialize a {@link ResponseMessageV4} to a Netty {@code ByteBuf}. + * Serialize a {@link ResponseMessage} to a Netty {@code ByteBuf}. * * @param responseMessage The response message to serialize to bytes. * @param allocator The Netty allocator for the {@code ByteBuf} to return back. */ - public ByteBuf serializeResponseAsBinary(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException; + public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException; /** - * Serialize a {@link ResponseMessageV4} to a Netty {@code ByteBuf}. + * Serialize a {@link ResponseMessage} to a Netty {@code ByteBuf}. * * @param requestMessage The request message to serialize to bytes. * @param allocator The Netty allocator for the {@code ByteBuf} to return back. */ - public ByteBuf serializeRequestAsBinary(final RequestMessageV4 requestMessage, final ByteBufAllocator allocator) throws SerializationException; + public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, final ByteBufAllocator allocator) throws SerializationException; /** - * Deserialize a Netty {@code ByteBuf} into a {@link RequestMessageV4}. + * Deserialize a Netty {@code ByteBuf} into a {@link RequestMessage}. */ - public RequestMessageV4 deserializeBinaryRequest(final ByteBuf msg) throws SerializationException; + public RequestMessage deserializeBinaryRequest(final ByteBuf msg) throws SerializationException; /** - * Deserialize a Netty {@code ByteBuf} into a {@link RequestMessageV4}. + * Deserialize a Netty {@code ByteBuf} into a {@link RequestMessage}. */ - public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg) throws SerializationException; + public ResponseMessage deserializeBinaryResponse(final ByteBuf msg) throws SerializationException; /** * The list of mime types that the serializer supports. They should be ordered in preferred ordered where the @@ -94,15 +94,15 @@ public interface MessageSerializerV4 { public default void configure(final Map config, final Map graphs) { } - public ByteBuf writeHeader(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException; + public ByteBuf writeHeader(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException; public ByteBuf writeChunk(final Object aggregate, final ByteBufAllocator allocator) throws SerializationException; - public ByteBuf writeFooter(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException; + public ByteBuf writeFooter(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException; - public ByteBuf writeErrorFooter(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException; + public ByteBuf writeErrorFooter(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException; - public ResponseMessageV4 readChunk(final ByteBuf byteBuf, final boolean isFirstChunk) throws SerializationException; + public ResponseMessage readChunk(final ByteBuf byteBuf, final boolean isFirstChunk) throws SerializationException; public enum MessageParts { HEADER, DATA, FOOTER; diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/TokensV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/Tokens.java similarity index 98% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/TokensV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/Tokens.java index 8ac7adb02f3..79aa5df6d4f 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/TokensV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/Tokens.java @@ -26,8 +26,8 @@ * * @author Stephen Mallette (http://stephen.genoprime.com) */ -public final class TokensV4 { - private TokensV4() {} +public final class Tokens { + private Tokens() {} /** * Argument name that allows definition of the number of iterations each HTTP chunk should contain - diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/RequestMessage.java similarity index 76% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/RequestMessage.java index 040cc2e17b6..16c168b304d 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/RequestMessage.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.util.message; -import org.apache.tinkerpop.gremlin.util.TokensV4; +import org.apache.tinkerpop.gremlin.util.Tokens; import java.util.Collections; import java.util.HashMap; @@ -29,24 +29,24 @@ /** * The model for a request message in the HTTP body that is sent to the server beginning in 4.0.0. */ -public final class RequestMessageV4 { +public final class RequestMessage { private String gremlin; private Map fields; - private RequestMessageV4(final String gremlin, final Map fields) { + private RequestMessage(final String gremlin, final Map fields) { if (null == gremlin) throw new IllegalArgumentException("RequestMessage requires gremlin argument"); this.gremlin = gremlin; this.fields = fields; // default language is "gremlin-groovy" for now, will be replaced in following PR's - this.fields.putIfAbsent(TokensV4.ARGS_LANGUAGE, "gremlin-groovy"); + this.fields.putIfAbsent(Tokens.ARGS_LANGUAGE, "gremlin-groovy"); } /** * Empty constructor for serialization. */ - private RequestMessageV4() { } + private RequestMessage() { } public Optional optionalField(final String key) { final Object o = fields.get(key); @@ -69,32 +69,32 @@ public Map getFields() { return Collections.unmodifiableMap(fields); } - public RequestMessageV4 trimMessage(int size) { + public RequestMessage trimMessage(int size) { gremlin = gremlin.substring(0, size) + "..."; return this; } - public static Builder from(final RequestMessageV4 msg) { + public static Builder from(final RequestMessage msg) { final Builder builder = build(msg.gremlin); builder.fields.putAll(msg.getFields()); - if (msg.getFields().containsKey(TokensV4.ARGS_BINDINGS)) { - builder.addBindings((Map) msg.getFields().get(TokensV4.ARGS_BINDINGS)); + if (msg.getFields().containsKey(Tokens.ARGS_BINDINGS)) { + builder.addBindings((Map) msg.getFields().get(Tokens.ARGS_BINDINGS)); } return builder; } - public static Builder from(final RequestMessageV4 msg, final String gremlin) { + public static Builder from(final RequestMessage msg, final String gremlin) { final Builder builder = build(gremlin); builder.fields.putAll(msg.getFields()); - if (msg.getFields().containsKey(TokensV4.ARGS_BINDINGS)) { - builder.addBindings((Map) msg.getFields().get(TokensV4.ARGS_BINDINGS)); + if (msg.getFields().containsKey(Tokens.ARGS_BINDINGS)) { + builder.addBindings((Map) msg.getFields().get(Tokens.ARGS_BINDINGS)); } return builder; } @Override public String toString() { - return "RequestMessageV4{" + + return "RequestMessage{" + ", fields=" + fields + ", gremlin=" + gremlin + '}'; @@ -105,7 +105,7 @@ public static Builder build(final String gremlin) { } /** - * Builder class for {@link RequestMessageV4}. + * Builder class for {@link RequestMessage}. */ public static final class Builder { private final String gremlin; @@ -118,7 +118,7 @@ private Builder(final String gremlin) { public Builder addLanguage(final String language) { Objects.requireNonNull(language, "language argument cannot be null."); - this.fields.put(TokensV4.ARGS_LANGUAGE, language); + this.fields.put(Tokens.ARGS_LANGUAGE, language); return this; } @@ -135,38 +135,38 @@ public Builder addBindings(final Map otherBindings) { public Builder addG(final String g) { Objects.requireNonNull(g, "g argument cannot be null."); - this.fields.put(TokensV4.ARGS_G, g); + this.fields.put(Tokens.ARGS_G, g); return this; } public Builder addChunkSize(final int chunkSize) { - this.fields.put(TokensV4.ARGS_BATCH_SIZE, chunkSize); + this.fields.put(Tokens.ARGS_BATCH_SIZE, chunkSize); return this; } public Builder addMaterializeProperties(final String materializeProps) { Objects.requireNonNull(materializeProps, "materializeProps argument cannot be null."); - if (!materializeProps.equals(TokensV4.MATERIALIZE_PROPERTIES_TOKENS) && !materializeProps.equals(TokensV4.MATERIALIZE_PROPERTIES_ALL)) { + if (!materializeProps.equals(Tokens.MATERIALIZE_PROPERTIES_TOKENS) && !materializeProps.equals(Tokens.MATERIALIZE_PROPERTIES_ALL)) { throw new IllegalArgumentException("materializeProperties argument must be either token or all."); } - this.fields.put(TokensV4.ARGS_MATERIALIZE_PROPERTIES, materializeProps); + this.fields.put(Tokens.ARGS_MATERIALIZE_PROPERTIES, materializeProps); return this; } public Builder addTimeoutMillis(final long timeout) { if (timeout < 0) throw new IllegalArgumentException("timeout argument cannot be negative."); - this.fields.put(TokensV4.TIMEOUT_MS, timeout); + this.fields.put(Tokens.TIMEOUT_MS, timeout); return this; } /** * Create the request message given the settings provided to the {@link Builder}. */ - public RequestMessageV4 create() { - this.fields.put(TokensV4.ARGS_BINDINGS, bindings); - return new RequestMessageV4(gremlin, fields); + public RequestMessage create() { + this.fields.put(Tokens.ARGS_BINDINGS, bindings); + return new RequestMessage(gremlin, fields); } } } diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseMessageV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseMessage.java similarity index 72% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseMessageV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseMessage.java index 967363d4399..dc502cee44a 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseMessageV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseMessage.java @@ -24,27 +24,27 @@ import java.util.List; /** - * The model for a response message that is sent to the server beginning in 4.0.0. ResponseMessageV4 is designed to be + * The model for a response message that is sent to the server beginning in 4.0.0. ResponseMessage is designed to be * streamed back the client in parts so depending on the state of the transfer, certain parts may be null at different * times. * * @author Stephen Mallette (http://stephen.genoprime.com) */ -public final class ResponseMessageV4 { - private final ResponseStatusV4 responseStatus; - private final ResponseResultV4 responseResult; +public final class ResponseMessage { + private final ResponseStatus responseStatus; + private final ResponseResult responseResult; - private ResponseMessageV4(final ResponseStatusV4 responseStatus, - final ResponseResultV4 responseResult) { + private ResponseMessage(final ResponseStatus responseStatus, + final ResponseResult responseResult) { this.responseResult = responseResult; this.responseStatus = responseStatus; } - public ResponseStatusV4 getStatus() { + public ResponseStatus getStatus() { return responseStatus; } - public ResponseResultV4 getResult() { + public ResponseResult getResult() { return responseResult; } @@ -57,15 +57,15 @@ public String toString() { } public static class ResponseMessageHeader { - private final ResponseMessageV4 responseMessage; + private final ResponseMessage responseMessage; private final boolean typed; - public ResponseMessageHeader(final ResponseMessageV4 responseMessage, final boolean typed) { + public ResponseMessageHeader(final ResponseMessage responseMessage, final boolean typed) { this.responseMessage = responseMessage; this.typed = typed; } - public ResponseMessageV4 getResponseMessage() { + public ResponseMessage getResponseMessage() { return responseMessage; } @@ -75,15 +75,15 @@ public boolean getTyped() { } public static class ResponseMessageFooter { - private final ResponseMessageV4 responseMessage; + private final ResponseMessage responseMessage; private final boolean typed; - public ResponseMessageFooter(final ResponseMessageV4 responseMessage, final boolean typed) { + public ResponseMessageFooter(final ResponseMessage responseMessage, final boolean typed) { this.responseMessage = responseMessage; this.typed = typed; } - public ResponseMessageV4 getResponseMessage() { + public ResponseMessage getResponseMessage() { return responseMessage; } @@ -124,14 +124,14 @@ public Builder result(final List result) { return this; } - public ResponseMessageV4 create() { - final ResponseResultV4 responseResult = new ResponseResultV4(result); + public ResponseMessage create() { + final ResponseResult responseResult = new ResponseResult(result); // skip null values if (code == null && statusMessage == null) { - return new ResponseMessageV4(null, responseResult); + return new ResponseMessage(null, responseResult); } - final ResponseStatusV4 responseStatus = new ResponseStatusV4(code, statusMessage, exception); - return new ResponseMessageV4(responseStatus, responseResult); + final ResponseStatus responseStatus = new ResponseStatus(code, statusMessage, exception); + return new ResponseMessage(responseStatus, responseResult); } } } diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseResultV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseResult.java similarity index 92% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseResultV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseResult.java index 7dd3aa7524c..6f7ad8fe6e9 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseResultV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseResult.java @@ -21,12 +21,12 @@ import java.util.List; /** - * Data model for the "result" portion of a {@link ResponseMessageV4}. + * Data model for the "result" portion of a {@link ResponseMessage}. */ -public final class ResponseResultV4 { +public final class ResponseResult { private final List data; - public ResponseResultV4(final List data) { + public ResponseResult(final List data) { this.data = data; } diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseStatusV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseStatus.java similarity index 90% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseStatusV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseStatus.java index cdf808f1973..71ceb484b64 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseStatusV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/message/ResponseStatus.java @@ -20,18 +20,15 @@ import io.netty.handler.codec.http.HttpResponseStatus; -import java.util.Collections; -import java.util.Map; - /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public final class ResponseStatusV4 { +public final class ResponseStatus { private final HttpResponseStatus code; private final String message; private final String exception; - public ResponseStatusV4(final HttpResponseStatus code, final String message, final String exception) { + public ResponseStatus(final HttpResponseStatus code, final String message, final String exception) { this.code = code; this.message = message; this.exception = exception; diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV4.java index 4a216dd50e2..16b7814caf5 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV4.java @@ -28,9 +28,9 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONXModuleV3; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator; import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException; import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; @@ -46,7 +46,7 @@ import java.util.List; import java.util.Map; -public abstract class AbstractGraphSONMessageSerializerV4 extends AbstractMessageSerializerV4 { +public abstract class AbstractGraphSONMessageSerializerV4 extends AbstractMessageSerializer { private static final Logger logger = LoggerFactory.getLogger(AbstractGraphSONMessageSerializerV4.class); protected ObjectMapper mapper; @@ -96,20 +96,20 @@ private GraphSONMapper.Builder applyMaxTokenLimits(final GraphSONMapper.Builder } @Override - public ByteBuf serializeResponseAsBinary(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { if (null == responseMessage.getStatus()) { - throw new SerializationException("ResponseStatusV4 can't be null when serializing a full ResponseMessageV4."); + throw new SerializationException("ResponseStatus can't be null when serializing a full ResponseMessage."); } return writeHeader(responseMessage, allocator); } @Override - public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg) throws SerializationException { + public ResponseMessage deserializeBinaryResponse(final ByteBuf msg) throws SerializationException { try { final byte[] payload = new byte[msg.readableBytes()]; msg.readBytes(payload); - return mapper.readValue(payload, ResponseMessageV4.class); + return mapper.readValue(payload, ResponseMessage.class); } catch (Exception ex) { logger.warn(String.format("Response [%s] could not be deserialized by %s.", msg, AbstractGraphSONMessageSerializerV4.class.getName()), ex); throw new SerializationException(ex); @@ -118,16 +118,16 @@ public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg) throws Ser protected boolean isTyped() { return true; } @Override - public ByteBuf writeHeader(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf writeHeader(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { ByteBuf encodedMessage = null; try { boolean writeFullMessage = responseMessage.getStatus() != null; - final byte[] header = mapper.writeValueAsBytes(new ResponseMessageV4.ResponseMessageHeader(responseMessage, isTyped())); + final byte[] header = mapper.writeValueAsBytes(new ResponseMessage.ResponseMessageHeader(responseMessage, isTyped())); final byte[] data = getChunk(true, responseMessage.getResult().getData()); final byte[] footer = writeFullMessage - ? mapper.writeValueAsBytes(new ResponseMessageV4.ResponseMessageFooter(responseMessage, isTyped())) + ? mapper.writeValueAsBytes(new ResponseMessage.ResponseMessageFooter(responseMessage, isTyped())) : new byte[0]; // skip closing } final int headerLen = header.length - (isTyped() ? 3 : 2); @@ -188,10 +188,10 @@ public ByteBuf writeChunk(final Object aggregate, final ByteBufAllocator allocat } @Override - public ByteBuf writeFooter(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf writeFooter(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { ByteBuf encodedMessage = null; try { - final byte[] footer = mapper.writeValueAsBytes(new ResponseMessageV4.ResponseMessageFooter(responseMessage, isTyped())); + final byte[] footer = mapper.writeValueAsBytes(new ResponseMessage.ResponseMessageFooter(responseMessage, isTyped())); final byte[] data = getChunk(false, responseMessage.getResult().getData()); // skip opening { encodedMessage = allocator.buffer(footer.length - 2 + data.length). @@ -207,10 +207,10 @@ public ByteBuf writeFooter(final ResponseMessageV4 responseMessage, final ByteBu } @Override - public ByteBuf writeErrorFooter(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf writeErrorFooter(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { ByteBuf encodedMessage = null; try { - final byte[] footer = mapper.writeValueAsBytes(new ResponseMessageV4.ResponseMessageFooter(responseMessage, isTyped())); + final byte[] footer = mapper.writeValueAsBytes(new ResponseMessage.ResponseMessageFooter(responseMessage, isTyped())); // skip opening { encodedMessage = allocator.buffer(footer.length - 2). writeBytes(footer, 1, footer.length - 1); @@ -225,12 +225,12 @@ public ByteBuf writeErrorFooter(final ResponseMessageV4 responseMessage, final B } @Override - public ResponseMessageV4 readChunk(final ByteBuf byteBuf, final boolean isFirstChunk) { + public ResponseMessage readChunk(final ByteBuf byteBuf, final boolean isFirstChunk) { throw new UnsupportedOperationException("Reading for streaming GraphSON is not supported"); } @Override - public ByteBuf serializeRequestAsBinary(RequestMessageV4 requestMessage, ByteBufAllocator allocator) throws SerializationException { + public ByteBuf serializeRequestAsBinary(RequestMessage requestMessage, ByteBufAllocator allocator) throws SerializationException { ByteBuf encodedMessage = null; try { final byte[] payload = mapper.writeValueAsBytes(requestMessage); @@ -248,11 +248,11 @@ public ByteBuf serializeRequestAsBinary(RequestMessageV4 requestMessage, ByteBuf } @Override - public RequestMessageV4 deserializeBinaryRequest(ByteBuf msg) throws SerializationException { + public RequestMessage deserializeBinaryRequest(ByteBuf msg) throws SerializationException { try { final byte[] payload = new byte[msg.readableBytes()]; msg.readBytes(payload); - return mapper.readValue(payload, RequestMessageV4.class); + return mapper.readValue(payload, RequestMessage.class); } catch (Exception ex) { logger.warn(String.format("Request [%s] could not be deserialized by %s.", msg, AbstractGraphSONMessageSerializerV4.class.getName()), ex); throw new SerializationException(ex); @@ -264,41 +264,41 @@ public GremlinServerModuleV4() { super("graphsonV4-gremlin-server"); // SERIALIZERS - addSerializer(ResponseMessageV4.class, new ResponseMessageSerializerV4()); - addSerializer(ResponseMessageV4.ResponseMessageHeader.class, new ResponseMessageHeaderSerializer()); - addSerializer(ResponseMessageV4.ResponseMessageFooter.class, new ResponseMessageFooterSerializer()); - addSerializer(RequestMessageV4.class, new GraphSONMessageSerializerV4.RequestMessageV4Serializer()); + addSerializer(ResponseMessage.class, new ResponseMessageSerializer()); + addSerializer(ResponseMessage.ResponseMessageHeader.class, new ResponseMessageHeaderSerializer()); + addSerializer(ResponseMessage.ResponseMessageFooter.class, new ResponseMessageFooterSerializer()); + addSerializer(RequestMessage.class, new RequestMessageSerializer()); // DESERIALIZERS - addDeserializer(ResponseMessageV4.class, new ResponseMessageV4Deserializer()); - addDeserializer(RequestMessageV4.class, new RequestMessageV4Deserializer()); + addDeserializer(ResponseMessage.class, new ResponseMessageDeserializer()); + addDeserializer(RequestMessage.class, new RequestMessageDeserializer()); } } - public final static class RequestMessageV4Serializer extends StdSerializer { - public RequestMessageV4Serializer() { - super(RequestMessageV4.class); + public final static class RequestMessageSerializer extends StdSerializer { + public RequestMessageSerializer() { + super(RequestMessage.class); } @Override - public void serialize(final RequestMessageV4 requestMessage, final JsonGenerator jsonGenerator, + public void serialize(final RequestMessage requestMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { ser(requestMessage, jsonGenerator, serializerProvider, null); } @Override - public void serializeWithType(final RequestMessageV4 requestMessage, final JsonGenerator jsonGenerator, + public void serializeWithType(final RequestMessage requestMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { ser(requestMessage, jsonGenerator, serializerProvider, typeSerializer); } - public void ser(final RequestMessageV4 requestMessage, final JsonGenerator jsonGenerator, + public void ser(final RequestMessage requestMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { GraphSONUtil.writeStartObject(requestMessage, jsonGenerator, typeSerializer); - jsonGenerator.writeObjectField(SerTokensV4.TOKEN_GREMLIN, requestMessage.getGremlin()); + jsonGenerator.writeObjectField(SerTokens.TOKEN_GREMLIN, requestMessage.getGremlin()); for (Map.Entry kv : requestMessage.getFields().entrySet()) { jsonGenerator.writeObjectField(kv.getKey(), kv.getValue()); } @@ -307,77 +307,77 @@ public void ser(final RequestMessageV4 requestMessage, final JsonGenerator jsonG } } - public final static class RequestMessageV4Deserializer extends AbstractObjectDeserializer { - private RequestMessageV4Deserializer() { - super(RequestMessageV4.class); + public final static class RequestMessageDeserializer extends AbstractObjectDeserializer { + private RequestMessageDeserializer() { + super(RequestMessage.class); } @Override - public RequestMessageV4 createObject(final Map data) { - final RequestMessageV4.Builder builder = RequestMessageV4.build(data.get(SerTokensV4.TOKEN_GREMLIN).toString()); + public RequestMessage createObject(final Map data) { + final RequestMessage.Builder builder = RequestMessage.build(data.get(SerTokens.TOKEN_GREMLIN).toString()); - if (data.containsKey(SerTokensV4.TOKEN_LANGUAGE)) { - builder.addLanguage(data.get(SerTokensV4.TOKEN_LANGUAGE).toString()); + if (data.containsKey(SerTokens.TOKEN_LANGUAGE)) { + builder.addLanguage(data.get(SerTokens.TOKEN_LANGUAGE).toString()); } - if (data.containsKey(SerTokensV4.TOKEN_G)) { - builder.addG(data.get(SerTokensV4.TOKEN_G).toString()); + if (data.containsKey(SerTokens.TOKEN_G)) { + builder.addG(data.get(SerTokens.TOKEN_G).toString()); } - if (data.containsKey(SerTokensV4.TOKEN_BINDINGS)) { - builder.addBindings((Map) data.get(SerTokensV4.TOKEN_BINDINGS)); + if (data.containsKey(SerTokens.TOKEN_BINDINGS)) { + builder.addBindings((Map) data.get(SerTokens.TOKEN_BINDINGS)); } - if (data.containsKey(TokensV4.TIMEOUT_MS)) { + if (data.containsKey(Tokens.TIMEOUT_MS)) { // Can be int for untyped JSON and long for typed GraphSON. - builder.addTimeoutMillis(Long.parseLong(data.get(TokensV4.TIMEOUT_MS).toString())); + builder.addTimeoutMillis(Long.parseLong(data.get(Tokens.TIMEOUT_MS).toString())); } - if (data.containsKey(TokensV4.ARGS_MATERIALIZE_PROPERTIES)) { - builder.addMaterializeProperties(data.get(TokensV4.ARGS_MATERIALIZE_PROPERTIES).toString()); + if (data.containsKey(Tokens.ARGS_MATERIALIZE_PROPERTIES)) { + builder.addMaterializeProperties(data.get(Tokens.ARGS_MATERIALIZE_PROPERTIES).toString()); } - if (data.containsKey(TokensV4.ARGS_BATCH_SIZE)) { - builder.addChunkSize((int) data.get(TokensV4.ARGS_BATCH_SIZE)); + if (data.containsKey(Tokens.ARGS_BATCH_SIZE)) { + builder.addChunkSize((int) data.get(Tokens.ARGS_BATCH_SIZE)); } return builder.create(); } } - public final static class ResponseMessageSerializerV4 extends StdSerializer { - public ResponseMessageSerializerV4() { - super(ResponseMessageV4.class); + public final static class ResponseMessageSerializer extends StdSerializer { + public ResponseMessageSerializer() { + super(ResponseMessage.class); } @Override - public void serialize(final ResponseMessageV4 responseMessage, final JsonGenerator jsonGenerator, + public void serialize(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { ser(responseMessage, jsonGenerator, serializerProvider, null); } @Override - public void serializeWithType(final ResponseMessageV4 responseMessage, final JsonGenerator jsonGenerator, + public void serializeWithType(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { ser(responseMessage, jsonGenerator, serializerProvider, typeSerializer); } - public void ser(final ResponseMessageV4 responseMessage, final JsonGenerator jsonGenerator, + public void ser(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); - jsonGenerator.writeFieldName(SerTokensV4.TOKEN_STATUS); + jsonGenerator.writeFieldName(SerTokens.TOKEN_STATUS); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); - jsonGenerator.writeNumberField(SerTokensV4.TOKEN_CODE, responseMessage.getStatus().getCode().code()); + jsonGenerator.writeNumberField(SerTokens.TOKEN_CODE, responseMessage.getStatus().getCode().code()); final String message = responseMessage.getStatus().getMessage(); if (message != null && !message.isEmpty()) { - jsonGenerator.writeStringField(SerTokensV4.TOKEN_MESSAGE, responseMessage.getStatus().getMessage()); + jsonGenerator.writeStringField(SerTokens.TOKEN_MESSAGE, responseMessage.getStatus().getMessage()); } final String exception = responseMessage.getStatus().getException(); if (exception != null && !exception.isEmpty()) { - jsonGenerator.writeStringField(SerTokensV4.TOKEN_EXCEPTION, responseMessage.getStatus().getException()); + jsonGenerator.writeStringField(SerTokens.TOKEN_EXCEPTION, responseMessage.getStatus().getException()); } GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); - jsonGenerator.writeFieldName(SerTokensV4.TOKEN_RESULT); + jsonGenerator.writeFieldName(SerTokens.TOKEN_RESULT); final List result = responseMessage.getResult().getData(); if (result != null) { serializerProvider.findTypedValueSerializer(result.getClass(), true, null).serialize(result, jsonGenerator, serializerProvider); @@ -389,32 +389,32 @@ public void ser(final ResponseMessageV4 responseMessage, final JsonGenerator jso } } - public final static class ResponseMessageHeaderSerializer extends StdSerializer { + public final static class ResponseMessageHeaderSerializer extends StdSerializer { public ResponseMessageHeaderSerializer() { - super(ResponseMessageV4.ResponseMessageHeader.class); + super(ResponseMessage.ResponseMessageHeader.class); } @Override - public void serialize(final ResponseMessageV4.ResponseMessageHeader responseMessage, final JsonGenerator jsonGenerator, + public void serialize(final ResponseMessage.ResponseMessageHeader responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { ser(responseMessage, jsonGenerator, serializerProvider, null); } @Override - public void serializeWithType(final ResponseMessageV4.ResponseMessageHeader responseMessage, final JsonGenerator jsonGenerator, + public void serializeWithType(final ResponseMessage.ResponseMessageHeader responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { ser(responseMessage, jsonGenerator, serializerProvider, typeSerializer); } - public void ser(final ResponseMessageV4.ResponseMessageHeader responseMessageHeader, final JsonGenerator jsonGenerator, + public void ser(final ResponseMessage.ResponseMessageHeader responseMessageHeader, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { - final ResponseMessageV4 responseMessage = responseMessageHeader.getResponseMessage(); + final ResponseMessage responseMessage = responseMessageHeader.getResponseMessage(); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); - jsonGenerator.writeFieldName(SerTokensV4.TOKEN_RESULT); + jsonGenerator.writeFieldName(SerTokens.TOKEN_RESULT); jsonGenerator.writeObject(Collections.emptyList()); // jsonGenerator will add 2 closing } @@ -422,28 +422,28 @@ public void ser(final ResponseMessageV4.ResponseMessageHeader responseMessageHea } } - public final static class ResponseMessageFooterSerializer extends StdSerializer { + public final static class ResponseMessageFooterSerializer extends StdSerializer { public ResponseMessageFooterSerializer() { - super(ResponseMessageV4.ResponseMessageFooter.class); + super(ResponseMessage.ResponseMessageFooter.class); } @Override - public void serialize(final ResponseMessageV4.ResponseMessageFooter responseMessage, final JsonGenerator jsonGenerator, + public void serialize(final ResponseMessage.ResponseMessageFooter responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { ser(responseMessage, jsonGenerator, serializerProvider, null); } @Override - public void serializeWithType(final ResponseMessageV4.ResponseMessageFooter responseMessage, final JsonGenerator jsonGenerator, + public void serializeWithType(final ResponseMessage.ResponseMessageFooter responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { ser(responseMessage, jsonGenerator, serializerProvider, typeSerializer); } - public void ser(final ResponseMessageV4.ResponseMessageFooter responseMessageFooter, final JsonGenerator jsonGenerator, + public void ser(final ResponseMessage.ResponseMessageFooter responseMessageFooter, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { - final ResponseMessageV4 responseMessage = responseMessageFooter.getResponseMessage(); + final ResponseMessage responseMessage = responseMessageFooter.getResponseMessage(); // todo: find a way to get rid off GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); @@ -451,14 +451,14 @@ public void ser(final ResponseMessageV4.ResponseMessageFooter responseMessageFoo // close result field. array inside object for types, just array for untyped jsonGenerator.writeRaw(responseMessageFooter.getTyped() ? "]}," : "],"); - jsonGenerator.writeFieldName(SerTokensV4.TOKEN_STATUS); + jsonGenerator.writeFieldName(SerTokens.TOKEN_STATUS); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); - jsonGenerator.writeNumberField(SerTokensV4.TOKEN_CODE, responseMessage.getStatus().getCode().code()); + jsonGenerator.writeNumberField(SerTokens.TOKEN_CODE, responseMessage.getStatus().getCode().code()); if (responseMessage.getStatus().getMessage() != null) { - jsonGenerator.writeStringField(SerTokensV4.TOKEN_MESSAGE, responseMessage.getStatus().getMessage()); + jsonGenerator.writeStringField(SerTokens.TOKEN_MESSAGE, responseMessage.getStatus().getMessage()); } if (responseMessage.getStatus().getException() != null) { - jsonGenerator.writeStringField(SerTokensV4.TOKEN_EXCEPTION, responseMessage.getStatus().getException()); + jsonGenerator.writeStringField(SerTokens.TOKEN_EXCEPTION, responseMessage.getStatus().getException()); } GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); @@ -466,23 +466,23 @@ public void ser(final ResponseMessageV4.ResponseMessageFooter responseMessageFoo } } - public final static class ResponseMessageV4Deserializer extends AbstractObjectDeserializer { - public ResponseMessageV4Deserializer() { - super(ResponseMessageV4.class); + public final static class ResponseMessageDeserializer extends AbstractObjectDeserializer { + public ResponseMessageDeserializer() { + super(ResponseMessage.class); } @Override - public ResponseMessageV4 createObject(final Map data) { - final Map status = (Map) data.get(SerTokensV4.TOKEN_STATUS); - ResponseMessageV4.Builder response = ResponseMessageV4.build() - .code(HttpResponseStatus.valueOf((Integer) status.get(SerTokensV4.TOKEN_CODE))) - .result((List) data.get(SerTokensV4.TOKEN_RESULT)); - - if (null != status.get(SerTokensV4.TOKEN_EXCEPTION)) { - response.exception(String.valueOf(status.get(SerTokensV4.TOKEN_EXCEPTION))); + public ResponseMessage createObject(final Map data) { + final Map status = (Map) data.get(SerTokens.TOKEN_STATUS); + ResponseMessage.Builder response = ResponseMessage.build() + .code(HttpResponseStatus.valueOf((Integer) status.get(SerTokens.TOKEN_CODE))) + .result((List) data.get(SerTokens.TOKEN_RESULT)); + + if (null != status.get(SerTokens.TOKEN_EXCEPTION)) { + response.exception(String.valueOf(status.get(SerTokens.TOKEN_EXCEPTION))); } - if (null != status.get(SerTokensV4.TOKEN_MESSAGE)) { - response.statusMessage(String.valueOf(status.get(SerTokensV4.TOKEN_MESSAGE))); + if (null != status.get(SerTokens.TOKEN_MESSAGE)) { + response.statusMessage(String.valueOf(status.get(SerTokens.TOKEN_MESSAGE))); } return response.create(); diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractMessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractMessageSerializer.java similarity index 93% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractMessageSerializerV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractMessageSerializer.java index de3883b6055..3004fdb20cf 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractMessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractMessageSerializer.java @@ -20,7 +20,7 @@ import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; import org.apache.tinkerpop.gremlin.structure.io.Mapper; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; import java.lang.reflect.Method; import java.util.Collections; @@ -28,12 +28,12 @@ import java.util.Map; /** - * Base {@link MessageSerializerV4} that serializers can implement to get some helper methods around configuring a + * Base {@link MessageSerializer} that serializers can implement to get some helper methods around configuring a * {@link Mapper.Builder}. * * @author Stephen Mallette (http://stephen.genoprime.com) */ -public abstract class AbstractMessageSerializerV4 implements MessageSerializerV4 { +public abstract class AbstractMessageSerializer implements MessageSerializer { public static final String TOKEN_IO_REGISTRIES = "ioRegistries"; /** diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphBinaryMessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphBinaryMessageSerializerV4.java index 7fc23f3ef85..63ed101c0c8 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphBinaryMessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphBinaryMessageSerializerV4.java @@ -31,10 +31,10 @@ import org.apache.tinkerpop.gremlin.structure.io.binary.Marker; import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry; import org.apache.tinkerpop.gremlin.structure.io.binary.types.CustomTypeSerializer; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseStatusV4; -import org.apache.tinkerpop.gremlin.util.ser.binary.RequestMessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseStatus; +import org.apache.tinkerpop.gremlin.util.ser.binary.RequestMessageSerializer; import org.javatuples.Pair; import org.javatuples.Triplet; @@ -47,17 +47,17 @@ import java.util.List; import java.util.Map; -public class GraphBinaryMessageSerializerV4 extends AbstractMessageSerializerV4 { +public class GraphBinaryMessageSerializerV4 extends AbstractMessageSerializer { public static final String TOKEN_CUSTOM = "custom"; public static final String TOKEN_BUILDER = "builder"; private GraphBinaryReader reader; private GraphBinaryWriter writer; - private RequestMessageSerializerV4 requestSerializer; + private RequestMessageSerializer requestSerializer; private final GraphBinaryMapper mapper; private static final NettyBufferFactory bufferFactory = new NettyBufferFactory(); - private static final String MIME_TYPE = SerTokensV4.MIME_GRAPHBINARY_V4; + private static final String MIME_TYPE = SerTokens.MIME_GRAPHBINARY_V4; /** * Creates a new instance of the message serializer using the default type serializers. @@ -71,7 +71,7 @@ public GraphBinaryMessageSerializerV4(final TypeSerializerRegistry registry) { writer = new GraphBinaryWriter(registry); mapper = new GraphBinaryMapper(writer, reader); - requestSerializer = new RequestMessageSerializerV4(); + requestSerializer = new RequestMessageSerializer(); } public GraphBinaryMessageSerializerV4(final TypeSerializerRegistry.Builder builder) { @@ -125,7 +125,7 @@ public void configure(final Map config, final Map reader = new GraphBinaryReader(registry); writer = new GraphBinaryWriter(registry); - requestSerializer = new RequestMessageSerializerV4(); + requestSerializer = new RequestMessageSerializer(); } @Override @@ -162,7 +162,7 @@ private void addCustomClasses(final Map config, final TypeSerial } @Override - public ByteBuf serializeRequestAsBinary(RequestMessageV4 requestMessage, ByteBufAllocator allocator) throws SerializationException { + public ByteBuf serializeRequestAsBinary(RequestMessage requestMessage, ByteBufAllocator allocator) throws SerializationException { final ByteBuf buffer = allocator.buffer(); try { @@ -176,14 +176,14 @@ public ByteBuf serializeRequestAsBinary(RequestMessageV4 requestMessage, ByteBuf } @Override - public RequestMessageV4 deserializeBinaryRequest(ByteBuf msg) throws SerializationException { + public RequestMessage deserializeBinaryRequest(ByteBuf msg) throws SerializationException { return requestSerializer.readValue(msg, reader); } @Override - public ByteBuf serializeResponseAsBinary(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { if (null == responseMessage.getStatus()) { - throw new SerializationException("ResponseStatusV4 can't be null when serializing a full ResponseMessageV4."); + throw new SerializationException("ResponseStatus can't be null when serializing a full ResponseMessage."); } return writeHeader(responseMessage, allocator); @@ -191,7 +191,7 @@ public ByteBuf serializeResponseAsBinary(final ResponseMessageV4 responseMessage //////////////// chunked write @Override - public ByteBuf writeHeader(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf writeHeader(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { final EnumSet parts = responseMessage.getStatus() != null ? MessageParts.ALL : MessageParts.START; return write(responseMessage, null, allocator, parts); @@ -203,16 +203,16 @@ public ByteBuf writeChunk(final Object aggregate, final ByteBufAllocator allocat } @Override - public ByteBuf writeFooter(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf writeFooter(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { return write(responseMessage, null, allocator, MessageParts.END); } @Override - public ByteBuf writeErrorFooter(final ResponseMessageV4 responseMessage, final ByteBufAllocator allocator) throws SerializationException { + public ByteBuf writeErrorFooter(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException { return write(responseMessage, null, allocator, MessageParts.ERROR); } - private ByteBuf write(final ResponseMessageV4 responseMessage, final Object aggregate, + private ByteBuf write(final ResponseMessage responseMessage, final Object aggregate, final ByteBufAllocator allocator, final EnumSet parts) throws SerializationException { final ByteBuf byteBuf = allocator.buffer(); final Buffer buffer = bufferFactory.create(byteBuf); @@ -235,7 +235,7 @@ private ByteBuf write(final ResponseMessageV4 responseMessage, final Object aggr } if (parts.contains(MessageParts.FOOTER)) { - final ResponseStatusV4 status = responseMessage.getStatus(); + final ResponseStatus status = responseMessage.getStatus(); // we don't know how much data we have, so need a special object writer.write(Marker.END_OF_STREAM, buffer); @@ -255,7 +255,7 @@ private ByteBuf write(final ResponseMessageV4 responseMessage, final Object aggr //////////////// read message methods @Override - public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg) throws SerializationException { + public ResponseMessage deserializeBinaryResponse(final ByteBuf msg) throws SerializationException { return readChunk(msg, true); } @@ -280,13 +280,13 @@ private Triplet readFooter(final Buffer buff } @Override - public ResponseMessageV4 readChunk(final ByteBuf byteBuf, final boolean isFirstChunk) throws SerializationException { + public ResponseMessage readChunk(final ByteBuf byteBuf, final boolean isFirstChunk) throws SerializationException { final Buffer buffer = bufferFactory.create(byteBuf); try { // empty input buffer if (buffer.readableBytes() == 0) { - return ResponseMessageV4.build().result(Collections.emptyList()).create(); + return ResponseMessage.build().result(Collections.emptyList()).create(); } if (isFirstChunk) { @@ -303,13 +303,13 @@ public ResponseMessageV4 readChunk(final ByteBuf byteBuf, final boolean isFirstC // no footer if (buffer.readableBytes() == 0) { - return ResponseMessageV4.build() + return ResponseMessage.build() .result(result) .create(); } final Triplet footer = readFooter(buffer); - return ResponseMessageV4.build() + return ResponseMessage.build() .result(result) .code(footer.getValue0()) .statusMessage(footer.getValue1()) diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4.java index d323457779c..eab7482823c 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4.java @@ -26,7 +26,7 @@ * Serialize results to JSON with version 4.0.x schema and the extended module. */ public final class GraphSONMessageSerializerV4 extends AbstractGraphSONMessageSerializerV4 { - private static final String MIME_TYPE = SerTokensV4.MIME_GRAPHSON_V4; + private static final String MIME_TYPE = SerTokens.MIME_GRAPHSON_V4; /** * Creates a default GraphSONMessageSerializer. @@ -53,7 +53,7 @@ public GraphSONMessageSerializerV4(final GraphSONMapper.Builder mapperBuilder) { @Override public String[] mimeTypesSupported() { - return new String[]{MIME_TYPE, SerTokensV4.MIME_JSON}; + return new String[]{MIME_TYPE, SerTokens.MIME_JSON}; } @Override diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4.java index 5788936d724..30a8a1b6725 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4.java @@ -26,7 +26,7 @@ * Serialize results to JSON with version 4 schema and the extended module without embedded types. */ public final class GraphSONUntypedMessageSerializerV4 extends AbstractGraphSONMessageSerializerV4 { - private static final String MIME_TYPE = SerTokensV4.MIME_GRAPHSON_V4_UNTYPED; + private static final String MIME_TYPE = SerTokens.MIME_GRAPHSON_V4_UNTYPED; /** * Creates a default GraphSONMessageSerializer. @@ -53,7 +53,7 @@ public GraphSONUntypedMessageSerializerV4(final GraphSONMapper.Builder mapperBui @Override public String[] mimeTypesSupported() { - return new String[]{MIME_TYPE, SerTokensV4.MIME_JSON}; + return new String[]{MIME_TYPE, SerTokens.MIME_JSON}; } @Override diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerTokensV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerTokens.java similarity index 96% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerTokensV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerTokens.java index 84836ff4426..583b8520dd8 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerTokensV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerTokens.java @@ -21,8 +21,8 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public final class SerTokensV4 { - private SerTokensV4() {} +public final class SerTokens { + private SerTokens() {} public static final String TOKEN_RESULT = "result"; public static final String TOKEN_STATUS = "status"; diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerializersV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/Serializers.java similarity index 74% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerializersV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/Serializers.java index 471c7dbf35b..b579c2ffc86 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/SerializersV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/Serializers.java @@ -18,38 +18,38 @@ */ package org.apache.tinkerpop.gremlin.util.ser; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; /** * An enum of the default serializers available starting in v4.0. * * @author Stephen Mallette (http://stephen.genoprime.com) */ -public enum SerializersV4 { +public enum Serializers { /** * GraphSON 4.0. */ - GRAPHSON(SerTokensV4.MIME_JSON), + GRAPHSON(SerTokens.MIME_JSON), /** * GraphSON 4.0 with types. */ - GRAPHSON_V4(SerTokensV4.MIME_GRAPHSON_V4), + GRAPHSON_V4(SerTokens.MIME_GRAPHSON_V4), /** * GraphSON 4.0 without types. */ - GRAPHSON_V4_UNTYPED(SerTokensV4.MIME_GRAPHSON_V4_UNTYPED), + GRAPHSON_V4_UNTYPED(SerTokens.MIME_GRAPHSON_V4_UNTYPED), /** * GraphBinary 4.0. */ - GRAPHBINARY_V4(SerTokensV4.MIME_GRAPHBINARY_V4); + GRAPHBINARY_V4(SerTokens.MIME_GRAPHBINARY_V4); private String value; - SerializersV4(final String mimeType) { + Serializers(final String mimeType) { this.value = mimeType; } @@ -57,14 +57,14 @@ public String getValue() { return value; } - public MessageSerializerV4 simpleInstance() { + public MessageSerializer simpleInstance() { switch (value) { - case SerTokensV4.MIME_JSON: - case SerTokensV4.MIME_GRAPHSON_V4: + case SerTokens.MIME_JSON: + case SerTokens.MIME_GRAPHSON_V4: return new GraphSONMessageSerializerV4(); - case SerTokensV4.MIME_GRAPHSON_V4_UNTYPED: + case SerTokens.MIME_GRAPHSON_V4_UNTYPED: return new GraphSONUntypedMessageSerializerV4(); - case SerTokensV4.MIME_GRAPHBINARY_V4: + case SerTokens.MIME_GRAPHBINARY_V4: return new GraphBinaryMessageSerializerV4(); default: throw new RuntimeException("Could not create a simple MessageSerializer instance of " + value); diff --git a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/RequestMessageSerializerV4.java b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/RequestMessageSerializer.java similarity index 68% rename from gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/RequestMessageSerializerV4.java rename to gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/RequestMessageSerializer.java index f75fcf128f9..bbf6d70ba43 100644 --- a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/RequestMessageSerializerV4.java +++ b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/binary/RequestMessageSerializer.java @@ -22,19 +22,19 @@ import org.apache.tinkerpop.gremlin.structure.io.Buffer; import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader; import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; import org.apache.tinkerpop.gremlin.util.ser.NettyBufferFactory; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; +import org.apache.tinkerpop.gremlin.util.ser.SerTokens; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import java.io.IOException; import java.util.Map; -public class RequestMessageSerializerV4 { +public class RequestMessageSerializer { private static NettyBufferFactory bufferFactory = new NettyBufferFactory(); - public RequestMessageV4 readValue(final ByteBuf byteBuf, final GraphBinaryReader context) throws SerializationException { + public RequestMessage readValue(final ByteBuf byteBuf, final GraphBinaryReader context) throws SerializationException { // Wrap netty's buffer final Buffer buffer = bufferFactory.create(byteBuf); @@ -51,24 +51,24 @@ public RequestMessageV4 readValue(final ByteBuf byteBuf, final GraphBinaryReader final String gremlin = context.readValue(buffer, String.class, false); - final RequestMessageV4.Builder builder = RequestMessageV4.build(gremlin); - if (fields.containsKey(SerTokensV4.TOKEN_LANGUAGE)) { - builder.addLanguage(fields.get(SerTokensV4.TOKEN_LANGUAGE).toString()); + final RequestMessage.Builder builder = RequestMessage.build(gremlin); + if (fields.containsKey(SerTokens.TOKEN_LANGUAGE)) { + builder.addLanguage(fields.get(SerTokens.TOKEN_LANGUAGE).toString()); } - if (fields.containsKey(SerTokensV4.TOKEN_G)) { - builder.addG(fields.get(SerTokensV4.TOKEN_G).toString()); + if (fields.containsKey(SerTokens.TOKEN_G)) { + builder.addG(fields.get(SerTokens.TOKEN_G).toString()); } - if (fields.containsKey(SerTokensV4.TOKEN_BINDINGS)) { - builder.addBindings((Map) fields.get(SerTokensV4.TOKEN_BINDINGS)); + if (fields.containsKey(SerTokens.TOKEN_BINDINGS)) { + builder.addBindings((Map) fields.get(SerTokens.TOKEN_BINDINGS)); } - if (fields.containsKey(TokensV4.TIMEOUT_MS)) { - builder.addTimeoutMillis((long) fields.get(TokensV4.TIMEOUT_MS)); + if (fields.containsKey(Tokens.TIMEOUT_MS)) { + builder.addTimeoutMillis((long) fields.get(Tokens.TIMEOUT_MS)); } - if (fields.containsKey(TokensV4.ARGS_MATERIALIZE_PROPERTIES)) { - builder.addMaterializeProperties(fields.get(TokensV4.ARGS_MATERIALIZE_PROPERTIES).toString()); + if (fields.containsKey(Tokens.ARGS_MATERIALIZE_PROPERTIES)) { + builder.addMaterializeProperties(fields.get(Tokens.ARGS_MATERIALIZE_PROPERTIES).toString()); } - if (fields.containsKey(TokensV4.ARGS_BATCH_SIZE)) { - builder.addChunkSize((int) fields.get(TokensV4.ARGS_BATCH_SIZE)); + if (fields.containsKey(Tokens.ARGS_BATCH_SIZE)) { + builder.addChunkSize((int) fields.get(Tokens.ARGS_BATCH_SIZE)); } return builder.create(); @@ -77,7 +77,7 @@ public RequestMessageV4 readValue(final ByteBuf byteBuf, final GraphBinaryReader } } - public void writeValue(final RequestMessageV4 value, final ByteBuf byteBuf, final GraphBinaryWriter context) throws SerializationException { + public void writeValue(final RequestMessage value, final ByteBuf byteBuf, final GraphBinaryWriter context) throws SerializationException { // Wrap netty's buffer final Buffer buffer = bufferFactory.create(byteBuf); diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractCompatibilityTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractCompatibilityTest.java index ee31ed63812..b71333657a6 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractCompatibilityTest.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractCompatibilityTest.java @@ -25,9 +25,9 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.apache.tinkerpop.gremlin.util.TestSupport; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; -import org.apache.tinkerpop.gremlin.util.ser.SerTokensV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; +import org.apache.tinkerpop.gremlin.util.ser.SerTokens; import java.io.File; import java.io.IOException; @@ -121,8 +121,8 @@ protected void assertProperty(final Property expected, final Property actual) { assertEquals(expected.value(), actual.value()); } - protected static void assertResponseMessage(final ResponseMessageV4 resource, final ResponseMessageV4 fromStatic, - final ResponseMessageV4 recycled) { + protected static void assertResponseMessage(final ResponseMessage resource, final ResponseMessage fromStatic, + final ResponseMessage recycled) { assertEquals(resource.getStatus().getCode().code(), recycled.getStatus().getCode().code()); assertEquals(resource.getStatus().getMessage(), recycled.getStatus().getMessage()); assertEquals(resource.getStatus().getException(), recycled.getStatus().getException()); @@ -134,21 +134,21 @@ protected static void assertResponseMessage(final ResponseMessageV4 resource, fi assertEquals(resource.getResult().getData(), fromStatic.getResult().getData()); } - protected static void assertRequestMessage(final RequestMessageV4 resource, final RequestMessageV4 fromStatic, - final RequestMessageV4 recycled) { + protected static void assertRequestMessage(final RequestMessage resource, final RequestMessage fromStatic, + final RequestMessage recycled) { // Check per field rather than map equals since a new field may get added later. assertEquals(resource.getGremlin(), recycled.getGremlin()); - assertEquals(resource.getField(SerTokensV4.TOKEN_BINDINGS), recycled.getField(SerTokensV4.TOKEN_BINDINGS)); - assertEquals(resource.getField(SerTokensV4.TOKEN_LANGUAGE), recycled.getField(SerTokensV4.TOKEN_LANGUAGE)); - assertEquals(resource.getField(SerTokensV4.TOKEN_G), recycled.getField(SerTokensV4.TOKEN_G)); - assertEquals(resource.getField(SerTokensV4.TOKEN_TIMEOUT_MS), recycled.getField(SerTokensV4.TOKEN_TIMEOUT_MS)); - assertEquals(resource.getField(SerTokensV4.TOKEN_MATERIALIZE_PROPERTIES), recycled.getField(SerTokensV4.TOKEN_MATERIALIZE_PROPERTIES)); + assertEquals(resource.getField(SerTokens.TOKEN_BINDINGS), recycled.getField(SerTokens.TOKEN_BINDINGS)); + assertEquals(resource.getField(SerTokens.TOKEN_LANGUAGE), recycled.getField(SerTokens.TOKEN_LANGUAGE)); + assertEquals(resource.getField(SerTokens.TOKEN_G), recycled.getField(SerTokens.TOKEN_G)); + assertEquals(resource.getField(SerTokens.TOKEN_TIMEOUT_MS), recycled.getField(SerTokens.TOKEN_TIMEOUT_MS)); + assertEquals(resource.getField(SerTokens.TOKEN_MATERIALIZE_PROPERTIES), recycled.getField(SerTokens.TOKEN_MATERIALIZE_PROPERTIES)); assertEquals(resource.getGremlin(), fromStatic.getGremlin()); - assertEquals(resource.getField(SerTokensV4.TOKEN_BINDINGS), fromStatic.getField(SerTokensV4.TOKEN_BINDINGS)); - assertEquals(resource.getField(SerTokensV4.TOKEN_LANGUAGE), fromStatic.getField(SerTokensV4.TOKEN_LANGUAGE)); - assertEquals(resource.getField(SerTokensV4.TOKEN_G), fromStatic.getField(SerTokensV4.TOKEN_G)); - assertEquals(resource.getField(SerTokensV4.TOKEN_TIMEOUT_MS), fromStatic.getField(SerTokensV4.TOKEN_TIMEOUT_MS)); - assertEquals(resource.getField(SerTokensV4.TOKEN_MATERIALIZE_PROPERTIES), fromStatic.getField(SerTokensV4.TOKEN_MATERIALIZE_PROPERTIES)); + assertEquals(resource.getField(SerTokens.TOKEN_BINDINGS), fromStatic.getField(SerTokens.TOKEN_BINDINGS)); + assertEquals(resource.getField(SerTokens.TOKEN_LANGUAGE), fromStatic.getField(SerTokens.TOKEN_LANGUAGE)); + assertEquals(resource.getField(SerTokens.TOKEN_G), fromStatic.getField(SerTokens.TOKEN_G)); + assertEquals(resource.getField(SerTokens.TOKEN_TIMEOUT_MS), fromStatic.getField(SerTokens.TOKEN_TIMEOUT_MS)); + assertEquals(resource.getField(SerTokens.TOKEN_MATERIALIZE_PROPERTIES), fromStatic.getField(SerTokens.TOKEN_MATERIALIZE_PROPERTIES)); } } diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java index ba6ebec1545..e495b3a80ce 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java @@ -20,7 +20,6 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import org.apache.tinkerpop.gremlin.process.traversal.GremlinLang; import org.apache.tinkerpop.gremlin.process.traversal.Operator; import org.apache.tinkerpop.gremlin.process.traversal.Order; import org.apache.tinkerpop.gremlin.process.traversal.P; @@ -43,8 +42,8 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypedCompatibilityTest; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.apache.tinkerpop.gremlin.util.function.Lambda; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; import org.junit.Test; @@ -622,13 +621,13 @@ public void shouldReadWriteStandardRequestMessage() throws Exception { assumeThat("GraphBinary does not test this because Request/ResponseMessage are not actual GraphBinary types", this.getClass().equals(GraphBinaryCompatibilityTest.class), is(false)); - assumeThat("RequestMessageV4 was supported starting in GraphSONv4", + assumeThat("RequestMessage was supported starting in GraphSONv4", getCompatibility(), is("v4")); - final RequestMessageV4 resource = findModelEntryObject(resourceName); - final RequestMessageV4 fromStatic = read(readFromResource(resourceName), RequestMessageV4.class); - final RequestMessageV4 recycled = read(write(fromStatic, RequestMessageV4.class, resourceName), RequestMessageV4.class); + final RequestMessage resource = findModelEntryObject(resourceName); + final RequestMessage fromStatic = read(readFromResource(resourceName), RequestMessage.class); + final RequestMessage recycled = read(write(fromStatic, RequestMessage.class, resourceName), RequestMessage.class); assertNotSame(fromStatic, recycled); assertRequestMessage(resource, fromStatic, recycled); } @@ -640,15 +639,15 @@ public void shouldReadWriteStandardExceptionResult() throws Exception { assumeThat("GraphBinary does not test this because Request/ResponseMessage are not actual GraphBinary types", this.getClass().equals(GraphBinaryCompatibilityTest.class), is(false)); - assumeThat("ResponseMessageV4 was supported starting in GraphSONv4", + assumeThat("ResponseMessage was supported starting in GraphSONv4", getCompatibility(), is("v4")); final GraphSONMessageSerializerV4 gsSerializer = new GraphSONMessageSerializerV4(); final ByteBuf resourceInBytes = gsSerializer.writeHeader(findModelEntryObject(resourceName), new UnpooledByteBufAllocator(false)); - final ResponseMessageV4 resource = read(resourceInBytes.array(), ResponseMessageV4.class); - final ResponseMessageV4 fromStatic = read(readFromResource(resourceName), ResponseMessageV4.class); - final ResponseMessageV4 recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessageV4.class); + final ResponseMessage resource = read(resourceInBytes.array(), ResponseMessage.class); + final ResponseMessage fromStatic = read(readFromResource(resourceName), ResponseMessage.class); + final ResponseMessage recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessage.class); assertNotSame(fromStatic, recycled); assertResponseMessage(resource, fromStatic, recycled); resourceInBytes.release(); @@ -661,15 +660,15 @@ public void shouldReadWriteStandardResult() throws Exception { assumeThat("GraphBinary does not test this because Request/ResponseMessage are not actual GraphBinary types", this.getClass().equals(GraphBinaryCompatibilityTest.class), is(false)); - assumeThat("ResponseMessageV4 was supported starting in GraphSONv4", + assumeThat("ResponseMessage was supported starting in GraphSONv4", getCompatibility(), is("v4")); final GraphSONMessageSerializerV4 gsSerializer = new GraphSONMessageSerializerV4(); final ByteBuf resourceInBytes = gsSerializer.writeHeader(findModelEntryObject(resourceName), new UnpooledByteBufAllocator(false)); - final ResponseMessageV4 resource = read(resourceInBytes.array(), ResponseMessageV4.class); - final ResponseMessageV4 fromStatic = read(readFromResource(resourceName), ResponseMessageV4.class); - final ResponseMessageV4 recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessageV4.class); + final ResponseMessage resource = read(resourceInBytes.array(), ResponseMessage.class); + final ResponseMessage fromStatic = read(readFromResource(resourceName), ResponseMessage.class); + final ResponseMessage recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessage.class); assertNotSame(fromStatic, recycled); assertResponseMessage(resource, fromStatic, recycled); } diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java index b5b2782fb4c..a786886c048 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java @@ -27,8 +27,8 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.apache.tinkerpop.gremlin.structure.io.graphbinary.GraphBinaryCompatibilityTest; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphSONUntypedMessageSerializerV4; import org.junit.Test; @@ -145,13 +145,13 @@ public void shouldReadWriteStandardRequestMessage() throws Exception { assumeThat("GraphBinary does not test this because Request/ResponseMessage are not actual GraphBinary types", this.getClass().equals(GraphBinaryCompatibilityTest.class), is(false)); - assumeThat("RequestMessageV4 was supported starting in GraphSONv4", + assumeThat("RequestMessage was supported starting in GraphSONv4", getCompatibility(), is("v4-no-types")); - final RequestMessageV4 resource = findModelEntryObject(resourceName); - final RequestMessageV4 fromStatic = read(readFromResource(resourceName), RequestMessageV4.class); - final RequestMessageV4 recycled = read(write(fromStatic, RequestMessageV4.class, resourceName), RequestMessageV4.class); + final RequestMessage resource = findModelEntryObject(resourceName); + final RequestMessage fromStatic = read(readFromResource(resourceName), RequestMessage.class); + final RequestMessage recycled = read(write(fromStatic, RequestMessage.class, resourceName), RequestMessage.class); assertNotSame(fromStatic, recycled); assertRequestMessage(resource, fromStatic, recycled); } @@ -163,15 +163,15 @@ public void shouldReadWriteStandardExceptionResult() throws Exception { assumeThat("GraphBinary does not test this because Request/ResponseMessage are not actual GraphBinary types", this.getClass().equals(GraphBinaryCompatibilityTest.class), is(false)); - assumeThat("ResponseMessageV4 was supported starting in GraphSONv4", + assumeThat("ResponseMessage was supported starting in GraphSONv4", getCompatibility(), is("v4-no-types")); final GraphSONUntypedMessageSerializerV4 gsSerializer = new GraphSONUntypedMessageSerializerV4(); final ByteBuf resourceInBytes = gsSerializer.writeHeader(findModelEntryObject(resourceName), new UnpooledByteBufAllocator(false)); - final ResponseMessageV4 resource = read(resourceInBytes.array(), ResponseMessageV4.class); - final ResponseMessageV4 fromStatic = read(readFromResource(resourceName), ResponseMessageV4.class); - final ResponseMessageV4 recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessageV4.class); + final ResponseMessage resource = read(resourceInBytes.array(), ResponseMessage.class); + final ResponseMessage fromStatic = read(readFromResource(resourceName), ResponseMessage.class); + final ResponseMessage recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessage.class); assertNotSame(fromStatic, recycled); assertResponseMessage(resource, fromStatic, recycled); resourceInBytes.release(); @@ -184,15 +184,15 @@ public void shouldReadWriteStandardResult() throws Exception { assumeThat("GraphBinary does not test this because Request/ResponseMessage are not actual GraphBinary types", this.getClass().equals(GraphBinaryCompatibilityTest.class), is(false)); - assumeThat("ResponseMessageV4 was supported starting in GraphSONv4", + assumeThat("ResponseMessage was supported starting in GraphSONv4", getCompatibility(), is("v4-no-types")); final GraphSONUntypedMessageSerializerV4 gsSerializer = new GraphSONUntypedMessageSerializerV4(); final ByteBuf resourceInBytes = gsSerializer.writeHeader(findModelEntryObject(resourceName), new UnpooledByteBufAllocator(false)); - final ResponseMessageV4 resource = read(resourceInBytes.array(), ResponseMessageV4.class); - final ResponseMessageV4 fromStatic = read(readFromResource(resourceName), ResponseMessageV4.class); - final ResponseMessageV4 recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessageV4.class); + final ResponseMessage resource = read(resourceInBytes.array(), ResponseMessage.class); + final ResponseMessage fromStatic = read(readFromResource(resourceName), ResponseMessage.class); + final ResponseMessage recycled = read(write(fromStatic, HashMap.class, resourceName), ResponseMessage.class); assertNotSame(fromStatic, recycled); assertResponseMessage(resource, fromStatic, recycled); } diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java index 32d74966d61..df3cd3c807e 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java @@ -40,9 +40,9 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import java.io.File; import java.math.BigDecimal; @@ -158,20 +158,20 @@ private Model() { final Map requestBindings = new HashMap<>(); requestBindings.put("x", 1); - RequestMessageV4 requestMessage = RequestMessageV4.build("social.V(x)"). + RequestMessage requestMessage = RequestMessage.build("social.V(x)"). addBindings(requestBindings). addLanguage("gremlin-groovy"). addG("social"). addTimeoutMillis(100). - addMaterializeProperties(TokensV4.MATERIALIZE_PROPERTIES_ALL).create(); - addRequestMessageEntry(requestMessage, "Standard Request", "The following `RequestMessageV4` is an example of a request for a script evaluation with an alias that binds the `TraversalSource` of \"g\" to \"social\"."); + addMaterializeProperties(Tokens.MATERIALIZE_PROPERTIES_ALL).create(); + addRequestMessageEntry(requestMessage, "Standard Request", "The following `RequestMessage` is an example of a request for a script evaluation with an alias that binds the `TraversalSource` of \"g\" to \"social\"."); - ResponseMessageV4 responseMessage; - responseMessage = ResponseMessageV4.build(). + ResponseMessage responseMessage; + responseMessage = ResponseMessage.build(). code(HttpResponseStatus.OK). result(Collections.singletonList(graph.vertices().next())).create(); addResponseMessageEntry(responseMessage, "Standard Result", "The following `ResponseMessage` is a typical example of the typical successful response Gremlin Server will return when returning results from a script."); - responseMessage = ResponseMessageV4.build(). + responseMessage = ResponseMessage.build(). code(HttpResponseStatus.INTERNAL_SERVER_ERROR). statusMessage("some error"). exception("ServerFailStepException"). diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageV4Test.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageTest.java similarity index 56% rename from gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageV4Test.java rename to gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageTest.java index 55eaa0d3c25..4af4e141ea9 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageV4Test.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/message/RequestMessageTest.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.util.message; -import org.apache.tinkerpop.gremlin.util.TokensV4; +import org.apache.tinkerpop.gremlin.util.Tokens; import org.junit.Test; import java.util.HashMap; @@ -29,11 +29,11 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -public class RequestMessageV4Test { +public class RequestMessageTest { @Test public void shouldSetScriptGremlin() { final String script = "g.V().both()"; - final RequestMessageV4 msg = RequestMessageV4.build(script).create(); + final RequestMessage msg = RequestMessage.build(script).create(); assertEquals(script, msg.getGremlin()); } @@ -42,8 +42,8 @@ public void shouldSetBindingsWithMap() { final Map bindings = new HashMap<>(); bindings.put("a", "b"); bindings.put("g", "gmodern"); - final RequestMessageV4 msg = RequestMessageV4.build("gremlin").addBindings(bindings).create(); - assertEquals(bindings, msg.getField(TokensV4.ARGS_BINDINGS)); + final RequestMessage msg = RequestMessage.build("gremlin").addBindings(bindings).create(); + assertEquals(bindings, msg.getField(Tokens.ARGS_BINDINGS)); } @Test @@ -51,47 +51,47 @@ public void shouldSetBindingsWithKeyValue() { final Map bindings = new HashMap<>(); bindings.put("a", "b"); bindings.put("g", "gmodern"); - final RequestMessageV4 msg = RequestMessageV4.build("gremlin") + final RequestMessage msg = RequestMessage.build("gremlin") .addBinding("a", "b") .addBinding("g", "gmodern") .create(); - assertEquals(bindings, msg.getField(TokensV4.ARGS_BINDINGS)); + assertEquals(bindings, msg.getField(Tokens.ARGS_BINDINGS)); } @Test public void shouldSetLanguage() { final String language = "fake-lang"; - final RequestMessageV4 msg = RequestMessageV4.build("g").addLanguage(language).create(); - assertEquals(language, msg.getField(TokensV4.ARGS_LANGUAGE)); + final RequestMessage msg = RequestMessage.build("g").addLanguage(language).create(); + assertEquals(language, msg.getField(Tokens.ARGS_LANGUAGE)); } @Test public void shouldSetG() { final String g = "gmodern"; - final RequestMessageV4 msg = RequestMessageV4.build("g").addG(g).create(); - assertEquals(g, msg.getField(TokensV4.ARGS_G)); + final RequestMessage msg = RequestMessage.build("g").addG(g).create(); + assertEquals(g, msg.getField(Tokens.ARGS_G)); } @Test public void shouldSetTimeout() { final long timeout = 101L; - final RequestMessageV4 msg = RequestMessageV4.build("g").addTimeoutMillis(timeout).create(); - assertEquals(timeout, (long) msg.getField(TokensV4.TIMEOUT_MS)); + final RequestMessage msg = RequestMessage.build("g").addTimeoutMillis(timeout).create(); + assertEquals(timeout, (long) msg.getField(Tokens.TIMEOUT_MS)); } @Test public void shouldSetMaterializeProperties() { - final RequestMessageV4 msgWithAll = RequestMessageV4.build("g").addMaterializeProperties(TokensV4.MATERIALIZE_PROPERTIES_ALL).create(); - assertEquals(TokensV4.MATERIALIZE_PROPERTIES_ALL, msgWithAll.getField(TokensV4.ARGS_MATERIALIZE_PROPERTIES)); + final RequestMessage msgWithAll = RequestMessage.build("g").addMaterializeProperties(Tokens.MATERIALIZE_PROPERTIES_ALL).create(); + assertEquals(Tokens.MATERIALIZE_PROPERTIES_ALL, msgWithAll.getField(Tokens.ARGS_MATERIALIZE_PROPERTIES)); - final RequestMessageV4 msgWithTokens = RequestMessageV4.build("g").addMaterializeProperties(TokensV4.MATERIALIZE_PROPERTIES_TOKENS).create(); - assertEquals(TokensV4.MATERIALIZE_PROPERTIES_TOKENS, msgWithTokens.getField(TokensV4.ARGS_MATERIALIZE_PROPERTIES)); + final RequestMessage msgWithTokens = RequestMessage.build("g").addMaterializeProperties(Tokens.MATERIALIZE_PROPERTIES_TOKENS).create(); + assertEquals(Tokens.MATERIALIZE_PROPERTIES_TOKENS, msgWithTokens.getField(Tokens.ARGS_MATERIALIZE_PROPERTIES)); } @Test public void shouldErrorSettingMaterializePropertiesWithInvalidValue() { try { - final RequestMessageV4 msgWithTokens = RequestMessageV4.build("g").addMaterializeProperties("notToken").create(); + final RequestMessage msgWithTokens = RequestMessage.build("g").addMaterializeProperties("notToken").create(); fail("RequestMessage shouldn't accept notToken for materializeProperties."); } catch (Exception e) { assertTrue(e.getMessage().contains("materializeProperties argument must be either token or all")); @@ -107,44 +107,44 @@ public void shouldGetFields() { bindings.put("b", "c"); bindings.put("g", "gmodern"); - final RequestMessageV4 msg = RequestMessageV4.build(query).addG(g).addBindings(bindings).addLanguage(lang).create(); + final RequestMessage msg = RequestMessage.build(query).addG(g).addBindings(bindings).addLanguage(lang).create(); final Map fields = msg.getFields(); - assertEquals(g, fields.get(TokensV4.ARGS_G)); - assertEquals(lang, fields.get(TokensV4.ARGS_LANGUAGE)); - assertEquals(bindings, fields.get(TokensV4.ARGS_BINDINGS)); + assertEquals(g, fields.get(Tokens.ARGS_G)); + assertEquals(lang, fields.get(Tokens.ARGS_LANGUAGE)); + assertEquals(bindings, fields.get(Tokens.ARGS_BINDINGS)); assertEquals(query, msg.getGremlin()); } @Test public void shouldGetGAsArg() { final String g = "gmodern"; - final RequestMessageV4 msg = RequestMessageV4.build("g").addG(g).create(); - assertEquals(g, msg.getField(TokensV4.ARGS_G)); + final RequestMessage msg = RequestMessage.build("g").addG(g).create(); + assertEquals(g, msg.getField(Tokens.ARGS_G)); } @Test public void shouldGetGAsArgOrDefault() { - final RequestMessageV4 msg = RequestMessageV4.build("g").create(); - assertEquals("b", msg.getFieldOrDefault(TokensV4.ARGS_G, "b")); + final RequestMessage msg = RequestMessage.build("g").create(); + assertEquals("b", msg.getFieldOrDefault(Tokens.ARGS_G, "b")); } @Test public void shouldGetGAsArgAsOptional() { final String g = "gmodern"; - final RequestMessageV4 msg = RequestMessageV4.build("g").addG(g).create(); - assertEquals(g, msg.optionalField(TokensV4.ARGS_G).get()); + final RequestMessage msg = RequestMessage.build("g").addG(g).create(); + assertEquals(g, msg.optionalField(Tokens.ARGS_G).get()); } @Test public void shouldNotBeAbleToGetGremlinQueryFromArgs() { final String query = "gmodern"; - final RequestMessageV4 msg = RequestMessageV4.build(query).create(); - assertTrue(null == msg.getField(TokensV4.ARGS_GREMLIN)); + final RequestMessage msg = RequestMessage.build(query).create(); + assertTrue(null == msg.getField(Tokens.ARGS_GREMLIN)); } @Test public void shouldNotContainRequestId() { - final RequestMessageV4 msg = RequestMessageV4.build("g.V()").create(); + final RequestMessage msg = RequestMessage.build("g.V()").create(); assertNull(msg.getField("requestId")); } } diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4RoundTripTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4RoundTripTest.java index e497056702c..0b3c5abce55 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4RoundTripTest.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4RoundTripTest.java @@ -22,7 +22,7 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.handler.codec.http.HttpResponseStatus; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.junit.Test; import java.util.Arrays; @@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals; public class GraphSONMessageSerializerV4RoundTripTest extends AbstractRoundTripTest { - private final ResponseMessageV4.Builder responseMessageBuilder = ResponseMessageV4.build(); + private final ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(); private final static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT; public final GraphSONMessageSerializerV4 serializer = new GraphSONMessageSerializerV4(); diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4Test.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4Test.java index 1fd82dc76d0..634c905b42c 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4Test.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONMessageSerializerV4Test.java @@ -29,9 +29,9 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONXModuleV3; import org.apache.tinkerpop.gremlin.structure.io.graphson.TinkerPopJacksonModule; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseResultV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseResult; import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator; import org.apache.tinkerpop.shaded.jackson.core.JsonParser; import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException; @@ -59,18 +59,18 @@ public class GraphSONMessageSerializerV4Test { private final static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT; - private final ResponseMessageV4.Builder responseMessageBuilder = ResponseMessageV4.build(); + private final ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(); private final GraphSONMessageSerializerV4 serializer = new GraphSONMessageSerializerV4(); private final ObjectMapper mapper = new ObjectMapper(); @Test public void shouldSerializeChunkedResponseMessage() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(Arrays.asList("header", 0)) .create(); - final ResponseMessageV4 footer = ResponseMessageV4.build() + final ResponseMessage footer = ResponseMessage.build() .result(Arrays.asList("footer", 3)) .code(HttpResponseStatus.OK) .statusMessage("OK") @@ -95,7 +95,7 @@ public void shouldSerializeChunkedResponseMessage() throws SerializationExceptio // a message composed of all chunks must be deserialized bbCombined.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bbCombined); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bbCombined); assertEquals(200, deserialized.getStatus().getCode().code()); assertEquals("OK", deserialized.getStatus().getMessage()); assertEquals(8, ((List)deserialized.getResult().getData()).size()); @@ -103,7 +103,7 @@ public void shouldSerializeChunkedResponseMessage() throws SerializationExceptio @Test public void shouldSerializeResponseMessageWithoutData() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .code(HttpResponseStatus.OK) .statusMessage("OK") .create(); @@ -119,7 +119,7 @@ public void shouldSerializeResponseMessageWithoutData() throws SerializationExce assertEquals(200, node.get("status").get("code").asInt()); bb0.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bb0); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bb0); assertEquals(200, deserialized.getStatus().getCode().code()); assertEquals("OK", deserialized.getStatus().getMessage()); assertEquals(0, ((List)deserialized.getResult().getData()).size()); @@ -127,7 +127,7 @@ public void shouldSerializeResponseMessageWithoutData() throws SerializationExce @Test public void shouldSerializeChunkedResponseMessageWithEmptyData() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(new ArrayList<>()) .code(HttpResponseStatus.OK) .statusMessage("OK") @@ -144,7 +144,7 @@ public void shouldSerializeChunkedResponseMessageWithEmptyData() throws Serializ assertEquals(200, node.get("status").get("code").asInt()); bb0.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bb0); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bb0); assertEquals(200, deserialized.getStatus().getCode().code()); assertEquals("OK", deserialized.getStatus().getMessage()); assertEquals(0, ((List)deserialized.getResult().getData()).size()); @@ -152,11 +152,11 @@ public void shouldSerializeChunkedResponseMessageWithEmptyData() throws Serializ @Test public void shouldSerializeChunkedResponseMessageWithError() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(Arrays.asList("header", 0)) .create(); - final ResponseMessageV4 footer = ResponseMessageV4.build() + final ResponseMessage footer = ResponseMessage.build() .result(Arrays.asList("footer", 3)) .code(HttpResponseStatus.INTERNAL_SERVER_ERROR) .statusMessage("SERVER_ERROR") @@ -180,7 +180,7 @@ public void shouldSerializeChunkedResponseMessageWithError() throws Serializatio assertEquals(500, node.get("status").get("code").asInt()); bbCombined.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bbCombined); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bbCombined); assertEquals(500, deserialized.getStatus().getCode().code()); assertEquals("SERVER_ERROR", deserialized.getStatus().getMessage()); assertEquals(6, ((List)deserialized.getResult().getData()).size()); @@ -190,14 +190,14 @@ public void shouldSerializeChunkedResponseMessageWithError() throws Serializatio public void shouldConfigureIoRegistry() throws Exception { final GraphSONMessageSerializerV4 serializer = new GraphSONMessageSerializerV4(); final Map config = new HashMap() {{ - put(AbstractMessageSerializerV4.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistry.class.getName())); + put(AbstractMessageSerializer.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistry.class.getName())); }}; serializer.configure(config, null); - final ResponseMessageV4 toSerialize = ResponseMessageV4.build().result(Collections.singletonList(Color.RED)).code(HttpResponseStatus.OK).create(); + final ResponseMessage toSerialize = ResponseMessage.build().result(Collections.singletonList(Color.RED)).code(HttpResponseStatus.OK).create(); final ByteBuf buffer = serializer.serializeResponseAsBinary(toSerialize, allocator); - ResponseResultV4 results = serializer.deserializeBinaryResponse(buffer).getResult(); + ResponseResult results = serializer.deserializeBinaryResponse(buffer).getResult(); assertEquals(Color.RED, results.getData().get(0)); } @@ -265,11 +265,11 @@ public void shouldRegisterGremlinServerModuleAutomaticallyWithMapper() throws Se GraphSONMapper.Builder builder = GraphSONMapper.build().version(GraphSONVersion.V4_0).addCustomModule(GraphSONXModuleV3.build()); GraphSONMessageSerializerV4 graphSONMessageSerializerV4 = new GraphSONMessageSerializerV4(builder); - ResponseMessageV4 rm = convert("hello", graphSONMessageSerializerV4); + ResponseMessage rm = convert("hello", graphSONMessageSerializerV4); assertEquals(rm.getResult().getData().get(0), "hello"); } - private ResponseMessageV4 convert(final Object toSerialize, MessageSerializerV4 serializer) throws SerializationException { + private ResponseMessage convert(final Object toSerialize, MessageSerializer serializer) throws SerializationException { final ByteBuf bb = serializer.serializeResponseAsBinary( responseMessageBuilder.result(Collections.singletonList(toSerialize)).code(HttpResponseStatus.OK).create(), allocator); return serializer.deserializeBinaryResponse(bb); diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4Test.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4Test.java index 483bd10c6f3..1c2aa3d80f5 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4Test.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/GraphSONUntypedMessageSerializerV4Test.java @@ -23,7 +23,7 @@ import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.CharsetUtil; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException; import org.apache.tinkerpop.shaded.jackson.databind.JsonNode; import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; @@ -38,18 +38,18 @@ public class GraphSONUntypedMessageSerializerV4Test { - private final ResponseMessageV4.Builder responseMessageBuilder = ResponseMessageV4.build(); + private final ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(); private final GraphSONUntypedMessageSerializerV4 serializer = new GraphSONUntypedMessageSerializerV4(); private final static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT; private final ObjectMapper mapper = new ObjectMapper(); @Test public void shouldSerializeChunkedResponseMessage() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(Arrays.asList("header", 0)) .create(); - final ResponseMessageV4 footer = ResponseMessageV4.build() + final ResponseMessage footer = ResponseMessage.build() .result(Arrays.asList("footer", 3)) .code(HttpResponseStatus.OK) .create(); @@ -73,7 +73,7 @@ public void shouldSerializeChunkedResponseMessage() throws SerializationExceptio // a message composed of all chunks must be deserialized bbCombined.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bbCombined); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bbCombined); assertEquals(200, deserialized.getStatus().getCode().code()); assertEquals(null, deserialized.getStatus().getMessage()); assertEquals(8, ((List)deserialized.getResult().getData()).size()); @@ -81,7 +81,7 @@ public void shouldSerializeChunkedResponseMessage() throws SerializationExceptio @Test public void shouldSerializeResponseMessageWithoutData() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .code(HttpResponseStatus.OK) .create(); @@ -96,7 +96,7 @@ public void shouldSerializeResponseMessageWithoutData() throws SerializationExce assertEquals(200, node.get("status").get("code").asInt()); bb0.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bb0); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bb0); assertEquals(200, deserialized.getStatus().getCode().code()); assertEquals(null, deserialized.getStatus().getMessage()); assertEquals(0, ((List)deserialized.getResult().getData()).size()); @@ -104,7 +104,7 @@ public void shouldSerializeResponseMessageWithoutData() throws SerializationExce @Test public void shouldSerializeChunkedResponseMessageWithEmptyData() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(new ArrayList<>()) .code(HttpResponseStatus.OK) .statusMessage("OK") @@ -121,7 +121,7 @@ public void shouldSerializeChunkedResponseMessageWithEmptyData() throws Serializ assertEquals(200, node.get("status").get("code").asInt()); bb0.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bb0); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bb0); assertEquals(200, deserialized.getStatus().getCode().code()); assertEquals("OK", deserialized.getStatus().getMessage()); assertEquals(0, ((List)deserialized.getResult().getData()).size()); @@ -129,11 +129,11 @@ public void shouldSerializeChunkedResponseMessageWithEmptyData() throws Serializ @Test public void shouldSerializeChunkedResponseMessageWithError() throws SerializationException, JsonProcessingException { - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(Arrays.asList("header", 0)) .create(); - final ResponseMessageV4 footer = ResponseMessageV4.build() + final ResponseMessage footer = ResponseMessage.build() .result(Arrays.asList("footer", 3)) .code(HttpResponseStatus.INTERNAL_SERVER_ERROR) .statusMessage("SERVER_ERROR") @@ -157,7 +157,7 @@ public void shouldSerializeChunkedResponseMessageWithError() throws Serializatio assertEquals(500, node.get("status").get("code").asInt()); bbCombined.resetReaderIndex(); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(bbCombined); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(bbCombined); assertEquals(500, deserialized.getStatus().getCode().code()); assertEquals("SERVER_ERROR", deserialized.getStatus().getMessage()); assertEquals(6, ((List)deserialized.getResult().getData()).size()); diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/GraphBinaryMessageSerializerV4Test.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/GraphBinaryMessageSerializerV4Test.java index 6d28f1c74e8..a12c1ba670e 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/GraphBinaryMessageSerializerV4Test.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/GraphBinaryMessageSerializerV4Test.java @@ -22,7 +22,7 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.handler.codec.http.HttpResponseStatus; import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; import org.junit.Test; @@ -54,24 +54,24 @@ public TypeSerializerRegistry create() { @Test public void shouldSerializeAndDeserializeResponseInSingleChunk() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .code(HttpResponseStatus.OK) .result(Arrays.asList(1, "test")) .create(); final ByteBuf buffer = serializer.writeHeader(response, allocator); - final ResponseMessageV4 deserialized = serializer.readChunk(buffer, true); + final ResponseMessage deserialized = serializer.readChunk(buffer, true); assertResponseEquals(response, deserialized); } @Test public void shouldSerializeAndDeserializeResponseInHeaderChunk() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .result(Arrays.asList(1, "test")) .create(); final ByteBuf buffer = serializer.writeHeader(response, allocator); - final ResponseMessageV4 deserialized = serializer.readChunk(buffer, true); + final ResponseMessage deserialized = serializer.readChunk(buffer, true); assertResponseEquals(response, deserialized); } @@ -79,40 +79,40 @@ public void shouldSerializeAndDeserializeResponseInHeaderChunk() throws Serializ public void shouldSerializeAndDeserializeResponseInDataChunk() throws SerializationException { final List data = Arrays.asList(1, "test"); final ByteBuf buffer = serializer.writeChunk(data, allocator); - final ResponseMessageV4 deserialized = serializer.readChunk(buffer, false); + final ResponseMessage deserialized = serializer.readChunk(buffer, false); assertEquals(data, deserialized.getResult().getData()); } @Test public void shouldSerializeAndDeserializeResponseInFooterChunk() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .result(Arrays.asList(1, "test")) .code(HttpResponseStatus.OK) .statusMessage("OK") .create(); final ByteBuf buffer = serializer.writeFooter(response, allocator); - final ResponseMessageV4 deserialized = serializer.readChunk(buffer, false); + final ResponseMessage deserialized = serializer.readChunk(buffer, false); assertResponseEquals(response, deserialized); } @Test public void shouldSerializeAndDeserializeErrorResponseWithEmptyData() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .code(HttpResponseStatus.FORBIDDEN) .statusMessage("FORBIDDEN") .create(); final ByteBuf buffer = serializer.writeHeader(response, allocator); - final ResponseMessageV4 deserialized = serializer.readChunk(buffer, true); + final ResponseMessage deserialized = serializer.readChunk(buffer, true); assertResponseEquals(response, deserialized); } @Test public void shouldSerializeAndDeserializeCompositeResponse() throws SerializationException { final List headerData = Arrays.asList(0, "header"); - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(headerData) .create(); @@ -120,7 +120,7 @@ public void shouldSerializeAndDeserializeCompositeResponse() throws Serializatio final List chunkData2 = Arrays.asList(2, "data2"); final List footerData = Arrays.asList(0xFF, "footer"); - final ResponseMessageV4 footer = ResponseMessageV4.build() + final ResponseMessage footer = ResponseMessage.build() .result(footerData) .code(HttpResponseStatus.OK) .statusMessage("OK") @@ -133,7 +133,7 @@ public void shouldSerializeAndDeserializeCompositeResponse() throws Serializatio final ByteBuf bbCombined = allocator.buffer().writeBytes(bb0).writeBytes(bb1).writeBytes(bb2).writeBytes(bb3); - final ResponseMessageV4 deserialized = serializer.readChunk(bbCombined, true); + final ResponseMessage deserialized = serializer.readChunk(bbCombined, true); // Status assertEquals(footer.getStatus().getCode(), deserialized.getStatus().getCode()); @@ -147,7 +147,7 @@ public void shouldSerializeAndDeserializeCompositeResponse() throws Serializatio @Test public void shouldSerializeAndDeserializeCompositeResponseWithError() throws SerializationException { final List headerData = Arrays.asList(0, "header"); - final ResponseMessageV4 header = ResponseMessageV4.build() + final ResponseMessage header = ResponseMessage.build() .result(headerData) .create(); @@ -155,7 +155,7 @@ public void shouldSerializeAndDeserializeCompositeResponseWithError() throws Ser final List chunkData2 = Arrays.asList(2, "data2"); final List footerData = Arrays.asList(0xFF, "footer"); - final ResponseMessageV4 footer = ResponseMessageV4.build() + final ResponseMessage footer = ResponseMessage.build() .result(footerData) .code(HttpResponseStatus.INTERNAL_SERVER_ERROR) .statusMessage("SERVER_ERROR") @@ -169,7 +169,7 @@ public void shouldSerializeAndDeserializeCompositeResponseWithError() throws Ser final ByteBuf bbCombined = allocator.buffer().writeBytes(bb0).writeBytes(bb1).writeBytes(bb2).writeBytes(bb3); - final ResponseMessageV4 deserialized = serializer.readChunk(bbCombined, true); + final ResponseMessage deserialized = serializer.readChunk(bbCombined, true); // Status assertEquals(footer.getStatus().getCode(), deserialized.getStatus().getCode()); @@ -203,7 +203,7 @@ public void shouldThrowWhenConfigurationOfRegistryBuilderFails() { } // copy-paste because response format will be different - private static void assertResponseEquals(final ResponseMessageV4 expected, final ResponseMessageV4 actual) { + private static void assertResponseEquals(final ResponseMessage expected, final ResponseMessage actual) { // Status if (expected.getStatus() != null && actual.getStatus() != null) { assertEquals(expected.getStatus().getCode(), actual.getStatus().getCode()); @@ -216,7 +216,7 @@ private static void assertResponseEquals(final ResponseMessageV4 expected, final } } - private static boolean isEmptyData(final ResponseMessageV4 responseMessage) { + private static boolean isEmptyData(final ResponseMessage responseMessage) { return responseMessage.getResult() == null || responseMessage.getResult().getData() == null || responseMessage.getResult().getData().isEmpty(); } diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/MessageSerializerV4Test.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/MessageSerializerTest.java similarity index 75% rename from gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/MessageSerializerV4Test.java rename to gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/MessageSerializerTest.java index f160224cffa..251cc8d1be8 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/MessageSerializerV4Test.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/MessageSerializerTest.java @@ -24,14 +24,14 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; -import org.apache.tinkerpop.gremlin.util.MessageSerializerV4; -import org.apache.tinkerpop.gremlin.util.TokensV4; -import org.apache.tinkerpop.gremlin.util.message.RequestMessageV4; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.Tokens; +import org.apache.tinkerpop.gremlin.util.message.RequestMessage; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4; import org.apache.tinkerpop.gremlin.util.ser.SerializationException; -import org.apache.tinkerpop.gremlin.util.ser.SerializersV4; +import org.apache.tinkerpop.gremlin.util.ser.Serializers; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -46,22 +46,22 @@ import static org.junit.Assert.assertEquals; @RunWith(Parameterized.class) -public class MessageSerializerV4Test { +public class MessageSerializerTest { private final ByteBufAllocator allocator = ByteBufAllocator.DEFAULT; @Parameterized.Parameters(name = "{0}") public static Iterable data() { return Arrays.asList(new Object[][]{ - {SerializersV4.GRAPHBINARY_V4, new GraphBinaryMessageSerializerV4()}, - {SerializersV4.GRAPHSON_V4, new GraphSONMessageSerializerV4()} + {Serializers.GRAPHBINARY_V4, new GraphBinaryMessageSerializerV4()}, + {Serializers.GRAPHSON_V4, new GraphSONMessageSerializerV4()} }); } @Parameterized.Parameter(0) - public SerializersV4 serializerType; + public Serializers serializerType; @Parameterized.Parameter(1) - public MessageSerializerV4 serializer; + public MessageSerializer serializer; @Test public void shouldSerializeAndDeserializeRequest() throws SerializationException { @@ -71,8 +71,8 @@ public void shouldSerializeAndDeserializeRequest() throws SerializationException final Map aliases = new HashMap<>(); aliases.put("g","g"); - final RequestMessageV4 request = RequestMessageV4.build(t.getGremlinLang().getGremlin()) - .addMaterializeProperties(TokensV4.MATERIALIZE_PROPERTIES_TOKENS) + final RequestMessage request = RequestMessage.build(t.getGremlinLang().getGremlin()) + .addMaterializeProperties(Tokens.MATERIALIZE_PROPERTIES_TOKENS) .addTimeoutMillis(500) .addG("g1") .addLanguage("some-lang") @@ -80,69 +80,69 @@ public void shouldSerializeAndDeserializeRequest() throws SerializationException .create(); final ByteBuf buffer = serializer.serializeRequestAsBinary(request, allocator); - final RequestMessageV4 deserialized = serializer.deserializeBinaryRequest(buffer); + final RequestMessage deserialized = serializer.deserializeBinaryRequest(buffer); assertThat(request, reflectionEquals(deserialized)); } @Test public void shouldSerializeAndDeserializeRequestWithoutArgs() throws SerializationException { - final RequestMessageV4 request = RequestMessageV4.build("query").create(); + final RequestMessage request = RequestMessage.build("query").create(); final ByteBuf buffer = serializer.serializeRequestAsBinary(request, allocator); - final RequestMessageV4 deserialized = serializer.deserializeBinaryRequest(buffer); + final RequestMessage deserialized = serializer.deserializeBinaryRequest(buffer); assertThat(request, reflectionEquals(deserialized)); } @Test public void shouldSerializeAndDeserializeResponse() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .code(HttpResponseStatus.OK) .statusMessage("Found") .result(Collections.singletonList("This is a fine message with a string")) .create(); final ByteBuf buffer = serializer.serializeResponseAsBinary(response, allocator); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(buffer); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(buffer); assertResponseEquals(response, deserialized); } @Test public void shouldSerializeAndDeserializeResponseWithoutStatusMessage() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .code(HttpResponseStatus.OK) .result(Collections.singletonList(123.3)) .create(); final ByteBuf buffer = serializer.serializeResponseAsBinary(response, allocator); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(buffer); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(buffer); assertResponseEquals(response, deserialized); } @Test public void shouldSerializeAndDeserializeResponseWithoutStatusAttributes() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .code(HttpResponseStatus.OK) .result(Collections.singletonList(123.3)) .create(); final ByteBuf buffer = serializer.serializeResponseAsBinary(response, allocator); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(buffer); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(buffer); assertResponseEquals(response, deserialized); } @Test public void shouldSerializeAndDeserializeResponseWithoutResult() throws SerializationException { - final ResponseMessageV4 response = ResponseMessageV4.build() + final ResponseMessage response = ResponseMessage.build() .code(HttpResponseStatus.INTERNAL_SERVER_ERROR) .statusMessage("Something happened on the server") .create(); final ByteBuf buffer = serializer.serializeResponseAsBinary(response, allocator); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(buffer); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(buffer); assertResponseEquals(response, deserialized); } - private static void assertResponseEquals(ResponseMessageV4 expected, ResponseMessageV4 actual) { + private static void assertResponseEquals(ResponseMessage expected, ResponseMessage actual) { // Status assertEquals(expected.getStatus().getCode(), actual.getStatus().getCode()); assertEquals(expected.getStatus().getMessage(), actual.getStatus().getMessage()); diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/types/sample/SamplePersonSerializerTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/types/sample/SamplePersonSerializerTest.java index 466c2943ce9..9e393a69acd 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/types/sample/SamplePersonSerializerTest.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/types/sample/SamplePersonSerializerTest.java @@ -22,7 +22,7 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.handler.codec.http.HttpResponseStatus; import org.apache.tinkerpop.gremlin.util.ser.NettyBufferFactory; -import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4; +import org.apache.tinkerpop.gremlin.util.message.ResponseMessage; import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4; import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry; import org.apache.tinkerpop.gremlin.structure.io.Buffer; @@ -41,7 +41,7 @@ import java.util.Map; import static org.apache.tinkerpop.gremlin.util.MockitoHamcrestMatcherAdapter.reflectionEquals; -import static org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializerV4.TOKEN_IO_REGISTRIES; +import static org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializer.TOKEN_IO_REGISTRIES; import static org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4.TOKEN_CUSTOM; import static org.hamcrest.MatcherAssert.assertThat; @@ -103,9 +103,9 @@ private void assertPerson(final GraphBinaryMessageSerializerV4 serializer) throw final SamplePerson person = new SamplePerson("Olivia", birthDate); final ByteBuf serialized = serializer.serializeResponseAsBinary( - ResponseMessageV4.build().result(Collections.singletonList(person)).code(HttpResponseStatus.OK).create(), allocator); + ResponseMessage.build().result(Collections.singletonList(person)).code(HttpResponseStatus.OK).create(), allocator); - final ResponseMessageV4 deserialized = serializer.deserializeBinaryResponse(serialized); + final ResponseMessage deserialized = serializer.deserializeBinaryResponse(serialized); final SamplePerson actual = (SamplePerson) deserialized.getResult().getData().get(0); assertThat(actual, reflectionEquals(person));