addProxyExecuteEntry(
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/config/DseDriverOption.java b/core/src/main/java/com/datastax/dse/driver/api/core/config/DseDriverOption.java
index 4d10501f6d2..0071b4c4d20 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/config/DseDriverOption.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/config/DseDriverOption.java
@@ -126,47 +126,53 @@ public enum DseDriverOption implements DriverOption {
"advanced.metrics.session.continuous-cql-requests.refresh-interval"),
/**
- * The read consistency level to use for graph statements.
+ * This option is ignored because DSE Graph support has been removed.
*
- * Value type: {@link String}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_READ_CONSISTENCY_LEVEL("basic.graph.read-consistency-level"),
/**
- * The write consistency level to use for graph statements.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link String}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_WRITE_CONSISTENCY_LEVEL("basic.graph.write-consistency-level"),
/**
- * The traversal source to use for graph statements.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link String}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_TRAVERSAL_SOURCE("basic.graph.traversal-source"),
/**
- * The sub-protocol the driver will use to communicate with DSE Graph, on top of the Cassandra
- * native protocol.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link String}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_SUB_PROTOCOL("advanced.graph.sub-protocol"),
/**
- * Whether a script statement represents a system query.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: boolean
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_IS_SYSTEM_QUERY("basic.graph.is-system-query"),
/**
- * The name of the graph targeted by graph statements.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link String}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_NAME("basic.graph.name"),
/**
- * How long the driver waits for a graph request to complete.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_TIMEOUT("basic.graph.timeout"),
/**
@@ -177,77 +183,84 @@ public enum DseDriverOption implements DriverOption {
MONITOR_REPORTING_ENABLED("advanced.monitor-reporting.enabled"),
/**
- * Whether to enable paging for Graph queries.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link String}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_PAGING_ENABLED("advanced.graph.paging-enabled"),
-
/**
- * The page size for Graph continuous paging.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: int
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_CONTINUOUS_PAGING_PAGE_SIZE("advanced.graph.paging-options.page-size"),
-
/**
- * The maximum number of Graph continuous pages to return.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: int
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_CONTINUOUS_PAGING_MAX_PAGES("advanced.graph.paging-options.max-pages"),
/**
- * The maximum number of Graph continuous pages per second.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: int
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_CONTINUOUS_PAGING_MAX_PAGES_PER_SECOND(
"advanced.graph.paging-options.max-pages-per-second"),
/**
- * The maximum number of Graph continuous pages that can be stored in the local queue.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: int
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES("advanced.graph.paging-options.max-enqueued-pages"),
/**
- * The largest latency that we expect to record for graph requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_SESSION_GRAPH_REQUESTS_HIGHEST("advanced.metrics.session.graph-requests.highest-latency"),
/**
- * The number of significant decimal digits to which internal structures will maintain for graph
- * requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: int
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_SESSION_GRAPH_REQUESTS_DIGITS(
"advanced.metrics.session.graph-requests.significant-digits"),
/**
- * The interval at which percentile data is refreshed for graph requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_SESSION_GRAPH_REQUESTS_INTERVAL(
"advanced.metrics.session.graph-requests.refresh-interval"),
/**
- * The largest latency that we expect to record for graph requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_NODE_GRAPH_MESSAGES_HIGHEST("advanced.metrics.node.graph-messages.highest-latency"),
/**
- * The number of significant decimal digits to which internal structures will maintain for graph
- * requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: int
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_NODE_GRAPH_MESSAGES_DIGITS("advanced.metrics.node.graph-messages.significant-digits"),
/**
- * The interval at which percentile data is refreshed for graph requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_NODE_GRAPH_MESSAGES_INTERVAL("advanced.metrics.node.graph-messages.refresh-interval"),
/**
@@ -266,48 +279,50 @@ public enum DseDriverOption implements DriverOption {
"advanced.metrics.session.continuous-cql-requests.slo"),
/**
- * The shortest latency that we expect to record for graph requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_SESSION_GRAPH_REQUESTS_LOWEST("advanced.metrics.session.graph-requests.lowest-latency"),
/**
- * Optional service-level objectives to meet, as a list of latencies to track.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_SESSION_GRAPH_REQUESTS_SLO("advanced.metrics.session.graph-requests.slo"),
-
/**
- * The shortest latency that we expect to record for graph requests.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_NODE_GRAPH_MESSAGES_LOWEST("advanced.metrics.node.graph-messages.lowest-latency"),
/**
- * Optional service-level objectives to meet, as a list of latencies to track.
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value-type: {@link java.time.Duration Duration}
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_NODE_GRAPH_MESSAGES_SLO("advanced.metrics.node.graph-messages.slo"),
/**
- * Optional list of percentiles to publish for graph-requests metric. Produces an additional time
- * series for each requested percentile. This percentile is computed locally, and so can't be
- * aggregated with percentiles computed across other dimensions (e.g. in a different instance).
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link java.util.List List}<{@link Double}>
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_SESSION_GRAPH_REQUESTS_PUBLISH_PERCENTILES(
"advanced.metrics.session.graph-requests.publish-percentiles"),
/**
- * Optional list of percentiles to publish for node graph-messages metric. Produces an additional
- * time series for each requested percentile. This percentile is computed locally, and so can't be
- * aggregated with percentiles computed across other dimensions (e.g. in a different instance).
+ * This option is ignored because DSE Graph support has been removed.
*
- *
Value type: {@link java.util.List List}<{@link Double}>
+ * @deprecated DSE Graph is no longer supported.
*/
+ @Deprecated
METRICS_NODE_GRAPH_MESSAGES_PUBLISH_PERCENTILES(
"advanced.metrics.node.graph-messages.publish-percentiles"),
+
/**
* Optional list of percentiles to publish for continuous paging requests metric. Produces an
* additional time series for each requested percentile. This percentile is computed locally, and
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/AsyncGraphResultSet.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/AsyncGraphResultSet.java
index 995de53959b..f91db9f8a38 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/AsyncGraphResultSet.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/AsyncGraphResultSet.java
@@ -17,7 +17,7 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.GraphExecutionInfoConverter;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
@@ -34,13 +34,16 @@
* concurrently).
*
* @see GraphResultSet
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface AsyncGraphResultSet {
/** The execution information for this page of results. */
@NonNull
default ExecutionInfo getRequestExecutionInfo() {
- return GraphExecutionInfoConverter.convert(getExecutionInfo());
+ throw GraphSupportRemoved.exception();
}
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatement.java
index 2169dc5f053..8640e7476d4 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatement.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatement.java
@@ -17,11 +17,8 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.DefaultBatchGraphStatement;
-import com.datastax.oss.driver.api.core.cql.Statement;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Collections;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
/**
@@ -54,7 +51,10 @@
* }
*
* @see DseGraph#g
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface BatchGraphStatement
extends GraphStatement, Iterable {
@@ -65,47 +65,19 @@ public interface BatchGraphStatement
*/
@NonNull
static BatchGraphStatement newInstance() {
- return new DefaultBatchGraphStatement(
- ImmutableList.of(),
- null,
- null,
- null,
- Statement.NO_DEFAULT_TIMESTAMP,
- null,
- null,
- Collections.emptyMap(),
- null,
- null,
- null,
- null,
- null,
- null);
+ throw GraphSupportRemoved.exception();
}
/** Create a new instance from the given list of traversals. */
@NonNull
static BatchGraphStatement newInstance(@NonNull Iterable traversals) {
- return new DefaultBatchGraphStatement(
- traversals,
- null,
- null,
- null,
- Statement.NO_DEFAULT_TIMESTAMP,
- null,
- null,
- Collections.emptyMap(),
- null,
- null,
- null,
- null,
- null,
- null);
+ throw GraphSupportRemoved.exception();
}
/** Create a new instance from the given list of traversals. */
@NonNull
static BatchGraphStatement newInstance(@NonNull GraphTraversal... traversals) {
- return newInstance(ImmutableList.copyOf(traversals));
+ throw GraphSupportRemoved.exception();
}
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatementBuilder.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatementBuilder.java
index ac1b85bdc71..6aa1ce58a76 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatementBuilder.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/BatchGraphStatementBuilder.java
@@ -17,8 +17,7 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.DefaultBatchGraphStatement;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
import net.jcip.annotations.NotThreadSafe;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -27,30 +26,28 @@
* A builder to create a batch graph statement.
*
* This class is mutable and not thread-safe.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
@NotThreadSafe
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public class BatchGraphStatementBuilder
extends GraphStatementBuilderBase {
- private ImmutableList.Builder traversalsBuilder = ImmutableList.builder();
- private int traversalsCount;
-
public BatchGraphStatementBuilder() {
- // nothing to do
+ throw GraphSupportRemoved.exception();
}
public BatchGraphStatementBuilder(BatchGraphStatement template) {
super(template);
- traversalsBuilder.addAll(template);
- traversalsCount = template.size();
+ throw GraphSupportRemoved.exception();
}
/** Add a traversal to this builder to include in the generated {@link BatchGraphStatement}. */
@NonNull
public BatchGraphStatementBuilder addTraversal(@NonNull GraphTraversal traversal) {
- traversalsBuilder.add(traversal);
- traversalsCount += 1;
- return this;
+ throw GraphSupportRemoved.exception();
}
/**
@@ -58,11 +55,7 @@ public BatchGraphStatementBuilder addTraversal(@NonNull GraphTraversal traversal
*/
@NonNull
public BatchGraphStatementBuilder addTraversals(@NonNull Iterable traversals) {
- for (GraphTraversal traversal : traversals) {
- traversalsBuilder.add(traversal);
- traversalsCount += 1;
- }
- return this;
+ throw GraphSupportRemoved.exception();
}
/**
@@ -70,43 +63,23 @@ public BatchGraphStatementBuilder addTraversals(@NonNull Iterable
*
* @see CqlSession
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface DseGraphRemoteConnectionBuilder {
/** Build the remote connection that was configured with this builder. */
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatement.java
index 051c6501c65..84bf30dd95a 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatement.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatement.java
@@ -17,10 +17,8 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.DefaultFluentGraphStatement;
-import com.datastax.oss.driver.api.core.cql.Statement;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Collections;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
/**
@@ -37,7 +35,10 @@
* }
*
* @see DseGraph#g
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface FluentGraphStatement extends GraphStatement {
/**
@@ -48,21 +49,7 @@ public interface FluentGraphStatement extends GraphStatement traversal) {
- return new DefaultFluentGraphStatement(
- traversal,
- null,
- null,
- null,
- Statement.NO_DEFAULT_TIMESTAMP,
- null,
- null,
- Collections.emptyMap(),
- null,
- null,
- null,
- null,
- null,
- null);
+ throw GraphSupportRemoved.exception();
}
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatementBuilder.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatementBuilder.java
index 59e588c564a..c4d251d8f1f 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatementBuilder.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/FluentGraphStatementBuilder.java
@@ -17,7 +17,7 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.DefaultFluentGraphStatement;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
import net.jcip.annotations.NotThreadSafe;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -26,39 +26,27 @@
* A builder to create a fluent graph statement.
*
* This class is mutable and not thread-safe.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
@NotThreadSafe
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public class FluentGraphStatementBuilder
extends GraphStatementBuilderBase {
- private GraphTraversal, ?> traversal;
-
public FluentGraphStatementBuilder(@NonNull GraphTraversal, ?> traversal) {
- this.traversal = traversal;
+ throw GraphSupportRemoved.exception();
}
public FluentGraphStatementBuilder(@NonNull FluentGraphStatement template) {
super(template);
- this.traversal = template.getTraversal();
+ throw GraphSupportRemoved.exception();
}
@NonNull
@Override
public FluentGraphStatement build() {
- return new DefaultFluentGraphStatement(
- this.traversal,
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- buildCustomPayload(),
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphExecutionInfo.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphExecutionInfo.java
index 758f6b358ed..7677c2f2d30 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphExecutionInfo.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphExecutionInfo.java
@@ -27,10 +27,9 @@
/**
* Information about the execution of a graph statement.
*
- * @deprecated This interface is not used by any driver component anymore; the driver now exposes
- * instances of {@link com.datastax.oss.driver.api.core.cql.ExecutionInfo} for all Graph
- * queries.
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
@Deprecated
public interface GraphExecutionInfo {
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphNode.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphNode.java
index 97d48a6b04d..8303741544c 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphNode.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphNode.java
@@ -44,7 +44,11 @@
* to cast it to a particular Java type. Two generic methods {@link #as(Class)} and {@link
* #as(GenericType)} can produce any arbitrary Java type, provided that the underlying serialization
* runtime has been correctly configured to support the requested conversion.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface GraphNode {
/** Whether this node represents a {@code null} value. */
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphResultSet.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphResultSet.java
index d9c8d8fa460..b2db9442a17 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphResultSet.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphResultSet.java
@@ -17,7 +17,7 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.GraphExecutionInfoConverter;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -40,7 +40,10 @@
*
* @see GraphNode
* @see GraphSession#execute(GraphStatement)
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface GraphResultSet extends Iterable {
/**
@@ -83,7 +86,7 @@ default List all() {
*/
@NonNull
default ExecutionInfo getRequestExecutionInfo() {
- return GraphExecutionInfoConverter.convert(getExecutionInfo());
+ throw GraphSupportRemoved.exception();
}
/** @deprecated Use {@link #getRequestExecutionInfo()} instead. */
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphSession.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphSession.java
index b985bc56353..1507c4c846d 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphSession.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphSession.java
@@ -17,10 +17,10 @@
*/
package com.datastax.dse.driver.api.core.graph;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.session.Session;
import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Objects;
import java.util.concurrent.CompletionStage;
/**
@@ -31,7 +31,11 @@
* integrated usage of DataStax Enterprise's multi-model database via a single entry point. However,
* it is still possible to cast a {@code CqlSession} to a {@code GraphSession} to only expose the
* DSE Graph execution methods.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface GraphSession extends Session {
/**
@@ -60,9 +64,7 @@ public interface GraphSession extends Session {
*/
@NonNull
default GraphResultSet execute(@NonNull GraphStatement> graphStatement) {
- return Objects.requireNonNull(
- execute(graphStatement, GraphStatement.SYNC),
- "The graph processor should never return a null result");
+ throw GraphSupportRemoved.exception();
}
/**
@@ -80,8 +82,6 @@ default GraphResultSet execute(@NonNull GraphStatement> graphStatement) {
@NonNull
default CompletionStage executeAsync(
@NonNull GraphStatement> graphStatement) {
- return Objects.requireNonNull(
- execute(graphStatement, GraphStatement.ASYNC),
- "The graph processor should never return a null result");
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatement.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatement.java
index f770469b824..00c641c444a 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatement.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatement.java
@@ -42,7 +42,10 @@
* A request to execute a DSE Graph query.
*
* @param the "self type" used for covariant returns in subtypes.
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface GraphStatement> extends Request {
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatementBuilderBase.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatementBuilderBase.java
index 5cb48613cf5..7048147565f 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatementBuilderBase.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/GraphStatementBuilderBase.java
@@ -17,6 +17,7 @@
*/
package com.datastax.dse.driver.api.core.graph;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import com.datastax.oss.driver.api.core.ConsistencyLevel;
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
import com.datastax.oss.driver.api.core.cql.Statement;
@@ -29,7 +30,10 @@
import java.util.Map;
import net.jcip.annotations.NotThreadSafe;
+/** @deprecated DSE Graph is not supported starting with driver 4.19.2.2. */
@NotThreadSafe
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public abstract class GraphStatementBuilderBase<
SelfT extends GraphStatementBuilderBase,
StatementT extends GraphStatement> {
@@ -52,27 +56,11 @@ public abstract class GraphStatementBuilderBase<
protected ConsistencyLevel writeConsistencyLevel;
protected GraphStatementBuilderBase() {
- // nothing to do
+ throw GraphSupportRemoved.exception();
}
protected GraphStatementBuilderBase(StatementT template) {
- this.isIdempotent = template.isIdempotent();
- this.timeout = template.getTimeout();
- this.node = template.getNode();
- this.timestamp = template.getTimestamp();
- this.executionProfile = template.getExecutionProfile();
- this.executionProfileName = template.getExecutionProfileName();
- if (!template.getCustomPayload().isEmpty()) {
- this.customPayloadBuilder =
- NullAllowingImmutableMap.builder()
- .putAll(template.getCustomPayload());
- }
- this.graphName = template.getGraphName();
- this.traversalSource = template.getTraversalSource();
- this.subProtocol = template.getSubProtocol();
- this.consistencyLevel = template.getConsistencyLevel();
- this.readConsistencyLevel = template.getReadConsistencyLevel();
- this.writeConsistencyLevel = template.getWriteConsistencyLevel();
+ throw GraphSupportRemoved.exception();
}
/** @see GraphStatement#setIdempotent(Boolean) */
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/PagingEnabledOptions.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/PagingEnabledOptions.java
index f59d0e50e93..38894a72e29 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/PagingEnabledOptions.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/PagingEnabledOptions.java
@@ -17,6 +17,9 @@
*/
package com.datastax.dse.driver.api.core.graph;
+/** @deprecated DSE Graph is not supported starting with driver 4.19.2.2. */
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public enum PagingEnabledOptions {
ENABLED,
DISABLED,
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatement.java
index 2ad7aafc232..2b01f622c79 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatement.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatement.java
@@ -17,12 +17,9 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.DefaultScriptGraphStatement;
-import com.datastax.oss.driver.api.core.cql.Statement;
-import com.datastax.oss.protocol.internal.util.collection.NullAllowingImmutableMap;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
-import java.util.Collections;
import java.util.Map;
/**
@@ -40,29 +37,17 @@
*
* GraphResultSet graphResultSet = dseSession.execute(statement);
* }
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface ScriptGraphStatement extends GraphStatement {
/** Create a new instance from the given script. */
@NonNull
static ScriptGraphStatement newInstance(@NonNull String script) {
- return new DefaultScriptGraphStatement(
- script,
- NullAllowingImmutableMap.of(),
- null,
- null,
- null,
- null,
- Statement.NO_DEFAULT_TIMESTAMP,
- null,
- null,
- Collections.emptyMap(),
- null,
- null,
- null,
- null,
- null,
- null);
+ throw GraphSupportRemoved.exception();
}
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatementBuilder.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatementBuilder.java
index 1985c58955f..3c90b892d92 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatementBuilder.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/ScriptGraphStatementBuilder.java
@@ -17,9 +17,7 @@
*/
package com.datastax.dse.driver.api.core.graph;
-import com.datastax.dse.driver.internal.core.graph.DefaultScriptGraphStatement;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import com.datastax.oss.driver.shaded.guava.common.collect.Maps;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.Map;
@@ -29,42 +27,37 @@
* A builder to create a script graph statement.
*
* This class is mutable and not thread-safe.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
@NotThreadSafe
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public class ScriptGraphStatementBuilder
extends GraphStatementBuilderBase {
- private String script;
- private Boolean isSystemQuery;
- private final Map queryParams;
-
public ScriptGraphStatementBuilder() {
- this.queryParams = Maps.newHashMap();
+ throw GraphSupportRemoved.exception();
}
public ScriptGraphStatementBuilder(String script) {
- this.script = script;
- this.queryParams = Maps.newHashMap();
+ throw GraphSupportRemoved.exception();
}
public ScriptGraphStatementBuilder(ScriptGraphStatement template) {
super(template);
- this.script = template.getScript();
- this.queryParams = Maps.newHashMap(template.getQueryParams());
- this.isSystemQuery = template.isSystemQuery();
+ throw GraphSupportRemoved.exception();
}
@NonNull
public ScriptGraphStatementBuilder setScript(@NonNull String script) {
- this.script = script;
- return this;
+ throw GraphSupportRemoved.exception();
}
/** @see ScriptGraphStatement#isSystemQuery() */
@NonNull
public ScriptGraphStatementBuilder setSystemQuery(@Nullable Boolean isSystemQuery) {
- this.isSystemQuery = isSystemQuery;
- return this;
+ throw GraphSupportRemoved.exception();
}
/**
@@ -74,8 +67,7 @@ public ScriptGraphStatementBuilder setSystemQuery(@Nullable Boolean isSystemQuer
*/
@NonNull
public ScriptGraphStatementBuilder setQueryParam(@NonNull String name, @Nullable Object value) {
- this.queryParams.put(name, value);
- return this;
+ throw GraphSupportRemoved.exception();
}
/**
@@ -85,8 +77,7 @@ public ScriptGraphStatementBuilder setQueryParam(@NonNull String name, @Nullable
*/
@NonNull
public ScriptGraphStatementBuilder setQueryParams(@NonNull Map params) {
- this.queryParams.putAll(params);
- return this;
+ throw GraphSupportRemoved.exception();
}
/**
@@ -101,36 +92,17 @@ public ScriptGraphStatementBuilder setQueryParams(@NonNull Map p
*/
@NonNull
public ScriptGraphStatementBuilder removeQueryParam(@NonNull String name) {
- this.queryParams.remove(name);
- return this;
+ throw GraphSupportRemoved.exception();
}
/** Clears all the parameters previously added to this builder. */
public ScriptGraphStatementBuilder clearQueryParams() {
- this.queryParams.clear();
- return this;
+ throw GraphSupportRemoved.exception();
}
@NonNull
@Override
public ScriptGraphStatement build() {
- Preconditions.checkNotNull(this.script, "Script hasn't been defined in this builder.");
- return new DefaultScriptGraphStatement(
- this.script,
- this.queryParams,
- this.isSystemQuery,
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- buildCustomPayload(),
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/CqlCollection.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/CqlCollection.java
index fdbf3fbe397..f31756c07f2 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/CqlCollection.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/CqlCollection.java
@@ -17,17 +17,20 @@
*/
package com.datastax.dse.driver.api.core.graph.predicates;
-import com.datastax.dse.driver.internal.core.graph.CqlCollectionPredicate;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import java.util.Collection;
import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.javatuples.Pair;
/**
* Predicates that can be used on CQL collections (lists, sets and maps).
*
* Note: CQL collection predicates are only available when using the binary subprotocol.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public class CqlCollection {
/**
@@ -37,9 +40,8 @@ public class CqlCollection {
* @return a predicate to apply in a {@link
* org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal}.
*/
- @SuppressWarnings("unchecked")
public static , V> P contains(V value) {
- return new P(CqlCollectionPredicate.contains, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -49,9 +51,8 @@ public static , V> P contains(V value) {
* @return a predicate to apply in a {@link
* org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal}.
*/
- @SuppressWarnings("unchecked")
public static , K> P containsKey(K key) {
- return new P(CqlCollectionPredicate.containsKey, key);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -61,9 +62,8 @@ public static , V> P contains(V value) {
* @return a predicate to apply in a {@link
* org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal}.
*/
- @SuppressWarnings("unchecked")
public static , V> P containsValue(V value) {
- return new P(CqlCollectionPredicate.containsValue, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -74,8 +74,7 @@ public static , V> P containsValue(V value) {
* @return a predicate to apply in a {@link
* org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal}.
*/
- @SuppressWarnings("unchecked")
public static , K, V> P entryEq(K key, V value) {
- return new P(CqlCollectionPredicate.entryEq, new Pair<>(key, value));
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Geo.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Geo.java
index 65dd84d0076..404067abe51 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Geo.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Geo.java
@@ -20,30 +20,25 @@
import com.datastax.dse.driver.api.core.data.geometry.LineString;
import com.datastax.dse.driver.api.core.data.geometry.Point;
import com.datastax.dse.driver.api.core.data.geometry.Polygon;
-import com.datastax.dse.driver.internal.core.data.geometry.Distance;
-import com.datastax.dse.driver.internal.core.graph.GeoPredicate;
-import com.datastax.dse.driver.internal.core.graph.GeoUtils;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+/** @deprecated DSE Graph is not supported starting with driver 4.19.2.2. */
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface Geo {
enum Unit {
- MILES(GeoUtils.MILES_TO_KM * GeoUtils.KM_TO_DEG),
- KILOMETERS(GeoUtils.KM_TO_DEG),
- METERS(GeoUtils.KM_TO_DEG / 1000.0),
- DEGREES(1);
-
- private final double multiplier;
-
- Unit(double multiplier) {
- this.multiplier = multiplier;
- }
+ MILES,
+ KILOMETERS,
+ METERS,
+ DEGREES;
/** Convert distance to degrees (used internally only). */
public double toDegrees(double distance) {
- return distance * multiplier;
+ throw GraphSupportRemoved.exception();
}
}
@@ -53,7 +48,7 @@ public double toDegrees(double distance) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P inside(Point center, double radius, Unit units) {
- return new P<>(GeoPredicate.inside, new Distance(center, units.toDegrees(radius)));
+ throw GraphSupportRemoved.exception();
}
/**
@@ -62,7 +57,7 @@ static P inside(Point center, double radius, Unit units) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P inside(Point center, double radius) {
- return new P<>(GeoPredicate.insideCartesian, new Distance(center, radius));
+ throw GraphSupportRemoved.exception();
}
/**
@@ -71,7 +66,7 @@ static P inside(Point center, double radius) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P inside(Polygon polygon) {
- return new P<>(GeoPredicate.insideCartesian, polygon);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -82,7 +77,7 @@ static P inside(Polygon polygon) {
*/
@NonNull
static Point point(double x, double y) {
- return Point.fromCoordinates(x, y);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -95,7 +90,7 @@ static Point point(double x, double y) {
@NonNull
static LineString lineString(
@NonNull Point point1, @NonNull Point point2, @NonNull Point... otherPoints) {
- return LineString.fromPoints(point1, point2, otherPoints);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -106,19 +101,7 @@ static LineString lineString(
*/
@NonNull
static LineString lineString(double... coordinates) {
- if (coordinates.length % 2 != 0) {
- throw new IllegalArgumentException("lineString() must be passed an even number of arguments");
- } else if (coordinates.length < 4) {
- throw new IllegalArgumentException(
- "lineString() must be passed at least 4 arguments (2 points)");
- }
- Point point1 = Point.fromCoordinates(coordinates[0], coordinates[1]);
- Point point2 = Point.fromCoordinates(coordinates[2], coordinates[3]);
- Point[] otherPoints = new Point[coordinates.length / 2 - 2];
- for (int i = 4; i < coordinates.length; i += 2) {
- otherPoints[i / 2 - 2] = Point.fromCoordinates(coordinates[i], coordinates[i + 1]);
- }
- return LineString.fromPoints(point1, point2, otherPoints);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -131,7 +114,7 @@ static LineString lineString(double... coordinates) {
@NonNull
static Polygon polygon(
@NonNull Point p1, @NonNull Point p2, @NonNull Point p3, @NonNull Point... otherPoints) {
- return Polygon.fromPoints(p1, p2, p3, otherPoints);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -142,19 +125,6 @@ static Polygon polygon(
*/
@NonNull
static Polygon polygon(double... coordinates) {
- if (coordinates.length % 2 != 0) {
- throw new IllegalArgumentException("polygon() must be passed an even number of arguments");
- } else if (coordinates.length < 6) {
- throw new IllegalArgumentException(
- "polygon() must be passed at least 6 arguments (3 points)");
- }
- Point point1 = Point.fromCoordinates(coordinates[0], coordinates[1]);
- Point point2 = Point.fromCoordinates(coordinates[2], coordinates[3]);
- Point point3 = Point.fromCoordinates(coordinates[4], coordinates[5]);
- Point[] otherPoints = new Point[coordinates.length / 2 - 3];
- for (int i = 6; i < coordinates.length; i += 2) {
- otherPoints[i / 2 - 3] = Point.fromCoordinates(coordinates[i], coordinates[i + 1]);
- }
- return Polygon.fromPoints(point1, point2, point3, otherPoints);
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Search.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Search.java
index e285c118c8a..5aba5f9c24f 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Search.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/predicates/Search.java
@@ -17,11 +17,13 @@
*/
package com.datastax.dse.driver.api.core.graph.predicates;
-import com.datastax.dse.driver.internal.core.graph.EditDistance;
-import com.datastax.dse.driver.internal.core.graph.SearchPredicate;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+/** @deprecated DSE Graph is not supported starting with driver 4.19.2.2. */
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface Search {
/**
@@ -30,7 +32,7 @@ public interface Search {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P token(String value) {
- return new P<>(SearchPredicate.token, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -40,7 +42,7 @@ static P token(String value) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P tokenPrefix(String value) {
- return new P<>(SearchPredicate.tokenPrefix, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -50,7 +52,7 @@ static P tokenPrefix(String value) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P tokenRegex(String value) {
- return new P<>(SearchPredicate.tokenRegex, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -59,7 +61,7 @@ static P tokenRegex(String value) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P prefix(String value) {
- return new P<>(SearchPredicate.prefix, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -68,7 +70,7 @@ static P prefix(String value) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P regex(String value) {
- return new P<>(SearchPredicate.regex, value);
+ throw GraphSupportRemoved.exception();
}
/**
@@ -89,7 +91,7 @@ static P regex(String value) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P phrase(String query, int distance) {
- return new P<>(SearchPredicate.phrase, new EditDistance(query, distance));
+ throw GraphSupportRemoved.exception();
}
/**
@@ -110,7 +112,7 @@ static P phrase(String query, int distance) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P fuzzy(String query, int distance) {
- return new P<>(SearchPredicate.fuzzy, new EditDistance(query, distance));
+ throw GraphSupportRemoved.exception();
}
/**
@@ -131,6 +133,6 @@ static P fuzzy(String query, int distance) {
* @return a predicate to apply in a {@link GraphTraversal}.
*/
static P tokenFuzzy(String query, int distance) {
- return new P<>(SearchPredicate.tokenFuzzy, new EditDistance(query, distance));
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphNode.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphNode.java
index ad7849633c6..bdf45a66938 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphNode.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphNode.java
@@ -30,7 +30,10 @@
*
* @see ReactiveGraphSession
* @see ReactiveGraphResultSet
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface ReactiveGraphNode extends GraphNode {
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphResultSet.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphResultSet.java
index a0e3231750e..95ff35f7875 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphResultSet.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphResultSet.java
@@ -45,7 +45,10 @@
*
* @see ReactiveGraphSession#executeReactive(GraphStatement)
* @see ReactiveGraphNode
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface ReactiveGraphResultSet extends Publisher {
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphSession.java b/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphSession.java
index 88f0e5def61..2436c33b3e1 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphSession.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/graph/reactive/ReactiveGraphSession.java
@@ -18,15 +18,18 @@
package com.datastax.dse.driver.api.core.graph.reactive;
import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.internal.core.graph.reactive.ReactiveGraphRequestProcessor;
+import com.datastax.dse.driver.internal.core.graph.GraphSupportRemoved;
import com.datastax.oss.driver.api.core.session.Session;
import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Objects;
/**
* A {@link Session} that offers utility methods to issue graph queries using reactive-style
* programming.
+ *
+ * @deprecated DSE Graph is not supported starting with driver 4.19.2.2.
*/
+@SuppressWarnings("DoNotCallSuggester")
+@Deprecated
public interface ReactiveGraphSession extends Session {
/**
@@ -43,7 +46,6 @@ public interface ReactiveGraphSession extends Session {
*/
@NonNull
default ReactiveGraphResultSet executeReactive(@NonNull GraphStatement> statement) {
- return Objects.requireNonNull(
- execute(statement, ReactiveGraphRequestProcessor.REACTIVE_GRAPH_RESULT_SET));
+ throw GraphSupportRemoved.exception();
}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseNodeMetric.java b/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseNodeMetric.java
index cf4b4d0aa18..14f603d89cf 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseNodeMetric.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseNodeMetric.java
@@ -22,7 +22,12 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Map;
-/** See {@code reference.conf} for a description of each metric. */
+/**
+ * Legacy DSE node metrics retained for compatibility.
+ *
+ * @deprecated DSE Graph is no longer supported; these metrics are ignored.
+ */
+@Deprecated
public enum DseNodeMetric implements NodeMetric {
GRAPH_MESSAGES("graph-messages");
diff --git a/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseSessionMetric.java b/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseSessionMetric.java
index 79584f3c44a..7c2892a8747 100644
--- a/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseSessionMetric.java
+++ b/core/src/main/java/com/datastax/dse/driver/api/core/metrics/DseSessionMetric.java
@@ -25,7 +25,11 @@
/** See {@code reference.conf} for a description of each metric. */
public enum DseSessionMetric implements SessionMetric {
CONTINUOUS_CQL_REQUESTS("continuous-cql-requests"),
+ /** @deprecated DSE Graph is no longer supported; this metric is ignored. */
+ @Deprecated
GRAPH_REQUESTS("graph-requests"),
+ /** @deprecated DSE Graph is no longer supported; this metric is ignored. */
+ @Deprecated
GRAPH_CLIENT_TIMEOUTS("graph-client-timeouts"),
;
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/data/geometry/Distance.java b/core/src/main/java/com/datastax/dse/driver/internal/core/data/geometry/Distance.java
deleted file mode 100644
index 518f6aa1346..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/data/geometry/Distance.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.data.geometry;
-
-import static java.util.regex.Pattern.CASE_INSENSITIVE;
-
-import com.datastax.dse.driver.api.core.data.geometry.Geometry;
-import com.datastax.dse.driver.api.core.data.geometry.LineString;
-import com.datastax.dse.driver.api.core.data.geometry.Point;
-import com.datastax.dse.driver.api.core.data.geometry.Polygon;
-import com.datastax.dse.driver.api.core.graph.predicates.Geo;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import com.esri.core.geometry.MultiPath;
-import com.esri.core.geometry.ogc.OGCGeometry;
-import com.esri.core.geometry.ogc.OGCPoint;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import net.jcip.annotations.Immutable;
-
-/**
- * The driver-side representation of DSE's {@code Geo.distance}.
- *
- * This is a circle in a two-dimensional XY plane represented by its center point and radius. It
- * is used as a search criteria to determine whether or not another geospatial object lies within a
- * circular area.
- *
- *
Note that this shape has no equivalent in the OGC and GeoJSON standards: as a consequence,
- * {@link #asWellKnownText()} returns a custom format, and {@link #getOgcGeometry()}, {@link
- * #asWellKnownBinary()}, and {@link #asGeoJson()} throw {@link UnsupportedOperationException}.
- *
- *
Unlike other geo types, this class is never exposed directly to driver clients: it is used
- * internally by {@linkplain Geo#inside(Point, double) geo predicates}, but cannot be a column type,
- * nor appear in CQL or graph results. Therefore it doesn't have a public-facing interface, nor a
- * built-in codec.
- */
-@Immutable
-public class Distance extends DefaultGeometry {
-
- private static final Pattern WKT_PATTERN =
- Pattern.compile(
- "distance *\\( *\\( *([\\d\\.-]+) *([\\d+\\.-]+) *\\) *([\\d+\\.-]+) *\\)",
- CASE_INSENSITIVE);
-
- /**
- * Creates a distance from its Well-known
- * Text (WKT) representation.
- *
- * @param source the Well-known Text representation to parse.
- * @return the point represented by the WKT.
- * @throws IllegalArgumentException if the string does not contain a valid Well-known Text
- * representation.
- * @see Distance#asWellKnownText()
- */
- @NonNull
- public static Distance fromWellKnownText(@NonNull String source) {
- Matcher matcher = WKT_PATTERN.matcher(source.trim());
- if (matcher.matches() && matcher.groupCount() == 3) {
- try {
- return new Distance(
- new DefaultPoint(
- Double.parseDouble(matcher.group(1)), Double.parseDouble(matcher.group(2))),
- Double.parseDouble(matcher.group(3)));
- } catch (NumberFormatException var3) {
- throw new IllegalArgumentException(String.format("Unable to parse %s", source));
- }
- } else {
- throw new IllegalArgumentException(String.format("Unable to parse %s", source));
- }
- }
-
- private final DefaultPoint center;
-
- private final double radius;
-
- /**
- * Creates a new distance with the given center and radius.
- *
- * @param center The center point.
- * @param radius The radius of the circle representing distance.
- */
- public Distance(@NonNull Point center, double radius) {
- super(((DefaultPoint) center).getOgcGeometry());
- Preconditions.checkNotNull(center);
- Preconditions.checkArgument(radius >= 0.0D, "Radius must be >= 0 (got %s)", radius);
- this.center = ((DefaultPoint) center);
- this.radius = radius;
- }
-
- /** @return The center point of the circle representing this distance. */
- @NonNull
- public Point getCenter() {
- return center;
- }
-
- /** @return The radius of the circle representing this distance. */
- public double getRadius() {
- return radius;
- }
-
- /**
- * Returns a Well-known Text (WKT)
- * representation of this geospatial type.
- *
- *
Since there is no Well-known Text specification for Distance, this returns a custom format
- * of: DISTANCE((center.x center.y) radius)
- *
- * @return a Well-known Text representation of this object.
- */
- @NonNull
- @Override
- public String asWellKnownText() {
- return String.format("DISTANCE((%s %s) %s)", this.center.X(), this.center.Y(), this.radius);
- }
-
- /**
- * The distance type has no equivalent in the OGC standard: this method throws an {@link
- * UnsupportedOperationException}.
- */
- @NonNull
- @Override
- public OGCGeometry getOgcGeometry() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * The distance type has no equivalent in the OGC standard: this method throws an {@link
- * UnsupportedOperationException}.
- */
- @NonNull
- @Override
- public ByteBuffer asWellKnownBinary() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * The distance type has no equivalent in the GeoJSON standard: this method throws an {@link
- * UnsupportedOperationException}.
- */
- @Override
- @NonNull
- public String asGeoJson() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- } else if (other instanceof Distance) {
- Distance that = (Distance) other;
- return Objects.equals(this.center, that.center) && this.radius == that.radius;
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(center, radius);
- }
-
- @SuppressWarnings("SimplifiableConditionalExpression")
- @Override
- public boolean contains(@NonNull Geometry geometry) {
- return geometry instanceof Distance
- ? this.containsDistance((Distance) geometry)
- : geometry instanceof Point
- ? this.containsPoint((Point) geometry)
- : geometry instanceof LineString
- ? this.containsLineString((LineString) geometry)
- : geometry instanceof Polygon ? this.containsPolygon((Polygon) geometry) : false;
- }
-
- private boolean containsDistance(Distance distance) {
- return this.center.getOgcGeometry().distance(distance.center.getOgcGeometry()) + distance.radius
- <= this.radius;
- }
-
- private boolean containsPoint(Point point) {
- return this.containsOGCPoint(((DefaultPoint) point).getOgcGeometry());
- }
-
- private boolean containsLineString(LineString lineString) {
- MultiPath multiPath =
- (MultiPath) ((DefaultLineString) lineString).getOgcGeometry().getEsriGeometry();
- return containsMultiPath(multiPath);
- }
-
- private boolean containsPolygon(Polygon polygon) {
- MultiPath multiPath =
- (com.esri.core.geometry.Polygon)
- ((DefaultPolygon) polygon).getOgcGeometry().getEsriGeometry();
- return containsMultiPath(multiPath);
- }
-
- private boolean containsMultiPath(MultiPath multiPath) {
- int numPoints = multiPath.getPointCount();
- for (int i = 0; i < numPoints; ++i) {
- OGCPoint point = new OGCPoint(multiPath.getPoint(i), DefaultGeometry.SPATIAL_REFERENCE_4326);
- if (!this.containsOGCPoint(point)) {
- return false;
- }
- }
- return true;
- }
-
- private boolean containsOGCPoint(OGCPoint point) {
- return this.center.getOgcGeometry().distance(point) <= this.radius;
- }
-
- /**
- * This object gets replaced by an internal proxy for serialization.
- *
- * @serialData Point (wkb) for center followed by double for radius
- */
- private Object writeReplace() {
- return new DistanceSerializationProxy(this);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/data/geometry/DistanceSerializationProxy.java b/core/src/main/java/com/datastax/dse/driver/internal/core/data/geometry/DistanceSerializationProxy.java
deleted file mode 100644
index 515af121980..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/data/geometry/DistanceSerializationProxy.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.data.geometry;
-
-import com.datastax.dse.driver.api.core.data.geometry.Point;
-import java.io.Serializable;
-
-/**
- * A thin wrapper around {@link Distance}, that gets substituted during the serialization /
- * deserialization process. This allows {@link Distance} to be immutable and reference centers' OGC
- * counterpart.
- */
-public class DistanceSerializationProxy implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final Point center;
- private final double radius;
-
- public DistanceSerializationProxy(Distance distance) {
- this.center = distance.getCenter();
- this.radius = distance.getRadius();
- }
-
- private Object readResolve() {
- return new Distance(center, radius);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ByteBufUtil.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ByteBufUtil.java
deleted file mode 100644
index 333ba6099d3..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ByteBufUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import java.nio.ByteBuffer;
-
-public class ByteBufUtil {
-
- // Does not move the reader index of the ByteBuf parameter
- public static ByteBuffer toByteBuffer(ByteBuf buffer) {
- if (buffer.isDirect()) {
- return buffer.nioBuffer();
- }
- final byte[] bytes = new byte[buffer.readableBytes()];
- buffer.getBytes(buffer.readerIndex(), bytes);
- return ByteBuffer.wrap(bytes);
- }
-
- static ByteBuf toByteBuf(ByteBuffer buffer) {
- return Unpooled.wrappedBuffer(buffer);
- }
-
- // read a predefined amount of bytes from the netty buffer and move its readerIndex
- public static ByteBuffer readBytes(ByteBuf nettyBuf, int size) {
- ByteBuffer res = ByteBuffer.allocate(size);
- nettyBuf.readBytes(res);
- res.flip();
- return res;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/BytecodeGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/BytecodeGraphStatement.java
deleted file mode 100644
index e8e4554e81f..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/BytecodeGraphStatement.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.FluentGraphStatement;
-import com.datastax.oss.driver.api.core.ConsistencyLevel;
-import com.datastax.oss.driver.api.core.RequestRoutingType;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.cql.Statement;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.Map;
-import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
-
-/**
- * A dedicated statement implementation for implicit traversal execution via a {@link
- * DseGraphRemoteConnection}.
- *
- *
This is a simplified version of {@link FluentGraphStatement} that exposes the bytecode
- * directly instead of the traversal.
- *
- *
This class is for internal use only.
- */
-public class BytecodeGraphStatement extends GraphStatementBase {
-
- private final Bytecode bytecode;
-
- public BytecodeGraphStatement(
- Bytecode bytecode, DriverExecutionProfile executionProfile, String executionProfileName) {
- this(
- bytecode,
- null,
- null,
- null,
- Statement.NO_DEFAULT_TIMESTAMP,
- executionProfile,
- executionProfileName,
- Collections.emptyMap(),
- null,
- null,
- null,
- null,
- null,
- null);
- }
-
- private BytecodeGraphStatement(
- Bytecode bytecode,
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- super(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- this.bytecode = bytecode;
- }
-
- public Bytecode getBytecode() {
- return bytecode;
- }
-
- @Override
- protected BytecodeGraphStatement newInstance(
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- return new BytecodeGraphStatement(
- bytecode,
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @NonNull
- @Override
- public RequestRoutingType getRequestRoutingType() {
- return RequestRoutingType.REGULAR;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ContinuousAsyncGraphResultSet.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ContinuousAsyncGraphResultSet.java
deleted file mode 100644
index 9c7f773c3a2..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ContinuousAsyncGraphResultSet.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
-import com.datastax.oss.driver.internal.core.util.CountingIterator;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Collections;
-import java.util.Queue;
-import java.util.concurrent.CompletionStage;
-import net.jcip.annotations.NotThreadSafe;
-
-@NotThreadSafe // wraps a mutable queue
-public class ContinuousAsyncGraphResultSet implements AsyncGraphResultSet {
-
- private final CountingIterator iterator;
- private final int pageNumber;
- private final boolean hasMorePages;
- private final ExecutionInfo executionInfo;
- private final ContinuousGraphRequestHandler continuousGraphRequestHandler;
- private final Iterable currentPage;
-
- public ContinuousAsyncGraphResultSet(
- ExecutionInfo executionInfo,
- Queue data,
- int pageNumber,
- boolean hasMorePages,
- ContinuousGraphRequestHandler continuousGraphRequestHandler,
- GraphProtocol graphProtocol) {
-
- this.iterator = new GraphResultIterator(data, graphProtocol);
- this.pageNumber = pageNumber;
- this.hasMorePages = hasMorePages;
- this.executionInfo = executionInfo;
- this.continuousGraphRequestHandler = continuousGraphRequestHandler;
- this.currentPage = () -> iterator;
- }
-
- @NonNull
- @Override
- public ExecutionInfo getRequestExecutionInfo() {
- return executionInfo;
- }
-
- @NonNull
- @Override
- @Deprecated
- public com.datastax.dse.driver.api.core.graph.GraphExecutionInfo getExecutionInfo() {
- return GraphExecutionInfoConverter.convert(executionInfo);
- }
-
- @Override
- public int remaining() {
- return iterator.remaining();
- }
-
- @NonNull
- @Override
- public Iterable currentPage() {
- return currentPage;
- }
-
- @Override
- public boolean hasMorePages() {
- return hasMorePages;
- }
-
- @NonNull
- @Override
- public CompletionStage fetchNextPage() throws IllegalStateException {
- if (!hasMorePages()) {
- throw new IllegalStateException(
- "Can't call fetchNextPage() on the last page (use hasMorePages() to check)");
- }
- return continuousGraphRequestHandler.fetchNextPage();
- }
-
- @Override
- public void cancel() {
- continuousGraphRequestHandler.cancel();
- }
-
- /** Returns the current page's number. Pages are numbered starting from 1. */
- public int pageNumber() {
- return pageNumber;
- }
-
- static AsyncGraphResultSet empty(ExecutionInfo executionInfo) {
-
- return new AsyncGraphResultSet() {
-
- @NonNull
- @Override
- public ExecutionInfo getRequestExecutionInfo() {
- return executionInfo;
- }
-
- @NonNull
- @Override
- @Deprecated
- public com.datastax.dse.driver.api.core.graph.GraphExecutionInfo getExecutionInfo() {
- return GraphExecutionInfoConverter.convert(executionInfo);
- }
-
- @NonNull
- @Override
- public Iterable currentPage() {
- return Collections.emptyList();
- }
-
- @Override
- public int remaining() {
- return 0;
- }
-
- @Override
- public boolean hasMorePages() {
- return false;
- }
-
- @NonNull
- @Override
- public CompletionStage fetchNextPage() throws IllegalStateException {
- throw new IllegalStateException(
- "Can't call fetchNextPage() on the last page (use hasMorePages() to check)");
- }
-
- @Override
- public void cancel() {
- // noop
- }
- };
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ContinuousGraphRequestHandler.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ContinuousGraphRequestHandler.java
deleted file mode 100644
index 07d9e4c84a3..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/ContinuousGraphRequestHandler.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.config.DseDriverOption;
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.api.core.metrics.DseNodeMetric;
-import com.datastax.dse.driver.api.core.metrics.DseSessionMetric;
-import com.datastax.dse.driver.internal.core.cql.continuous.ContinuousRequestHandlerBase;
-import com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule;
-import com.datastax.dse.protocol.internal.response.result.DseRowsMetadata;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.cql.ColumnDefinitions;
-import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.cql.Conversions;
-import com.datastax.oss.driver.internal.core.session.DefaultSession;
-import com.datastax.oss.driver.shaded.guava.common.base.MoreObjects;
-import com.datastax.oss.protocol.internal.Message;
-import com.datastax.oss.protocol.internal.response.result.Rows;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.ArrayDeque;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import net.jcip.annotations.ThreadSafe;
-
-/**
- * Handles a Graph request that supports multiple response messages (a.k.a. continuous paging
- * request).
- */
-@ThreadSafe
-public class ContinuousGraphRequestHandler
- extends ContinuousRequestHandlerBase, AsyncGraphResultSet> {
-
- private final GraphBinaryModule graphBinaryModule;
- private final GraphSupportChecker graphSupportChecker;
- private final Duration globalTimeout;
-
- ContinuousGraphRequestHandler(
- @NonNull GraphStatement> statement,
- @NonNull DefaultSession session,
- @NonNull InternalDriverContext context,
- @NonNull String sessionLogPrefix,
- @NonNull GraphBinaryModule graphBinaryModule,
- @NonNull GraphSupportChecker graphSupportChecker) {
- super(
- statement,
- session,
- context,
- sessionLogPrefix,
- AsyncGraphResultSet.class,
- true,
- DseSessionMetric.GRAPH_CLIENT_TIMEOUTS,
- DseSessionMetric.GRAPH_REQUESTS,
- DseNodeMetric.GRAPH_MESSAGES);
- this.graphBinaryModule = graphBinaryModule;
- this.graphSupportChecker = graphSupportChecker;
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- globalTimeout =
- MoreObjects.firstNonNull(
- statement.getTimeout(),
- executionProfile.getDuration(DseDriverOption.GRAPH_TIMEOUT, Duration.ZERO));
- // NOTE that ordering of the following statement matters.
- // We should register this request after all fields have been initialized.
- throttler.register(this);
- }
-
- @NonNull
- @Override
- protected Duration getGlobalTimeout() {
- return globalTimeout;
- }
-
- @NonNull
- @Override
- protected Duration getPageTimeout(@NonNull GraphStatement> statement, int pageNumber) {
- return Duration.ZERO;
- }
-
- @NonNull
- @Override
- protected Duration getReviseRequestTimeout(@NonNull GraphStatement> statement) {
- return Duration.ZERO;
- }
-
- @Override
- protected int getMaxEnqueuedPages(@NonNull GraphStatement> statement) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- return executionProfile.getInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES);
- }
-
- @Override
- protected int getMaxPages(@NonNull GraphStatement> statement) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- return executionProfile.getInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES);
- }
-
- @NonNull
- @Override
- protected Message getMessage(@NonNull GraphStatement> statement) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- GraphProtocol subProtocol =
- graphSupportChecker.inferGraphProtocol(statement, executionProfile, context);
- return GraphConversions.createContinuousMessageFromGraphStatement(
- statement, subProtocol, executionProfile, context, graphBinaryModule);
- }
-
- @Override
- protected boolean isTracingEnabled(@NonNull GraphStatement> statement) {
- return statement.isTracing();
- }
-
- @NonNull
- @Override
- protected Map createPayload(@NonNull GraphStatement> statement) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- GraphProtocol subProtocol =
- graphSupportChecker.inferGraphProtocol(statement, executionProfile, context);
- return GraphConversions.createCustomPayload(
- statement, subProtocol, executionProfile, context, graphBinaryModule);
- }
-
- @NonNull
- @Override
- protected AsyncGraphResultSet createEmptyResultSet(@NonNull ExecutionInfo executionInfo) {
- return ContinuousAsyncGraphResultSet.empty(executionInfo);
- }
-
- @NonNull
- @Override
- protected ContinuousAsyncGraphResultSet createResultSet(
- @NonNull GraphStatement> statement,
- @NonNull Rows rows,
- @NonNull ExecutionInfo executionInfo,
- @NonNull ColumnDefinitions columnDefinitions)
- throws IOException {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- GraphProtocol subProtocol =
- graphSupportChecker.inferGraphProtocol(statement, executionProfile, context);
-
- Queue graphNodes = new ArrayDeque<>();
- for (List row : rows.getData()) {
- if (subProtocol.isGraphBinary()) {
- graphNodes.offer(GraphConversions.createGraphBinaryGraphNode(row, this.graphBinaryModule));
- } else {
- graphNodes.offer(GraphSONUtils.createGraphNode(row, subProtocol));
- }
- }
-
- DseRowsMetadata metadata = (DseRowsMetadata) rows.getMetadata();
- return new ContinuousAsyncGraphResultSet(
- executionInfo,
- graphNodes,
- metadata.continuousPageNumber,
- !metadata.isLastContinuousPage,
- this,
- subProtocol);
- }
-
- @Override
- protected int pageNumber(@NonNull AsyncGraphResultSet resultSet) {
- return ((ContinuousAsyncGraphResultSet) resultSet).pageNumber();
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/CqlCollectionPredicate.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/CqlCollectionPredicate.java
deleted file mode 100644
index 349321da0cf..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/CqlCollectionPredicate.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Objects;
-import org.javatuples.Pair;
-
-/** Predicates that can be used on CQL Collections. */
-public enum CqlCollectionPredicate implements DsePredicate {
- contains {
- @Override
- public boolean test(Object value, Object condition) {
- preEvaluate(condition);
- Preconditions.checkArgument(value instanceof Collection);
- return ((Collection) value).contains(condition);
- }
- },
-
- containsKey {
- @Override
- public boolean test(Object value, Object condition) {
- preEvaluate(condition);
- Preconditions.checkArgument(value instanceof Map);
- return ((Map) value).containsKey(condition);
- }
- },
-
- containsValue {
- @Override
- public boolean test(Object value, Object condition) {
- preEvaluate(condition);
- Preconditions.checkArgument(value instanceof Map);
- return ((Map) value).containsValue(condition);
- }
- },
-
- entryEq {
- @Override
- public boolean test(Object value, Object condition) {
- preEvaluate(condition);
- Preconditions.checkArgument(condition instanceof Pair);
- Preconditions.checkArgument(value instanceof Map);
- Pair pair = (Pair) condition;
- Map map = (Map) value;
- return Objects.equals(map.get(pair.getValue0()), pair.getValue1());
- }
- };
-
- @Override
- public boolean isValidCondition(Object condition) {
- if (condition instanceof Pair) {
- Pair pair = (Pair) condition;
- return pair.getValue0() != null && pair.getValue1() != null;
- }
- return condition != null;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultAsyncGraphResultSet.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultAsyncGraphResultSet.java
deleted file mode 100644
index abc7cc9514e..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultAsyncGraphResultSet.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
-import com.datastax.oss.driver.internal.core.util.CountingIterator;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Queue;
-import java.util.concurrent.CompletionStage;
-import net.jcip.annotations.NotThreadSafe;
-
-@NotThreadSafe // wraps a mutable queue
-public class DefaultAsyncGraphResultSet implements AsyncGraphResultSet {
-
- private final ExecutionInfo executionInfo;
- private final CountingIterator iterator;
- private final Iterable currentPage;
-
- public DefaultAsyncGraphResultSet(
- ExecutionInfo executionInfo, Queue data, GraphProtocol graphProtocol) {
- this.executionInfo = executionInfo;
- this.iterator = new GraphResultIterator(data, graphProtocol);
- this.currentPage = () -> iterator;
- }
-
- @NonNull
- @Override
- public ExecutionInfo getRequestExecutionInfo() {
- return executionInfo;
- }
-
- @NonNull
- @Override
- @Deprecated
- public com.datastax.dse.driver.api.core.graph.GraphExecutionInfo getExecutionInfo() {
- return GraphExecutionInfoConverter.convert(executionInfo);
- }
-
- @Override
- public int remaining() {
- return iterator.remaining();
- }
-
- @NonNull
- @Override
- public Iterable currentPage() {
- return currentPage;
- }
-
- @Override
- public boolean hasMorePages() {
- return false;
- }
-
- @NonNull
- @Override
- public CompletionStage fetchNextPage() throws IllegalStateException {
- throw new IllegalStateException(
- "No next page. Use #hasMorePages before calling this method to avoid this error.");
- }
-
- @Override
- public void cancel() {
- // nothing to do
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultBatchGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultBatchGraphStatement.java
deleted file mode 100644
index 632d45e61d6..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultBatchGraphStatement.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.BatchGraphStatement;
-import com.datastax.oss.driver.api.core.ConsistencyLevel;
-import com.datastax.oss.driver.api.core.RequestRoutingType;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import net.jcip.annotations.Immutable;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-
-@Immutable
-public class DefaultBatchGraphStatement extends GraphStatementBase
- implements BatchGraphStatement {
-
- private final List traversals;
-
- public DefaultBatchGraphStatement(
- Iterable traversals,
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- super(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- this.traversals = ImmutableList.copyOf(traversals);
- }
-
- @NonNull
- @Override
- public DefaultBatchGraphStatement addTraversal(@NonNull GraphTraversal newTraversal) {
- return new DefaultBatchGraphStatement(
- ImmutableList.builder().addAll(traversals).add(newTraversal).build(),
- isIdempotent(),
- getTimeout(),
- getNode(),
- getTimestamp(),
- getExecutionProfile(),
- getExecutionProfileName(),
- getCustomPayload(),
- getGraphName(),
- getTraversalSource(),
- getSubProtocol(),
- getConsistencyLevel(),
- getReadConsistencyLevel(),
- getWriteConsistencyLevel());
- }
-
- @NonNull
- @Override
- public DefaultBatchGraphStatement addTraversals(@NonNull Iterable newTraversals) {
- return new DefaultBatchGraphStatement(
- ImmutableList.builder().addAll(traversals).addAll(newTraversals).build(),
- isIdempotent(),
- getTimeout(),
- getNode(),
- getTimestamp(),
- getExecutionProfile(),
- getExecutionProfileName(),
- getCustomPayload(),
- getGraphName(),
- getTraversalSource(),
- getSubProtocol(),
- getConsistencyLevel(),
- getReadConsistencyLevel(),
- getWriteConsistencyLevel());
- }
-
- @Override
- public int size() {
- return this.traversals.size();
- }
-
- @Override
- protected BatchGraphStatement newInstance(
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- return new DefaultBatchGraphStatement(
- traversals,
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @NonNull
- @Override
- public Iterator iterator() {
- return this.traversals.iterator();
- }
-
- @NonNull
- @Override
- public RequestRoutingType getRequestRoutingType() {
- return RequestRoutingType.REGULAR;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultDseRemoteConnectionBuilder.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultDseRemoteConnectionBuilder.java
deleted file mode 100644
index 146e8e17ea2..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultDseRemoteConnectionBuilder.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.DseGraphRemoteConnectionBuilder;
-import com.datastax.oss.driver.api.core.CqlSession;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import net.jcip.annotations.NotThreadSafe;
-import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
-
-@NotThreadSafe
-public class DefaultDseRemoteConnectionBuilder implements DseGraphRemoteConnectionBuilder {
-
- private final CqlSession session;
- private DriverExecutionProfile executionProfile;
- private String executionProfileName;
-
- public DefaultDseRemoteConnectionBuilder(CqlSession session) {
- this.session = session;
- }
-
- @Override
- public RemoteConnection build() {
- return new DseGraphRemoteConnection(session, executionProfile, executionProfileName);
- }
-
- @Override
- public DseGraphRemoteConnectionBuilder withExecutionProfile(
- DriverExecutionProfile executionProfile) {
- this.executionProfile = executionProfile;
- return this;
- }
-
- @Override
- public DseGraphRemoteConnectionBuilder withExecutionProfileName(String executionProfileName) {
- this.executionProfileName = executionProfileName;
- return this;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultFluentGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultFluentGraphStatement.java
deleted file mode 100644
index 44fa9e41853..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultFluentGraphStatement.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.FluentGraphStatement;
-import com.datastax.oss.driver.api.core.ConsistencyLevel;
-import com.datastax.oss.driver.api.core.RequestRoutingType;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Map;
-import net.jcip.annotations.Immutable;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-
-@Immutable
-public class DefaultFluentGraphStatement extends GraphStatementBase
- implements FluentGraphStatement {
-
- private final GraphTraversal, ?> traversal;
-
- public DefaultFluentGraphStatement(
- GraphTraversal, ?> traversal,
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- super(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- this.traversal = traversal;
- }
-
- @Override
- protected FluentGraphStatement newInstance(
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- return new DefaultFluentGraphStatement(
- traversal,
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @NonNull
- @Override
- public GraphTraversal, ?> getTraversal() {
- return traversal;
- }
-
- @NonNull
- @Override
- public RequestRoutingType getRequestRoutingType() {
- return RequestRoutingType.REGULAR;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultScriptGraphStatement.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultScriptGraphStatement.java
deleted file mode 100644
index 587e1221b41..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DefaultScriptGraphStatement.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.ScriptGraphStatement;
-import com.datastax.oss.driver.api.core.ConsistencyLevel;
-import com.datastax.oss.driver.api.core.RequestRoutingType;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.protocol.internal.util.collection.NullAllowingImmutableMap;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.Nullable;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Map;
-import net.jcip.annotations.Immutable;
-
-@Immutable
-public class DefaultScriptGraphStatement extends GraphStatementBase
- implements ScriptGraphStatement {
-
- private final String script;
- private final Boolean isSystemQuery;
- private final NullAllowingImmutableMap queryParams;
-
- public DefaultScriptGraphStatement(
- String script,
- Map queryParams,
- Boolean isSystemQuery,
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- super(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- this.script = script;
- this.isSystemQuery = isSystemQuery;
- this.queryParams = NullAllowingImmutableMap.copyOf(queryParams);
- }
-
- //// Script GraphStatement level options
-
- @NonNull
- @Override
- public String getScript() {
- return script;
- }
-
- @NonNull
- @Override
- public ScriptGraphStatement setSystemQuery(@Nullable Boolean newValue) {
- return new DefaultScriptGraphStatement(
- script,
- queryParams,
- newValue,
- isIdempotent(),
- getTimeout(),
- getNode(),
- getTimestamp(),
- getExecutionProfile(),
- getExecutionProfileName(),
- getCustomPayload(),
- getGraphName(),
- getTraversalSource(),
- getSubProtocol(),
- getConsistencyLevel(),
- getReadConsistencyLevel(),
- getWriteConsistencyLevel());
- }
-
- @Nullable
- @Override
- public Boolean isSystemQuery() {
- return isSystemQuery;
- }
-
- @NonNull
- @Override
- public Map getQueryParams() {
- return this.queryParams;
- }
-
- @NonNull
- @Override
- public ScriptGraphStatement setQueryParam(@NonNull String name, @Nullable Object value) {
- NullAllowingImmutableMap.Builder newQueryParamsBuilder =
- NullAllowingImmutableMap.builder();
- for (Map.Entry entry : queryParams.entrySet()) {
- if (!entry.getKey().equals(name)) {
- newQueryParamsBuilder.put(entry.getKey(), entry.getValue());
- }
- }
- newQueryParamsBuilder.put(name, value);
- return setQueryParams(newQueryParamsBuilder.build());
- }
-
- @NonNull
- @Override
- public ScriptGraphStatement removeQueryParam(@NonNull String name) {
- if (!queryParams.containsKey(name)) {
- return this;
- } else {
- NullAllowingImmutableMap.Builder newQueryParamsBuilder =
- NullAllowingImmutableMap.builder();
- for (Map.Entry entry : queryParams.entrySet()) {
- if (!entry.getKey().equals(name)) {
- newQueryParamsBuilder.put(entry.getKey(), entry.getValue());
- }
- }
- return setQueryParams(newQueryParamsBuilder.build());
- }
- }
-
- private ScriptGraphStatement setQueryParams(Map newQueryParams) {
- return new DefaultScriptGraphStatement(
- script,
- newQueryParams,
- isSystemQuery,
- isIdempotent(),
- getTimeout(),
- getNode(),
- getTimestamp(),
- getExecutionProfile(),
- getExecutionProfileName(),
- getCustomPayload(),
- getGraphName(),
- getTraversalSource(),
- getSubProtocol(),
- getConsistencyLevel(),
- getReadConsistencyLevel(),
- getWriteConsistencyLevel());
- }
-
- @Override
- protected ScriptGraphStatement newInstance(
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- return new DefaultScriptGraphStatement(
- script,
- queryParams,
- isSystemQuery,
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Override
- public String toString() {
- return String.format("ScriptGraphStatement['%s', params: %s]", this.script, this.queryParams);
- }
-
- @NonNull
- @Override
- public RequestRoutingType getRequestRoutingType() {
- return RequestRoutingType.REGULAR;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DseGraphRemoteConnection.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DseGraphRemoteConnection.java
deleted file mode 100644
index a5ec0a1d115..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DseGraphRemoteConnection.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.oss.driver.api.core.CqlSession;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import java.util.concurrent.CompletableFuture;
-import net.jcip.annotations.Immutable;
-import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
-import org.apache.tinkerpop.gremlin.process.remote.traversal.RemoteTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
-
-@Immutable
-public class DseGraphRemoteConnection implements RemoteConnection {
-
- private final CqlSession session;
- private final DriverExecutionProfile executionProfile;
- private final String executionProfileName;
-
- public DseGraphRemoteConnection(
- CqlSession session, DriverExecutionProfile executionProfile, String executionProfileName) {
- this.session = session;
- this.executionProfile = executionProfile;
- this.executionProfileName = executionProfileName;
- }
-
- @Override
- public CompletableFuture> submitAsync(Bytecode bytecode) {
- return session
- .executeAsync(new BytecodeGraphStatement(bytecode, executionProfile, executionProfileName))
- .toCompletableFuture()
- .thenApply(DseGraphTraversal::new);
- }
-
- @Override
- public void close() throws Exception {
- // do not close the DseSession here.
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DseGraphTraversal.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DseGraphTraversal.java
deleted file mode 100644
index e0a5cf2d675..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DseGraphTraversal.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import net.jcip.annotations.NotThreadSafe;
-import org.apache.tinkerpop.gremlin.process.remote.traversal.AbstractRemoteTraversal;
-import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-
-@NotThreadSafe
-class DseGraphTraversal extends AbstractRemoteTraversal {
-
- private final Iterator graphNodeIterator;
-
- public DseGraphTraversal(AsyncGraphResultSet firstPage) {
- this.graphNodeIterator = GraphResultSets.toSync(firstPage).iterator();
- }
-
- @Override
- public boolean hasNext() {
- return graphNodeIterator.hasNext();
- }
-
- @Override
- public E next() {
- return nextTraverser().get();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Traverser.Admin nextTraverser() {
- if (hasNext()) {
- GraphNode nextGraphNode = graphNodeIterator.next();
-
- // get the Raw object from the ObjectGraphNode, create a new remote Traverser
- // with bulk = 1 because bulk is not supported yet. Casting should be ok
- // because we have been able to deserialize into the right type.
- return new DefaultRemoteTraverser<>((E) nextGraphNode.as(Object.class), 1);
- } else {
- // finished iterating/nothing to iterate. Normal behaviour.
- throw new NoSuchElementException();
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DsePredicate.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DsePredicate.java
deleted file mode 100644
index b5f8c30fd8c..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/DsePredicate.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import java.util.function.BiPredicate;
-
-/**
- * An extension of TinkerPop's {@link BiPredicate} adding simple pre-condition checking methods that
- * have to be written in the implementations.
- */
-public interface DsePredicate extends BiPredicate {
-
- default void preEvaluate(Object condition) {
- Preconditions.checkArgument(
- this.isValidCondition(condition), "Invalid condition provided: %s", condition);
- }
-
- boolean isValidCondition(Object condition);
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/EditDistance.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/EditDistance.java
deleted file mode 100644
index 5ab836babbf..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/EditDistance.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.oss.driver.shaded.guava.common.base.Objects;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import java.io.Serializable;
-import net.jcip.annotations.Immutable;
-
-/**
- * A container for a term and maximum edit distance.
- *
- * The context in which this is used determines the semantics of the edit distance. For instance,
- * it might indicate single-character edits if used with fuzzy search queries or whole word
- * movements if used with phrase proximity queries.
- */
-@Immutable
-public class EditDistance implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final int DEFAULT_EDIT_DISTANCE = 0;
-
- public final String query;
- public final int distance;
-
- public EditDistance(String query) {
- this(query, DEFAULT_EDIT_DISTANCE);
- }
-
- public EditDistance(String query, int distance) {
- Preconditions.checkNotNull(query, "Query cannot be null.");
- Preconditions.checkArgument(distance >= 0, "Edit distance cannot be negative.");
- this.query = query;
- this.distance = distance;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof EditDistance)) {
- return false;
- }
- EditDistance that = (EditDistance) o;
- return distance == that.distance && Objects.equal(query, that.query);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(query, distance);
- }
-
- @Override
- public String toString() {
- return "EditDistance{" + "query='" + query + '\'' + ", distance=" + distance + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GeoPredicate.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GeoPredicate.java
deleted file mode 100644
index 39949e97198..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GeoPredicate.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.data.geometry.Geometry;
-import com.datastax.dse.driver.api.core.data.geometry.LineString;
-import com.datastax.dse.driver.api.core.data.geometry.Point;
-import com.datastax.dse.driver.api.core.data.geometry.Polygon;
-import com.datastax.dse.driver.api.core.graph.predicates.Geo;
-import com.datastax.dse.driver.internal.core.data.geometry.Distance;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-
-/**
- * List of predicates for geolocation usage with DseGraph and Search indexes. Should not be accessed
- * directly but through the {@link Geo} static methods.
- */
-public enum GeoPredicate implements DsePredicate {
-
- /** Matches values within the distance specified by the condition over a Haversine geometry. */
- inside {
- @Override
- public boolean test(Object value, Object condition) {
- preEvaluate(condition);
- if (value == null) {
- return false;
- }
- Preconditions.checkArgument(value instanceof Geometry);
- Distance distance = (Distance) condition;
- if (value instanceof Point) {
- return haversineDistanceInDegrees(distance.getCenter(), (Point) value)
- <= distance.getRadius();
- } else if (value instanceof Polygon) {
- for (Point point : ((Polygon) value).getExteriorRing()) {
- if (haversineDistanceInDegrees(distance.getCenter(), point) > distance.getRadius()) {
- return false;
- }
- }
- } else if (value instanceof LineString) {
- for (Point point : ((LineString) value).getPoints()) {
- if (haversineDistanceInDegrees(distance.getCenter(), point) > distance.getRadius()) {
- return false;
- }
- }
- } else {
- throw new UnsupportedOperationException(
- String.format("Value type '%s' unsupported", value.getClass().getName()));
- }
-
- return true;
- }
-
- @Override
- public String toString() {
- return "inside";
- }
- },
-
- /**
- * Matches values contained in the geometric entity specified by the condition on a 2D Euclidean
- * plane.
- */
- insideCartesian {
- @Override
- public boolean test(Object value, Object condition) {
- preEvaluate(condition);
- if (value == null) {
- return false;
- }
- Preconditions.checkArgument(value instanceof Geometry);
- return ((Geometry) condition).contains((Geometry) value);
- }
-
- @Override
- public String toString() {
- return "insideCartesian";
- }
- };
-
- @Override
- public boolean isValidCondition(Object condition) {
- return condition != null;
- }
-
- static double haversineDistanceInDegrees(Point p1, Point p2) {
- double dLat = Math.toRadians(p2.Y() - p1.Y());
- double dLon = Math.toRadians(p2.X() - p1.X());
- double lat1 = Math.toRadians(p1.Y());
- double lat2 = Math.toRadians(p2.Y());
-
- double a =
- Math.pow(Math.sin(dLat / 2), 2)
- + Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
- double c = 2 * Math.asin(Math.sqrt(a));
- return Math.toDegrees(c);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GeoUtils.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GeoUtils.java
deleted file mode 100644
index 80d55dac69d..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GeoUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-public class GeoUtils {
- private static final double DEGREES_TO_RADIANS = Math.PI / 180;
- private static final double EARTH_MEAN_RADIUS_KM = 6371.0087714;
- private static final double DEG_TO_KM = DEGREES_TO_RADIANS * EARTH_MEAN_RADIUS_KM;
- private static final double KM_TO_MILES = 0.621371192;
- public static final double KM_TO_DEG = 1 / DEG_TO_KM;
- public static final double MILES_TO_KM = 1 / KM_TO_MILES;
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphConversions.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphConversions.java
deleted file mode 100644
index c95b26b2e26..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphConversions.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-import com.datastax.dse.driver.api.core.config.DseDriverOption;
-import com.datastax.dse.driver.api.core.graph.BatchGraphStatement;
-import com.datastax.dse.driver.api.core.graph.FluentGraphStatement;
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.api.core.graph.ScriptGraphStatement;
-import com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule;
-import com.datastax.dse.driver.internal.core.graph.binary.buffer.DseNettyBufferFactory;
-import com.datastax.dse.protocol.internal.request.RawBytesQuery;
-import com.datastax.dse.protocol.internal.request.query.ContinuousPagingOptions;
-import com.datastax.dse.protocol.internal.request.query.DseQueryOptions;
-import com.datastax.oss.driver.api.core.ConsistencyLevel;
-import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
-import com.datastax.oss.driver.api.core.ProtocolVersion;
-import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.cql.Statement;
-import com.datastax.oss.driver.api.core.type.codec.TypeCodecs;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.cql.Conversions;
-import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
-import com.datastax.oss.driver.shaded.guava.common.collect.Iterators;
-import com.datastax.oss.protocol.internal.Message;
-import com.datastax.oss.protocol.internal.ProtocolConstants;
-import com.datastax.oss.protocol.internal.request.Query;
-import com.datastax.oss.protocol.internal.util.collection.NullAllowingImmutableMap;
-import io.netty.buffer.ByteBuf;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.structure.io.Buffer;
-import org.apache.tinkerpop.gremlin.structure.io.BufferFactory;
-
-/**
- * Utility class to move boilerplate out of {@link GraphRequestHandler}.
- *
- *
We extend {@link Conversions} only for methods that can be directly reused as-is; if something
- * needs to be customized, it will be duplicated here instead of making the parent method
- * "pluggable".
- */
-public class GraphConversions extends Conversions {
-
- static final String GRAPH_LANG_OPTION_KEY = "graph-language";
- static final String GRAPH_NAME_OPTION_KEY = "graph-name";
- static final String GRAPH_SOURCE_OPTION_KEY = "graph-source";
- static final String GRAPH_READ_CONSISTENCY_LEVEL_OPTION_KEY = "graph-read-consistency";
- static final String GRAPH_WRITE_CONSISTENCY_LEVEL_OPTION_KEY = "graph-write-consistency";
- static final String GRAPH_RESULTS_OPTION_KEY = "graph-results";
- static final String GRAPH_TIMEOUT_OPTION_KEY = "request-timeout";
- static final String GRAPH_BINARY_QUERY_OPTION_KEY = "graph-binary-query";
-
- static final String LANGUAGE_GROOVY = "gremlin-groovy";
- static final String LANGUAGE_BYTECODE = "bytecode-json";
-
- private static final BufferFactory FACTORY = new DseNettyBufferFactory();
-
- @VisibleForTesting static final byte[] EMPTY_STRING_QUERY = "".getBytes(UTF_8);
-
- public static Message createContinuousMessageFromGraphStatement(
- GraphStatement> statement,
- GraphProtocol subProtocol,
- DriverExecutionProfile config,
- InternalDriverContext context,
- GraphBinaryModule graphBinaryModule) {
-
- final List encodedQueryParams;
- if (!(statement instanceof ScriptGraphStatement)
- || ((ScriptGraphStatement) statement).getQueryParams().isEmpty()) {
- encodedQueryParams = Collections.emptyList();
- } else {
- try {
- Map queryParams = ((ScriptGraphStatement) statement).getQueryParams();
- if (subProtocol.isGraphBinary()) {
- Buffer graphBinaryParams = graphBinaryModule.serialize(queryParams);
- encodedQueryParams = Collections.singletonList(graphBinaryParams.nioBuffer());
- graphBinaryParams.release();
- } else {
- encodedQueryParams =
- Collections.singletonList(
- GraphSONUtils.serializeToByteBuffer(queryParams, subProtocol));
- }
- } catch (IOException e) {
- throw new UncheckedIOException(
- "Couldn't serialize parameters for GraphStatement: " + statement, e);
- }
- }
-
- int consistencyLevel =
- DefaultConsistencyLevel.valueOf(config.getString(DefaultDriverOption.REQUEST_CONSISTENCY))
- .getProtocolCode();
-
- long timestamp = statement.getTimestamp();
- if (timestamp == Statement.NO_DEFAULT_TIMESTAMP) {
- timestamp = context.getTimestampGenerator().next();
- }
-
- int pageSize = config.getInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_PAGE_SIZE);
- int maxPages = config.getInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES);
- int maxPagesPerSecond =
- config.getInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES_PER_SECOND);
- int maxEnqueuedPages =
- config.getInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES);
- ContinuousPagingOptions options =
- new ContinuousPagingOptions(maxPages, maxPagesPerSecond, maxEnqueuedPages);
-
- DseQueryOptions queryOptions =
- new DseQueryOptions(
- consistencyLevel,
- encodedQueryParams,
- Collections.emptyMap(), // ignored by the DSE Graph server
- true, // also ignored
- pageSize,
- null,
- ProtocolConstants.ConsistencyLevel.LOCAL_SERIAL, // also ignored
- timestamp,
- null, // also ignored
- false, // graph CP does not support sizeInBytes
- options);
-
- if (statement instanceof ScriptGraphStatement) {
- return new Query(((ScriptGraphStatement) statement).getScript(), queryOptions);
- } else {
- return new RawBytesQuery(getQueryBytes(statement, subProtocol), queryOptions);
- }
- }
-
- static Message createMessageFromGraphStatement(
- GraphStatement> statement,
- GraphProtocol subProtocol,
- DriverExecutionProfile config,
- InternalDriverContext context,
- GraphBinaryModule graphBinaryModule) {
-
- final List encodedQueryParams;
- if (!(statement instanceof ScriptGraphStatement)
- || ((ScriptGraphStatement) statement).getQueryParams().isEmpty()) {
- encodedQueryParams = Collections.emptyList();
- } else {
- try {
- Map queryParams = ((ScriptGraphStatement) statement).getQueryParams();
- if (subProtocol.isGraphBinary()) {
- Buffer graphBinaryParams = graphBinaryModule.serialize(queryParams);
- encodedQueryParams = Collections.singletonList(graphBinaryParams.nioBuffer());
- graphBinaryParams.release();
- } else {
- encodedQueryParams =
- Collections.singletonList(
- GraphSONUtils.serializeToByteBuffer(queryParams, subProtocol));
- }
- } catch (IOException e) {
- throw new UncheckedIOException(
- "Couldn't serialize parameters for GraphStatement: " + statement, e);
- }
- }
-
- ConsistencyLevel consistency = statement.getConsistencyLevel();
- int consistencyLevel =
- (consistency == null)
- ? context
- .getConsistencyLevelRegistry()
- .nameToCode(config.getString(DefaultDriverOption.REQUEST_CONSISTENCY))
- : consistency.getProtocolCode();
-
- long timestamp = statement.getTimestamp();
- if (timestamp == Statement.NO_DEFAULT_TIMESTAMP) {
- timestamp = context.getTimestampGenerator().next();
- }
-
- DseQueryOptions queryOptions =
- new DseQueryOptions(
- consistencyLevel,
- encodedQueryParams,
- Collections.emptyMap(), // ignored by the DSE Graph server
- true, // also ignored
- 50, // also ignored
- null, // also ignored
- ProtocolConstants.ConsistencyLevel.LOCAL_SERIAL, // also ignored
- timestamp,
- null, // also ignored
- false, // also ignored
- null // also ignored
- );
-
- if (statement instanceof ScriptGraphStatement) {
- return new Query(((ScriptGraphStatement) statement).getScript(), queryOptions);
- } else {
- return new RawBytesQuery(getQueryBytes(statement, subProtocol), queryOptions);
- }
- }
-
- // This method returns either a Bytecode object, or a List if the statement is a
- // BatchGraphStatement
- @VisibleForTesting
- public static Object bytecodeToSerialize(GraphStatement> statement) {
- Preconditions.checkArgument(
- statement instanceof FluentGraphStatement
- || statement instanceof BatchGraphStatement
- || statement instanceof BytecodeGraphStatement,
- "To serialize bytecode the query must be a fluent or batch statement, but was: %s",
- statement.getClass());
-
- Object toSerialize;
- if (statement instanceof FluentGraphStatement) {
- toSerialize = ((FluentGraphStatement) statement).getTraversal().asAdmin().getBytecode();
- } else if (statement instanceof BatchGraphStatement) {
- // transform the Iterator to List
- toSerialize =
- ImmutableList.copyOf(
- Iterators.transform(
- ((BatchGraphStatement) statement).iterator(),
- traversal -> traversal.asAdmin().getBytecode()));
- } else {
- toSerialize = ((BytecodeGraphStatement) statement).getBytecode();
- }
- return toSerialize;
- }
-
- private static byte[] getQueryBytes(GraphStatement> statement, GraphProtocol graphSubProtocol) {
- try {
- return graphSubProtocol.isGraphBinary()
- // if GraphBinary, the query is encoded in the custom payload, and not in the query field
- // see GraphConversions#createCustomPayload()
- ? EMPTY_STRING_QUERY
- : GraphSONUtils.serializeToBytes(bytecodeToSerialize(statement), graphSubProtocol);
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- public static Map createCustomPayload(
- GraphStatement> statement,
- GraphProtocol subProtocol,
- DriverExecutionProfile config,
- InternalDriverContext context,
- GraphBinaryModule graphBinaryModule) {
-
- ProtocolVersion protocolVersion = context.getProtocolVersion();
-
- NullAllowingImmutableMap.Builder payload =
- NullAllowingImmutableMap.builder();
- Map statementOptions = statement.getCustomPayload();
- payload.putAll(statementOptions);
-
- final String graphLanguage;
-
- // Don't override anything that's already provided at the statement level
- if (!statementOptions.containsKey(GRAPH_LANG_OPTION_KEY)) {
- graphLanguage =
- statement instanceof ScriptGraphStatement ? LANGUAGE_GROOVY : LANGUAGE_BYTECODE;
- payload.put(GRAPH_LANG_OPTION_KEY, TypeCodecs.TEXT.encode(graphLanguage, protocolVersion));
- } else {
- graphLanguage =
- TypeCodecs.TEXT.decode(statementOptions.get(GRAPH_LANG_OPTION_KEY), protocolVersion);
- Preconditions.checkNotNull(
- graphLanguage, "A null value was set for the graph-language custom payload key.");
- }
-
- if (!isSystemQuery(statement, config)) {
- if (!statementOptions.containsKey(GRAPH_NAME_OPTION_KEY)) {
- String graphName = statement.getGraphName();
- if (graphName == null) {
- graphName = config.getString(DseDriverOption.GRAPH_NAME, null);
- }
- if (graphName != null) {
- payload.put(GRAPH_NAME_OPTION_KEY, TypeCodecs.TEXT.encode(graphName, protocolVersion));
- }
- }
- if (!statementOptions.containsKey(GRAPH_SOURCE_OPTION_KEY)) {
- String traversalSource = statement.getTraversalSource();
- if (traversalSource == null) {
- traversalSource = config.getString(DseDriverOption.GRAPH_TRAVERSAL_SOURCE, null);
- }
- if (traversalSource != null) {
- payload.put(
- GRAPH_SOURCE_OPTION_KEY, TypeCodecs.TEXT.encode(traversalSource, protocolVersion));
- }
- }
- }
-
- // the payload allows null entry values so doing a get directly here and checking for null
- final ByteBuffer payloadInitialProtocol = statementOptions.get(GRAPH_RESULTS_OPTION_KEY);
- if (payloadInitialProtocol == null) {
- Preconditions.checkNotNull(subProtocol);
- payload.put(
- GRAPH_RESULTS_OPTION_KEY,
- TypeCodecs.TEXT.encode(subProtocol.toInternalCode(), protocolVersion));
- } else {
- subProtocol =
- GraphProtocol.fromString(TypeCodecs.TEXT.decode(payloadInitialProtocol, protocolVersion));
- }
-
- if (subProtocol.isGraphBinary() && graphLanguage.equals(LANGUAGE_BYTECODE)) {
- Object bytecodeQuery = bytecodeToSerialize(statement);
- try {
- Buffer bytecodeByteBuf = graphBinaryModule.serialize(bytecodeQuery);
- payload.put(GRAPH_BINARY_QUERY_OPTION_KEY, bytecodeByteBuf.nioBuffer());
- bytecodeByteBuf.release();
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- if (!statementOptions.containsKey(GRAPH_READ_CONSISTENCY_LEVEL_OPTION_KEY)) {
- ConsistencyLevel readCl = statement.getReadConsistencyLevel();
- String readClString =
- readCl != null
- ? readCl.name()
- : config.getString(DseDriverOption.GRAPH_READ_CONSISTENCY_LEVEL, null);
- if (readClString != null) {
- payload.put(
- GRAPH_READ_CONSISTENCY_LEVEL_OPTION_KEY,
- TypeCodecs.TEXT.encode(readClString, protocolVersion));
- }
- }
-
- if (!statementOptions.containsKey(GRAPH_WRITE_CONSISTENCY_LEVEL_OPTION_KEY)) {
- ConsistencyLevel writeCl = statement.getWriteConsistencyLevel();
- String writeClString =
- writeCl != null
- ? writeCl.name()
- : config.getString(DseDriverOption.GRAPH_WRITE_CONSISTENCY_LEVEL, null);
- if (writeClString != null) {
- payload.put(
- GRAPH_WRITE_CONSISTENCY_LEVEL_OPTION_KEY,
- TypeCodecs.TEXT.encode(writeClString, protocolVersion));
- }
- }
-
- if (!statementOptions.containsKey(GRAPH_TIMEOUT_OPTION_KEY)) {
- Duration timeout = statement.getTimeout();
- if (timeout == null) {
- timeout = config.getDuration(DseDriverOption.GRAPH_TIMEOUT, Duration.ZERO);
- }
- if (timeout != null && !timeout.isZero()) {
- payload.put(
- GRAPH_TIMEOUT_OPTION_KEY,
- TypeCodecs.BIGINT.encode(timeout.toMillis(), protocolVersion));
- }
- }
- return payload.build();
- }
-
- private static boolean isSystemQuery(GraphStatement> statement, DriverExecutionProfile config) {
- if (statement instanceof ScriptGraphStatement) {
- Boolean statementValue = ((ScriptGraphStatement) statement).isSystemQuery();
- if (statementValue != null) {
- return statementValue;
- }
- }
- return config.getBoolean(DseDriverOption.GRAPH_IS_SYSTEM_QUERY, false);
- }
-
- public static GraphNode createGraphBinaryGraphNode(
- List data, GraphBinaryModule graphBinaryModule) throws IOException {
- // there should be only one column in the given row
- Preconditions.checkArgument(data.size() == 1, "Invalid row given to deserialize");
-
- Buffer toDeserialize = FACTORY.wrap(data.get(0));
- Object deserializedObject = graphBinaryModule.deserialize(toDeserialize);
- toDeserialize.release();
- assert deserializedObject instanceof Traverser
- : "Graph protocol error. Received object should be a Traverser but it is not.";
- return new ObjectGraphNode(deserializedObject);
- }
-
- public static Duration resolveGraphRequestTimeout(
- GraphStatement> statement, InternalDriverContext context) {
- DriverExecutionProfile executionProfile = resolveExecutionProfile(statement, context);
- return statement.getTimeout() != null
- ? statement.getTimeout()
- : executionProfile.getDuration(DseDriverOption.GRAPH_TIMEOUT);
- }
-
- public static GraphProtocol resolveGraphSubProtocol(
- GraphStatement> statement,
- GraphSupportChecker graphSupportChecker,
- InternalDriverContext context) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- return graphSupportChecker.inferGraphProtocol(statement, executionProfile, context);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphExecutionInfoConverter.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphExecutionInfoConverter.java
deleted file mode 100644
index b6472f690d3..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphExecutionInfoConverter.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
-import com.datastax.oss.driver.api.core.cql.QueryTrace;
-import com.datastax.oss.driver.api.core.cql.Statement;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.api.core.session.Request;
-import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.Nullable;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.UUID;
-import java.util.concurrent.CompletionStage;
-
-/**
- * Handles conversions from / to GraphExecutionInfo and ExecutionInfo since GraphExecutionInfo has
- * been deprecated by JAVA-2556.
- */
-public class GraphExecutionInfoConverter {
-
- /**
- * Called exclusively from default methods in API interfaces {@link
- * com.datastax.dse.driver.api.core.graph.GraphResultSet} and {@link
- * com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet}. Graph result set implementations
- * do not use this method but rather the other one below.
- */
- @SuppressWarnings("deprecation")
- public static ExecutionInfo convert(
- com.datastax.dse.driver.api.core.graph.GraphExecutionInfo graphExecutionInfo) {
- return new ExecutionInfo() {
-
- @NonNull
- @Override
- public Request getRequest() {
- return graphExecutionInfo.getStatement();
- }
-
- @NonNull
- @Override
- public Statement> getStatement() {
- throw new ClassCastException("GraphStatement cannot be cast to Statement");
- }
-
- @Nullable
- @Override
- public Node getCoordinator() {
- return graphExecutionInfo.getCoordinator();
- }
-
- @Override
- public int getSpeculativeExecutionCount() {
- return graphExecutionInfo.getSpeculativeExecutionCount();
- }
-
- @Override
- public int getSuccessfulExecutionIndex() {
- return graphExecutionInfo.getSuccessfulExecutionIndex();
- }
-
- @NonNull
- @Override
- public List> getErrors() {
- return graphExecutionInfo.getErrors();
- }
-
- @Nullable
- @Override
- public ByteBuffer getPagingState() {
- return null;
- }
-
- @NonNull
- @Override
- public List getWarnings() {
- return graphExecutionInfo.getWarnings();
- }
-
- @NonNull
- @Override
- public Map getIncomingPayload() {
- return graphExecutionInfo.getIncomingPayload();
- }
-
- @Override
- public boolean isSchemaInAgreement() {
- return true;
- }
-
- @Nullable
- @Override
- public UUID getTracingId() {
- return null;
- }
-
- @NonNull
- @Override
- public CompletionStage getQueryTraceAsync() {
- return CompletableFutures.failedFuture(
- new IllegalStateException("Tracing was disabled for this request"));
- }
-
- @Override
- public int getResponseSizeInBytes() {
- return -1;
- }
-
- @Override
- public int getCompressedResponseSizeInBytes() {
- return -1;
- }
- };
- }
-
- /**
- * Called from graph result set implementations, to convert the original {@link ExecutionInfo}
- * produced by request handlers into the (deprecated) type GraphExecutionInfo.
- */
- @SuppressWarnings("deprecation")
- public static com.datastax.dse.driver.api.core.graph.GraphExecutionInfo convert(
- ExecutionInfo executionInfo) {
- return new com.datastax.dse.driver.api.core.graph.GraphExecutionInfo() {
-
- @Override
- public GraphStatement> getStatement() {
- return (GraphStatement>) executionInfo.getRequest();
- }
-
- @Override
- public Node getCoordinator() {
- return executionInfo.getCoordinator();
- }
-
- @Override
- public int getSpeculativeExecutionCount() {
- return executionInfo.getSpeculativeExecutionCount();
- }
-
- @Override
- public int getSuccessfulExecutionIndex() {
- return executionInfo.getSuccessfulExecutionIndex();
- }
-
- @Override
- public List> getErrors() {
- return executionInfo.getErrors();
- }
-
- @Override
- public List getWarnings() {
- return executionInfo.getWarnings();
- }
-
- @Override
- public Map getIncomingPayload() {
- return executionInfo.getIncomingPayload();
- }
- };
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphProtocol.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphProtocol.java
deleted file mode 100644
index 6b7a9f4c430..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphProtocol.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.Nullable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-public enum GraphProtocol {
- GRAPHSON_1_0("graphson-1.0"),
- GRAPHSON_2_0("graphson-2.0"),
- GRAPH_BINARY_1_0("graph-binary-1.0"),
- ;
-
- private static final Map BY_CODE;
-
- static {
- Map tmp = new HashMap<>();
- for (GraphProtocol value : values()) {
- tmp.put(value.stringRepresentation, value);
- }
- BY_CODE = Collections.unmodifiableMap(tmp);
- }
-
- private final String stringRepresentation;
-
- GraphProtocol(String stringRepresentation) {
- this.stringRepresentation = stringRepresentation;
- }
-
- @NonNull
- public String toInternalCode() {
- return stringRepresentation;
- }
-
- @NonNull
- public static GraphProtocol fromString(@Nullable String stringRepresentation) {
- if (stringRepresentation == null || !BY_CODE.containsKey(stringRepresentation)) {
- StringBuilder sb =
- new StringBuilder(
- String.format(
- "Graph protocol used [\"%s\"] unknown. Possible values are: [ \"%s\"",
- stringRepresentation, GraphProtocol.values()[0].toInternalCode()));
- for (int i = 1; i < GraphProtocol.values().length; i++) {
- sb.append(String.format(", \"%s\"", GraphProtocol.values()[i].toInternalCode()));
- }
- sb.append("]");
- throw new IllegalArgumentException(sb.toString());
- }
- return BY_CODE.get(stringRepresentation);
- }
-
- public boolean isGraphBinary() {
- return this == GRAPH_BINARY_1_0;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestAsyncProcessor.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestAsyncProcessor.java
deleted file mode 100644
index 050b03c66f4..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestAsyncProcessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.BatchGraphStatement;
-import com.datastax.dse.driver.api.core.graph.FluentGraphStatement;
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.api.core.graph.ScriptGraphStatement;
-import com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule;
-import com.datastax.oss.driver.api.core.session.Request;
-import com.datastax.oss.driver.api.core.type.reflect.GenericType;
-import com.datastax.oss.driver.internal.core.context.DefaultDriverContext;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.session.DefaultSession;
-import com.datastax.oss.driver.internal.core.session.RequestProcessor;
-import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.concurrent.CompletionStage;
-import net.jcip.annotations.ThreadSafe;
-import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader;
-import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter;
-import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry;
-
-@ThreadSafe
-public class GraphRequestAsyncProcessor
- implements RequestProcessor, CompletionStage> {
-
- private final GraphBinaryModule graphBinaryModule;
- private final GraphSupportChecker graphSupportChecker;
-
- public GraphRequestAsyncProcessor(
- DefaultDriverContext context, GraphSupportChecker graphSupportChecker) {
- TypeSerializerRegistry typeSerializerRegistry =
- GraphBinaryModule.createDseTypeSerializerRegistry(context);
- this.graphBinaryModule =
- new GraphBinaryModule(
- new GraphBinaryReader(typeSerializerRegistry),
- new GraphBinaryWriter(typeSerializerRegistry));
- this.graphSupportChecker = graphSupportChecker;
- }
-
- @NonNull
- public GraphBinaryModule getGraphBinaryModule() {
- return graphBinaryModule;
- }
-
- @Override
- public boolean canProcess(Request request, GenericType> resultType) {
- return (request instanceof ScriptGraphStatement
- || request instanceof FluentGraphStatement
- || request instanceof BatchGraphStatement
- || request instanceof BytecodeGraphStatement)
- && resultType.equals(GraphStatement.ASYNC);
- }
-
- @Override
- public CompletionStage process(
- GraphStatement> request,
- DefaultSession session,
- InternalDriverContext context,
- String sessionLogPrefix) {
-
- if (graphSupportChecker.isPagingEnabled(request, context)) {
- return new ContinuousGraphRequestHandler(
- request,
- session,
- context,
- sessionLogPrefix,
- getGraphBinaryModule(),
- graphSupportChecker)
- .handle();
- } else {
- return new GraphRequestHandler(
- request,
- session,
- context,
- sessionLogPrefix,
- getGraphBinaryModule(),
- graphSupportChecker)
- .handle();
- }
- }
-
- @Override
- public CompletionStage newFailure(RuntimeException error) {
- return CompletableFutures.failedFuture(error);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestHandler.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestHandler.java
deleted file mode 100644
index cf6875dd362..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestHandler.java
+++ /dev/null
@@ -1,908 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import static com.datastax.oss.driver.api.core.DriverTimeoutException.UNAVAILABLE;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.api.core.metrics.DseNodeMetric;
-import com.datastax.dse.driver.api.core.metrics.DseSessionMetric;
-import com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule;
-import com.datastax.oss.driver.api.core.AllNodesFailedException;
-import com.datastax.oss.driver.api.core.DriverException;
-import com.datastax.oss.driver.api.core.DriverTimeoutException;
-import com.datastax.oss.driver.api.core.DriverTimeoutException.NodeDiagnostics;
-import com.datastax.oss.driver.api.core.NodeUnavailableException;
-import com.datastax.oss.driver.api.core.RequestThrottlingException;
-import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.connection.FrameTooLongException;
-import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric;
-import com.datastax.oss.driver.api.core.metrics.DefaultSessionMetric;
-import com.datastax.oss.driver.api.core.retry.RetryPolicy;
-import com.datastax.oss.driver.api.core.retry.RetryVerdict;
-import com.datastax.oss.driver.api.core.servererrors.BootstrappingException;
-import com.datastax.oss.driver.api.core.servererrors.CoordinatorException;
-import com.datastax.oss.driver.api.core.servererrors.FunctionFailureException;
-import com.datastax.oss.driver.api.core.servererrors.ProtocolError;
-import com.datastax.oss.driver.api.core.servererrors.QueryValidationException;
-import com.datastax.oss.driver.api.core.servererrors.ReadTimeoutException;
-import com.datastax.oss.driver.api.core.servererrors.UnavailableException;
-import com.datastax.oss.driver.api.core.servererrors.WriteTimeoutException;
-import com.datastax.oss.driver.api.core.session.throttling.RequestThrottler;
-import com.datastax.oss.driver.api.core.session.throttling.Throttled;
-import com.datastax.oss.driver.api.core.tracker.RequestTracker;
-import com.datastax.oss.driver.internal.core.channel.DriverChannel;
-import com.datastax.oss.driver.internal.core.channel.ResponseCallback;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.cql.Conversions;
-import com.datastax.oss.driver.internal.core.cql.DefaultExecutionInfo;
-import com.datastax.oss.driver.internal.core.metadata.DefaultNode;
-import com.datastax.oss.driver.internal.core.metrics.NodeMetricUpdater;
-import com.datastax.oss.driver.internal.core.metrics.SessionMetricUpdater;
-import com.datastax.oss.driver.internal.core.pool.ChannelPool;
-import com.datastax.oss.driver.internal.core.session.DefaultSession;
-import com.datastax.oss.driver.internal.core.tracker.NoopRequestTracker;
-import com.datastax.oss.driver.internal.core.tracker.RequestLogger;
-import com.datastax.oss.driver.internal.core.util.Loggers;
-import com.datastax.oss.driver.internal.core.util.collection.SimpleQueryPlan;
-import com.datastax.oss.protocol.internal.Frame;
-import com.datastax.oss.protocol.internal.Message;
-import com.datastax.oss.protocol.internal.response.Error;
-import com.datastax.oss.protocol.internal.response.Result;
-import com.datastax.oss.protocol.internal.response.result.Rows;
-import com.datastax.oss.protocol.internal.response.result.Void;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.Nullable;
-import io.netty.handler.codec.EncoderException;
-import io.netty.util.Timeout;
-import io.netty.util.Timer;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.AbstractMap;
-import java.util.ArrayDeque;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import net.jcip.annotations.ThreadSafe;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@ThreadSafe
-public class GraphRequestHandler implements Throttled {
-
- private static final Logger LOG = LoggerFactory.getLogger(GraphRequestHandler.class);
-
- private static final long NANOTIME_NOT_MEASURED_YET = -1;
- private static final int NO_SUCCESSFUL_EXECUTION = -1;
-
- private final long startTimeNanos;
- private final String logPrefix;
- private final GraphStatement> initialStatement;
- private final DefaultSession session;
- private final InternalDriverContext context;
- protected final CompletableFuture result;
- private final Timer timer;
-
- /**
- * How many speculative executions are currently running (including the initial execution). We
- * track this in order to know when to fail the request if all executions have reached the end of
- * the query plan.
- */
- private final AtomicInteger activeExecutionsCount;
-
- /**
- * How many speculative executions have started (excluding the initial execution), whether they
- * have completed or not. We track this in order to fill {@link
- * ExecutionInfo#getSpeculativeExecutionCount()}.
- */
- private final AtomicInteger startedSpeculativeExecutionsCount;
-
- private final Timeout scheduledTimeout;
- private final List scheduledExecutions;
- private final List inFlightCallbacks;
- private final RequestThrottler throttler;
- private final RequestTracker requestTracker;
- private final SessionMetricUpdater sessionMetricUpdater;
- private final GraphBinaryModule graphBinaryModule;
- private final GraphSupportChecker graphSupportChecker;
-
- // The errors on the nodes that were already tried (lazily initialized on the first error).
- // We don't use a map because nodes can appear multiple times.
- private volatile List> errors;
-
- GraphRequestHandler(
- @NonNull GraphStatement> statement,
- @NonNull DefaultSession dseSession,
- @NonNull InternalDriverContext context,
- @NonNull String sessionLogPrefix,
- @NonNull GraphBinaryModule graphBinaryModule,
- @NonNull GraphSupportChecker graphSupportChecker) {
- this.startTimeNanos = System.nanoTime();
- this.logPrefix = sessionLogPrefix + "|" + this.hashCode();
- LOG.trace("[{}] Creating new Graph request handler for request {}", logPrefix, statement);
- this.initialStatement = statement;
- this.session = dseSession;
- this.context = context;
- this.graphSupportChecker = graphSupportChecker;
- this.result = new CompletableFuture<>();
- this.result.exceptionally(
- t -> {
- try {
- if (t instanceof CancellationException) {
- cancelScheduledTasks();
- context.getRequestThrottler().signalCancel(this);
- }
- } catch (Throwable t2) {
- Loggers.warnWithException(LOG, "[{}] Uncaught exception", logPrefix, t2);
- }
- return null;
- });
- this.graphBinaryModule = graphBinaryModule;
- this.timer = context.getNettyOptions().getTimer();
-
- this.activeExecutionsCount = new AtomicInteger(1);
- this.startedSpeculativeExecutionsCount = new AtomicInteger(0);
- this.scheduledExecutions = new CopyOnWriteArrayList<>();
- this.inFlightCallbacks = new CopyOnWriteArrayList<>();
-
- this.requestTracker = context.getRequestTracker();
- this.sessionMetricUpdater = session.getMetricUpdater();
-
- Duration timeout = GraphConversions.resolveGraphRequestTimeout(statement, context);
- this.scheduledTimeout = scheduleTimeout(timeout);
-
- this.throttler = context.getRequestThrottler();
- this.throttler.register(this);
- }
-
- @Override
- public void onThrottleReady(boolean wasDelayed) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(initialStatement, context);
- if (wasDelayed
- // avoid call to nanoTime() if metric is disabled:
- && sessionMetricUpdater.isEnabled(
- DefaultSessionMetric.THROTTLING_DELAY, executionProfile.getName())) {
- sessionMetricUpdater.updateTimer(
- DefaultSessionMetric.THROTTLING_DELAY,
- executionProfile.getName(),
- System.nanoTime() - startTimeNanos,
- TimeUnit.NANOSECONDS);
- }
- Queue queryPlan =
- initialStatement.getNode() != null
- ? new SimpleQueryPlan(initialStatement.getNode())
- : context
- .getLoadBalancingPolicyWrapper()
- .newQueryPlan(initialStatement, executionProfile.getName(), session);
- sendRequest(initialStatement, null, queryPlan, 0, 0, true);
- }
-
- public CompletionStage handle() {
- return result;
- }
-
- private Timeout scheduleTimeout(Duration timeoutDuration) {
- if (timeoutDuration != null && timeoutDuration.toNanos() > 0) {
- try {
- return this.timer.newTimeout(
- (Timeout timeout1) -> {
- NodeDiagnostics diagnostics = buildNodeDiagnostics();
- setFinalError(
- initialStatement,
- new DriverTimeoutException(
- "Query timed out after " + timeoutDuration, diagnostics),
- null,
- NO_SUCCESSFUL_EXECUTION);
- },
- timeoutDuration.toNanos(),
- TimeUnit.NANOSECONDS);
- } catch (IllegalStateException e) {
- // If we raced with session shutdown the timer might be closed already, rethrow with a more
- // explicit message
- result.completeExceptionally(
- "cannot be started once stopped".equals(e.getMessage())
- ? new IllegalStateException("Session is closed")
- : e);
- }
- }
- return null;
- }
-
- @Nullable
- private NodeDiagnostics buildNodeDiagnostics() {
- List callbacks = inFlightCallbacks;
- if (callbacks.isEmpty()) {
- return null;
- }
- NodeResponseCallback cb = callbacks.get(0);
- int channelInFlight = cb.channel.getInFlight();
- ChannelPool pool = session.getPools().get(cb.node);
- return NodeDiagnostics.of(
- cb.node.getEndPoint(),
- cb.node.getState(),
- cb.node.getDistance(),
- cb.node.getDatacenter(),
- channelInFlight,
- pool != null ? pool.size() : UNAVAILABLE,
- pool != null ? pool.getInFlight() : UNAVAILABLE,
- pool != null ? pool.getAvailableIds() : UNAVAILABLE,
- pool != null ? pool.getOrphanedIds() : UNAVAILABLE);
- }
-
- /**
- * Sends the request to the next available node.
- *
- * @param retriedNode if not null, it will be attempted first before the rest of the query plan.
- * @param queryPlan the list of nodes to try (shared with all other executions)
- * @param currentExecutionIndex 0 for the initial execution, 1 for the first speculative one, etc.
- * @param retryCount the number of times that the retry policy was invoked for this execution
- * already (note that some internal retries don't go through the policy, and therefore don't
- * increment this counter)
- * @param scheduleNextExecution whether to schedule the next speculative execution
- */
- private void sendRequest(
- GraphStatement> statement,
- Node retriedNode,
- Queue queryPlan,
- int currentExecutionIndex,
- int retryCount,
- boolean scheduleNextExecution) {
- if (result.isDone()) {
- return;
- }
- Node node = retriedNode;
- DriverChannel channel = null;
- if (node == null || (channel = session.getChannel(node, logPrefix)) == null) {
- while (!result.isDone() && (node = queryPlan.poll()) != null) {
- channel = session.getChannel(node, logPrefix);
- if (channel != null) {
- break;
- } else {
- recordError(node, new NodeUnavailableException(node));
- }
- }
- }
- if (channel == null) {
- // We've reached the end of the query plan without finding any node to write to
- if (!result.isDone() && activeExecutionsCount.decrementAndGet() == 0) {
- // We're the last execution so fail the result
- setFinalError(
- statement,
- AllNodesFailedException.fromErrors(this.errors),
- null,
- NO_SUCCESSFUL_EXECUTION);
- }
- } else {
- boolean writeSubmitted = false;
- try {
- NodeResponseCallback nodeResponseCallback =
- new NodeResponseCallback(
- statement,
- node,
- queryPlan,
- channel,
- currentExecutionIndex,
- retryCount,
- scheduleNextExecution,
- logPrefix);
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- GraphProtocol graphSubProtocol =
- GraphConversions.resolveGraphSubProtocol(statement, graphSupportChecker, context);
- Message message =
- GraphConversions.createMessageFromGraphStatement(
- statement, graphSubProtocol, executionProfile, context, graphBinaryModule);
- Map customPayload =
- GraphConversions.createCustomPayload(
- statement, graphSubProtocol, executionProfile, context, graphBinaryModule);
- Future writeFuture =
- channel.write(message, statement.isTracing(), customPayload, nodeResponseCallback);
- writeSubmitted = true;
- writeFuture.addListener(nodeResponseCallback);
- } finally {
- if (!writeSubmitted) {
- channel.cancelPreAcquireId();
- }
- }
- }
- }
-
- private void recordError(Node node, Throwable error) {
- // Use a local variable to do only a single single volatile read in the nominal case
- List> errorsSnapshot = this.errors;
- if (errorsSnapshot == null) {
- synchronized (GraphRequestHandler.this) {
- errorsSnapshot = this.errors;
- if (errorsSnapshot == null) {
- this.errors = errorsSnapshot = new CopyOnWriteArrayList<>();
- }
- }
- }
- errorsSnapshot.add(new AbstractMap.SimpleEntry<>(node, error));
- }
-
- private void cancelScheduledTasks() {
- if (this.scheduledTimeout != null) {
- this.scheduledTimeout.cancel();
- }
- if (scheduledExecutions != null) {
- for (Timeout scheduledExecution : scheduledExecutions) {
- scheduledExecution.cancel();
- }
- }
- for (NodeResponseCallback callback : inFlightCallbacks) {
- callback.cancel();
- }
- }
-
- private void setFinalResult(
- Result resultMessage, Frame responseFrame, NodeResponseCallback callback) {
- try {
- ExecutionInfo executionInfo = buildExecutionInfo(callback, responseFrame);
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(callback.statement, context);
- GraphProtocol subProtocol =
- GraphConversions.resolveGraphSubProtocol(
- callback.statement, graphSupportChecker, context);
- Queue graphNodes = new ArrayDeque<>();
- for (List row : ((Rows) resultMessage).getData()) {
- if (subProtocol.isGraphBinary()) {
- graphNodes.offer(
- GraphConversions.createGraphBinaryGraphNode(
- row, GraphRequestHandler.this.graphBinaryModule));
- } else {
- graphNodes.offer(GraphSONUtils.createGraphNode(row, subProtocol));
- }
- }
-
- DefaultAsyncGraphResultSet resultSet =
- new DefaultAsyncGraphResultSet(executionInfo, graphNodes, subProtocol);
- if (result.complete(resultSet)) {
- cancelScheduledTasks();
- throttler.signalSuccess(this);
-
- // Only call nanoTime() if we're actually going to use it
- long completionTimeNanos = NANOTIME_NOT_MEASURED_YET,
- totalLatencyNanos = NANOTIME_NOT_MEASURED_YET;
- if (!(requestTracker instanceof NoopRequestTracker)) {
- completionTimeNanos = System.nanoTime();
- totalLatencyNanos = completionTimeNanos - startTimeNanos;
- long nodeLatencyNanos = completionTimeNanos - callback.nodeStartTimeNanos;
- requestTracker.onNodeSuccess(
- callback.statement, nodeLatencyNanos, executionProfile, callback.node, logPrefix);
- requestTracker.onSuccess(
- callback.statement, totalLatencyNanos, executionProfile, callback.node, logPrefix);
- }
- if (sessionMetricUpdater.isEnabled(
- DseSessionMetric.GRAPH_REQUESTS, executionProfile.getName())) {
- if (completionTimeNanos == NANOTIME_NOT_MEASURED_YET) {
- completionTimeNanos = System.nanoTime();
- totalLatencyNanos = completionTimeNanos - startTimeNanos;
- }
- sessionMetricUpdater.updateTimer(
- DseSessionMetric.GRAPH_REQUESTS,
- executionProfile.getName(),
- totalLatencyNanos,
- TimeUnit.NANOSECONDS);
- }
- }
- // log the warnings if they have NOT been disabled
- if (!executionInfo.getWarnings().isEmpty()
- && executionProfile.getBoolean(DefaultDriverOption.REQUEST_LOG_WARNINGS)
- && LOG.isWarnEnabled()) {
- logServerWarnings(callback.statement, executionInfo.getWarnings());
- }
- } catch (Throwable error) {
- setFinalError(callback.statement, error, callback.node, NO_SUCCESSFUL_EXECUTION);
- }
- }
-
- private void logServerWarnings(GraphStatement> statement, List warnings) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- // use the RequestLogFormatter to format the query
- StringBuilder statementString = new StringBuilder();
- context
- .getRequestLogFormatter()
- .appendRequest(
- statement,
- executionProfile.getInt(
- DefaultDriverOption.REQUEST_LOGGER_MAX_QUERY_LENGTH,
- RequestLogger.DEFAULT_REQUEST_LOGGER_MAX_QUERY_LENGTH),
- executionProfile.getBoolean(
- DefaultDriverOption.REQUEST_LOGGER_VALUES,
- RequestLogger.DEFAULT_REQUEST_LOGGER_SHOW_VALUES),
- executionProfile.getInt(
- DefaultDriverOption.REQUEST_LOGGER_MAX_VALUES,
- RequestLogger.DEFAULT_REQUEST_LOGGER_MAX_VALUES),
- executionProfile.getInt(
- DefaultDriverOption.REQUEST_LOGGER_MAX_VALUE_LENGTH,
- RequestLogger.DEFAULT_REQUEST_LOGGER_MAX_VALUE_LENGTH),
- statementString);
- // log each warning separately
- warnings.forEach(
- (warning) ->
- LOG.warn("Query '{}' generated server side warning(s): {}", statementString, warning));
- }
-
- private ExecutionInfo buildExecutionInfo(NodeResponseCallback callback, Frame responseFrame) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(callback.statement, context);
- return new DefaultExecutionInfo(
- callback.statement,
- callback.node,
- startedSpeculativeExecutionsCount.get(),
- callback.execution,
- errors,
- null,
- responseFrame,
- true,
- session,
- context,
- executionProfile);
- }
-
- @Override
- public void onThrottleFailure(@NonNull RequestThrottlingException error) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(initialStatement, context);
- sessionMetricUpdater.incrementCounter(
- DefaultSessionMetric.THROTTLING_ERRORS, executionProfile.getName());
- setFinalError(initialStatement, error, null, NO_SUCCESSFUL_EXECUTION);
- }
-
- private void setFinalError(
- GraphStatement> statement, Throwable error, Node node, int execution) {
- DriverExecutionProfile executionProfile =
- Conversions.resolveExecutionProfile(statement, context);
- if (error instanceof DriverException) {
- ((DriverException) error)
- .setExecutionInfo(
- new DefaultExecutionInfo(
- statement,
- node,
- startedSpeculativeExecutionsCount.get(),
- execution,
- errors,
- null,
- null,
- true,
- session,
- context,
- executionProfile));
- }
- if (result.completeExceptionally(error)) {
- cancelScheduledTasks();
- if (!(requestTracker instanceof NoopRequestTracker)) {
- long latencyNanos = System.nanoTime() - startTimeNanos;
- requestTracker.onError(statement, error, latencyNanos, executionProfile, node, logPrefix);
- }
- if (error instanceof DriverTimeoutException) {
- throttler.signalTimeout(this);
- sessionMetricUpdater.incrementCounter(
- DseSessionMetric.GRAPH_CLIENT_TIMEOUTS, executionProfile.getName());
- } else if (!(error instanceof RequestThrottlingException)) {
- throttler.signalError(this, error);
- }
- }
- }
-
- /**
- * Handles the interaction with a single node in the query plan.
- *
- * An instance of this class is created each time we (re)try a node.
- */
- private class NodeResponseCallback
- implements ResponseCallback, GenericFutureListener> {
-
- private final long nodeStartTimeNanos = System.nanoTime();
- private final GraphStatement> statement;
- private final Node node;
- private final Queue queryPlan;
- private final DriverChannel channel;
- // The identifier of the current execution (0 for the initial execution, 1 for the first
- // speculative execution, etc.)
- private final int execution;
- // How many times we've invoked the retry policy and it has returned a "retry" decision (0 for
- // the first attempt of each execution).
- private final int retryCount;
- private final boolean scheduleNextExecution;
- private final String logPrefix;
- private final DriverExecutionProfile executionProfile;
-
- private NodeResponseCallback(
- GraphStatement> statement,
- Node node,
- Queue queryPlan,
- DriverChannel channel,
- int execution,
- int retryCount,
- boolean scheduleNextExecution,
- String logPrefix) {
- this.statement = statement;
- this.node = node;
- this.queryPlan = queryPlan;
- this.channel = channel;
- this.execution = execution;
- this.retryCount = retryCount;
- this.scheduleNextExecution = scheduleNextExecution;
- this.logPrefix = logPrefix + "|" + execution;
- this.executionProfile = Conversions.resolveExecutionProfile(statement, context);
- }
-
- // this gets invoked once the write completes.
- @Override
- public void operationComplete(Future future) {
- if (!future.isSuccess()) {
- Throwable error = future.cause();
- if (error instanceof EncoderException
- && error.getCause() instanceof FrameTooLongException) {
- trackNodeError(node, error.getCause(), NANOTIME_NOT_MEASURED_YET);
- setFinalError(statement, error.getCause(), node, execution);
- } else {
- LOG.trace(
- "[{}] Failed to send request on {}, trying next node (cause: {})",
- logPrefix,
- channel,
- error);
- recordError(node, error);
- trackNodeError(node, error, NANOTIME_NOT_MEASURED_YET);
- ((DefaultNode) node)
- .getMetricUpdater()
- .incrementCounter(DefaultNodeMetric.UNSENT_REQUESTS, executionProfile.getName());
- sendRequest(
- statement,
- null,
- queryPlan,
- execution,
- retryCount,
- scheduleNextExecution); // try next node
- }
- } else {
- LOG.trace("[{}] Request sent on {}", logPrefix, channel);
- if (result.isDone()) {
- // If the handler completed since the last time we checked, cancel directly because we
- // don't know if cancelScheduledTasks() has run yet
- cancel();
- } else {
- inFlightCallbacks.add(this);
- if (scheduleNextExecution
- && Conversions.resolveIdempotence(statement, executionProfile)) {
- int nextExecution = execution + 1;
- long nextDelay;
- try {
- nextDelay =
- Conversions.resolveSpeculativeExecutionPolicy(context, executionProfile)
- .nextExecution(node, null, statement, nextExecution);
- } catch (Throwable cause) {
- // This is a bug in the policy, but not fatal since we have at least one other
- // execution already running. Don't fail the whole request.
- LOG.error(
- "[{}] Unexpected error while invoking the speculative execution policy",
- logPrefix,
- cause);
- return;
- }
- if (nextDelay >= 0) {
- scheduleSpeculativeExecution(nextExecution, nextDelay);
- } else {
- LOG.trace(
- "[{}] Speculative execution policy returned {}, no next execution",
- logPrefix,
- nextDelay);
- }
- }
- }
- }
- }
-
- private void scheduleSpeculativeExecution(int index, long delay) {
- LOG.trace("[{}] Scheduling speculative execution {} in {} ms", logPrefix, index, delay);
- try {
- scheduledExecutions.add(
- timer.newTimeout(
- (Timeout timeout1) -> {
- if (!result.isDone()) {
- LOG.trace(
- "[{}] Starting speculative execution {}",
- GraphRequestHandler.this.logPrefix,
- index);
- activeExecutionsCount.incrementAndGet();
- startedSpeculativeExecutionsCount.incrementAndGet();
- // Note that `node` is the first node of the execution, it might not be the
- // "slow" one if there were retries, but in practice retries are rare.
- ((DefaultNode) node)
- .getMetricUpdater()
- .incrementCounter(
- DefaultNodeMetric.SPECULATIVE_EXECUTIONS, executionProfile.getName());
- sendRequest(statement, null, queryPlan, index, 0, true);
- }
- },
- delay,
- TimeUnit.MILLISECONDS));
- } catch (IllegalStateException e) {
- // If we're racing with session shutdown, the timer might be stopped already. We don't want
- // to schedule more executions anyway, so swallow the error.
- if (!"cannot be started once stopped".equals(e.getMessage())) {
- Loggers.warnWithException(
- LOG, "[{}] Error while scheduling speculative execution", logPrefix, e);
- }
- }
- }
-
- @Override
- public void onResponse(Frame responseFrame) {
- long nodeResponseTimeNanos = NANOTIME_NOT_MEASURED_YET;
- NodeMetricUpdater nodeMetricUpdater = ((DefaultNode) node).getMetricUpdater();
- if (nodeMetricUpdater.isEnabled(DseNodeMetric.GRAPH_MESSAGES, executionProfile.getName())) {
- nodeResponseTimeNanos = System.nanoTime();
- long nodeLatency = System.nanoTime() - nodeStartTimeNanos;
- nodeMetricUpdater.updateTimer(
- DseNodeMetric.GRAPH_MESSAGES,
- executionProfile.getName(),
- nodeLatency,
- TimeUnit.NANOSECONDS);
- }
- inFlightCallbacks.remove(this);
- if (result.isDone()) {
- return;
- }
- try {
- Message responseMessage = responseFrame.message;
- if (responseMessage instanceof Result) {
- LOG.trace("[{}] Got result, completing", logPrefix);
- setFinalResult((Result) responseMessage, responseFrame, this);
- } else if (responseMessage instanceof Error) {
- LOG.trace("[{}] Got error response, processing", logPrefix);
- processErrorResponse((Error) responseMessage);
- } else {
- trackNodeError(
- node,
- new IllegalStateException("Unexpected response " + responseMessage),
- nodeResponseTimeNanos);
- setFinalError(
- statement,
- new IllegalStateException("Unexpected response " + responseMessage),
- node,
- execution);
- }
- } catch (Throwable t) {
- trackNodeError(node, t, nodeResponseTimeNanos);
- setFinalError(statement, t, node, execution);
- }
- }
-
- private void processErrorResponse(Error errorMessage) {
- CoordinatorException error = Conversions.toThrowable(node, errorMessage, context);
- NodeMetricUpdater metricUpdater = ((DefaultNode) node).getMetricUpdater();
- if (error instanceof BootstrappingException) {
- LOG.trace("[{}] {} is bootstrapping, trying next node", logPrefix, node);
- recordError(node, error);
- trackNodeError(node, error, NANOTIME_NOT_MEASURED_YET);
- sendRequest(statement, null, queryPlan, execution, retryCount, false);
- } else if (error instanceof QueryValidationException
- || error instanceof FunctionFailureException
- || error instanceof ProtocolError) {
- LOG.trace("[{}] Unrecoverable error, rethrowing", logPrefix);
- metricUpdater.incrementCounter(DefaultNodeMetric.OTHER_ERRORS, executionProfile.getName());
- trackNodeError(node, error, NANOTIME_NOT_MEASURED_YET);
- setFinalError(statement, error, node, execution);
- } else {
- RetryPolicy retryPolicy = Conversions.resolveRetryPolicy(context, executionProfile);
- RetryVerdict verdict;
- if (error instanceof ReadTimeoutException) {
- ReadTimeoutException readTimeout = (ReadTimeoutException) error;
- verdict =
- retryPolicy.onReadTimeoutVerdict(
- statement,
- readTimeout.getConsistencyLevel(),
- readTimeout.getBlockFor(),
- readTimeout.getReceived(),
- readTimeout.wasDataPresent(),
- retryCount);
- updateErrorMetrics(
- metricUpdater,
- verdict,
- DefaultNodeMetric.READ_TIMEOUTS,
- DefaultNodeMetric.RETRIES_ON_READ_TIMEOUT,
- DefaultNodeMetric.IGNORES_ON_READ_TIMEOUT);
- } else if (error instanceof WriteTimeoutException) {
- WriteTimeoutException writeTimeout = (WriteTimeoutException) error;
- verdict =
- Conversions.resolveIdempotence(statement, executionProfile)
- ? retryPolicy.onWriteTimeoutVerdict(
- statement,
- writeTimeout.getConsistencyLevel(),
- writeTimeout.getWriteType(),
- writeTimeout.getBlockFor(),
- writeTimeout.getReceived(),
- retryCount)
- : RetryVerdict.RETHROW;
- updateErrorMetrics(
- metricUpdater,
- verdict,
- DefaultNodeMetric.WRITE_TIMEOUTS,
- DefaultNodeMetric.RETRIES_ON_WRITE_TIMEOUT,
- DefaultNodeMetric.IGNORES_ON_WRITE_TIMEOUT);
- } else if (error instanceof UnavailableException) {
- UnavailableException unavailable = (UnavailableException) error;
- verdict =
- retryPolicy.onUnavailableVerdict(
- statement,
- unavailable.getConsistencyLevel(),
- unavailable.getRequired(),
- unavailable.getAlive(),
- retryCount);
- updateErrorMetrics(
- metricUpdater,
- verdict,
- DefaultNodeMetric.UNAVAILABLES,
- DefaultNodeMetric.RETRIES_ON_UNAVAILABLE,
- DefaultNodeMetric.IGNORES_ON_UNAVAILABLE);
- } else {
- verdict =
- Conversions.resolveIdempotence(statement, executionProfile)
- ? retryPolicy.onErrorResponseVerdict(statement, error, retryCount)
- : RetryVerdict.RETHROW;
- updateErrorMetrics(
- metricUpdater,
- verdict,
- DefaultNodeMetric.OTHER_ERRORS,
- DefaultNodeMetric.RETRIES_ON_OTHER_ERROR,
- DefaultNodeMetric.IGNORES_ON_OTHER_ERROR);
- }
- processRetryVerdict(verdict, error);
- }
- }
-
- private void processRetryVerdict(RetryVerdict verdict, Throwable error) {
- LOG.trace("[{}] Processing retry decision {}", logPrefix, verdict);
- switch (verdict.getRetryDecision()) {
- case RETRY_SAME:
- recordError(node, error);
- trackNodeError(node, error, NANOTIME_NOT_MEASURED_YET);
- sendRequest(
- verdict.getRetryRequest(statement),
- node,
- queryPlan,
- execution,
- retryCount + 1,
- false);
- break;
- case RETRY_NEXT:
- recordError(node, error);
- trackNodeError(node, error, NANOTIME_NOT_MEASURED_YET);
- sendRequest(
- verdict.getRetryRequest(statement),
- null,
- queryPlan,
- execution,
- retryCount + 1,
- false);
- break;
- case RETHROW:
- trackNodeError(node, error, NANOTIME_NOT_MEASURED_YET);
- setFinalError(statement, error, node, execution);
- break;
- case IGNORE:
- setFinalResult(Void.INSTANCE, null, this);
- break;
- }
- }
-
- private void updateErrorMetrics(
- NodeMetricUpdater metricUpdater,
- RetryVerdict verdict,
- DefaultNodeMetric error,
- DefaultNodeMetric retriesOnError,
- DefaultNodeMetric ignoresOnError) {
- metricUpdater.incrementCounter(error, executionProfile.getName());
- switch (verdict.getRetryDecision()) {
- case RETRY_SAME:
- case RETRY_NEXT:
- metricUpdater.incrementCounter(DefaultNodeMetric.RETRIES, executionProfile.getName());
- metricUpdater.incrementCounter(retriesOnError, executionProfile.getName());
- break;
- case IGNORE:
- metricUpdater.incrementCounter(DefaultNodeMetric.IGNORES, executionProfile.getName());
- metricUpdater.incrementCounter(ignoresOnError, executionProfile.getName());
- break;
- case RETHROW:
- // nothing do do
- }
- }
-
- @Override
- public void onFailure(Throwable error) {
- inFlightCallbacks.remove(this);
- if (result.isDone()) {
- return;
- }
- LOG.trace("[{}] Request failure, processing: {}", logPrefix, error);
- RetryVerdict verdict;
- if (!Conversions.resolveIdempotence(statement, executionProfile)
- || error instanceof FrameTooLongException) {
- verdict = RetryVerdict.RETHROW;
- } else {
- try {
- RetryPolicy retryPolicy = Conversions.resolveRetryPolicy(context, executionProfile);
- verdict = retryPolicy.onRequestAbortedVerdict(statement, error, retryCount);
- } catch (Throwable cause) {
- setFinalError(
- statement,
- new IllegalStateException("Unexpected error while invoking the retry policy", cause),
- node,
- NO_SUCCESSFUL_EXECUTION);
- return;
- }
- }
- processRetryVerdict(verdict, error);
- updateErrorMetrics(
- ((DefaultNode) node).getMetricUpdater(),
- verdict,
- DefaultNodeMetric.ABORTED_REQUESTS,
- DefaultNodeMetric.RETRIES_ON_ABORTED,
- DefaultNodeMetric.IGNORES_ON_ABORTED);
- }
-
- void cancel() {
- try {
- if (!channel.closeFuture().isDone()) {
- this.channel.cancel(this);
- }
- } catch (Throwable t) {
- Loggers.warnWithException(LOG, "[{}] Error cancelling", logPrefix, t);
- }
- }
-
- /**
- * @param nodeResponseTimeNanos the time we received the response, if it's already been
- * measured. If {@link #NANOTIME_NOT_MEASURED_YET}, it hasn't and we need to measure it now
- * (this is to avoid unnecessary calls to System.nanoTime)
- */
- private void trackNodeError(Node node, Throwable error, long nodeResponseTimeNanos) {
- if (requestTracker instanceof NoopRequestTracker) {
- return;
- }
- if (nodeResponseTimeNanos == NANOTIME_NOT_MEASURED_YET) {
- nodeResponseTimeNanos = System.nanoTime();
- }
- long latencyNanos = nodeResponseTimeNanos - this.nodeStartTimeNanos;
- requestTracker.onNodeError(statement, error, latencyNanos, executionProfile, node, logPrefix);
- }
-
- @Override
- public String toString() {
- return logPrefix;
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestSyncProcessor.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestSyncProcessor.java
deleted file mode 100644
index bc2381482a8..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestSyncProcessor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.BatchGraphStatement;
-import com.datastax.dse.driver.api.core.graph.FluentGraphStatement;
-import com.datastax.dse.driver.api.core.graph.GraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.api.core.graph.ScriptGraphStatement;
-import com.datastax.oss.driver.api.core.session.Request;
-import com.datastax.oss.driver.api.core.type.reflect.GenericType;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.session.DefaultSession;
-import com.datastax.oss.driver.internal.core.session.RequestProcessor;
-import com.datastax.oss.driver.internal.core.util.concurrent.BlockingOperation;
-import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
-import net.jcip.annotations.ThreadSafe;
-
-@ThreadSafe
-public class GraphRequestSyncProcessor
- implements RequestProcessor, GraphResultSet> {
-
- private final GraphRequestAsyncProcessor asyncProcessor;
-
- public GraphRequestSyncProcessor(GraphRequestAsyncProcessor asyncProcessor) {
- this.asyncProcessor = asyncProcessor;
- }
-
- @Override
- public boolean canProcess(Request request, GenericType> resultType) {
- return (request instanceof ScriptGraphStatement
- || request instanceof FluentGraphStatement
- || request instanceof BatchGraphStatement
- || request instanceof BytecodeGraphStatement)
- && resultType.equals(GraphStatement.SYNC);
- }
-
- @Override
- public GraphResultSet process(
- GraphStatement> request,
- DefaultSession session,
- InternalDriverContext context,
- String sessionLogPrefix) {
- BlockingOperation.checkNotDriverThread();
- AsyncGraphResultSet firstPage =
- CompletableFutures.getUninterruptibly(
- asyncProcessor.process(request, session, context, sessionLogPrefix));
- return GraphResultSets.toSync(firstPage);
- }
-
- @Override
- public GraphResultSet newFailure(RuntimeException error) {
- throw error;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphResultIterator.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphResultIterator.java
deleted file mode 100644
index 7e9043affec..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphResultIterator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.oss.driver.internal.core.util.CountingIterator;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import java.util.Queue;
-import net.jcip.annotations.NotThreadSafe;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-
-@NotThreadSafe // wraps a mutable queue
-class GraphResultIterator extends CountingIterator {
-
- private final Queue data;
- private final GraphProtocol graphProtocol;
-
- // Sometimes a traversal can yield the same result multiple times consecutively. To avoid
- // duplicating the data, DSE graph sends it only once with a counter indicating how many times
- // it's repeated.
- private long repeat = 0;
- private GraphNode lastGraphNode = null;
-
- GraphResultIterator(Queue data, GraphProtocol graphProtocol) {
- super(data.size());
- this.data = data;
- this.graphProtocol = graphProtocol;
- }
-
- @Override
- protected GraphNode computeNext() {
- if (repeat > 1) {
- repeat -= 1;
- // Note that we don't make a defensive copy, we assume the client won't mutate the node
- return lastGraphNode;
- }
-
- GraphNode container = data.poll();
- if (container == null) {
- return endOfData();
- }
-
- if (graphProtocol.isGraphBinary()) {
- // results are contained in a Traverser object and not a Map if the protocol
- // is GraphBinary
- Preconditions.checkState(
- container.as(Object.class) instanceof Traverser,
- "Graph protocol error. Received object should be a Traverser but it is not.");
- Traverser t = container.as(Traverser.class);
- this.repeat = t.bulk();
- this.lastGraphNode = new ObjectGraphNode(t.get());
- return lastGraphNode;
- } else {
- // The repeat counter is called "bulk" in the JSON payload
- GraphNode b = container.getByKey("bulk");
- if (b != null) {
- this.repeat = b.asLong();
- }
-
- lastGraphNode = container.getByKey("result");
- return lastGraphNode;
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphResultSets.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphResultSets.java
deleted file mode 100644
index fb21f857cfa..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphResultSets.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
-import com.datastax.dse.driver.api.core.graph.GraphResultSet;
-
-public class GraphResultSets {
-
- public static GraphResultSet toSync(AsyncGraphResultSet firstPage) {
- if (firstPage.hasMorePages()) {
- return new MultiPageGraphResultSet(firstPage);
- } else {
- return new SinglePageGraphResultSet(firstPage);
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSON1SerdeTP.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSON1SerdeTP.java
deleted file mode 100644
index f880bca3764..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSON1SerdeTP.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.data.geometry.Geometry;
-import com.datastax.dse.driver.api.core.data.geometry.LineString;
-import com.datastax.dse.driver.api.core.data.geometry.Point;
-import com.datastax.dse.driver.api.core.data.geometry.Polygon;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
-import com.datastax.oss.driver.shaded.guava.common.net.InetAddresses;
-import java.io.IOException;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.util.List;
-import java.util.Map;
-import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
-import org.apache.tinkerpop.shaded.jackson.core.JsonParseException;
-import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
-import org.apache.tinkerpop.shaded.jackson.core.Version;
-import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
-import org.apache.tinkerpop.shaded.jackson.databind.JsonDeserializer;
-import org.apache.tinkerpop.shaded.jackson.databind.JsonSerializer;
-import org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider;
-import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
-import org.apache.tinkerpop.shaded.jackson.databind.module.SimpleModule;
-import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
-
-public class GraphSON1SerdeTP {
-
- //////////////////////// DESERIALIZERS ////////////////////////
-
- /**
- * Default deserializer used by the driver for {@link InetAddress} instances. The actual subclass
- * returned by this deserializer depends on the type of address: {@link Inet4Address IPV4} or
- * {@link Inet6Address IPV6}.
- */
- static class DefaultInetAddressDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- private final Class inetClass;
-
- DefaultInetAddressDeserializer(Class inetClass) {
- super(inetClass);
- this.inetClass = inetClass;
- }
-
- @Override
- public T deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
- String ip = parser.readValueAs(String.class);
- try {
- InetAddress inet = InetAddresses.forString(ip);
- return inetClass.cast(inet);
- } catch (ClassCastException e) {
- throw new JsonParseException(
- parser,
- String.format("Inet address cannot be cast to %s: %s", inetClass.getSimpleName(), ip),
- e);
- } catch (IllegalArgumentException e) {
- throw new JsonParseException(parser, String.format("Expected inet address, got %s", ip), e);
- }
- }
- }
-
- /**
- * Default deserializer used by the driver for geospatial types. It deserializes such types into
- * {@link Geometry} instances. The actual subclass depends on the type being deserialized.
- */
- static class DefaultGeometryDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- private final Class geometryClass;
-
- DefaultGeometryDeserializer(Class geometryClass) {
- super(geometryClass);
- this.geometryClass = geometryClass;
- }
-
- @Override
- public T deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
- String wkt = parser.readValueAs(String.class);
- Geometry geometry;
- if (wkt.startsWith("POINT")) geometry = Point.fromWellKnownText(wkt);
- else if (wkt.startsWith("LINESTRING")) geometry = LineString.fromWellKnownText(wkt);
- else if (wkt.startsWith("POLYGON")) geometry = Polygon.fromWellKnownText(wkt);
- else throw new JsonParseException(parser, "Unknown geometry type: " + wkt);
- return geometryClass.cast(geometry);
- }
- }
-
- /** Base class for serializing the {@code java.time.*} types to ISO-8061 formats. */
- abstract static class AbstractJavaTimeSerializer extends StdSerializer {
-
- private static final long serialVersionUID = 1L;
-
- AbstractJavaTimeSerializer(final Class clazz) {
- super(clazz);
- }
-
- @Override
- public void serialize(
- final T value, final JsonGenerator gen, final SerializerProvider serializerProvider)
- throws IOException {
- gen.writeString(value.toString());
- }
- }
-
- /** Base class for deserializing the {@code java.time.*} types from ISO-8061 formats. */
- abstract static class AbstractJavaTimeJacksonDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- AbstractJavaTimeJacksonDeserializer(final Class clazz) {
- super(clazz);
- }
-
- abstract T parse(final String val);
-
- @Override
- public T deserialize(
- final JsonParser jsonParser, final DeserializationContext deserializationContext)
- throws IOException {
- return parse(jsonParser.getText());
- }
- }
-
- static final class DurationJacksonSerializer
- extends AbstractJavaTimeSerializer {
-
- private static final long serialVersionUID = 1L;
-
- DurationJacksonSerializer() {
- super(java.time.Duration.class);
- }
- }
-
- static final class DurationJacksonDeserializer
- extends AbstractJavaTimeJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- DurationJacksonDeserializer() {
- super(java.time.Duration.class);
- }
-
- @Override
- public java.time.Duration parse(final String val) {
- return java.time.Duration.parse(val);
- }
- }
-
- static final class InstantJacksonSerializer
- extends AbstractJavaTimeSerializer {
-
- private static final long serialVersionUID = 1L;
-
- InstantJacksonSerializer() {
- super(java.time.Instant.class);
- }
- }
-
- static final class InstantJacksonDeserializer
- extends AbstractJavaTimeJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- InstantJacksonDeserializer() {
- super(java.time.Instant.class);
- }
-
- @Override
- public java.time.Instant parse(final String val) {
- return java.time.Instant.parse(val);
- }
- }
-
- static final class LocalDateJacksonSerializer
- extends AbstractJavaTimeSerializer {
-
- private static final long serialVersionUID = 1L;
-
- LocalDateJacksonSerializer() {
- super(java.time.LocalDate.class);
- }
- }
-
- static final class LocalDateJacksonDeserializer
- extends AbstractJavaTimeJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- LocalDateJacksonDeserializer() {
- super(java.time.LocalDate.class);
- }
-
- @Override
- public java.time.LocalDate parse(final String val) {
- return java.time.LocalDate.parse(val);
- }
- }
-
- static final class LocalTimeJacksonSerializer
- extends AbstractJavaTimeSerializer {
-
- private static final long serialVersionUID = 1L;
-
- LocalTimeJacksonSerializer() {
- super(java.time.LocalTime.class);
- }
- }
-
- static final class LocalTimeJacksonDeserializer
- extends AbstractJavaTimeJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- LocalTimeJacksonDeserializer() {
- super(java.time.LocalTime.class);
- }
-
- @Override
- public java.time.LocalTime parse(final String val) {
- return java.time.LocalTime.parse(val);
- }
- }
-
- //////////////////////// SERIALIZERS ////////////////////////
-
- /** Default serializer used by the driver for {@link LegacyGraphNode} instances. */
- static class DefaultGraphNodeSerializer extends StdSerializer {
-
- private static final long serialVersionUID = 1L;
-
- DefaultGraphNodeSerializer() {
- super(LegacyGraphNode.class);
- }
-
- @Override
- public void serialize(
- LegacyGraphNode value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
- throws IOException {
- jsonGenerator.writeTree(value.getDelegate());
- }
- }
-
- /**
- * Default serializer used by the driver for geospatial types. It serializes {@link Geometry}
- * instances into their Well-Known Text (WKT) equivalent.
- */
- static class DefaultGeometrySerializer extends StdSerializer {
-
- private static final long serialVersionUID = 1L;
-
- DefaultGeometrySerializer() {
- super(Geometry.class);
- }
-
- @Override
- public void serialize(
- Geometry value, JsonGenerator jsonGenerator, SerializerProvider serializers)
- throws IOException {
- jsonGenerator.writeString(value.asWellKnownText());
- }
- }
-
- /** The default Jackson module used by DSE Graph. */
- static class GraphSON1DefaultModule extends SimpleModule {
-
- private static final long serialVersionUID = 1L;
-
- GraphSON1DefaultModule(String name, Version version) {
- super(name, version, createDeserializers(), createSerializers());
- }
-
- private static Map, JsonDeserializer>> createDeserializers() {
-
- return ImmutableMap., JsonDeserializer>>builder()
-
- // Inet (there is no built-in deserializer for InetAddress and subclasses)
- .put(InetAddress.class, new DefaultInetAddressDeserializer<>(InetAddress.class))
- .put(Inet4Address.class, new DefaultInetAddressDeserializer<>(Inet4Address.class))
- .put(Inet6Address.class, new DefaultInetAddressDeserializer<>(Inet6Address.class))
-
- // Geospatial types
- .put(Geometry.class, new DefaultGeometryDeserializer<>(Geometry.class))
- .put(Point.class, new DefaultGeometryDeserializer<>(Point.class))
- .put(LineString.class, new DefaultGeometryDeserializer<>(LineString.class))
- .put(Polygon.class, new DefaultGeometryDeserializer<>(Polygon.class))
- .build();
- }
-
- private static List> createSerializers() {
- return ImmutableList.>builder()
- .add(new DefaultGraphNodeSerializer())
- .add(new DefaultGeometrySerializer())
- .build();
- }
- }
-
- /** Serializers and deserializers for JSR 310 {@code java.time.*}. */
- static class GraphSON1JavaTimeModule extends SimpleModule {
-
- private static final long serialVersionUID = 1L;
-
- GraphSON1JavaTimeModule(String name, Version version) {
- super(name, version, createDeserializers(), createSerializers());
- }
-
- private static Map, JsonDeserializer>> createDeserializers() {
-
- return ImmutableMap., JsonDeserializer>>builder()
- .put(java.time.Duration.class, new DurationJacksonDeserializer())
- .put(java.time.Instant.class, new InstantJacksonDeserializer())
- .put(java.time.LocalDate.class, new LocalDateJacksonDeserializer())
- .put(java.time.LocalTime.class, new LocalTimeJacksonDeserializer())
- .build();
- }
-
- private static List> createSerializers() {
- return ImmutableList.>builder()
- .add(new DurationJacksonSerializer())
- .add(new InstantJacksonSerializer())
- .add(new LocalDateJacksonSerializer())
- .add(new LocalTimeJacksonSerializer())
- .build();
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSON2SerdeTP.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSON2SerdeTP.java
deleted file mode 100644
index 05e09b018ab..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSON2SerdeTP.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.data.geometry.Geometry;
-import com.datastax.dse.driver.api.core.data.geometry.LineString;
-import com.datastax.dse.driver.api.core.data.geometry.Point;
-import com.datastax.dse.driver.api.core.data.geometry.Polygon;
-import com.datastax.dse.driver.api.core.graph.predicates.Geo;
-import com.datastax.dse.driver.api.core.graph.predicates.Search;
-import com.datastax.dse.driver.internal.core.data.geometry.DefaultLineString;
-import com.datastax.dse.driver.internal.core.data.geometry.DefaultPoint;
-import com.datastax.dse.driver.internal.core.data.geometry.DefaultPolygon;
-import com.datastax.dse.driver.internal.core.data.geometry.Distance;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.util.AndP;
-import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
-import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.AbstractObjectDeserializer;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.TinkerPopJacksonModule;
-import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
-import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
-import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
-import org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider;
-import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
-import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
-import org.apache.tinkerpop.shaded.jackson.databind.module.SimpleModule;
-import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdScalarSerializer;
-import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
-
-public class GraphSON2SerdeTP {
-
- /**
- * A Jackson Module to use for TinkerPop serialization/deserialization. It extends {@link
- * org.apache.tinkerpop.gremlin.structure.io.graphson.TinkerPopJacksonModule} because of the
- * specific typing format used in GraphSON.
- */
- public static class DseGraphModule extends TinkerPopJacksonModule {
-
- private static final long serialVersionUID = 1L;
-
- public DseGraphModule() {
- super("dse-driver-2.0");
- addSerializer(DefaultPoint.class, new PointGeometrySerializer());
- addSerializer(DefaultLineString.class, new LineStringGeometrySerializer());
- addSerializer(DefaultPolygon.class, new PolygonGeometrySerializer());
- addSerializer(Distance.class, new DistanceGeometrySerializer());
- // override TinkerPop's P predicates because of DSE's Search and Geo predicates
- addSerializer(P.class, new DsePJacksonSerializer());
- addSerializer(EditDistance.class, new EditDistanceSerializer());
-
- addDeserializer(DefaultLineString.class, new LineStringGeometryDeserializer());
- addDeserializer(DefaultPoint.class, new PointGeometryDeserializer());
- addDeserializer(DefaultPolygon.class, new PolygonGeometryDeserializer());
- addDeserializer(Distance.class, new DistanceGeometryDeserializer());
- // override TinkerPop's P predicates because of DSE's Search and Geo predicates
- addDeserializer(P.class, new DsePJacksonDeserializer());
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Map getTypeDefinitions() {
- Map definitions = new HashMap<>();
- definitions.put(DefaultLineString.class, "LineString");
- definitions.put(DefaultPoint.class, "Point");
- definitions.put(DefaultPolygon.class, "Polygon");
- definitions.put(byte[].class, "Blob");
- definitions.put(Distance.class, "Distance");
- definitions.put(P.class, "P");
- return definitions;
- }
-
- @Override
- public String getTypeNamespace() {
- return "dse";
- }
-
- abstract static class AbstractGeometryJacksonDeserializer
- extends StdDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- AbstractGeometryJacksonDeserializer(final Class clazz) {
- super(clazz);
- }
-
- public abstract T parse(final String val);
-
- @Override
- public T deserialize(
- final JsonParser jsonParser, final DeserializationContext deserializationContext)
- throws IOException {
- return parse(jsonParser.getText());
- }
- }
-
- abstract static class AbstractGeometryJacksonSerializer
- extends StdScalarSerializer {
-
- private static final long serialVersionUID = 1L;
-
- AbstractGeometryJacksonSerializer(final Class clazz) {
- super(clazz);
- }
-
- @Override
- public void serialize(
- final T value, final JsonGenerator gen, final SerializerProvider serializerProvider)
- throws IOException {
- gen.writeString(value.asWellKnownText());
- }
- }
-
- public static class LineStringGeometrySerializer
- extends AbstractGeometryJacksonSerializer {
-
- private static final long serialVersionUID = 1L;
-
- LineStringGeometrySerializer() {
- super(LineString.class);
- }
- }
-
- public static class LineStringGeometryDeserializer
- extends AbstractGeometryJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- LineStringGeometryDeserializer() {
- super(DefaultLineString.class);
- }
-
- @Override
- public DefaultLineString parse(final String val) {
- return (DefaultLineString) LineString.fromWellKnownText(val);
- }
- }
-
- public static class PolygonGeometrySerializer
- extends AbstractGeometryJacksonSerializer {
-
- private static final long serialVersionUID = 1L;
-
- PolygonGeometrySerializer() {
- super(Polygon.class);
- }
- }
-
- public static class PolygonGeometryDeserializer
- extends AbstractGeometryJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- PolygonGeometryDeserializer() {
- super(DefaultPolygon.class);
- }
-
- @Override
- public DefaultPolygon parse(final String val) {
- return (DefaultPolygon) Polygon.fromWellKnownText(val);
- }
- }
-
- public static class PointGeometrySerializer extends AbstractGeometryJacksonSerializer {
-
- private static final long serialVersionUID = 1L;
-
- PointGeometrySerializer() {
- super(Point.class);
- }
- }
-
- public static class PointGeometryDeserializer
- extends AbstractGeometryJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- PointGeometryDeserializer() {
- super(DefaultPoint.class);
- }
-
- @Override
- public DefaultPoint parse(final String val) {
- return (DefaultPoint) Point.fromWellKnownText(val);
- }
- }
-
- public static class DistanceGeometrySerializer
- extends AbstractGeometryJacksonSerializer {
-
- private static final long serialVersionUID = 1L;
-
- DistanceGeometrySerializer() {
- super(Distance.class);
- }
- }
-
- public static class DistanceGeometryDeserializer
- extends AbstractGeometryJacksonDeserializer {
-
- private static final long serialVersionUID = 1L;
-
- DistanceGeometryDeserializer() {
- super(Distance.class);
- }
-
- @Override
- public Distance parse(final String val) {
- return Distance.fromWellKnownText(val);
- }
- }
-
- @SuppressWarnings("rawtypes")
- static final class DsePJacksonSerializer extends StdScalarSerializer {
-
- private static final long serialVersionUID = 1L;
-
- DsePJacksonSerializer() {
- super(P.class);
- }
-
- @Override
- public void serialize(
- final P p, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
- throws IOException {
- jsonGenerator.writeStartObject();
- jsonGenerator.writeStringField("predicateType", getPredicateType(p));
- jsonGenerator.writeStringField(
- GraphSONTokens.PREDICATE,
- p instanceof ConnectiveP
- ? p instanceof AndP ? GraphSONTokens.AND : GraphSONTokens.OR
- : p.getBiPredicate().toString());
- if (p instanceof ConnectiveP) {
- jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
- for (final P> predicate : ((ConnectiveP>) p).getPredicates()) {
- jsonGenerator.writeObject(predicate);
- }
- jsonGenerator.writeEndArray();
- } else {
- if (p.getValue() instanceof Collection) {
- jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
- for (final Object object : (Collection) p.getValue()) {
- jsonGenerator.writeObject(object);
- }
- jsonGenerator.writeEndArray();
- } else {
- jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p.getValue());
- }
- }
- jsonGenerator.writeEndObject();
- }
-
- private String getPredicateType(P p) {
- if (p.getBiPredicate() instanceof SearchPredicate) {
- return Search.class.getSimpleName();
- } else if (p.getBiPredicate() instanceof GeoPredicate) {
- return Geo.class.getSimpleName();
- } else {
- return P.class.getSimpleName();
- }
- }
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- static final class DsePJacksonDeserializer extends AbstractObjectDeserializer
{
-
- private static final long serialVersionUID = 1L;
-
- DsePJacksonDeserializer() {
- super(P.class);
- }
-
- @Override
- public P createObject(final Map data) {
- final String predicate = (String) data.get(GraphSONTokens.PREDICATE);
- final String predicateType = (String) data.get("predicateType");
- final Object value = data.get(GraphSONTokens.VALUE);
- if (predicate.equals(GraphSONTokens.AND) || predicate.equals(GraphSONTokens.OR)) {
- return predicate.equals(GraphSONTokens.AND)
- ? new AndP((List) value)
- : new OrP((List
) value);
- } else {
- try {
- if (value instanceof Collection) {
- if (predicate.equals("between")) {
- return P.between(((List) value).get(0), ((List) value).get(1));
- } else if (predicateType.equals(P.class.getSimpleName())
- && predicate.equals("inside")) {
- return P.between(((List) value).get(0), ((List) value).get(1));
- } else if (predicate.equals("outside")) {
- return P.outside(((List) value).get(0), ((List) value).get(1));
- } else if (predicate.equals("within")) {
- return P.within((Collection) value);
- } else if (predicate.equals("without")) {
- return P.without((Collection) value);
- } else {
- return (P)
- P.class.getMethod(predicate, Collection.class).invoke(null, (Collection) value);
- }
- } else {
- if (predicate.equals(SearchPredicate.prefix.name())) {
- return Search.prefix((String) value);
- } else if (predicate.equals(SearchPredicate.tokenPrefix.name())) {
- return Search.tokenPrefix((String) value);
- } else if (predicate.equals(SearchPredicate.regex.name())) {
- return Search.regex((String) value);
- } else if (predicate.equals(SearchPredicate.tokenRegex.name())) {
- return Search.tokenRegex((String) value);
- } else if (predicate.equals(SearchPredicate.token.name())) {
- return Search.token((String) value);
- } else if (predicate.equals(SearchPredicate.fuzzy.name())) {
- Map arguments = (Map) value;
- return Search.fuzzy(
- (String) arguments.get("query"), (int) arguments.get("distance"));
- } else if (predicate.equals(SearchPredicate.tokenFuzzy.name())) {
- Map arguments = (Map) value;
- return Search.tokenFuzzy(
- (String) arguments.get("query"), (int) arguments.get("distance"));
- } else if (predicate.equals(SearchPredicate.phrase.name())) {
- Map arguments = (Map) value;
- return Search.phrase(
- (String) arguments.get("query"), (int) arguments.get("distance"));
- } else if (predicateType.equals(Geo.class.getSimpleName())
- && predicate.equals(GeoPredicate.inside.name())) {
- return Geo.inside(
- ((Distance) value).getCenter(),
- ((Distance) value).getRadius(),
- Geo.Unit.DEGREES);
- } else if (predicateType.equals(Geo.class.getSimpleName())
- && predicate.equals(GeoPredicate.insideCartesian.name())) {
- return Geo.inside(((Distance) value).getCenter(), ((Distance) value).getRadius());
- } else {
- return (P) P.class.getMethod(predicate, Object.class).invoke(null, value);
- }
- }
- } catch (final Exception e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
- }
- }
-
- public static class EditDistanceSerializer extends StdSerializer {
-
- private static final long serialVersionUID = 1L;
-
- EditDistanceSerializer() {
- super(EditDistance.class);
- }
-
- @Override
- public void serialize(
- EditDistance editDistance, JsonGenerator generator, SerializerProvider provider)
- throws IOException {
- generator.writeObject(
- ImmutableMap.of("query", editDistance.query, "distance", editDistance.distance));
- }
-
- @Override
- public void serializeWithType(
- EditDistance editDistance,
- JsonGenerator generator,
- SerializerProvider provider,
- TypeSerializer serializer)
- throws IOException {
- serialize(editDistance, generator, provider);
- }
- }
- }
-
- public static class DriverObjectsModule extends SimpleModule {
-
- private static final long serialVersionUID = 1L;
-
- public DriverObjectsModule() {
- super("datastax-driver-module");
- addSerializer(ObjectGraphNode.class, new ObjectGraphNodeGraphSON2Serializer());
- }
-
- static final class ObjectGraphNodeGraphSON2Serializer extends StdSerializer {
-
- private static final long serialVersionUID = 1L;
-
- ObjectGraphNodeGraphSON2Serializer() {
- super(ObjectGraphNode.class);
- }
-
- @Override
- public void serialize(
- ObjectGraphNode objectGraphNode,
- JsonGenerator jsonGenerator,
- SerializerProvider serializerProvider)
- throws IOException {
- jsonGenerator.writeObject(objectGraphNode.as(Object.class));
- }
-
- @Override
- public void serializeWithType(
- ObjectGraphNode objectGraphNode,
- JsonGenerator jsonGenerator,
- SerializerProvider serializerProvider,
- TypeSerializer typeSerializer)
- throws IOException {
- serialize(objectGraphNode, jsonGenerator, serializerProvider);
- }
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSONUtils.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSONUtils.java
deleted file mode 100644
index 02b35f7ee36..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSONUtils.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.oss.driver.api.core.CqlSession;
-import com.datastax.oss.driver.shaded.guava.common.base.Suppliers;
-import com.datastax.oss.driver.shaded.guava.common.base.Throwables;
-import com.datastax.oss.driver.shaded.guava.common.cache.CacheBuilder;
-import com.datastax.oss.driver.shaded.guava.common.cache.CacheLoader;
-import com.datastax.oss.driver.shaded.guava.common.cache.LoadingCache;
-import com.datastax.oss.protocol.internal.util.Bytes;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.function.Supplier;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONXModuleV2d0;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0;
-import org.apache.tinkerpop.shaded.jackson.core.Version;
-import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
-
-public class GraphSONUtils {
-
- private static final LoadingCache OBJECT_MAPPERS =
- CacheBuilder.newBuilder()
- .build(
- new CacheLoader() {
- @Override
- public ObjectMapper load(@NonNull GraphProtocol graphSubProtocol) throws Exception {
- switch (graphSubProtocol) {
- case GRAPHSON_1_0:
- com.datastax.oss.driver.api.core.Version driverVersion =
- CqlSession.OSS_DRIVER_COORDINATES.getVersion();
- Version driverJacksonVersion =
- new Version(
- driverVersion.getMajor(),
- driverVersion.getMinor(),
- driverVersion.getPatch(),
- driverVersion.getPreReleaseLabels() != null
- && driverVersion.getPreReleaseLabels().contains("SNAPSHOT")
- ? "SNAPSHOT"
- : null,
- "com.datastax.dse",
- "dse-java-driver-core");
-
- ObjectMapper mapper =
- GraphSONMapper.build()
- .version(GraphSONVersion.V1_0)
- .create()
- .createMapper();
- mapper.registerModule(
- new GraphSON1SerdeTP.GraphSON1DefaultModule(
- "graph-graphson1default", driverJacksonVersion));
- mapper.registerModule(
- new GraphSON1SerdeTP.GraphSON1JavaTimeModule(
- "graph-graphson1javatime", driverJacksonVersion));
-
- return mapper;
- case GRAPHSON_2_0:
- return GraphSONMapper.build()
- .version(GraphSONVersion.V2_0)
- .addCustomModule(GraphSONXModuleV2d0.build().create(false))
- .addRegistry(TinkerIoRegistryV2d0.instance())
- .addCustomModule(new GraphSON2SerdeTP.DseGraphModule())
- .addCustomModule(new GraphSON2SerdeTP.DriverObjectsModule())
- .create()
- .createMapper();
-
- default:
- throw new IllegalStateException(
- String.format("GraphSON sub-protocol unknown: {%s}", graphSubProtocol));
- }
- }
- });
-
- static final Supplier GRAPHSON1_READER =
- Suppliers.memoize(
- () ->
- GraphSONReader.build()
- .mapper(GraphSONMapper.build().version(GraphSONVersion.V1_0).create())
- .create());
-
- public static ByteBuffer serializeToByteBuffer(Object object, GraphProtocol graphSubProtocol)
- throws IOException {
- return ByteBuffer.wrap(serializeToBytes(object, graphSubProtocol));
- }
-
- static byte[] serializeToBytes(Object object, GraphProtocol graphSubProtocol) throws IOException {
- try {
- return OBJECT_MAPPERS.get(graphSubProtocol).writeValueAsBytes(object);
- } catch (ExecutionException e) {
- Throwables.throwIfUnchecked(e);
- throw new RuntimeException(e);
- }
- }
-
- public static GraphNode createGraphNode(List data, GraphProtocol graphSubProtocol)
- throws IOException {
- try {
- ObjectMapper mapper = OBJECT_MAPPERS.get(graphSubProtocol);
- switch (graphSubProtocol) {
- case GRAPHSON_1_0:
- return new LegacyGraphNode(mapper.readTree(Bytes.getArray(data.get(0))), mapper);
- case GRAPHSON_2_0:
- return new ObjectGraphNode(mapper.readValue(Bytes.getArray(data.get(0)), Object.class));
- default:
- // Should already be caught when we lookup in the cache
- throw new AssertionError(
- String.format("Unknown GraphSON sub-protocol: {%s}", graphSubProtocol));
- }
- } catch (ExecutionException e) {
- Throwables.throwIfUnchecked(e);
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphStatementBase.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphStatementBase.java
deleted file mode 100644
index b8baa2f5e49..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphStatementBase.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.oss.driver.api.core.ConsistencyLevel;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.Nullable;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Map;
-import net.jcip.annotations.Immutable;
-
-@Immutable
-public abstract class GraphStatementBase>
- implements GraphStatement {
- private final Boolean isIdempotent;
- private final Duration timeout;
- private final Node node;
- private final long timestamp;
- private final DriverExecutionProfile executionProfile;
- private final String executionProfileName;
- private final Map customPayload;
- private final String graphName;
- private final String traversalSource;
- private final String subProtocol;
- private final ConsistencyLevel consistencyLevel;
- private final ConsistencyLevel readConsistencyLevel;
- private final ConsistencyLevel writeConsistencyLevel;
-
- protected GraphStatementBase(
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel) {
- this.isIdempotent = isIdempotent;
- this.timeout = timeout;
- this.node = node;
- this.timestamp = timestamp;
- this.executionProfile = executionProfile;
- this.executionProfileName = executionProfileName;
- this.customPayload = customPayload;
- this.graphName = graphName;
- this.traversalSource = traversalSource;
- this.subProtocol = subProtocol;
- this.consistencyLevel = consistencyLevel;
- this.readConsistencyLevel = readConsistencyLevel;
- this.writeConsistencyLevel = writeConsistencyLevel;
- }
-
- protected abstract SelfT newInstance(
- Boolean isIdempotent,
- Duration timeout,
- Node node,
- long timestamp,
- DriverExecutionProfile executionProfile,
- String executionProfileName,
- Map customPayload,
- String graphName,
- String traversalSource,
- String subProtocol,
- ConsistencyLevel consistencyLevel,
- ConsistencyLevel readConsistencyLevel,
- ConsistencyLevel writeConsistencyLevel);
-
- @Override
- public Boolean isIdempotent() {
- return isIdempotent;
- }
-
- @NonNull
- @Override
- public SelfT setIdempotent(@Nullable Boolean newIdempotence) {
- return newInstance(
- newIdempotence,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public Duration getTimeout() {
- return timeout;
- }
-
- @NonNull
- @Override
- public SelfT setTimeout(@Nullable Duration newTimeout) {
- return newInstance(
- isIdempotent,
- newTimeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public Node getNode() {
- return node;
- }
-
- @NonNull
- @Override
- public SelfT setNode(@Nullable Node newNode) {
- return newInstance(
- isIdempotent,
- timeout,
- newNode,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Override
- public long getTimestamp() {
- return this.timestamp;
- }
-
- @NonNull
- @Override
- public SelfT setTimestamp(long newTimestamp) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- newTimestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public DriverExecutionProfile getExecutionProfile() {
- return executionProfile;
- }
-
- @NonNull
- @Override
- public SelfT setExecutionProfile(@Nullable DriverExecutionProfile newExecutionProfile) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- newExecutionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public String getExecutionProfileName() {
- return executionProfileName;
- }
-
- @NonNull
- @Override
- public SelfT setExecutionProfileName(@Nullable String newExecutionProfileName) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- newExecutionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @NonNull
- @Override
- public Map getCustomPayload() {
- return customPayload;
- }
-
- @NonNull
- @Override
- public SelfT setCustomPayload(@NonNull Map newCustomPayload) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- newCustomPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public String getGraphName() {
- return graphName;
- }
-
- @NonNull
- @Override
- public SelfT setGraphName(@Nullable String newGraphName) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- newGraphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public String getTraversalSource() {
- return traversalSource;
- }
-
- @NonNull
- @Override
- public SelfT setTraversalSource(@Nullable String newTraversalSource) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- newTraversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public String getSubProtocol() {
- return subProtocol;
- }
-
- @NonNull
- @Override
- public SelfT setSubProtocol(@Nullable String newSubProtocol) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- newSubProtocol,
- consistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public ConsistencyLevel getConsistencyLevel() {
- return consistencyLevel;
- }
-
- @Override
- public SelfT setConsistencyLevel(@Nullable ConsistencyLevel newConsistencyLevel) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- newConsistencyLevel,
- readConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public ConsistencyLevel getReadConsistencyLevel() {
- return readConsistencyLevel;
- }
-
- @NonNull
- @Override
- public SelfT setReadConsistencyLevel(@Nullable ConsistencyLevel newReadConsistencyLevel) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- newReadConsistencyLevel,
- writeConsistencyLevel);
- }
-
- @Nullable
- @Override
- public ConsistencyLevel getWriteConsistencyLevel() {
- return writeConsistencyLevel;
- }
-
- @NonNull
- @Override
- public SelfT setWriteConsistencyLevel(@Nullable ConsistencyLevel newWriteConsistencyLevel) {
- return newInstance(
- isIdempotent,
- timeout,
- node,
- timestamp,
- executionProfile,
- executionProfileName,
- customPayload,
- graphName,
- traversalSource,
- subProtocol,
- consistencyLevel,
- readConsistencyLevel,
- newWriteConsistencyLevel);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSupportChecker.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSupportChecker.java
deleted file mode 100644
index 6e586bbcf3f..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSupportChecker.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.config.DseDriverOption;
-import com.datastax.dse.driver.api.core.graph.GraphStatement;
-import com.datastax.dse.driver.api.core.graph.PagingEnabledOptions;
-import com.datastax.dse.driver.api.core.metadata.DseNodeProperties;
-import com.datastax.dse.driver.internal.core.DseProtocolFeature;
-import com.datastax.oss.driver.api.core.ProtocolVersion;
-import com.datastax.oss.driver.api.core.Version;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.cql.Conversions;
-import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Collection;
-import java.util.Objects;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GraphSupportChecker {
-
- private static final Logger LOG = LoggerFactory.getLogger(GraphSupportChecker.class);
-
- /**
- * The minimum DSE version supporting both graph paging and the GraphBinary sub-protocol is DSE
- * 6.8.
- */
- private static final Version MIN_DSE_VERSION_GRAPH_BINARY_AND_PAGING =
- Objects.requireNonNull(Version.parse("6.8.0"));
-
- private volatile Boolean contextGraphPagingEnabled;
- private volatile Boolean isDse68OrAbove;
-
- /**
- * Checks whether graph paging is available.
- *
- * Graph paging is available if:
- *
- *
- * Continuous paging is generally available (this implies protocol version {@link
- * com.datastax.dse.driver.api.core.DseProtocolVersion#DSE_V1 DSE_V1} or higher);
- * Graph paging is set to ENABLED or AUTO in the configuration
- * with {@link DseDriverOption#GRAPH_PAGING_ENABLED};
- * If graph paging is set to AUTO, then a check will be performed to verify
- * that all hosts are running DSE 6.8+; if that is the case, then graph paging will be
- * assumed to be available.
- *
- *
- * Note that the hosts check will be done only once, then memoized; if other hosts join the
- * cluster later and do not support graph paging, the user has to manually disable graph paging.
- */
- public boolean isPagingEnabled(
- @NonNull GraphStatement> graphStatement, @NonNull InternalDriverContext context) {
- DriverExecutionProfile driverExecutionProfile =
- Conversions.resolveExecutionProfile(graphStatement, context);
- PagingEnabledOptions pagingEnabledOptions =
- PagingEnabledOptions.valueOf(
- driverExecutionProfile.getString(DseDriverOption.GRAPH_PAGING_ENABLED));
- if (LOG.isTraceEnabled()) {
- LOG.trace("GRAPH_PAGING_ENABLED: {}", pagingEnabledOptions);
- }
- if (pagingEnabledOptions == PagingEnabledOptions.DISABLED) {
- return false;
- } else if (pagingEnabledOptions == PagingEnabledOptions.ENABLED) {
- return true;
- } else {
- return isContextGraphPagingEnabled(context);
- }
- }
-
- /**
- * Infers the {@link GraphProtocol} to use to execute the given statement.
- *
- * The graph protocol is computed as follows:
- *
- *
- * If the statement declares the protocol to use with {@link
- * GraphStatement#getSubProtocol()}, then that protocol is returned.
- * If the driver configuration explicitly defines the protocol to use (see {@link
- * DseDriverOption#GRAPH_SUB_PROTOCOL} and reference.conf), then that protocol is returned.
- * Otherwise, the graph protocol to use is determined by the DSE version of hosts in the
- * cluster. If any host has DSE version 6.7.x or lower, the default graph protocol is {@link
- * GraphProtocol#GRAPHSON_2_0}. If all hosts have DSE version 6.8.0 or higher, the default
- * graph protocol is {@link GraphProtocol#GRAPH_BINARY_1_0}.
- *
- *
- * Note that the hosts check will be done only once, then memoized; if other hosts join the and do
- * not support the computed graph protocol, the user has to manually set the graph protocol to
- * use.
- *
- * Also note that GRAPH_BINARY_1_0 can only be used with "core" graph engines; if
- * you are targeting a "classic" graph engine instead, the user has to manually set the graph
- * protocol to something else.
- */
- @NonNull
- public GraphProtocol inferGraphProtocol(
- @NonNull GraphStatement> statement,
- @NonNull DriverExecutionProfile config,
- @NonNull InternalDriverContext context) {
- String graphProtocol = statement.getSubProtocol();
- if (graphProtocol == null) {
- // use the protocol specified in configuration, otherwise get the default from the context
- graphProtocol =
- config.isDefined(DseDriverOption.GRAPH_SUB_PROTOCOL)
- ? config.getString(DseDriverOption.GRAPH_SUB_PROTOCOL)
- : getDefaultGraphProtocol(context).toInternalCode();
- }
- // should not be null because we call config.getString() with a default value
- Objects.requireNonNull(
- graphProtocol,
- "Could not determine the graph protocol for the query. This is a bug, please report.");
-
- return GraphProtocol.fromString(graphProtocol);
- }
-
- private boolean isContextGraphPagingEnabled(InternalDriverContext context) {
- if (contextGraphPagingEnabled == null) {
- ProtocolVersion protocolVersion = context.getProtocolVersion();
- if (!context
- .getProtocolVersionRegistry()
- .supports(protocolVersion, DseProtocolFeature.CONTINUOUS_PAGING)) {
- contextGraphPagingEnabled = false;
- } else {
- if (isDse68OrAbove == null) {
- isDse68OrAbove = checkIsDse68OrAbove(context);
- }
- contextGraphPagingEnabled = isDse68OrAbove;
- }
- }
- return contextGraphPagingEnabled;
- }
-
- /**
- * Determines the default {@link GraphProtocol} for the given context.
- *
- * @return The default GraphProtocol to used based on the provided context.
- */
- @VisibleForTesting
- GraphProtocol getDefaultGraphProtocol(@NonNull InternalDriverContext context) {
- if (isDse68OrAbove == null) {
- isDse68OrAbove = checkIsDse68OrAbove(context);
- }
- // if the DSE version can't be determined, default to GraphSON 2.0
- return isDse68OrAbove ? GraphProtocol.GRAPH_BINARY_1_0 : GraphProtocol.GRAPHSON_2_0;
- }
-
- private boolean checkIsDse68OrAbove(@NonNull InternalDriverContext context) {
- Collection nodes = context.getMetadataManager().getMetadata().getNodes().values();
-
- for (Node node : nodes) {
- Version dseVersion = (Version) node.getExtras().get(DseNodeProperties.DSE_VERSION);
- if (dseVersion == null || dseVersion.compareTo(MIN_DSE_VERSION_GRAPH_BINARY_AND_PAGING) < 0) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/TinkerpopBufferUtil.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSupportRemoved.java
similarity index 69%
rename from core/src/main/java/com/datastax/dse/driver/internal/core/graph/TinkerpopBufferUtil.java
rename to core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSupportRemoved.java
index 5650d904350..9bb91ef0d2f 100644
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/TinkerpopBufferUtil.java
+++ b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphSupportRemoved.java
@@ -17,16 +17,15 @@
*/
package com.datastax.dse.driver.internal.core.graph;
-import java.nio.ByteBuffer;
-import org.apache.tinkerpop.gremlin.structure.io.Buffer;
+public final class GraphSupportRemoved {
-/** Mirror of {@link ByteBufUtil} for Tinkerpop Buffer's */
-public class TinkerpopBufferUtil {
+ public static final String MESSAGE =
+ "DSE Graph is not supported starting with Java driver 4.19.2.2; "
+ + "use 4.19.2.1 or migrate the Graph workload before upgrading";
- public static ByteBuffer readBytes(Buffer tinkerBuff, int size) {
- ByteBuffer res = ByteBuffer.allocate(size);
- tinkerBuff.readBytes(res);
- res.flip();
- return res;
+ public static UnsupportedOperationException exception() {
+ return new UnsupportedOperationException(MESSAGE);
}
+
+ private GraphSupportRemoved() {}
}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/LegacyGraphNode.java b/core/src/main/java/com/datastax/dse/driver/internal/core/graph/LegacyGraphNode.java
deleted file mode 100644
index 1749bf00873..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/graph/LegacyGraphNode.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.datastax.dse.driver.internal.core.graph;
-
-import com.datastax.dse.driver.api.core.graph.GraphNode;
-import com.datastax.oss.driver.api.core.type.reflect.GenericType;
-import com.datastax.oss.driver.shaded.guava.common.base.Objects;
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import net.jcip.annotations.Immutable;
-import org.apache.tinkerpop.gremlin.process.traversal.Path;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-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.structure.io.graphson.GraphSONTokens;
-import org.apache.tinkerpop.gremlin.structure.util.Attachable;
-import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
-import org.apache.tinkerpop.shaded.jackson.databind.JavaType;
-import org.apache.tinkerpop.shaded.jackson.databind.JsonNode;
-import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
-
-/**
- * Legacy implementation for GraphSON 1 results.
- *
- * The server returns plain JSON with no type information. The driver works with the JSON
- * representation directly.
- */
-@Immutable
-public class LegacyGraphNode implements GraphNode {
- private static final String TYPE = "type";
- private static final String VERTEX_TYPE = "vertex";
- private static final String EDGE_TYPE = "edge";
-
- private static final GenericType> LIST_TYPE = GenericType.listOf(Object.class);
- private static final GenericType> MAP_TYPE =
- GenericType.mapOf(String.class, Object.class);
-
- private final JsonNode delegate;
- private final ObjectMapper objectMapper;
-
- public LegacyGraphNode(JsonNode delegate, ObjectMapper objectMapper) {
- Preconditions.checkNotNull(delegate);
- Preconditions.checkNotNull(objectMapper);
- this.delegate = delegate;
- this.objectMapper = objectMapper;
- }
-
- /**
- * The underlying JSON representation.
- *
- * This is an implementation detail, it's only exposed through the internal API.
- */
- public JsonNode getDelegate() {
- return delegate;
- }
-
- /**
- * The object mapper used to deserialize results in {@link #as(Class)} and {@link
- * #as(GenericType)}.
- *
- *
This is an implementation detail, it's only exposed through the internal API.
- */
- public ObjectMapper getObjectMapper() {
- return objectMapper;
- }
-
- @Override
- public boolean isNull() {
- return delegate.isNull();
- }
-
- @Override
- public boolean isMap() {
- return delegate.isObject();
- }
-
- @Override
- public Iterable> keys() {
- return (Iterable) delegate::fieldNames;
- }
-
- @Override
- public LegacyGraphNode getByKey(Object key) {
- if (!(key instanceof String)) {
- return null;
- }
- JsonNode node = delegate.get(((String) key));
- if (node == null) {
- return null;
- }
- return new LegacyGraphNode(node, objectMapper);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map asMap() {
- return (Map) as(MAP_TYPE);
- }
-
- @Override
- public boolean isList() {
- return delegate.isArray();
- }
-
- @Override
- public int size() {
- return delegate.size();
- }
-
- @Override
- public LegacyGraphNode getByIndex(int index) {
- JsonNode node = delegate.get(index);
- if (node == null) {
- return null;
- }
- return new LegacyGraphNode(node, objectMapper);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List asList() {
- return (List) as(LIST_TYPE);
- }
-
- @Override
- public boolean isValue() {
- return delegate.isValueNode();
- }
-
- @Override
- public int asInt() {
- return delegate.asInt();
- }
-
- @Override
- public boolean asBoolean() {
- return delegate.asBoolean();
- }
-
- @Override
- public long asLong() {
- return delegate.asLong();
- }
-
- @Override
- public double asDouble() {
- return delegate.asDouble();
- }
-
- @Override
- public String asString() {
- return delegate.asText();
- }
-
- @Override
- public boolean isVertex() {
- return isType(VERTEX_TYPE);
- }
-
- @Override
- public Vertex asVertex() {
- try {
- return GraphSONUtils.GRAPHSON1_READER
- .get()
- .readVertex(
- new ByteArrayInputStream(delegate.toString().getBytes(StandardCharsets.UTF_8)),
- null,
- null,
- null);
- } catch (IOException e) {
- throw new UncheckedIOException("Could not deserialize node as Vertex.", e);
- }
- }
-
- @Override
- public boolean isEdge() {
- return isType(EDGE_TYPE);
- }
-
- @Override
- public Edge asEdge() {
- try {
- return GraphSONUtils.GRAPHSON1_READER
- .get()
- .readEdge(
- new ByteArrayInputStream(delegate.toString().getBytes(StandardCharsets.UTF_8)),
- Attachable::get);
- } catch (IOException e) {
- throw new UncheckedIOException("Could not deserialize node as Edge.", e);
- }
- }
-
- @Override
- public boolean isPath() {
- return false;
- }
-
- @Override
- public Path asPath() {
- throw new UnsupportedOperationException(
- "GraphSON1 does not support Path, use another Graph sub-protocol such as GraphSON2.");
- }
-
- @Override
- public boolean isProperty() {
- return delegate.has(GraphSONTokens.KEY) && delegate.has(GraphSONTokens.VALUE);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Property asProperty() {
- try {
- return GraphSONUtils.GRAPHSON1_READER
- .get()
- .readProperty(
- new ByteArrayInputStream(delegate.toString().getBytes(StandardCharsets.UTF_8)),
- Attachable::get);
- } catch (IOException e) {
- throw new UncheckedIOException("Could not deserialize node as Property.", e);
- }
- }
-
- @Override
- public boolean isVertexProperty() {
- return delegate.has(GraphSONTokens.ID)
- && delegate.has(GraphSONTokens.VALUE)
- && delegate.has(GraphSONTokens.LABEL);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public VertexProperty