diff --git a/core/pom.xml b/core/pom.xml
index 45f2ee64cf6..095f72f16e4 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -217,22 +217,6 @@
META-INF
-
-
- src/test/resources
-
- project.properties
-
- true
-
-
- src/test/resources
-
- project.properties
-
- false
-
-
maven-jar-plugin
@@ -332,24 +316,6 @@
-
- maven-dependency-plugin
-
-
- generate-dependency-list
-
- list
-
- generate-resources
-
- runtime
- true
- com.datastax.cassandra,com.datastax.dse
- ${project.build.outputDirectory}/com/datastax/dse/driver/internal/deps.txt
-
-
-
-
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..630f52c5a8d 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
@@ -170,10 +170,17 @@ public enum DseDriverOption implements DriverOption {
GRAPH_TIMEOUT("basic.graph.timeout"),
/**
- * Whether to send events for Insights monitoring.
+ * Legacy option that controlled DataStax Insights monitoring.
+ *
+ *
This option is retained for source and binary compatibility. Insights monitoring has been
+ * removed, so the value has no effect. Configuring it to {@code true} causes the driver to log a
+ * warning when the session is created.
*
*
Value type: boolean
+ *
+ * @deprecated DataStax Insights monitoring is no longer supported; there is no replacement.
*/
+ @Deprecated
MONITOR_REPORTING_ENABLED("advanced.monitor-reporting.enabled"),
/**
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/InsightsClientLifecycleListener.java b/core/src/main/java/com/datastax/dse/driver/internal/core/InsightsClientLifecycleListener.java
deleted file mode 100644
index e4dd6f93bf7..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/InsightsClientLifecycleListener.java
+++ /dev/null
@@ -1,66 +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;
-
-import static com.datastax.dse.driver.api.core.config.DseDriverOption.MONITOR_REPORTING_ENABLED;
-
-import com.datastax.dse.driver.internal.core.insights.InsightsClient;
-import com.datastax.dse.driver.internal.core.insights.configuration.InsightsConfiguration;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.internal.core.context.LifecycleListener;
-
-public class InsightsClientLifecycleListener implements LifecycleListener {
- private static final boolean DEFAULT_INSIGHTS_ENABLED = true;
- private static final long STATUS_EVENT_DELAY_MILLIS = 300000L;
- private final InternalDriverContext context;
- private final StackTraceElement[] initCallStackTrace;
- private volatile InsightsClient insightsClient;
-
- public InsightsClientLifecycleListener(
- InternalDriverContext context, StackTraceElement[] initCallStackTrace) {
- this.context = context;
- this.initCallStackTrace = initCallStackTrace;
- }
-
- @Override
- public void onSessionReady() {
- boolean monitorReportingEnabled =
- context
- .getConfig()
- .getDefaultProfile()
- .getBoolean(MONITOR_REPORTING_ENABLED, DEFAULT_INSIGHTS_ENABLED);
-
- this.insightsClient =
- InsightsClient.createInsightsClient(
- new InsightsConfiguration(
- monitorReportingEnabled,
- STATUS_EVENT_DELAY_MILLIS,
- context.getNettyOptions().adminEventExecutorGroup().next()),
- context,
- initCallStackTrace);
- insightsClient.sendStartupMessage();
- insightsClient.scheduleStatusMessageSend();
- }
-
- @Override
- public void close() {
- if (insightsClient != null) {
- insightsClient.shutdown();
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/AddressFormatter.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/AddressFormatter.java
deleted file mode 100644
index cecc951a3ab..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/AddressFormatter.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.insights;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-
-class AddressFormatter {
-
- static String nullSafeToString(Object address) {
- if (address instanceof InetAddress) {
- return nullSafeToString((InetAddress) address);
- } else if (address instanceof InetSocketAddress) {
- return nullSafeToString((InetSocketAddress) address);
- } else if (address instanceof String) {
- return address.toString();
- } else {
- return "";
- }
- }
-
- static String nullSafeToString(InetAddress inetAddress) {
- return inetAddress != null ? inetAddress.getHostAddress() : null;
- }
-
- static String nullSafeToString(InetSocketAddress inetSocketAddress) {
- if (inetSocketAddress != null) {
- if (inetSocketAddress.isUnresolved()) {
- return String.format(
- "%s:%s",
- nullSafeToString(inetSocketAddress.getHostName()), inetSocketAddress.getPort());
- } else {
- return String.format(
- "%s:%s", nullSafeToString(inetSocketAddress.getAddress()), inetSocketAddress.getPort());
- }
- }
- return null;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ConfigAntiPatternsFinder.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ConfigAntiPatternsFinder.java
deleted file mode 100644
index 7f5b9c20a0e..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ConfigAntiPatternsFinder.java
+++ /dev/null
@@ -1,46 +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.insights;
-
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_HOSTNAME_VALIDATION;
-
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import java.util.HashMap;
-import java.util.Map;
-
-class ConfigAntiPatternsFinder {
- Map findAntiPatterns(InternalDriverContext driverContext) {
- Map antiPatterns = new HashMap<>();
- findSslAntiPattern(driverContext, antiPatterns);
- return antiPatterns;
- }
-
- private void findSslAntiPattern(
- InternalDriverContext driverContext, Map antiPatterns) {
- boolean isSslDefined =
- driverContext.getConfig().getDefaultProfile().isDefined(SSL_ENGINE_FACTORY_CLASS);
- boolean certValidation =
- driverContext.getConfig().getDefaultProfile().getBoolean(SSL_HOSTNAME_VALIDATION, false);
- if (isSslDefined && !certValidation) {
- antiPatterns.put(
- "sslWithoutCertValidation",
- "Client-to-node encryption is enabled but server certificate validation is disabled");
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/DataCentersFinder.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/DataCentersFinder.java
deleted file mode 100644
index 7112b8dcdf7..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/DataCentersFinder.java
+++ /dev/null
@@ -1,55 +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.insights;
-
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE;
-
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.loadbalancing.NodeDistance;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-class DataCentersFinder {
-
- Set getDataCenters(InternalDriverContext driverContext) {
- return getDataCenters(
- driverContext.getMetadataManager().getMetadata().getNodes().values(),
- driverContext.getConfig().getDefaultProfile());
- }
-
- @VisibleForTesting
- Set getDataCenters(Collection nodes, DriverExecutionProfile executionProfile) {
-
- int remoteConnectionsLength = executionProfile.getInt(CONNECTION_POOL_REMOTE_SIZE);
-
- Set dataCenters = new HashSet<>();
- for (Node n : nodes) {
- NodeDistance distance = n.getDistance();
-
- if (distance.equals(NodeDistance.LOCAL)
- || (distance.equals(NodeDistance.REMOTE) && remoteConnectionsLength > 0)) {
- dataCenters.add(n.getDatacenter());
- }
- }
- return dataCenters;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfilesInfoFinder.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfilesInfoFinder.java
deleted file mode 100644
index a7c92d80d96..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfilesInfoFinder.java
+++ /dev/null
@@ -1,184 +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.insights;
-
-import static com.datastax.dse.driver.api.core.config.DseDriverOption.GRAPH_TRAVERSAL_SOURCE;
-
-import com.datastax.dse.driver.internal.core.insights.PackageUtil.ClassSettingDetails;
-import com.datastax.dse.driver.internal.core.insights.schema.LoadBalancingInfo;
-import com.datastax.dse.driver.internal.core.insights.schema.SpecificExecutionProfile;
-import com.datastax.dse.driver.internal.core.insights.schema.SpeculativeExecutionInfo;
-import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-class ExecutionProfilesInfoFinder {
- Map getExecutionProfilesInfo(
- InternalDriverContext driverContext) {
-
- SpecificExecutionProfile defaultProfile =
- mapToSpecificProfile(driverContext.getConfig().getDefaultProfile());
-
- return driverContext.getConfig().getProfiles().entrySet().stream()
- .collect(
- Collectors.toMap(
- Map.Entry::getKey,
- e -> {
- if (isNotDefaultProfile(e)) {
- SpecificExecutionProfile specificExecutionProfile =
- mapToSpecificProfile(e.getValue());
- return retainOnlyDifferentFieldsFromSpecificProfile(
- defaultProfile, specificExecutionProfile);
- } else {
- return defaultProfile;
- }
- }));
- }
-
- private boolean isNotDefaultProfile(Map.Entry e) {
- return !e.getKey().equals("default");
- }
-
- private SpecificExecutionProfile retainOnlyDifferentFieldsFromSpecificProfile(
- SpecificExecutionProfile defaultProfile, SpecificExecutionProfile specificExecutionProfile) {
- Integer readTimeout =
- getIfDifferentOrReturnNull(
- defaultProfile, specificExecutionProfile, SpecificExecutionProfile::getReadTimeout);
- LoadBalancingInfo loadBalancingInfo =
- getIfDifferentOrReturnNull(
- defaultProfile, specificExecutionProfile, SpecificExecutionProfile::getLoadBalancing);
-
- SpeculativeExecutionInfo speculativeExecutionInfo =
- getIfDifferentOrReturnNull(
- defaultProfile,
- specificExecutionProfile,
- SpecificExecutionProfile::getSpeculativeExecution);
-
- String consistency =
- getIfDifferentOrReturnNull(
- defaultProfile, specificExecutionProfile, SpecificExecutionProfile::getConsistency);
-
- String serialConsistency =
- getIfDifferentOrReturnNull(
- defaultProfile,
- specificExecutionProfile,
- SpecificExecutionProfile::getSerialConsistency);
-
- Map graphOptions =
- getIfDifferentOrReturnNull(
- defaultProfile, specificExecutionProfile, SpecificExecutionProfile::getGraphOptions);
-
- return new SpecificExecutionProfile(
- readTimeout,
- loadBalancingInfo,
- speculativeExecutionInfo,
- consistency,
- serialConsistency,
- graphOptions);
- }
-
- private T getIfDifferentOrReturnNull(
- SpecificExecutionProfile defaultProfile,
- SpecificExecutionProfile profile,
- Function valueExtractor) {
- T defaultProfileValue = valueExtractor.apply(defaultProfile);
- T specificProfileValue = valueExtractor.apply(profile);
- if (defaultProfileValue.equals(specificProfileValue)) {
- return null;
- } else {
- return specificProfileValue;
- }
- }
-
- private SpecificExecutionProfile mapToSpecificProfile(
- DriverExecutionProfile driverExecutionProfile) {
- return new SpecificExecutionProfile(
- (int) driverExecutionProfile.getDuration(DefaultDriverOption.REQUEST_TIMEOUT).toMillis(),
- getLoadBalancingInfo(driverExecutionProfile),
- getSpeculativeExecutionInfo(driverExecutionProfile),
- driverExecutionProfile.getString(DefaultDriverOption.REQUEST_CONSISTENCY),
- driverExecutionProfile.getString(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY),
- getGraphOptions(driverExecutionProfile));
- }
-
- private SpeculativeExecutionInfo getSpeculativeExecutionInfo(
- DriverExecutionProfile driverExecutionProfile) {
- Map options = new LinkedHashMap<>();
-
- putIfExists(
- options,
- "maxSpeculativeExecutions",
- DefaultDriverOption.SPECULATIVE_EXECUTION_MAX,
- driverExecutionProfile);
- putIfExists(
- options, "delay", DefaultDriverOption.SPECULATIVE_EXECUTION_DELAY, driverExecutionProfile);
-
- ClassSettingDetails speculativeExecutionDetails =
- PackageUtil.getSpeculativeExecutionDetails(
- driverExecutionProfile.getString(
- DefaultDriverOption.SPECULATIVE_EXECUTION_POLICY_CLASS));
- return new SpeculativeExecutionInfo(
- speculativeExecutionDetails.getClassName(),
- options,
- speculativeExecutionDetails.getFullPackage());
- }
-
- private void putIfExists(
- Map options,
- String key,
- DefaultDriverOption option,
- DriverExecutionProfile executionProfile) {
- if (executionProfile.isDefined(option)) {
- options.put(key, executionProfile.getInt(option));
- }
- }
-
- private LoadBalancingInfo getLoadBalancingInfo(DriverExecutionProfile driverExecutionProfile) {
- Map options = new LinkedHashMap<>();
- if (driverExecutionProfile.isDefined(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER)) {
- options.put(
- "localDataCenter",
- driverExecutionProfile.getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER));
- }
- @SuppressWarnings("deprecation")
- boolean hasNodeFiltering =
- driverExecutionProfile.isDefined(DefaultDriverOption.LOAD_BALANCING_FILTER_CLASS)
- || driverExecutionProfile.isDefined(
- DefaultDriverOption.LOAD_BALANCING_DISTANCE_EVALUATOR_CLASS);
- options.put("filterFunction", hasNodeFiltering);
- ClassSettingDetails loadBalancingDetails =
- PackageUtil.getLoadBalancingDetails(
- driverExecutionProfile.getString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS));
- return new LoadBalancingInfo(
- loadBalancingDetails.getClassName(), options, loadBalancingDetails.getFullPackage());
- }
-
- private Map getGraphOptions(DriverExecutionProfile driverExecutionProfile) {
- Map graphOptionsMap = new HashMap<>();
- String graphTraversalSource = driverExecutionProfile.getString(GRAPH_TRAVERSAL_SOURCE, null);
- if (graphTraversalSource != null) {
- graphOptionsMap.put("source", graphTraversalSource);
- }
- return graphOptionsMap;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsClient.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsClient.java
deleted file mode 100644
index 168477894ed..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsClient.java
+++ /dev/null
@@ -1,490 +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.insights;
-
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.AUTH_PROVIDER_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.HEARTBEAT_INTERVAL;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.PROTOCOL_COMPRESSION;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_HOSTNAME_VALIDATION;
-
-import com.datastax.dse.driver.api.core.DseProtocolVersion;
-import com.datastax.dse.driver.internal.core.insights.PackageUtil.ClassSettingDetails;
-import com.datastax.dse.driver.internal.core.insights.configuration.InsightsConfiguration;
-import com.datastax.dse.driver.internal.core.insights.exceptions.InsightEventFormatException;
-import com.datastax.dse.driver.internal.core.insights.schema.AuthProviderType;
-import com.datastax.dse.driver.internal.core.insights.schema.Insight;
-import com.datastax.dse.driver.internal.core.insights.schema.InsightMetadata;
-import com.datastax.dse.driver.internal.core.insights.schema.InsightType;
-import com.datastax.dse.driver.internal.core.insights.schema.InsightsStartupData;
-import com.datastax.dse.driver.internal.core.insights.schema.InsightsStatusData;
-import com.datastax.dse.driver.internal.core.insights.schema.PoolSizeByHostDistance;
-import com.datastax.dse.driver.internal.core.insights.schema.SSL;
-import com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode;
-import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.api.core.session.SessionBuilder;
-import com.datastax.oss.driver.api.core.type.DataTypes;
-import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
-import com.datastax.oss.driver.api.core.uuid.Uuids;
-import com.datastax.oss.driver.internal.core.adminrequest.AdminRequestHandler;
-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.context.StartupOptionsBuilder;
-import com.datastax.oss.driver.internal.core.control.ControlConnection;
-import com.datastax.oss.driver.internal.core.pool.ChannelPool;
-import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
-import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
-import com.datastax.oss.protocol.internal.request.Query;
-import com.datastax.oss.protocol.internal.request.query.QueryOptions;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class InsightsClient {
- private static final Logger LOGGER = LoggerFactory.getLogger(InsightsClient.class);
- private static final String STARTUP_MESSAGE_NAME = "driver.startup";
- private static final String STATUS_MESSAGE_NAME = "driver.status";
- private static final String REPORT_INSIGHT_RPC = "CALL InsightsRpc.reportInsight(?)";
- private static final Map TAGS = ImmutableMap.of("language", "java");
- private static final String STARTUP_VERSION_1_ID = "v1";
- private static final String STATUS_VERSION_1_ID = "v1";
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
- private static final int MAX_NUMBER_OF_STATUS_ERROR_LOGS = 5;
- static final String DEFAULT_JAVA_APPLICATION = "Default Java Application";
-
- private final ControlConnection controlConnection;
- private final String id = Uuids.random().toString();
- private final InsightsConfiguration insightsConfiguration;
- private final AtomicInteger numberOfStatusEventErrors = new AtomicInteger();
-
- private final InternalDriverContext driverContext;
- private final Supplier timestampSupplier;
- private final PlatformInfoFinder platformInfoFinder;
- private final ReconnectionPolicyInfoFinder reconnectionPolicyInfoInfoFinder;
- private final ExecutionProfilesInfoFinder executionProfilesInfoFinder;
- private final ConfigAntiPatternsFinder configAntiPatternsFinder;
- private final DataCentersFinder dataCentersFinder;
- private final StackTraceElement[] initCallStackTrace;
-
- private volatile ScheduledFuture> scheduleInsightsTask;
-
- public static InsightsClient createInsightsClient(
- InsightsConfiguration insightsConfiguration,
- InternalDriverContext driverContext,
- StackTraceElement[] initCallStackTrace) {
- DataCentersFinder dataCentersFinder = new DataCentersFinder();
- return new InsightsClient(
- driverContext,
- System::currentTimeMillis,
- insightsConfiguration,
- new PlatformInfoFinder(),
- new ReconnectionPolicyInfoFinder(),
- new ExecutionProfilesInfoFinder(),
- new ConfigAntiPatternsFinder(),
- dataCentersFinder,
- initCallStackTrace);
- }
-
- InsightsClient(
- InternalDriverContext driverContext,
- Supplier timestampSupplier,
- InsightsConfiguration insightsConfiguration,
- PlatformInfoFinder platformInfoFinder,
- ReconnectionPolicyInfoFinder reconnectionPolicyInfoInfoFinder,
- ExecutionProfilesInfoFinder executionProfilesInfoFinder,
- ConfigAntiPatternsFinder configAntiPatternsFinder,
- DataCentersFinder dataCentersFinder,
- StackTraceElement[] initCallStackTrace) {
- this.driverContext = driverContext;
- this.controlConnection = driverContext.getControlConnection();
- this.timestampSupplier = timestampSupplier;
- this.insightsConfiguration = insightsConfiguration;
- this.platformInfoFinder = platformInfoFinder;
- this.reconnectionPolicyInfoInfoFinder = reconnectionPolicyInfoInfoFinder;
- this.executionProfilesInfoFinder = executionProfilesInfoFinder;
- this.configAntiPatternsFinder = configAntiPatternsFinder;
- this.dataCentersFinder = dataCentersFinder;
- this.initCallStackTrace = initCallStackTrace;
- }
-
- public CompletionStage sendStartupMessage() {
- try {
- if (!shouldSendEvent()) {
- return CompletableFuture.completedFuture(null);
- } else {
- String startupMessage = createStartupMessage();
- return sendJsonMessage(startupMessage)
- .whenComplete(
- (aVoid, throwable) -> {
- if (throwable != null) {
- LOGGER.debug(
- "Error while sending startup message to Insights. Message was: "
- + trimToFirst500characters(startupMessage),
- throwable);
- }
- });
- }
- } catch (Exception e) {
- LOGGER.debug("Unexpected error while sending startup message to Insights.", e);
- return CompletableFutures.failedFuture(e);
- }
- }
-
- private static String trimToFirst500characters(String startupMessage) {
- return startupMessage.substring(0, Math.min(startupMessage.length(), 500));
- }
-
- public void scheduleStatusMessageSend() {
- if (!shouldSendEvent()) {
- return;
- }
- scheduleInsightsTask =
- scheduleInsightsTask(
- insightsConfiguration.getStatusEventDelayMillis(),
- insightsConfiguration.getExecutor(),
- this::sendStatusMessage);
- }
-
- public void shutdown() {
- if (scheduleInsightsTask != null) {
- scheduleInsightsTask.cancel(false);
- }
- }
-
- @VisibleForTesting
- public CompletionStage sendStatusMessage() {
- try {
- String statusMessage = createStatusMessage();
- CompletionStage result = sendJsonMessage(statusMessage);
- return result.whenComplete(
- (aVoid, throwable) -> {
- if (throwable != null) {
- if (numberOfStatusEventErrors.getAndIncrement() < MAX_NUMBER_OF_STATUS_ERROR_LOGS) {
- LOGGER.debug(
- "Error while sending status message to Insights. Message was: "
- + trimToFirst500characters(statusMessage),
- throwable);
- }
- }
- });
- } catch (Exception e) {
- LOGGER.debug("Unexpected error while sending status message to Insights.", e);
- return CompletableFutures.failedFuture(e);
- }
- }
-
- private CompletionStage sendJsonMessage(String jsonMessage) {
-
- QueryOptions queryOptions = createQueryOptionsWithJson(jsonMessage);
- String logPrefix = driverContext.getSessionName();
- Duration timeout =
- driverContext
- .getConfig()
- .getDefaultProfile()
- .getDuration(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT);
- LOGGER.debug("sending JSON message: {}", jsonMessage);
-
- Query query = new Query(REPORT_INSIGHT_RPC, queryOptions);
- return AdminRequestHandler.call(controlConnection.channel(), query, timeout, logPrefix).start();
- }
-
- private QueryOptions createQueryOptionsWithJson(String json) {
- TypeCodec codec =
- driverContext.getCodecRegistry().codecFor(DataTypes.TEXT, String.class);
- ByteBuffer startupMessageSerialized = codec.encode(json, DseProtocolVersion.DSE_V2);
- return new QueryOptions(
- QueryOptions.DEFAULT.consistency,
- Collections.singletonList(startupMessageSerialized),
- QueryOptions.DEFAULT.namedValues,
- QueryOptions.DEFAULT.skipMetadata,
- QueryOptions.DEFAULT.pageSize,
- QueryOptions.DEFAULT.pagingState,
- QueryOptions.DEFAULT.serialConsistency,
- QueryOptions.DEFAULT.defaultTimestamp,
- QueryOptions.DEFAULT.keyspace,
- QueryOptions.DEFAULT.nowInSeconds);
- }
-
- private boolean shouldSendEvent() {
- try {
- return insightsConfiguration.isMonitorReportingEnabled()
- && InsightsSupportVerifier.supportsInsights(
- driverContext.getMetadataManager().getMetadata().getNodes().values());
- } catch (Exception e) {
- LOGGER.debug("Unexpected error while checking Insights support.", e);
- return false;
- }
- }
-
- @VisibleForTesting
- String createStartupMessage() {
- InsightMetadata insightMetadata = createMetadata(STARTUP_MESSAGE_NAME, STARTUP_VERSION_1_ID);
- InsightsStartupData data = createStartupData();
-
- try {
- return OBJECT_MAPPER.writeValueAsString(new Insight<>(insightMetadata, data));
- } catch (JsonProcessingException e) {
- throw new InsightEventFormatException("Problem when creating: " + STARTUP_MESSAGE_NAME, e);
- }
- }
-
- @VisibleForTesting
- String createStatusMessage() {
- InsightMetadata insightMetadata = createMetadata(STATUS_MESSAGE_NAME, STATUS_VERSION_1_ID);
- InsightsStatusData data = createStatusData();
-
- try {
- return OBJECT_MAPPER.writeValueAsString(new Insight<>(insightMetadata, data));
- } catch (JsonProcessingException e) {
- throw new InsightEventFormatException("Problem when creating: " + STATUS_MESSAGE_NAME, e);
- }
- }
-
- private InsightsStatusData createStatusData() {
- Map startupOptions = driverContext.getStartupOptions();
- return InsightsStatusData.builder()
- .withClientId(getClientId(startupOptions))
- .withSessionId(id)
- .withControlConnection(getControlConnectionSocketAddress())
- .withConnectedNodes(getConnectedNodes())
- .build();
- }
-
- private Map getConnectedNodes() {
- Map pools = driverContext.getPoolManager().getPools();
- return pools.entrySet().stream()
- .collect(
- Collectors.toMap(
- entry -> AddressFormatter.nullSafeToString(entry.getKey().getEndPoint().resolve()),
- this::constructSessionStateForNode));
- }
-
- private SessionStateForNode constructSessionStateForNode(Map.Entry entry) {
- return new SessionStateForNode(
- entry.getKey().getOpenConnections(), entry.getValue().getInFlight());
- }
-
- private InsightsStartupData createStartupData() {
- Map startupOptions = driverContext.getStartupOptions();
- return InsightsStartupData.builder()
- .withClientId(getClientId(startupOptions))
- .withSessionId(id)
- .withApplicationName(getApplicationName(startupOptions))
- .withApplicationVersion(getApplicationVersion(startupOptions))
- .withDriverName(getDriverName(startupOptions))
- .withDriverVersion(getDriverVersion(startupOptions))
- .withContactPoints(
- getResolvedContactPoints(
- driverContext.getMetadataManager().getContactPoints().stream()
- .map(n -> n.getEndPoint().resolve())
- .filter(InetSocketAddress.class::isInstance)
- .map(InetSocketAddress.class::cast)
- .collect(Collectors.toSet())))
- .withInitialControlConnection(getControlConnectionSocketAddress())
- .withProtocolVersion(driverContext.getProtocolVersion().getCode())
- .withLocalAddress(getLocalAddress())
- .withExecutionProfiles(executionProfilesInfoFinder.getExecutionProfilesInfo(driverContext))
- .withPoolSizeByHostDistance(getPoolSizeByHostDistance())
- .withHeartbeatInterval(
- driverContext
- .getConfig()
- .getDefaultProfile()
- .getDuration(HEARTBEAT_INTERVAL)
- .toMillis())
- .withCompression(
- driverContext.getConfig().getDefaultProfile().getString(PROTOCOL_COMPRESSION, "none"))
- .withReconnectionPolicy(
- reconnectionPolicyInfoInfoFinder.getReconnectionPolicyInfo(
- driverContext.getReconnectionPolicy(),
- driverContext.getConfig().getDefaultProfile()))
- .withSsl(getSsl())
- .withAuthProvider(getAuthProvider())
- .withOtherOptions(getOtherOptions())
- .withPlatformInfo(platformInfoFinder.getInsightsPlatformInfo())
- .withConfigAntiPatterns(configAntiPatternsFinder.findAntiPatterns(driverContext))
- .withPeriodicStatusInterval(getPeriodicStatusInterval())
- .withHostName(getLocalHostName())
- .withApplicationNameWasGenerated(isApplicationNameGenerated(startupOptions))
- .withDataCenters(dataCentersFinder.getDataCenters(driverContext))
- .build();
- }
-
- private AuthProviderType getAuthProvider() {
- String authProviderClassName =
- driverContext
- .getConfig()
- .getDefaultProfile()
- .getString(AUTH_PROVIDER_CLASS, "NoAuthProvider");
- ClassSettingDetails authProviderDetails =
- PackageUtil.getAuthProviderDetails(authProviderClassName);
- return new AuthProviderType(
- authProviderDetails.getClassName(), authProviderDetails.getFullPackage());
- }
-
- private long getPeriodicStatusInterval() {
- return TimeUnit.MILLISECONDS.toSeconds(insightsConfiguration.getStatusEventDelayMillis());
- }
-
- @VisibleForTesting
- static Map> getResolvedContactPoints(Set contactPoints) {
- if (contactPoints == null) {
- return Collections.emptyMap();
- }
- return contactPoints.stream()
- .collect(
- Collectors.groupingBy(
- InetSocketAddress::getHostName,
- Collectors.mapping(AddressFormatter::nullSafeToString, Collectors.toList())));
- }
-
- private String getDriverVersion(Map startupOptions) {
- return startupOptions.get(StartupOptionsBuilder.DRIVER_VERSION_KEY);
- }
-
- private String getDriverName(Map startupOptions) {
- return startupOptions.get(StartupOptionsBuilder.DRIVER_NAME_KEY);
- }
-
- private String getClientId(Map startupOptions) {
- return startupOptions.get(StartupOptionsBuilder.CLIENT_ID_KEY);
- }
-
- private boolean isApplicationNameGenerated(Map startupOptions) {
- return startupOptions.get(StartupOptionsBuilder.APPLICATION_NAME_KEY) == null;
- }
-
- private String getApplicationVersion(Map startupOptions) {
- String applicationVersion = startupOptions.get(StartupOptionsBuilder.APPLICATION_VERSION_KEY);
- if (applicationVersion == null) {
- return "";
- }
- return applicationVersion;
- }
-
- private String getApplicationName(Map startupOptions) {
- String applicationName = startupOptions.get(StartupOptionsBuilder.APPLICATION_NAME_KEY);
- if (applicationName == null || applicationName.isEmpty()) {
- return getClusterCreateCaller(initCallStackTrace);
- }
- return applicationName;
- }
-
- @VisibleForTesting
- static String getClusterCreateCaller(StackTraceElement[] stackTrace) {
- for (int i = 0; i < stackTrace.length - 1; i++) {
- if (isClusterStackTrace(stackTrace[i])) {
- int nextElement = i + 1;
- if (!isClusterStackTrace(stackTrace[nextElement])) {
- return stackTrace[nextElement].getClassName();
- }
- }
- }
- return DEFAULT_JAVA_APPLICATION;
- }
-
- private static boolean isClusterStackTrace(StackTraceElement stackTraceElement) {
- return stackTraceElement.getClassName().equals(DefaultDriverContext.class.getName())
- || stackTraceElement.getClassName().equals(SessionBuilder.class.getName());
- }
-
- private String getLocalHostName() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- LOGGER.warn("Can not resolve the name of a host, returning null", e);
- return null;
- }
- }
-
- private Map getOtherOptions() {
- return Collections.emptyMap(); // todo
- }
-
- private SSL getSsl() {
- boolean isSslDefined =
- driverContext.getConfig().getDefaultProfile().isDefined(SSL_ENGINE_FACTORY_CLASS);
- boolean certValidation =
- driverContext.getConfig().getDefaultProfile().getBoolean(SSL_HOSTNAME_VALIDATION, false);
- return new SSL(isSslDefined, certValidation);
- }
-
- private PoolSizeByHostDistance getPoolSizeByHostDistance() {
-
- return new PoolSizeByHostDistance(
- driverContext.getConfig().getDefaultProfile().getInt(CONNECTION_POOL_LOCAL_SIZE),
- driverContext.getConfig().getDefaultProfile().getInt(CONNECTION_POOL_REMOTE_SIZE),
- 0);
- }
-
- private String getControlConnectionSocketAddress() {
- SocketAddress controlConnectionAddress = controlConnection.channel().getEndPoint().resolve();
- return AddressFormatter.nullSafeToString(controlConnectionAddress);
- }
-
- private String getLocalAddress() {
- SocketAddress controlConnectionLocalAddress = controlConnection.channel().localAddress();
- if (controlConnectionLocalAddress instanceof InetSocketAddress) {
- return AddressFormatter.nullSafeToString(
- ((InetSocketAddress) controlConnectionLocalAddress).getAddress());
- }
- return null;
- }
-
- private InsightMetadata createMetadata(String messageName, String messageVersion) {
- return new InsightMetadata(
- messageName, timestampSupplier.get(), TAGS, InsightType.EVENT, messageVersion);
- }
-
- @VisibleForTesting
- static ScheduledFuture> scheduleInsightsTask(
- long statusEventDelayMillis,
- ScheduledExecutorService scheduledTasksExecutor,
- Runnable runnable) {
- long initialDelay =
- (long) Math.floor(statusEventDelayMillis - zeroToTenPercentRandom(statusEventDelayMillis));
- return scheduledTasksExecutor.scheduleWithFixedDelay(
- runnable, initialDelay, statusEventDelayMillis, TimeUnit.MILLISECONDS);
- }
-
- private static double zeroToTenPercentRandom(long statusEventDelayMillis) {
- return 0.1 * statusEventDelayMillis * Math.random();
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsSupportVerifier.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsSupportVerifier.java
deleted file mode 100644
index ec016ef52d8..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsSupportVerifier.java
+++ /dev/null
@@ -1,50 +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.insights;
-
-import com.datastax.dse.driver.api.core.metadata.DseNodeProperties;
-import com.datastax.oss.driver.api.core.Version;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import java.util.Collection;
-
-class InsightsSupportVerifier {
- private static final Version minDse6Version = Version.parse("6.0.5");
- private static final Version minDse51Version = Version.parse("5.1.13");
- private static final Version dse600Version = Version.parse("6.0.0");
-
- static boolean supportsInsights(Collection nodes) {
- assert minDse6Version != null;
- assert dse600Version != null;
- assert minDse51Version != null;
- if (nodes.isEmpty()) return false;
-
- for (Node node : nodes) {
- Object version = node.getExtras().get(DseNodeProperties.DSE_VERSION);
- if (version == null) {
- return false;
- }
- Version dseVersion = (Version) version;
- if (!(dseVersion.compareTo(minDse6Version) >= 0
- || (dseVersion.compareTo(dse600Version) < 0
- && dseVersion.compareTo(minDse51Version) >= 0))) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/PackageUtil.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/PackageUtil.java
deleted file mode 100644
index c7e15bbdfae..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/PackageUtil.java
+++ /dev/null
@@ -1,86 +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.insights;
-
-import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-
-class PackageUtil {
- static final String DEFAULT_SPECULATIVE_EXECUTION_PACKAGE =
- "com.datastax.oss.driver.internal.core.specex";
- static final String DEFAULT_LOAD_BALANCING_PACKAGE =
- "com.datastax.oss.driver.internal.core.loadbalancing";
- static final String DEFAULT_AUTH_PROVIDER_PACKAGE = "com.datastax.oss.driver.internal.core.auth";
-
- static String getNamespace(Class> tClass) {
- String namespace = "";
- Package packageInfo = tClass.getPackage();
- if (packageInfo != null) {
- namespace = packageInfo.getName();
- }
- return namespace;
- }
-
- static ClassSettingDetails getSpeculativeExecutionDetails(String classSetting) {
- return getClassSettingDetails(classSetting, DEFAULT_SPECULATIVE_EXECUTION_PACKAGE);
- }
-
- static ClassSettingDetails getLoadBalancingDetails(String classSetting) {
- return getClassSettingDetails(classSetting, DEFAULT_LOAD_BALANCING_PACKAGE);
- }
-
- static ClassSettingDetails getAuthProviderDetails(String classSetting) {
- return getClassSettingDetails(classSetting, DEFAULT_AUTH_PROVIDER_PACKAGE);
- }
-
- private static ClassSettingDetails getClassSettingDetails(
- String classSetting, String packageName) {
- String className = getClassName(classSetting);
- String fullPackage = getFullPackageOrDefault(classSetting, packageName);
- return new ClassSettingDetails(className, fullPackage);
- }
-
- @VisibleForTesting
- static String getClassName(String classSetting) {
- int lastDot = classSetting.lastIndexOf('.');
- return lastDot < 0 ? classSetting : classSetting.substring(lastDot + 1);
- }
-
- @VisibleForTesting
- static String getFullPackageOrDefault(String classSetting, String defaultValue) {
- int lastDot = classSetting.lastIndexOf('.');
- return lastDot < 0 ? defaultValue : classSetting.substring(0, lastDot);
- }
-
- static class ClassSettingDetails {
- private final String className;
- private final String fullPackage;
-
- ClassSettingDetails(String className, String fullPackage) {
- this.className = className;
- this.fullPackage = fullPackage;
- }
-
- String getClassName() {
- return className;
- }
-
- String getFullPackage() {
- return fullPackage;
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/PlatformInfoFinder.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/PlatformInfoFinder.java
deleted file mode 100644
index 84b4d76e8b7..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/PlatformInfoFinder.java
+++ /dev/null
@@ -1,297 +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.insights;
-
-import static com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.OS;
-import static com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.RuntimeAndCompileTimeVersions;
-
-import com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo;
-import com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.CPUS;
-import com.datastax.oss.driver.internal.core.os.Native;
-import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-import com.datastax.oss.driver.shaded.guava.common.base.Splitter;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.function.Function;
-
-class PlatformInfoFinder {
- private static final String MAVEN_IGNORE_LINE = "The following files have been resolved:";
- private static final Splitter DEPENDENCY_SPLITTER = Splitter.on(':');
- static final String UNVERIFIED_RUNTIME_VERSION = "UNVERIFIED";
- private final Function propertiesUrlProvider;
-
- @SuppressWarnings("UnnecessaryLambda")
- private static final Function M2_PROPERTIES_PROVIDER =
- d -> {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- if (contextClassLoader == null) {
- contextClassLoader = PlatformInfoFinder.class.getClassLoader();
- }
- return contextClassLoader.getResource(
- "META-INF/maven/" + d.groupId + "/" + d.artifactId + "/pom.properties");
- };
-
- PlatformInfoFinder() {
- this(M2_PROPERTIES_PROVIDER);
- }
-
- @VisibleForTesting
- PlatformInfoFinder(Function pomPropertiesUrlProvider) {
- this.propertiesUrlProvider = pomPropertiesUrlProvider;
- }
-
- InsightsPlatformInfo getInsightsPlatformInfo() {
- OS os = getOsInfo();
- CPUS cpus = getCpuInfo();
- Map> runtimeInfo = getRuntimeInfo();
-
- return new InsightsPlatformInfo(os, cpus, runtimeInfo);
- }
-
- private Map> getRuntimeInfo() {
- Map coreDeps =
- fetchDependenciesFromFile(
- this.getClass().getResourceAsStream("/com/datastax/dse/driver/internal/deps.txt"));
-
- Map queryBuilderDeps =
- fetchDependenciesFromFile(
- this.getClass()
- .getResourceAsStream("/com/datastax/dse/driver/internal/querybuilder/deps.txt"));
-
- Map mapperProcessorDeps =
- fetchDependenciesFromFile(
- this.getClass()
- .getResourceAsStream(
- "/com/datastax/dse/driver/internal/mapper/processor/deps.txt"));
-
- Map mapperRuntimeDeps =
- fetchDependenciesFromFile(
- this.getClass()
- .getResourceAsStream("/com/datastax/dse/driver/internal/mapper/deps.txt"));
-
- Map> runtimeDependencies =
- new LinkedHashMap<>();
- putIfNonEmpty(coreDeps, runtimeDependencies, "core");
- putIfNonEmpty(queryBuilderDeps, runtimeDependencies, "query-builder");
- putIfNonEmpty(mapperProcessorDeps, runtimeDependencies, "mapper-processor");
- putIfNonEmpty(mapperRuntimeDeps, runtimeDependencies, "mapper-runtime");
- addJavaVersion(runtimeDependencies);
- return runtimeDependencies;
- }
-
- private void putIfNonEmpty(
- Map moduleDependencies,
- Map> runtimeDependencies,
- String moduleName) {
- if (!moduleDependencies.isEmpty()) {
- runtimeDependencies.put(moduleName, moduleDependencies);
- }
- }
-
- @VisibleForTesting
- void addJavaVersion(Map> runtimeDependencies) {
- Package javaPackage = Runtime.class.getPackage();
- Map javaDependencies = new LinkedHashMap<>();
- javaDependencies.put(
- "version", toSameRuntimeAndCompileVersion(javaPackage.getImplementationVersion()));
- javaDependencies.put(
- "vendor", toSameRuntimeAndCompileVersion(javaPackage.getImplementationVendor()));
- javaDependencies.put(
- "title", toSameRuntimeAndCompileVersion(javaPackage.getImplementationTitle()));
- putIfNonEmpty(javaDependencies, runtimeDependencies, "java");
- }
-
- private RuntimeAndCompileTimeVersions toSameRuntimeAndCompileVersion(String version) {
- return new RuntimeAndCompileTimeVersions(version, version, false);
- }
-
- /**
- * Method is fetching dependencies from file. Lines in file should be in format:
- * com.organization:artifactId:jar:1.2.0 or com.organization:artifactId:jar:native:1.2.0
- *
- * For such file the output will be: Map
- * "com.organization:artifactId",{"runtimeVersion":"1.2.0", "compileVersion:"1.2.0", "optional":
- * false} Duplicates will be omitted. If there are two dependencies for the exactly the same
- * organizationId:artifactId it is not deterministic which version will be taken. In the case of
- * an error while opening file this method will fail silently returning an empty Map
- */
- @VisibleForTesting
- Map fetchDependenciesFromFile(InputStream inputStream) {
- Map dependencies = new LinkedHashMap<>();
- if (inputStream == null) {
- return dependencies;
- }
- try {
- List dependenciesFromFile = extractMavenDependenciesFromFile(inputStream);
- for (DependencyFromFile d : dependenciesFromFile) {
- dependencies.put(formatDependencyName(d), getRuntimeAndCompileVersion(d));
- }
- } catch (IOException e) {
- return dependencies;
- }
- return dependencies;
- }
-
- private RuntimeAndCompileTimeVersions getRuntimeAndCompileVersion(DependencyFromFile d) {
- URL url = propertiesUrlProvider.apply(d);
- if (url == null) {
- return new RuntimeAndCompileTimeVersions(
- UNVERIFIED_RUNTIME_VERSION, d.getVersion(), d.isOptional());
- }
- Properties properties = new Properties();
- try {
- properties.load(url.openStream());
- } catch (IOException e) {
- return new RuntimeAndCompileTimeVersions(
- UNVERIFIED_RUNTIME_VERSION, d.getVersion(), d.isOptional());
- }
- Object version = properties.get("version");
- if (version == null) {
- return new RuntimeAndCompileTimeVersions(
- UNVERIFIED_RUNTIME_VERSION, d.getVersion(), d.isOptional());
- } else {
- return new RuntimeAndCompileTimeVersions(version.toString(), d.getVersion(), d.isOptional());
- }
- }
-
- private String formatDependencyName(DependencyFromFile d) {
- return String.format("%s:%s", d.getGroupId(), d.getArtifactId());
- }
-
- private List extractMavenDependenciesFromFile(InputStream inputStream)
- throws IOException {
- List dependenciesFromFile = new ArrayList<>();
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
- for (String line; (line = reader.readLine()) != null; ) {
- if (lineWithDependencyInfo(line)) {
- dependenciesFromFile.add(extractDependencyFromLine(line.trim()));
- }
- }
- return dependenciesFromFile;
- }
-
- private DependencyFromFile extractDependencyFromLine(String line) {
- List split = DEPENDENCY_SPLITTER.splitToList(line);
- if (split.size() == 6) { // case for i.e.: com.github.jnr:jffi:jar:native:1.2.16:compile
- return new DependencyFromFile(
- split.get(0), split.get(1), split.get(4), checkIsOptional(split.get(5)));
- } else { // case for normal: org.ow2.asm:asm:jar:5.0.3:compile
- return new DependencyFromFile(
- split.get(0), split.get(1), split.get(3), checkIsOptional(split.get(4)));
- }
- }
-
- private boolean checkIsOptional(String scope) {
- return scope.contains("(optional)");
- }
-
- private boolean lineWithDependencyInfo(String line) {
- return (!line.equals(MAVEN_IGNORE_LINE) && !line.isEmpty());
- }
-
- private CPUS getCpuInfo() {
- int numberOfProcessors = Runtime.getRuntime().availableProcessors();
- String model = Native.getCpu();
- return new CPUS(numberOfProcessors, model);
- }
-
- private OS getOsInfo() {
- String osName = System.getProperty("os.name");
- String osVersion = System.getProperty("os.version");
- String osArch = System.getProperty("os.arch");
- return new OS(osName, osVersion, osArch);
- }
-
- static class DependencyFromFile {
- private final String groupId;
- private final String artifactId;
- private final String version;
- private final boolean optional;
-
- DependencyFromFile(String groupId, String artifactId, String version, boolean optional) {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.version = version;
- this.optional = optional;
- }
-
- String getGroupId() {
- return groupId;
- }
-
- String getArtifactId() {
- return artifactId;
- }
-
- String getVersion() {
- return version;
- }
-
- boolean isOptional() {
- return optional;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof DependencyFromFile)) {
- return false;
- }
- DependencyFromFile that = (DependencyFromFile) o;
- return optional == that.optional
- && Objects.equals(groupId, that.groupId)
- && Objects.equals(artifactId, that.artifactId)
- && Objects.equals(version, that.version);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(groupId, artifactId, version, optional);
- }
-
- @Override
- public String toString() {
- return "DependencyFromFile{"
- + "groupId='"
- + groupId
- + '\''
- + ", artifactId='"
- + artifactId
- + '\''
- + ", version='"
- + version
- + '\''
- + ", optional="
- + optional
- + '}';
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ReconnectionPolicyInfoFinder.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ReconnectionPolicyInfoFinder.java
deleted file mode 100644
index af8aff74035..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/ReconnectionPolicyInfoFinder.java
+++ /dev/null
@@ -1,49 +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.insights;
-
-import com.datastax.dse.driver.internal.core.insights.schema.ReconnectionPolicyInfo;
-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.ReconnectionPolicy;
-import com.datastax.oss.driver.internal.core.connection.ConstantReconnectionPolicy;
-import com.datastax.oss.driver.internal.core.connection.ExponentialReconnectionPolicy;
-import java.util.HashMap;
-import java.util.Map;
-
-class ReconnectionPolicyInfoFinder {
- ReconnectionPolicyInfo getReconnectionPolicyInfo(
- ReconnectionPolicy reconnectionPolicy, DriverExecutionProfile executionProfile) {
- Class extends ReconnectionPolicy> reconnectionPolicyClass = reconnectionPolicy.getClass();
- String type = reconnectionPolicyClass.getSimpleName();
- String namespace = PackageUtil.getNamespace(reconnectionPolicyClass);
- Map options = new HashMap<>();
- if (reconnectionPolicy instanceof ConstantReconnectionPolicy) {
- options.put(
- "delayMs",
- executionProfile.getDuration(DefaultDriverOption.RECONNECTION_BASE_DELAY).toMillis());
- } else if (reconnectionPolicy instanceof ExponentialReconnectionPolicy) {
- ExponentialReconnectionPolicy exponentialReconnectionPolicy =
- (ExponentialReconnectionPolicy) reconnectionPolicy;
- options.put("maxDelayMs", exponentialReconnectionPolicy.getMaxDelayMs());
- options.put("baseDelayMs", exponentialReconnectionPolicy.getBaseDelayMs());
- options.put("maxAttempts", exponentialReconnectionPolicy.getMaxAttempts());
- }
- return new ReconnectionPolicyInfo(type, options, namespace);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/configuration/InsightsConfiguration.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/configuration/InsightsConfiguration.java
deleted file mode 100644
index ac27bb76389..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/configuration/InsightsConfiguration.java
+++ /dev/null
@@ -1,45 +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.insights.configuration;
-
-import io.netty.util.concurrent.EventExecutor;
-
-public class InsightsConfiguration {
- private final boolean monitorReportingEnabled;
- private final long statusEventDelayMillis;
- private final EventExecutor executor;
-
- public InsightsConfiguration(
- boolean monitorReportingEnabled, long statusEventDelayMillis, EventExecutor executor) {
- this.monitorReportingEnabled = monitorReportingEnabled;
- this.statusEventDelayMillis = statusEventDelayMillis;
- this.executor = executor;
- }
-
- public boolean isMonitorReportingEnabled() {
- return monitorReportingEnabled;
- }
-
- public long getStatusEventDelayMillis() {
- return statusEventDelayMillis;
- }
-
- public EventExecutor getExecutor() {
- return executor;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/exceptions/InsightEventFormatException.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/exceptions/InsightEventFormatException.java
deleted file mode 100644
index cfce68971ef..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/exceptions/InsightEventFormatException.java
+++ /dev/null
@@ -1,25 +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.insights.exceptions;
-
-public class InsightEventFormatException extends RuntimeException {
-
- public InsightEventFormatException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/AuthProviderType.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/AuthProviderType.java
deleted file mode 100644
index 18aec53e899..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/AuthProviderType.java
+++ /dev/null
@@ -1,67 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Objects;
-
-public class AuthProviderType {
- @JsonProperty("type")
- private final String type;
-
- @JsonProperty("namespace")
- private final String namespace;
-
- @JsonCreator
- public AuthProviderType(
- @JsonProperty("type") String type, @JsonProperty("namespace") String namespace) {
- this.type = type;
- this.namespace = namespace;
- }
-
- public String getType() {
- return type;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof AuthProviderType)) {
- return false;
- }
- AuthProviderType that = (AuthProviderType) o;
- return Objects.equals(type, that.type) && Objects.equals(namespace, that.namespace);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, namespace);
- }
-
- @Override
- public String toString() {
- return "AuthProviderType{" + "type='" + type + '\'' + ", namespace='" + namespace + '\'' + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/Insight.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/Insight.java
deleted file mode 100644
index ca4e6455345..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/Insight.java
+++ /dev/null
@@ -1,52 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class Insight {
- @JsonProperty("metadata")
- private final InsightMetadata metadata;
-
- @JsonProperty("data")
- private final T insightData;
-
- @JsonCreator
- public Insight(@JsonProperty("metadata") InsightMetadata metadata, @JsonProperty("data") T data) {
- this.metadata = metadata;
- this.insightData = data;
- }
-
- public InsightMetadata getMetadata() {
- return metadata;
- }
-
- public T getInsightData() {
- return insightData;
- }
-
- @Override
- public String toString() {
- return "Insight{" + "metadata=" + metadata + ", insightData=" + insightData + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightMetadata.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightMetadata.java
deleted file mode 100644
index d7397d813aa..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightMetadata.java
+++ /dev/null
@@ -1,118 +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.insights.schema;
-
-import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
-import com.datastax.oss.driver.shaded.guava.common.base.Strings;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-public class InsightMetadata {
- @JsonProperty("name")
- private final String name;
-
- @JsonProperty("timestamp")
- private final long timestamp;
-
- @JsonProperty("tags")
- private final Map tags;
-
- @JsonProperty("insightType")
- private final InsightType insightType;
-
- @JsonProperty("insightMappingId")
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String insightMappingId;
-
- @JsonCreator
- public InsightMetadata(
- @JsonProperty("name") String name,
- @JsonProperty("timestamp") long timestamp,
- @JsonProperty("tags") Map tags,
- @JsonProperty("insightType") InsightType insightType,
- @JsonProperty("insightMappingId") String insightMappingId) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "name is required");
-
- this.name = name;
- this.timestamp = timestamp;
- this.tags = tags;
- this.insightType = insightType;
- this.insightMappingId = insightMappingId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof InsightMetadata)) {
- return false;
- }
- InsightMetadata that = (InsightMetadata) o;
- return Objects.equals(name, that.name)
- && timestamp == that.timestamp
- && Objects.equals(tags, that.tags)
- && insightType == that.insightType
- && Objects.equals(insightMappingId, that.insightMappingId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, timestamp, tags, insightType, insightMappingId);
- }
-
- @Override
- public String toString() {
- return "InsightMetadata{"
- + "name='"
- + name
- + '\''
- + ", timestamp="
- + timestamp
- + ", tags="
- + tags
- + ", insightType="
- + insightType
- + ", insightMappingId="
- + insightMappingId
- + '}';
- }
-
- public String getName() {
- return name;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public Map getTags() {
- return tags;
- }
-
- public InsightType getInsightType() {
- return insightType;
- }
-
- public String getInsightMappingId() {
- return insightMappingId;
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightType.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightType.java
deleted file mode 100644
index ae91e27d227..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightType.java
+++ /dev/null
@@ -1,28 +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.insights.schema;
-
-public enum InsightType {
- EVENT,
- GAUGE,
- COUNTER,
- HISTOGRAM,
- TIMER,
- METER,
- LOG;
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsPlatformInfo.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsPlatformInfo.java
deleted file mode 100644
index 231f082d785..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsPlatformInfo.java
+++ /dev/null
@@ -1,236 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-public class InsightsPlatformInfo {
- @JsonProperty("os")
- private final OS os;
-
- @JsonProperty("cpus")
- private CPUS cpus;
-
- /**
- * All dependencies in a map format grouped by the module: {"core" : {"com.datastax.driver:core":
- * {"runtimeVersion:" : "1.0.0", "compileVersion": "1.0.1"},...}}, "extras"" {...}
- */
- @JsonProperty("runtime")
- private Map> runtime;
-
- @JsonCreator
- public InsightsPlatformInfo(
- @JsonProperty("os") OS os,
- @JsonProperty("cpus") CPUS cpus,
- @JsonProperty("runtime") Map> runtime) {
- this.os = os;
- this.cpus = cpus;
- this.runtime = runtime;
- }
-
- public OS getOs() {
- return os;
- }
-
- public CPUS getCpus() {
- return cpus;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof InsightsPlatformInfo)) {
- return false;
- }
- InsightsPlatformInfo that = (InsightsPlatformInfo) o;
- return Objects.equals(os, that.os)
- && Objects.equals(cpus, that.cpus)
- && Objects.equals(runtime, that.runtime);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(os, cpus, runtime);
- }
-
- Map> getRuntime() {
- return runtime;
- }
-
- public static class OS {
- @JsonProperty("name")
- private final String name;
-
- @JsonProperty("version")
- private final String version;
-
- @JsonProperty("arch")
- private final String arch;
-
- @JsonCreator
- public OS(
- @JsonProperty("name") String name,
- @JsonProperty("version") String version,
- @JsonProperty("arch") String arch) {
- this.name = name;
- this.version = version;
- this.arch = arch;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getArch() {
- return arch;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof OS)) {
- return false;
- }
- OS os = (OS) o;
- return Objects.equals(name, os.name)
- && Objects.equals(version, os.version)
- && Objects.equals(arch, os.arch);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, version, arch);
- }
- }
-
- public static class CPUS {
- @JsonProperty("length")
- private final int length;
-
- @JsonProperty("model")
- private final String model;
-
- @JsonCreator
- public CPUS(@JsonProperty("length") int length, @JsonProperty("model") String model) {
- this.length = length;
- this.model = model;
- }
-
- public int getLength() {
- return length;
- }
-
- public String getModel() {
- return model;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof CPUS)) {
- return false;
- }
- CPUS cpus = (CPUS) o;
- return length == cpus.length && Objects.equals(model, cpus.model);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(length, model);
- }
- }
-
- public static class RuntimeAndCompileTimeVersions {
- @JsonProperty("runtimeVersion")
- private final String runtimeVersion;
-
- @JsonProperty("compileVersion")
- private final String compileVersion;
-
- @JsonProperty("optional")
- private final boolean optional;
-
- @JsonCreator
- public RuntimeAndCompileTimeVersions(
- @JsonProperty("runtimeVersion") String runtimeVersion,
- @JsonProperty("compileVersion") String compileVersion,
- @JsonProperty("optional") boolean optional) {
- this.runtimeVersion = runtimeVersion;
- this.compileVersion = compileVersion;
- this.optional = optional;
- }
-
- public String getRuntimeVersion() {
- return runtimeVersion;
- }
-
- public String getCompileVersion() {
- return compileVersion;
- }
-
- public boolean isOptional() {
- return optional;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof RuntimeAndCompileTimeVersions)) {
- return false;
- }
- RuntimeAndCompileTimeVersions that = (RuntimeAndCompileTimeVersions) o;
- return optional == that.optional
- && Objects.equals(runtimeVersion, that.runtimeVersion)
- && Objects.equals(compileVersion, that.compileVersion);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(runtimeVersion, compileVersion, optional);
- }
-
- @Override
- public String toString() {
- return "RuntimeAndCompileTimeVersions{"
- + "runtimeVersion='"
- + runtimeVersion
- + '\''
- + ", compileVersion='"
- + compileVersion
- + '\''
- + ", optional="
- + optional
- + '}';
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsStartupData.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsStartupData.java
deleted file mode 100644
index bddd3ef94b3..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsStartupData.java
+++ /dev/null
@@ -1,425 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class InsightsStartupData {
- @JsonProperty("clientId")
- private final String clientId;
-
- @JsonProperty("sessionId")
- private final String sessionId;
-
- @JsonProperty("applicationName")
- private final String applicationName;
-
- @JsonProperty("applicationVersion")
- private final String applicationVersion;
-
- @JsonProperty("contactPoints")
- private final Map> contactPoints;
-
- @JsonProperty("initialControlConnection")
- private final String initialControlConnection;
-
- @JsonProperty("protocolVersion")
- private final int protocolVersion;
-
- @JsonProperty("localAddress")
- private final String localAddress;
-
- @JsonProperty("executionProfiles")
- private final Map executionProfiles;
-
- @JsonProperty("poolSizeByHostDistance")
- private final PoolSizeByHostDistance poolSizeByHostDistance;
-
- @JsonProperty("heartbeatInterval")
- private final long heartbeatInterval;
-
- @JsonProperty("compression")
- private final String compression;
-
- @JsonProperty("reconnectionPolicy")
- private final ReconnectionPolicyInfo reconnectionPolicy;
-
- @JsonProperty("ssl")
- private final SSL ssl;
-
- @JsonProperty("authProvider")
- private final AuthProviderType authProvider;
-
- @JsonProperty("otherOptions")
- private final Map otherOptions;
-
- @JsonProperty("configAntiPatterns")
- private final Map configAntiPatterns;
-
- @JsonProperty("periodicStatusInterval")
- private final long periodicStatusInterval;
-
- @JsonProperty("platformInfo")
- private final InsightsPlatformInfo platformInfo;
-
- @JsonProperty("hostName")
- private final String hostName;
-
- @JsonProperty("driverName")
- private String driverName;
-
- @JsonProperty("applicationNameWasGenerated")
- private boolean applicationNameWasGenerated;
-
- @JsonProperty("driverVersion")
- private String driverVersion;
-
- @JsonProperty("dataCenters")
- private Set dataCenters;
-
- @JsonCreator
- private InsightsStartupData(
- @JsonProperty("clientId") String clientId,
- @JsonProperty("sessionId") String sessionId,
- @JsonProperty("applicationName") String applicationName,
- @JsonProperty("applicationVersion") String applicationVersion,
- @JsonProperty("contactPoints") Map> contactPoints,
- @JsonProperty("initialControlConnection") String initialControlConnection,
- @JsonProperty("protocolVersion") int protocolVersion,
- @JsonProperty("localAddress") String localAddress,
- @JsonProperty("executionProfiles") Map executionProfiles,
- @JsonProperty("poolSizeByHostDistance") PoolSizeByHostDistance poolSizeByHostDistance,
- @JsonProperty("heartbeatInterval") long heartbeatInterval,
- @JsonProperty("compression") String compression,
- @JsonProperty("reconnectionPolicy") ReconnectionPolicyInfo reconnectionPolicy,
- @JsonProperty("ssl") SSL ssl,
- @JsonProperty("authProvider") AuthProviderType authProvider,
- @JsonProperty("otherOptions") Map otherOptions,
- @JsonProperty("configAntiPatterns") Map configAntiPatterns,
- @JsonProperty("periodicStatusInterval") long periodicStatusInterval,
- @JsonProperty("platformInfo") InsightsPlatformInfo platformInfo,
- @JsonProperty("hostName") String hostName,
- @JsonProperty("driverName") String driverName,
- @JsonProperty("applicationNameWasGenerated") boolean applicationNameWasGenerated,
- @JsonProperty("driverVersion") String driverVersion,
- @JsonProperty("dataCenters") Set dataCenters) {
- this.clientId = clientId;
- this.sessionId = sessionId;
- this.applicationName = applicationName;
- this.applicationVersion = applicationVersion;
- this.contactPoints = contactPoints;
- this.initialControlConnection = initialControlConnection;
- this.protocolVersion = protocolVersion;
- this.localAddress = localAddress;
- this.executionProfiles = executionProfiles;
- this.poolSizeByHostDistance = poolSizeByHostDistance;
- this.heartbeatInterval = heartbeatInterval;
- this.compression = compression;
- this.reconnectionPolicy = reconnectionPolicy;
- this.ssl = ssl;
- this.authProvider = authProvider;
- this.otherOptions = otherOptions;
- this.configAntiPatterns = configAntiPatterns;
- this.periodicStatusInterval = periodicStatusInterval;
- this.platformInfo = platformInfo;
- this.hostName = hostName;
- this.driverName = driverName;
- this.applicationNameWasGenerated = applicationNameWasGenerated;
- this.driverVersion = driverVersion;
- this.dataCenters = dataCenters;
- }
-
- public String getClientId() {
- return clientId;
- }
-
- public String getSessionId() {
- return sessionId;
- }
-
- public String getApplicationName() {
- return applicationName;
- }
-
- public String getApplicationVersion() {
- return applicationVersion;
- }
-
- public Map> getContactPoints() {
- return contactPoints;
- }
-
- public String getInitialControlConnection() {
- return initialControlConnection;
- }
-
- public int getProtocolVersion() {
- return protocolVersion;
- }
-
- public String getLocalAddress() {
- return localAddress;
- }
-
- public Map getExecutionProfiles() {
- return executionProfiles;
- }
-
- public PoolSizeByHostDistance getPoolSizeByHostDistance() {
- return poolSizeByHostDistance;
- }
-
- public long getHeartbeatInterval() {
- return heartbeatInterval;
- }
-
- public String getCompression() {
- return compression;
- }
-
- public ReconnectionPolicyInfo getReconnectionPolicy() {
- return reconnectionPolicy;
- }
-
- public SSL getSsl() {
- return ssl;
- }
-
- public AuthProviderType getAuthProvider() {
- return authProvider;
- }
-
- public Map getOtherOptions() {
- return otherOptions;
- }
-
- public Map getConfigAntiPatterns() {
- return configAntiPatterns;
- }
-
- public long getPeriodicStatusInterval() {
- return periodicStatusInterval;
- }
-
- public InsightsPlatformInfo getPlatformInfo() {
- return platformInfo;
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public String getDriverName() {
- return driverName;
- }
-
- public boolean isApplicationNameWasGenerated() {
- return applicationNameWasGenerated;
- }
-
- public String getDriverVersion() {
- return driverVersion;
- }
-
- public Set getDataCenters() {
- return dataCenters;
- }
-
- public static InsightsStartupData.Builder builder() {
- return new InsightsStartupData.Builder();
- }
-
- public static class Builder {
- private String clientId;
- private String sessionId;
- private String applicationName;
- private String applicationVersion;
- private Map> contactPoints;
- private String initialControlConnection;
- private int protocolVersion;
- private String localAddress;
- private Map executionProfiles;
- private PoolSizeByHostDistance poolSizeByHostDistance;
- private long heartbeatInterval;
- private String compression;
- private ReconnectionPolicyInfo reconnectionPolicy;
- private SSL ssl;
- private AuthProviderType authProvider;
- private Map otherOptions;
- private Map configAntiPatterns;
- private long periodicStatusInterval;
- private InsightsPlatformInfo platformInfo;
- private String hostName;
- private String driverName;
- private String driverVersion;
- private boolean applicationNameWasGenerated;
- private Set dataCenters;
-
- public InsightsStartupData build() {
- return new InsightsStartupData(
- clientId,
- sessionId,
- applicationName,
- applicationVersion,
- contactPoints,
- initialControlConnection,
- protocolVersion,
- localAddress,
- executionProfiles,
- poolSizeByHostDistance,
- heartbeatInterval,
- compression,
- reconnectionPolicy,
- ssl,
- authProvider,
- otherOptions,
- configAntiPatterns,
- periodicStatusInterval,
- platformInfo,
- hostName,
- driverName,
- applicationNameWasGenerated,
- driverVersion,
- dataCenters);
- }
-
- public Builder withClientId(String clientId) {
- this.clientId = clientId;
- return this;
- }
-
- public Builder withSessionId(String id) {
- this.sessionId = id;
- return this;
- }
-
- public Builder withApplicationName(String applicationName) {
- this.applicationName = applicationName;
- return this;
- }
-
- public Builder withApplicationVersion(String applicationVersion) {
- this.applicationVersion = applicationVersion;
- return this;
- }
-
- public Builder withContactPoints(Map> contactPoints) {
- this.contactPoints = contactPoints;
- return this;
- }
-
- public Builder withInitialControlConnection(String inetSocketAddress) {
- this.initialControlConnection = inetSocketAddress;
- return this;
- }
-
- public Builder withProtocolVersion(int protocolVersion) {
- this.protocolVersion = protocolVersion;
- return this;
- }
-
- public Builder withLocalAddress(String localAddress) {
- this.localAddress = localAddress;
- return this;
- }
-
- public Builder withExecutionProfiles(Map executionProfiles) {
- this.executionProfiles = executionProfiles;
- return this;
- }
-
- public Builder withPoolSizeByHostDistance(PoolSizeByHostDistance poolSizeByHostDistance) {
- this.poolSizeByHostDistance = poolSizeByHostDistance;
- return this;
- }
-
- public Builder withHeartbeatInterval(long heartbeatInterval) {
- this.heartbeatInterval = heartbeatInterval;
- return this;
- }
-
- public Builder withCompression(String compression) {
- this.compression = compression;
- return this;
- }
-
- public Builder withReconnectionPolicy(ReconnectionPolicyInfo reconnectionPolicy) {
- this.reconnectionPolicy = reconnectionPolicy;
- return this;
- }
-
- public Builder withSsl(SSL ssl) {
- this.ssl = ssl;
- return this;
- }
-
- public Builder withAuthProvider(AuthProviderType authProvider) {
- this.authProvider = authProvider;
- return this;
- }
-
- public Builder withOtherOptions(Map otherOptions) {
- this.otherOptions = otherOptions;
- return this;
- }
-
- public Builder withConfigAntiPatterns(Map configAntiPatterns) {
- this.configAntiPatterns = configAntiPatterns;
- return this;
- }
-
- public Builder withPeriodicStatusInterval(long periodicStatusInterval) {
- this.periodicStatusInterval = periodicStatusInterval;
- return this;
- }
-
- public Builder withPlatformInfo(InsightsPlatformInfo insightsPlatformInfo) {
- this.platformInfo = insightsPlatformInfo;
- return this;
- }
-
- public Builder withHostName(String hostName) {
- this.hostName = hostName;
- return this;
- }
-
- public Builder withDriverName(String driverName) {
- this.driverName = driverName;
- return this;
- }
-
- public Builder withDriverVersion(String driverVersion) {
- this.driverVersion = driverVersion;
- return this;
- }
-
- public Builder withApplicationNameWasGenerated(boolean applicationNameWasGenerated) {
- this.applicationNameWasGenerated = applicationNameWasGenerated;
- return this;
- }
-
- public Builder withDataCenters(Set dataCenters) {
- this.dataCenters = dataCenters;
- return this;
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsStatusData.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsStatusData.java
deleted file mode 100644
index 6f5a135f7c4..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/InsightsStatusData.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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-public class InsightsStatusData {
- @JsonProperty("clientId")
- private final String clientId;
-
- @JsonProperty("sessionId")
- private final String sessionId;
-
- @JsonProperty("controlConnection")
- private final String controlConnection;
-
- @JsonProperty("connectedNodes")
- private final Map connectedNodes;
-
- @JsonCreator
- private InsightsStatusData(
- @JsonProperty("clientId") String clientId,
- @JsonProperty("sessionId") String sessionId,
- @JsonProperty("controlConnection") String controlConnection,
- @JsonProperty("connectedNodes") Map connectedNodes) {
- this.clientId = clientId;
- this.sessionId = sessionId;
- this.controlConnection = controlConnection;
- this.connectedNodes = connectedNodes;
- }
-
- public String getClientId() {
- return clientId;
- }
-
- public String getSessionId() {
- return sessionId;
- }
-
- public String getControlConnection() {
- return controlConnection;
- }
-
- public Map getConnectedNodes() {
- return connectedNodes;
- }
-
- @Override
- public String toString() {
- return "InsightsStatusData{"
- + "clientId='"
- + clientId
- + '\''
- + ", sessionId='"
- + sessionId
- + '\''
- + ", controlConnection="
- + controlConnection
- + ", connectedNodes="
- + connectedNodes
- + '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof InsightsStatusData)) {
- return false;
- }
- InsightsStatusData that = (InsightsStatusData) o;
- return Objects.equals(clientId, that.clientId)
- && Objects.equals(sessionId, that.sessionId)
- && Objects.equals(controlConnection, that.controlConnection)
- && Objects.equals(connectedNodes, that.connectedNodes);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(clientId, sessionId, controlConnection, connectedNodes);
- }
-
- public static InsightsStatusData.Builder builder() {
- return new InsightsStatusData.Builder();
- }
-
- public static class Builder {
- private String clientId;
- private String sessionId;
- private String controlConnection;
- private Map connectedNodes;
-
- public Builder withClientId(String clientId) {
- this.clientId = clientId;
- return this;
- }
-
- public Builder withSessionId(String id) {
- this.sessionId = id;
- return this;
- }
-
- public Builder withControlConnection(String controlConnection) {
- this.controlConnection = controlConnection;
- return this;
- }
-
- public Builder withConnectedNodes(Map connectedNodes) {
- this.connectedNodes = connectedNodes;
- return this;
- }
-
- public InsightsStatusData build() {
- return new InsightsStatusData(clientId, sessionId, controlConnection, connectedNodes);
- }
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/LoadBalancingInfo.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/LoadBalancingInfo.java
deleted file mode 100644
index 594583e3f28..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/LoadBalancingInfo.java
+++ /dev/null
@@ -1,89 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-public class LoadBalancingInfo {
- @JsonProperty("type")
- private final String type;
-
- @JsonProperty("options")
- private final Map options;
-
- @JsonProperty("namespace")
- private final String namespace;
-
- @JsonCreator
- public LoadBalancingInfo(
- @JsonProperty("type") String type,
- @JsonProperty("options") Map options,
- @JsonProperty("namespace") String namespace) {
- this.type = type;
- this.options = options;
- this.namespace = namespace;
- }
-
- public String getType() {
- return type;
- }
-
- public Map getOptions() {
- return options;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof LoadBalancingInfo)) {
- return false;
- }
- LoadBalancingInfo that = (LoadBalancingInfo) o;
- return Objects.equals(type, that.type)
- && Objects.equals(options, that.options)
- && Objects.equals(namespace, that.namespace);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, options, namespace);
- }
-
- @Override
- public String toString() {
- return "LoadBalancingInfo{"
- + "type='"
- + type
- + '\''
- + ", options="
- + options
- + ", namespace='"
- + namespace
- + '\''
- + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/PoolSizeByHostDistance.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/PoolSizeByHostDistance.java
deleted file mode 100644
index 07f76a18d40..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/PoolSizeByHostDistance.java
+++ /dev/null
@@ -1,85 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Objects;
-
-public class PoolSizeByHostDistance {
- @JsonProperty("local")
- private final int local;
-
- @JsonProperty("remote")
- private final int remote;
-
- @JsonProperty("ignored")
- private final int ignored;
-
- @JsonCreator
- public PoolSizeByHostDistance(
- @JsonProperty("local") int local,
- @JsonProperty("remote") int remote,
- @JsonProperty("ignored") int ignored) {
-
- this.local = local;
- this.remote = remote;
- this.ignored = ignored;
- }
-
- public int getLocal() {
- return local;
- }
-
- public int getRemote() {
- return remote;
- }
-
- public int getIgnored() {
- return ignored;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof PoolSizeByHostDistance)) {
- return false;
- }
- PoolSizeByHostDistance that = (PoolSizeByHostDistance) o;
- return local == that.local && remote == that.remote && ignored == that.ignored;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(local, remote, ignored);
- }
-
- @Override
- public String toString() {
- return "PoolSizeByHostDistance{"
- + "local="
- + local
- + ", remote="
- + remote
- + ", ignored="
- + ignored
- + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/ReconnectionPolicyInfo.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/ReconnectionPolicyInfo.java
deleted file mode 100644
index 463c23a4325..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/ReconnectionPolicyInfo.java
+++ /dev/null
@@ -1,90 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-public class ReconnectionPolicyInfo {
- @JsonProperty("type")
- private final String type;
-
- @JsonProperty("options")
- private final Map options;
-
- @JsonProperty("namespace")
- private final String namespace;
-
- @JsonCreator
- public ReconnectionPolicyInfo(
- @JsonProperty("type") String type,
- @JsonProperty("options") Map options,
- @JsonProperty("namespace") String namespace) {
-
- this.type = type;
- this.options = options;
- this.namespace = namespace;
- }
-
- public String getType() {
- return type;
- }
-
- public Map getOptions() {
- return options;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof ReconnectionPolicyInfo)) {
- return false;
- }
- ReconnectionPolicyInfo that = (ReconnectionPolicyInfo) o;
- return Objects.equals(type, that.type)
- && Objects.equals(options, that.options)
- && Objects.equals(namespace, that.namespace);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, options, namespace);
- }
-
- @Override
- public String toString() {
- return "ReconnectionPolicyInfo{"
- + "type='"
- + type
- + '\''
- + ", options="
- + options
- + ", namespace='"
- + namespace
- + '\''
- + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SSL.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SSL.java
deleted file mode 100644
index debcd85c025..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SSL.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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Objects;
-
-public class SSL {
- @JsonProperty("enabled")
- private final boolean enabled;
-
- @JsonProperty("certValidation")
- private final boolean certValidation;
-
- @JsonCreator
- public SSL(
- @JsonProperty("enabled") boolean enabled,
- @JsonProperty("certValidation") boolean certValidation) {
- this.enabled = enabled;
- this.certValidation = certValidation;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public boolean isCertValidation() {
- return certValidation;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof SSL)) {
- return false;
- }
- SSL that = (SSL) o;
- return enabled == that.enabled && certValidation == that.certValidation;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(enabled, certValidation);
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SessionStateForNode.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SessionStateForNode.java
deleted file mode 100644
index 8b50e5b2313..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SessionStateForNode.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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Objects;
-
-public class SessionStateForNode {
- @JsonProperty("connections")
- private final Integer connections;
-
- @JsonProperty("inFlightQueries")
- private final Integer inFlightQueries;
-
- @JsonCreator
- public SessionStateForNode(
- @JsonProperty("connections") Integer connections,
- @JsonProperty("inFlightQueries") Integer inFlightQueries) {
- this.connections = connections;
- this.inFlightQueries = inFlightQueries;
- }
-
- public Integer getConnections() {
- return connections;
- }
-
- public Integer getInFlightQueries() {
- return inFlightQueries;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof SessionStateForNode)) {
- return false;
- }
- SessionStateForNode that = (SessionStateForNode) o;
- return Objects.equals(connections, that.connections)
- && Objects.equals(inFlightQueries, that.inFlightQueries);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connections, inFlightQueries);
- }
-
- @Override
- public String toString() {
- return "SessionStateForNode{"
- + "connections="
- + connections
- + ", inFlightQueries="
- + inFlightQueries
- + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SpecificExecutionProfile.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SpecificExecutionProfile.java
deleted file mode 100644
index 58652fdf885..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SpecificExecutionProfile.java
+++ /dev/null
@@ -1,133 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class SpecificExecutionProfile {
- @JsonProperty("readTimeout")
- private final Integer readTimeout;
-
- @JsonProperty("loadBalancing")
- private final LoadBalancingInfo loadBalancing;
-
- @JsonProperty("speculativeExecution")
- private SpeculativeExecutionInfo speculativeExecution;
-
- @JsonProperty("consistency")
- private final String consistency;
-
- @JsonProperty("serialConsistency")
- private final String serialConsistency;
-
- @JsonProperty("graphOptions")
- private Map graphOptions;
-
- @JsonCreator
- public SpecificExecutionProfile(
- @JsonProperty("readTimeout") Integer readTimeoutMillis,
- @JsonProperty("loadBalancing") LoadBalancingInfo loadBalancing,
- @JsonProperty("speculativeExecution") SpeculativeExecutionInfo speculativeExecutionInfo,
- @JsonProperty("consistency") String consistency,
- @JsonProperty("serialConsistency") String serialConsistency,
- @JsonProperty("graphOptions") Map graphOptions) {
- readTimeout = readTimeoutMillis;
- this.loadBalancing = loadBalancing;
- this.speculativeExecution = speculativeExecutionInfo;
- this.consistency = consistency;
- this.serialConsistency = serialConsistency;
- this.graphOptions = graphOptions;
- }
-
- public Integer getReadTimeout() {
- return readTimeout;
- }
-
- public LoadBalancingInfo getLoadBalancing() {
- return loadBalancing;
- }
-
- public SpeculativeExecutionInfo getSpeculativeExecution() {
- return speculativeExecution;
- }
-
- public String getConsistency() {
- return consistency;
- }
-
- public String getSerialConsistency() {
- return serialConsistency;
- }
-
- public Map getGraphOptions() {
- return graphOptions;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof SpecificExecutionProfile)) {
- return false;
- }
- SpecificExecutionProfile that = (SpecificExecutionProfile) o;
- return Objects.equals(readTimeout, that.readTimeout)
- && Objects.equals(loadBalancing, that.loadBalancing)
- && Objects.equals(speculativeExecution, that.speculativeExecution)
- && Objects.equals(consistency, that.consistency)
- && Objects.equals(serialConsistency, that.serialConsistency)
- && Objects.equals(graphOptions, that.graphOptions);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- readTimeout,
- loadBalancing,
- speculativeExecution,
- consistency,
- serialConsistency,
- graphOptions);
- }
-
- @Override
- public String toString() {
- return "SpecificExecutionProfile{"
- + "readTimeout="
- + readTimeout
- + ", loadBalancing="
- + loadBalancing
- + ", speculativeExecution="
- + speculativeExecution
- + ", consistency='"
- + consistency
- + '\''
- + ", serialConsistency='"
- + serialConsistency
- + '\''
- + ", graphOptions="
- + graphOptions
- + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SpeculativeExecutionInfo.java b/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SpeculativeExecutionInfo.java
deleted file mode 100644
index 779a4ed9e51..00000000000
--- a/core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/SpeculativeExecutionInfo.java
+++ /dev/null
@@ -1,89 +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.insights.schema;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Map;
-import java.util.Objects;
-
-public class SpeculativeExecutionInfo {
- @JsonProperty("type")
- private final String type;
-
- @JsonProperty("options")
- private final Map options;
-
- @JsonProperty("namespace")
- private String namespace;
-
- @JsonCreator
- public SpeculativeExecutionInfo(
- @JsonProperty("type") String type,
- @JsonProperty("options") Map options,
- @JsonProperty("namespace") String namespace) {
- this.type = type;
- this.options = options;
- this.namespace = namespace;
- }
-
- public String getType() {
- return type;
- }
-
- public Map getOptions() {
- return options;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof SpeculativeExecutionInfo)) {
- return false;
- }
- SpeculativeExecutionInfo that = (SpeculativeExecutionInfo) o;
- return Objects.equals(type, that.type)
- && Objects.equals(options, that.options)
- && Objects.equals(namespace, that.namespace);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, options, namespace);
- }
-
- @Override
- public String toString() {
- return "SpeculativeExecutionInfo{"
- + "type='"
- + type
- + '\''
- + ", options="
- + options
- + ", namespace='"
- + namespace
- + '\''
- + '}';
- }
-}
diff --git a/core/src/main/java/com/datastax/oss/driver/api/core/config/OptionsMap.java b/core/src/main/java/com/datastax/oss/driver/api/core/config/OptionsMap.java
index c1a428b3524..13ae9263ad5 100644
--- a/core/src/main/java/com/datastax/oss/driver/api/core/config/OptionsMap.java
+++ b/core/src/main/java/com/datastax/oss/driver/api/core/config/OptionsMap.java
@@ -245,6 +245,7 @@ private void readObject(ObjectInputStream stream) throws InvalidObjectException
throw new InvalidObjectException("Proxy required");
}
+ @SuppressWarnings("deprecation")
protected static void fillWithDriverDefaults(OptionsMap map) {
Duration initQueryTimeout = Duration.ofSeconds(5);
Duration requestTimeout = Duration.ofSeconds(2);
@@ -314,7 +315,7 @@ protected static void fillWithDriverDefaults(OptionsMap map) {
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, continuousMaxEnqueuedPages);
map.put(TypedDriverOption.CONTINUOUS_PAGING_TIMEOUT_FIRST_PAGE, Duration.ofSeconds(2));
map.put(TypedDriverOption.CONTINUOUS_PAGING_TIMEOUT_OTHER_PAGES, Duration.ofSeconds(1));
- map.put(TypedDriverOption.MONITOR_REPORTING_ENABLED, true);
+ map.put(TypedDriverOption.MONITOR_REPORTING_ENABLED, false);
map.put(TypedDriverOption.METRICS_SESSION_ENABLED, Collections.emptyList());
map.put(TypedDriverOption.METRICS_SESSION_CQL_REQUESTS_HIGHEST, Duration.ofSeconds(3));
map.put(TypedDriverOption.METRICS_SESSION_CQL_REQUESTS_LOWEST, Duration.ofMillis(1));
diff --git a/core/src/main/java/com/datastax/oss/driver/api/core/config/TypedDriverOption.java b/core/src/main/java/com/datastax/oss/driver/api/core/config/TypedDriverOption.java
index af93e734ef1..9f5e57f39a6 100644
--- a/core/src/main/java/com/datastax/oss/driver/api/core/config/TypedDriverOption.java
+++ b/core/src/main/java/com/datastax/oss/driver/api/core/config/TypedDriverOption.java
@@ -817,7 +817,13 @@ public String toString() {
/** How long the driver waits for a graph request to complete. */
public static final TypedDriverOption GRAPH_TIMEOUT =
new TypedDriverOption<>(DseDriverOption.GRAPH_TIMEOUT, GenericType.DURATION);
- /** Whether to send events for Insights monitoring. */
+ /**
+ * Legacy no-op option that controlled DataStax Insights monitoring.
+ *
+ * @deprecated DataStax Insights monitoring is no longer supported; there is no replacement. This
+ * constant is retained for source and binary compatibility.
+ */
+ @Deprecated
public static final TypedDriverOption MONITOR_REPORTING_ENABLED =
new TypedDriverOption<>(DseDriverOption.MONITOR_REPORTING_ENABLED, GenericType.BOOLEAN);
/** Whether to enable paging for Graph queries. */
diff --git a/core/src/main/java/com/datastax/oss/driver/api/core/session/SessionBuilder.java b/core/src/main/java/com/datastax/oss/driver/api/core/session/SessionBuilder.java
index 8375f0ef30b..041b00b95ef 100644
--- a/core/src/main/java/com/datastax/oss/driver/api/core/session/SessionBuilder.java
+++ b/core/src/main/java/com/datastax/oss/driver/api/core/session/SessionBuilder.java
@@ -790,9 +790,8 @@ public SelfT withClientRoutesConfig(@Nullable ClientRoutesConfig clientRoutesCon
* A unique identifier for the created session.
*
* It will be sent in the {@code STARTUP} protocol message, under the key {@code CLIENT_ID},
- * for each new connection established by the driver. Currently, this information is used by
- * Insights monitoring (if the target cluster does not support Insights, the entry will be ignored
- * by the server).
+ * for each new connection established by the driver. Servers that do not recognize this option
+ * ignore it.
*
*
If you don't call this method, the driver will generate an identifier with {@link
* Uuids#random()}.
@@ -807,9 +806,8 @@ public SelfT withClientId(@Nullable UUID clientId) {
* The name of the application using the created session.
*
*
It will be sent in the {@code STARTUP} protocol message, under the key {@code
- * APPLICATION_NAME}, for each new connection established by the driver. Currently, this
- * information is used by Insights monitoring (if the target cluster does not support Insights,
- * the entry will be ignored by the server).
+ * APPLICATION_NAME}, for each new connection established by the driver. Servers that do not
+ * recognize this option ignore it.
*
*
This can also be defined in the driver configuration with the option {@code
* basic.application.name}; if you specify both, this method takes precedence and the
@@ -826,9 +824,8 @@ public SelfT withApplicationName(@Nullable String applicationName) {
* The version of the application using the created session.
*
*
It will be sent in the {@code STARTUP} protocol message, under the key {@code
- * APPLICATION_VERSION}, for each new connection established by the driver. Currently, this
- * information is used by Insights monitoring (if the target cluster does not support Insights,
- * the entry will be ignored by the server).
+ * APPLICATION_VERSION}, for each new connection established by the driver. Servers that do not
+ * recognize this option ignore it.
*
*
This can also be defined in the driver configuration with the option {@code
* basic.application.version}; if you specify both, this method takes precedence and the
diff --git a/core/src/main/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContext.java b/core/src/main/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContext.java
index e6323b6b84c..71bbbf880a4 100644
--- a/core/src/main/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContext.java
+++ b/core/src/main/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContext.java
@@ -20,7 +20,6 @@
import static com.datastax.oss.driver.internal.core.util.Dependency.JACKSON;
import com.datastax.dse.driver.api.core.config.DseDriverOption;
-import com.datastax.dse.driver.internal.core.InsightsClientLifecycleListener;
import com.datastax.dse.driver.internal.core.type.codec.DseTypeCodecsRegistrar;
import com.datastax.dse.protocol.internal.DseProtocolV1ClientCodecs;
import com.datastax.dse.protocol.internal.DseProtocolV2ClientCodecs;
@@ -98,6 +97,7 @@
import com.datastax.oss.driver.internal.core.tracker.RequestLogFormatter;
import com.datastax.oss.driver.internal.core.type.codec.registry.DefaultCodecRegistry;
import com.datastax.oss.driver.internal.core.util.DefaultDependencyChecker;
+import com.datastax.oss.driver.internal.core.util.Loggers;
import com.datastax.oss.driver.internal.core.util.Reflection;
import com.datastax.oss.driver.internal.core.util.concurrent.CycleDetector;
import com.datastax.oss.driver.internal.core.util.concurrent.LazyReference;
@@ -262,9 +262,6 @@ public class DefaultDriverContext implements InternalDriverContext {
private final String startupApplicationName;
private final String startupApplicationVersion;
private final Object metricRegistry;
- // A stack trace captured in the constructor. Used to extract information about the client
- // application.
- private final StackTraceElement[] initStackTrace;
public DefaultDriverContext(
DriverConfigLoader configLoader, ProgrammaticArguments programmaticArguments) {
@@ -276,6 +273,25 @@ public DefaultDriverContext(
} else {
this.sessionName = "s" + SESSION_NAME_COUNTER.getAndIncrement();
}
+ try {
+ @SuppressWarnings("deprecation")
+ boolean insightsMonitoringRequested =
+ defaultProfile.getBoolean(DseDriverOption.MONITOR_REPORTING_ENABLED, false);
+ if (insightsMonitoringRequested) {
+ LOG.warn(
+ "[{}] Configuration option {} is deprecated and ignored; "
+ + "DataStax Insights monitoring is no longer supported",
+ sessionName,
+ DseDriverOption.MONITOR_REPORTING_ENABLED.getPath());
+ }
+ } catch (RuntimeException e) {
+ Loggers.warnWithException(
+ LOG,
+ "[{}] Could not read deprecated configuration option {}; it will be ignored",
+ sessionName,
+ DseDriverOption.MONITOR_REPORTING_ENABLED.getPath(),
+ e);
+ }
this.localDatacentersFromBuilder = programmaticArguments.getLocalDatacenters();
this.codecRegistry = buildCodecRegistry(programmaticArguments);
this.nodeStateListenerFromBuilder = programmaticArguments.getNodeStateListener();
@@ -320,14 +336,6 @@ public DefaultDriverContext(
this.startupClientId = programmaticArguments.getStartupClientId();
this.startupApplicationName = programmaticArguments.getStartupApplicationName();
this.startupApplicationVersion = programmaticArguments.getStartupApplicationVersion();
- StackTraceElement[] stackTrace;
- try {
- stackTrace = Thread.currentThread().getStackTrace();
- } catch (Exception ex) {
- // ignore and use empty
- stackTrace = new StackTraceElement[] {};
- }
- this.initStackTrace = stackTrace;
this.metricRegistry = programmaticArguments.getMetricRegistry();
}
@@ -395,9 +403,8 @@ protected DriverConfigReporter buildDriverConfigReporter() {
if (DefaultDependencyChecker.isPresent(JACKSON)) {
return new DefaultDriverConfigReporter(this);
}
- // Logged unconditionally, unlike the Insights equivalent in #buildLifecycleListeners: reporting
- // ships enabled, so someone who trimmed Jackson never opted out of it and would otherwise have
- // no signal that it is off.
+ // Reporting ships enabled, so someone who trimmed Jackson never opted out of it and would
+ // otherwise have no signal that it is off.
LOG.info(
"Could not initialize driver configuration reporting; "
+ "this is normal if Jackson was explicitly excluded from classpath");
@@ -960,16 +967,7 @@ protected Optional buildAuthProvider(AuthProvider authProviderFrom
}
protected List buildLifecycleListeners() {
- if (DefaultDependencyChecker.isPresent(JACKSON)) {
- return Collections.singletonList(new InsightsClientLifecycleListener(this, initStackTrace));
- } else {
- if (config.getDefaultProfile().getBoolean(DseDriverOption.MONITOR_REPORTING_ENABLED)) {
- LOG.info(
- "Could not initialize Insights monitoring; "
- + "this is normal if Jackson was explicitly excluded from classpath");
- }
- return Collections.emptyList();
- }
+ return Collections.emptyList();
}
@NonNull
diff --git a/core/src/main/java/com/datastax/oss/driver/internal/core/context/InternalDriverContext.java b/core/src/main/java/com/datastax/oss/driver/internal/core/context/InternalDriverContext.java
index 87933b7385e..054b487239b 100644
--- a/core/src/main/java/com/datastax/oss/driver/internal/core/context/InternalDriverContext.java
+++ b/core/src/main/java/com/datastax/oss/driver/internal/core/context/InternalDriverContext.java
@@ -187,8 +187,7 @@ public interface InternalDriverContext extends DriverContext {
* A list of additional components to notify of session lifecycle events.
*
* For historical reasons, this method has a default implementation that returns an empty list.
- * The built-in {@link DefaultDriverContext} overrides it to plug in the Insights monitoring
- * listener. Custom driver extensions might override this method to add their own components.
+ * Custom driver extensions might override this method to add their own components.
*
*
Note that the driver assumes that the returned list is constant; there is no way to add
* listeners dynamically.
diff --git a/core/src/main/java/com/datastax/oss/driver/internal/core/context/NoopDriverConfigReporter.java b/core/src/main/java/com/datastax/oss/driver/internal/core/context/NoopDriverConfigReporter.java
index 213c3657585..cd95240c171 100644
--- a/core/src/main/java/com/datastax/oss/driver/internal/core/context/NoopDriverConfigReporter.java
+++ b/core/src/main/java/com/datastax/oss/driver/internal/core/context/NoopDriverConfigReporter.java
@@ -27,8 +27,7 @@
*
Today that means Jackson is absent from the classpath: the driver declares it as a required
* dependency but documents that it can be excluded (see {@code manual/core/integration}), and
* {@link DefaultDriverConfigReporter} serializes the report with it. Substituting this
- * implementation keeps that exclusion working, the same way {@code
- * DefaultDriverContext#buildLifecycleListeners()} skips Insights monitoring.
+ * implementation keeps that exclusion working.
*
*
Deliberately free of any reference to Jackson, including in the signatures it inherits — a
* single one would make loading this class fail for exactly the deployments it exists to
diff --git a/core/src/main/java/com/datastax/oss/driver/internal/core/context/StartupOptionsBuilder.java b/core/src/main/java/com/datastax/oss/driver/internal/core/context/StartupOptionsBuilder.java
index dd3a0307a79..f85fd600f15 100644
--- a/core/src/main/java/com/datastax/oss/driver/internal/core/context/StartupOptionsBuilder.java
+++ b/core/src/main/java/com/datastax/oss/driver/internal/core/context/StartupOptionsBuilder.java
@@ -115,7 +115,7 @@ public Map build() {
builder.put(DRIVER_NAME_KEY, getDriverName()).put(DRIVER_VERSION_KEY, getDriverVersion());
// Identifier of this session, sent on every connection so the server can group them. Not
- // derived from the (user-settable, Insights-oriented) CLIENT_ID below, so that it is guaranteed
+ // derived from the user-settable CLIENT_ID below, so that it is guaranteed
// unique per session as the grouping key requires. Generated lazily here rather than eagerly in
// a field initializer, mirroring clientId; DefaultDriverContext builds the startup options
// exactly once per session (LazyReference), which is what makes the value stable across all of
@@ -125,7 +125,7 @@ public Map build() {
}
builder.put(SESSION_ID_KEY, sessionId.toString());
- // Add Insights entries, falling back to generation / config if no programmatic values provided:
+ // Add client and application metadata, falling back to configuration when needed:
if (clientId == null) {
clientId = Uuids.random();
}
diff --git a/core/src/main/resources/reference.conf b/core/src/main/resources/reference.conf
index 590784b70c5..852ddc02402 100644
--- a/core/src/main/resources/reference.conf
+++ b/core/src/main/resources/reference.conf
@@ -272,14 +272,14 @@ datastax-java-driver {
// secure-connect-bundle = /location/of/secure/connect/bundle
}
- # DataStax Insights monitoring.
+ # Application metadata sent in the STARTUP message.
basic.application {
# The name of the application using the session.
#
# It will be sent in the STARTUP protocol message for each new connection established by the
# driver.
#
- # This can also be defined programmatically with DseSessionBuilder.withApplicationName(). If you
+ # This can also be defined programmatically with SessionBuilder.withApplicationName(). If you
# specify both, the programmatic value takes precedence and this option is ignored.
#
# Required: no
@@ -292,7 +292,7 @@ datastax-java-driver {
# It will be sent in the STARTUP protocol message for each new connection established by the
# driver.
#
- # This can also be defined programmatically with DseSessionBuilder.withApplicationVersion(). If
+ # This can also be defined programmatically with SessionBuilder.withApplicationVersion(). If
# you specify both, the programmatic value takes precedence and this option is ignored.
#
# Required: no
@@ -1555,16 +1555,16 @@ datastax-java-driver {
}
}
- # DataStax Insights
+ # Legacy DataStax Insights monitoring option.
+ #
+ # Insights monitoring has been removed. This option is retained for configuration compatibility
+ # and has no effect. Setting it to true causes the driver to log a warning when the session is
+ # created.
advanced.monitor-reporting {
- # Whether to send monitoring events.
- #
- # The default is true.
- #
- # Required: no (defaults to true)
+ # Required: no (defaults to false)
# Modifiable at runtime: no
# Overridable in a profile: no
- enabled = true
+ enabled = false
}
advanced.metrics {
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/DependencyCheckTest.java b/core/src/test/java/com/datastax/dse/driver/internal/DependencyCheckTest.java
deleted file mode 100644
index d001f791e82..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/DependencyCheckTest.java
+++ /dev/null
@@ -1,38 +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;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-public class DependencyCheckTest extends DependencyCheckTestBase {
-
- @Override
- protected Path getDepsTxtPath() {
- return Paths.get(
- getBaseResourcePathString(),
- "target",
- "classes",
- "com",
- "datastax",
- "dse",
- "driver",
- "internal",
- "deps.txt");
- }
-}
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/DependencyCheckTestBase.java b/core/src/test/java/com/datastax/dse/driver/internal/DependencyCheckTestBase.java
deleted file mode 100644
index f2ce5513d65..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/DependencyCheckTestBase.java
+++ /dev/null
@@ -1,55 +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;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.Properties;
-import org.junit.Test;
-
-public abstract class DependencyCheckTestBase {
-
- private String baseResourcePath;
-
- protected DependencyCheckTestBase() {
- Properties projectProperties = new Properties();
- try (InputStream is = this.getClass().getResourceAsStream("/project.properties")) {
- projectProperties.load(is);
- baseResourcePath = projectProperties.getProperty("project.basedir");
- } catch (IOException ioe) {
- throw new AssertionError(
- "Error retrieving \"project.basedir\" value from \"/project.properties\". Please check test resources in this project.",
- ioe);
- }
- assert baseResourcePath != null;
- }
-
- @Test
- public void should_generate_deps_txt() {
- assertThat(getDepsTxtPath()).exists();
- }
-
- protected final String getBaseResourcePathString() {
- return baseResourcePath;
- }
-
- protected abstract Path getDepsTxtPath();
-}
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/AddressFormatterTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/AddressFormatterTest.java
deleted file mode 100644
index 85af9b5691b..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/AddressFormatterTest.java
+++ /dev/null
@@ -1,53 +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.insights;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.tngtech.java.junit.dataprovider.DataProvider;
-import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(DataProviderRunner.class)
-public class AddressFormatterTest {
-
- @Test
- @UseDataProvider("addressesProvider")
- public void should_format_addresses(Object address, String expected) {
- // when
- String result = AddressFormatter.nullSafeToString(address);
-
- // then
- assertThat(result).isEqualTo(expected);
- }
-
- @DataProvider
- public static Object[][] addressesProvider() throws UnknownHostException {
- return new Object[][] {
- {new InetSocketAddress(8888), "0.0.0.0:8888"},
- {new InetSocketAddress("127.0.0.1", 8888), "127.0.0.1:8888"},
- {InetSocketAddress.createUnresolved("127.0.0.2", 8080), "127.0.0.2:8080"},
- {InetAddress.getByName("127.0.0.1"), "127.0.0.1"},
- };
- }
-}
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ConfigAntiPatternsFinderTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ConfigAntiPatternsFinderTest.java
deleted file mode 100644
index d5466b23dbc..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ConfigAntiPatternsFinderTest.java
+++ /dev/null
@@ -1,84 +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.insights;
-
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_HOSTNAME_VALIDATION;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.datastax.oss.driver.api.core.config.DriverConfig;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
-import com.tngtech.java.junit.dataprovider.DataProvider;
-import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
-import java.util.Collections;
-import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(DataProviderRunner.class)
-public class ConfigAntiPatternsFinderTest {
-
- private static final ImmutableMap SSL_ANTI_PATTERN =
- ImmutableMap.of(
- "sslWithoutCertValidation",
- "Client-to-node encryption is enabled but server certificate validation is disabled");
-
- @Test
- @UseDataProvider("sslConfigProvider")
- public void should_find_ssl_anti_pattern(
- boolean sslEngineFactoryClassDefined,
- boolean hostnameValidation,
- Map expected) {
- // given
- InternalDriverContext context =
- mockDefaultProfile(sslEngineFactoryClassDefined, hostnameValidation);
-
- // when
- Map antiPatterns = new ConfigAntiPatternsFinder().findAntiPatterns(context);
-
- // then
- assertThat(antiPatterns).isEqualTo(expected);
- }
-
- private InternalDriverContext mockDefaultProfile(
- boolean sslEngineFactoryClassDefined, boolean hostnameValidation) {
- InternalDriverContext context = mock(InternalDriverContext.class);
- DriverConfig driverConfig = mock(DriverConfig.class);
- when(context.getConfig()).thenReturn(driverConfig);
- DriverExecutionProfile profile = mock(DriverExecutionProfile.class);
- when(profile.isDefined(SSL_ENGINE_FACTORY_CLASS)).thenReturn(sslEngineFactoryClassDefined);
- when(profile.getBoolean(SSL_HOSTNAME_VALIDATION, false)).thenReturn(hostnameValidation);
- when(driverConfig.getDefaultProfile()).thenReturn(profile);
- return context;
- }
-
- @DataProvider
- public static Object[][] sslConfigProvider() {
- return new Object[][] {
- {true, true, Collections.emptyMap()},
- {true, false, SSL_ANTI_PATTERN},
- {false, false, Collections.emptyMap()},
- {false, true, Collections.emptyMap()}
- };
- }
-}
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/DataCentersFinderTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/DataCentersFinderTest.java
deleted file mode 100644
index dde6db6059e..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/DataCentersFinderTest.java
+++ /dev/null
@@ -1,88 +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.insights;
-
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.api.core.loadbalancing.NodeDistance;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSet;
-import com.datastax.oss.driver.shaded.guava.common.collect.Sets;
-import com.tngtech.java.junit.dataprovider.DataProvider;
-import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
-import java.util.Collection;
-import java.util.Set;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(DataProviderRunner.class)
-public class DataCentersFinderTest {
-
- @Test
- @UseDataProvider("hostProvider")
- public void should_detect_data_centers(
- int numberOfRemoteHosts,
- String dc1,
- NodeDistance h1Distance,
- String dc2,
- NodeDistance h2Distance,
- Set expected) {
- // given
- DriverExecutionProfile executionProfile = mock(DriverExecutionProfile.class);
- when(executionProfile.getInt(CONNECTION_POOL_REMOTE_SIZE)).thenReturn(numberOfRemoteHosts);
- Collection nodes = mockNodes(dc1, h1Distance, dc2, h2Distance);
-
- // when
- Set dataCenters = new DataCentersFinder().getDataCenters(nodes, executionProfile);
-
- // then
- assertThat(dataCenters).isEqualTo(Sets.newHashSet(expected));
- }
-
- @DataProvider
- public static Object[][] hostProvider() {
- return new Object[][] {
- {1, "dc1", NodeDistance.LOCAL, "dc2", NodeDistance.REMOTE, Sets.newHashSet("dc1", "dc2")},
- {1, "dc1", NodeDistance.LOCAL, "dc1", NodeDistance.REMOTE, Sets.newHashSet("dc1")},
- {0, "dc1", NodeDistance.LOCAL, "dc2", NodeDistance.REMOTE, Sets.newHashSet("dc1")},
- {0, "dc1", NodeDistance.IGNORED, "dc2", NodeDistance.REMOTE, Sets.newHashSet()},
- {1, "dc1", NodeDistance.IGNORED, "dc2", NodeDistance.REMOTE, Sets.newHashSet("dc2")},
- {1, "dc1", NodeDistance.LOCAL, "dc2", NodeDistance.IGNORED, Sets.newHashSet("dc1")},
- {0, "dc1", NodeDistance.IGNORED, "dc2", NodeDistance.REMOTE, Sets.newHashSet()},
- {0, "dc1", NodeDistance.LOCAL, "dc2", NodeDistance.IGNORED, Sets.newHashSet("dc1")},
- };
- }
-
- private Collection mockNodes(
- String dc1, NodeDistance h1Distance, String dc2, NodeDistance h2Distance) {
- Node n1 = mock(Node.class);
- when(n1.getDatacenter()).thenReturn(dc1);
- when(n1.getDistance()).thenReturn(h1Distance);
-
- Node n2 = mock(Node.class);
- when(n2.getDatacenter()).thenReturn(dc2);
- when(n2.getDistance()).thenReturn(h2Distance);
-
- return ImmutableSet.of(n1, n2);
- }
-}
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfileMockUtil.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfileMockUtil.java
deleted file mode 100644
index de0f3a9d60b..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfileMockUtil.java
+++ /dev/null
@@ -1,119 +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.insights;
-
-import static com.datastax.dse.driver.api.core.config.DseDriverOption.GRAPH_TRAVERSAL_SOURCE;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.AUTH_PROVIDER_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.HEARTBEAT_INTERVAL;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.LOAD_BALANCING_DISTANCE_EVALUATOR_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.PROTOCOL_COMPRESSION;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.RECONNECTION_BASE_DELAY;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.REQUEST_CONSISTENCY;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.REQUEST_TIMEOUT;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SPECULATIVE_EXECUTION_DELAY;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SPECULATIVE_EXECUTION_MAX;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SPECULATIVE_EXECUTION_POLICY_CLASS;
-import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import java.time.Duration;
-
-class ExecutionProfileMockUtil {
- static final String DEFAULT_LOCAL_DC = "local-dc";
- static final int SPECEX_MAX_DEFAULT = 100;
- static final int SPECEX_DELAY_DEFAULT = 20;
-
- static DriverExecutionProfile mockDefaultExecutionProfile() {
- DriverExecutionProfile profile = mock(DriverExecutionProfile.class);
-
- when(profile.getDuration(REQUEST_TIMEOUT)).thenReturn(Duration.ofMillis(100));
- when(profile.getString(LOAD_BALANCING_POLICY_CLASS)).thenReturn("LoadBalancingPolicyImpl");
- when(profile.isDefined(LOAD_BALANCING_DISTANCE_EVALUATOR_CLASS)).thenReturn(true);
- when(profile.isDefined(LOAD_BALANCING_LOCAL_DATACENTER)).thenReturn(true);
- when(profile.getString(LOAD_BALANCING_LOCAL_DATACENTER)).thenReturn(DEFAULT_LOCAL_DC);
- when(profile.isDefined(SPECULATIVE_EXECUTION_MAX)).thenReturn(true);
- when(profile.getInt(SPECULATIVE_EXECUTION_MAX)).thenReturn(SPECEX_MAX_DEFAULT);
- when(profile.isDefined(SPECULATIVE_EXECUTION_DELAY)).thenReturn(true);
- when(profile.getInt(SPECULATIVE_EXECUTION_DELAY)).thenReturn(SPECEX_DELAY_DEFAULT);
- when(profile.getString(SPECULATIVE_EXECUTION_POLICY_CLASS))
- .thenReturn("SpeculativeExecutionImpl");
- when(profile.getString(REQUEST_CONSISTENCY)).thenReturn("LOCAL_ONE");
- when(profile.getString(REQUEST_SERIAL_CONSISTENCY)).thenReturn("SERIAL");
- when(profile.getInt(CONNECTION_POOL_LOCAL_SIZE)).thenReturn(2);
- when(profile.getInt(CONNECTION_POOL_REMOTE_SIZE)).thenReturn(1);
- when(profile.getString(eq(PROTOCOL_COMPRESSION), any())).thenReturn("none");
- when(profile.getDuration(HEARTBEAT_INTERVAL)).thenReturn(Duration.ofMillis(100));
- when(profile.getDuration(RECONNECTION_BASE_DELAY)).thenReturn(Duration.ofMillis(100));
- when(profile.isDefined(SSL_ENGINE_FACTORY_CLASS)).thenReturn(true);
- when(profile.getString(eq(AUTH_PROVIDER_CLASS), any())).thenReturn("AuthProviderImpl");
- when(profile.getString(GRAPH_TRAVERSAL_SOURCE, null)).thenReturn("src-graph");
- return profile;
- }
-
- static DriverExecutionProfile mockNonDefaultRequestTimeoutExecutionProfile() {
- DriverExecutionProfile profile = mockDefaultExecutionProfile();
- when(profile.getDuration(REQUEST_TIMEOUT)).thenReturn(Duration.ofMillis(50));
- return profile;
- }
-
- static DriverExecutionProfile mockNonDefaultLoadBalancingExecutionProfile() {
- DriverExecutionProfile profile = mockDefaultExecutionProfile();
- when(profile.getString(LOAD_BALANCING_POLICY_CLASS)).thenReturn("NonDefaultLoadBalancing");
- return profile;
- }
-
- static DriverExecutionProfile mockUndefinedLocalDcExecutionProfile() {
- DriverExecutionProfile profile = mockNonDefaultLoadBalancingExecutionProfile();
- when(profile.isDefined(LOAD_BALANCING_LOCAL_DATACENTER)).thenReturn(false);
- return profile;
- }
-
- static DriverExecutionProfile mockNonDefaultSpeculativeExecutionInfo() {
- DriverExecutionProfile profile = mockDefaultExecutionProfile();
- when(profile.getString(SPECULATIVE_EXECUTION_POLICY_CLASS))
- .thenReturn("NonDefaultSpecexPolicy");
- return profile;
- }
-
- static DriverExecutionProfile mockNonDefaultConsistency() {
- DriverExecutionProfile profile = mockDefaultExecutionProfile();
- when(profile.getString(REQUEST_CONSISTENCY)).thenReturn("ALL");
- return profile;
- }
-
- static DriverExecutionProfile mockNonDefaultSerialConsistency() {
- DriverExecutionProfile profile = mockDefaultExecutionProfile();
- when(profile.getString(REQUEST_SERIAL_CONSISTENCY)).thenReturn("ONE");
- return profile;
- }
-
- static DriverExecutionProfile mockNonDefaultGraphOptions() {
- DriverExecutionProfile profile = mockDefaultExecutionProfile();
- when(profile.getString(GRAPH_TRAVERSAL_SOURCE, null)).thenReturn("non-default-graph");
- return profile;
- }
-}
diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfilesInfoFinderTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfilesInfoFinderTest.java
deleted file mode 100644
index fc92ab20521..00000000000
--- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ExecutionProfilesInfoFinderTest.java
+++ /dev/null
@@ -1,235 +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.insights;
-
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.DEFAULT_LOCAL_DC;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.SPECEX_DELAY_DEFAULT;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.SPECEX_MAX_DEFAULT;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockDefaultExecutionProfile;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultConsistency;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultGraphOptions;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultLoadBalancingExecutionProfile;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultRequestTimeoutExecutionProfile;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultSerialConsistency;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultSpeculativeExecutionInfo;
-import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockUndefinedLocalDcExecutionProfile;
-import static com.datastax.dse.driver.internal.core.insights.PackageUtil.DEFAULT_LOAD_BALANCING_PACKAGE;
-import static com.datastax.dse.driver.internal.core.insights.PackageUtil.DEFAULT_SPECULATIVE_EXECUTION_PACKAGE;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.datastax.dse.driver.internal.core.insights.schema.LoadBalancingInfo;
-import com.datastax.dse.driver.internal.core.insights.schema.SpecificExecutionProfile;
-import com.datastax.dse.driver.internal.core.insights.schema.SpeculativeExecutionInfo;
-import com.datastax.oss.driver.api.core.config.DriverConfig;
-import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
-import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
-import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.tngtech.java.junit.dataprovider.DataProvider;
-import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
-import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-
-@RunWith(DataProviderRunner.class)
-public class ExecutionProfilesInfoFinderTest {
-
- @Test
- public void should_include_info_about_default_profile() {
- // given
- DriverExecutionProfile defaultExecutionProfile = mockDefaultExecutionProfile();
- Map profiles =
- ImmutableMap.of("default", defaultExecutionProfile);
-
- InternalDriverContext context =
- mockDriverContextWithProfiles(defaultExecutionProfile, profiles);
-
- // when
- Map executionProfilesInfo =
- new ExecutionProfilesInfoFinder().getExecutionProfilesInfo(context);
-
- // then
- assertThat(executionProfilesInfo)
- .isEqualTo(
- ImmutableMap.of(
- "default",
- new SpecificExecutionProfile(
- 100,
- new LoadBalancingInfo(
- "LoadBalancingPolicyImpl",
- ImmutableMap.of("localDataCenter", "local-dc", "filterFunction", true),
- DEFAULT_LOAD_BALANCING_PACKAGE),
- new SpeculativeExecutionInfo(
- "SpeculativeExecutionImpl",
- ImmutableMap.of("maxSpeculativeExecutions", 100, "delay", 20),
- DEFAULT_SPECULATIVE_EXECUTION_PACKAGE),
- "LOCAL_ONE",
- "SERIAL",
- ImmutableMap.of("source", "src-graph"))));
- }
-
- @Test
- @UseDataProvider("executionProfileProvider")
- public void should_include_info_about_default_profile_and_only_difference_for_specific_profile(
- DriverExecutionProfile nonDefaultExecutionProfile, SpecificExecutionProfile expected) {
- // given
-
- DriverExecutionProfile defaultExecutionProfile = mockDefaultExecutionProfile();
- Map profiles =
- ImmutableMap.of(
- "default", defaultExecutionProfile, "non-default", nonDefaultExecutionProfile);
- InternalDriverContext context =
- mockDriverContextWithProfiles(defaultExecutionProfile, profiles);
- // when
- Map executionProfilesInfo =
- new ExecutionProfilesInfoFinder().getExecutionProfilesInfo(context);
-
- // then
- assertThat(executionProfilesInfo)
- .isEqualTo(
- ImmutableMap.of(
- "default",
- new SpecificExecutionProfile(
- 100,
- new LoadBalancingInfo(
- "LoadBalancingPolicyImpl",
- ImmutableMap.of("localDataCenter", "local-dc", "filterFunction", true),
- DEFAULT_LOAD_BALANCING_PACKAGE),
- new SpeculativeExecutionInfo(
- "SpeculativeExecutionImpl",
- ImmutableMap.of("maxSpeculativeExecutions", 100, "delay", 20),
- DEFAULT_SPECULATIVE_EXECUTION_PACKAGE),
- "LOCAL_ONE",
- "SERIAL",
- ImmutableMap.of("source", "src-graph")),
- "non-default",
- expected));
- }
-
- @DataProvider
- public static Object[][] executionProfileProvider() {
- return new Object[][] {
- {
- mockNonDefaultRequestTimeoutExecutionProfile(),
- new SpecificExecutionProfile(50, null, null, null, null, null)
- },
- {
- mockNonDefaultLoadBalancingExecutionProfile(),
- new SpecificExecutionProfile(
- null,
- new LoadBalancingInfo(
- "NonDefaultLoadBalancing",
- ImmutableMap.of("localDataCenter", DEFAULT_LOCAL_DC, "filterFunction", true),
- DEFAULT_LOAD_BALANCING_PACKAGE),
- null,
- null,
- null,
- null)
- },
- {
- mockUndefinedLocalDcExecutionProfile(),
- new SpecificExecutionProfile(
- null,
- new LoadBalancingInfo(
- "NonDefaultLoadBalancing",
- ImmutableMap.of("filterFunction", true),
- DEFAULT_LOAD_BALANCING_PACKAGE),
- null,
- null,
- null,
- null)
- },
- {
- mockNonDefaultSpeculativeExecutionInfo(),
- new SpecificExecutionProfile(
- null,
- null,
- new SpeculativeExecutionInfo(
- "NonDefaultSpecexPolicy",
- ImmutableMap.of(
- "maxSpeculativeExecutions", SPECEX_MAX_DEFAULT, "delay", SPECEX_DELAY_DEFAULT),
- DEFAULT_SPECULATIVE_EXECUTION_PACKAGE),
- null,
- null,
- null)
- },
- {
- mockNonDefaultConsistency(),
- new SpecificExecutionProfile(null, null, null, "ALL", null, null)
- },
- {
- mockNonDefaultSerialConsistency(),
- new SpecificExecutionProfile(null, null, null, null, "ONE", null)
- },
- {
- mockNonDefaultGraphOptions(),
- new SpecificExecutionProfile(
- null, null, null, null, null, ImmutableMap.of("source", "non-default-graph"))
- },
- {
- mockDefaultExecutionProfile(),
- new SpecificExecutionProfile(null, null, null, null, null, null)
- }
- };
- }
-
- @Test
- public void should_not_include_null_fields_in_json() throws JsonProcessingException {
- // given
- SpecificExecutionProfile specificExecutionProfile =
- new SpecificExecutionProfile(50, null, null, "ONE", null, ImmutableMap.of("a", "b"));
-
- // when
- String result = new ObjectMapper().writeValueAsString(specificExecutionProfile);
-
- // then
- assertThat(result)
- .isEqualTo("{\"readTimeout\":50,\"consistency\":\"ONE\",\"graphOptions\":{\"a\":\"b\"}}");
- }
-
- @Test
- public void should_include_empty_execution_profile_if_has_all_nulls()
- throws JsonProcessingException {
- // given
- Map executionProfiles =
- ImmutableMap.of("p", new SpecificExecutionProfile(null, null, null, null, null, null));
-
- // when
- String result = new ObjectMapper().writeValueAsString(executionProfiles);
-
- // then
- assertThat(result).isEqualTo("{\"p\":{}}");
- }
-
- private InternalDriverContext mockDriverContextWithProfiles(
- DriverExecutionProfile defaultExecutionProfile,
- Map profiles) {
- InternalDriverContext context = mock(InternalDriverContext.class);
- DriverConfig driverConfig = mock(DriverConfig.class);
- Mockito.