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 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.>when(driverConfig.getProfiles()) - .thenReturn(profiles); - when(driverConfig.getDefaultProfile()).thenReturn(defaultExecutionProfile); - when(context.getConfig()).thenReturn(driverConfig); - return context; - } -} diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/InsightsClientTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/InsightsClientTest.java deleted file mode 100644 index 5085432dbec..00000000000 --- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/InsightsClientTest.java +++ /dev/null @@ -1,535 +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.DseProtocolVersion.DSE_V2; -import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockDefaultExecutionProfile; -import static com.datastax.dse.driver.internal.core.insights.ExecutionProfileMockUtil.mockNonDefaultRequestTimeoutExecutionProfile; -import static com.datastax.dse.driver.internal.core.insights.PackageUtil.DEFAULT_AUTH_PROVIDER_PACKAGE; -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 java.util.concurrent.TimeUnit.SECONDS; -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.datastax.dse.driver.api.core.metadata.DseNodeProperties; -import com.datastax.dse.driver.internal.core.insights.configuration.InsightsConfiguration; -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.InsightsPlatformInfo; -import com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.CPUS; -import com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.OS; -import com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.RuntimeAndCompileTimeVersions; -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.LoadBalancingInfo; -import com.datastax.dse.driver.internal.core.insights.schema.PoolSizeByHostDistance; -import com.datastax.dse.driver.internal.core.insights.schema.ReconnectionPolicyInfo; -import com.datastax.dse.driver.internal.core.insights.schema.SSL; -import com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode; -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.Version; -import com.datastax.oss.driver.api.core.config.DriverConfig; -import com.datastax.oss.driver.api.core.config.DriverExecutionProfile; -import com.datastax.oss.driver.api.core.metadata.EndPoint; -import com.datastax.oss.driver.api.core.metadata.Metadata; -import com.datastax.oss.driver.api.core.metadata.Node; -import com.datastax.oss.driver.internal.core.channel.DriverChannel; -import com.datastax.oss.driver.internal.core.context.DefaultDriverContext; -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.metadata.DefaultNode; -import com.datastax.oss.driver.internal.core.metadata.MetadataManager; -import com.datastax.oss.driver.internal.core.pool.ChannelPool; -import com.datastax.oss.driver.internal.core.session.PoolManager; -import com.datastax.oss.driver.shaded.guava.common.base.Suppliers; -import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList; -import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap; -import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSet; -import com.datastax.oss.driver.shaded.guava.common.collect.Sets; -import com.fasterxml.jackson.core.type.TypeReference; -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 io.netty.channel.DefaultEventLoop; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Supplier; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; - -@RunWith(DataProviderRunner.class) -public class InsightsClientTest { - private static final StackTraceElement[] EMPTY_STACK_TRACE = {}; - private static final Map EMPTY_OBJECT_MAP = Collections.emptyMap(); - private static final Supplier MOCK_TIME_SUPPLIER = Suppliers.ofInstance(1L); - private static final InsightsConfiguration INSIGHTS_CONFIGURATION = - new InsightsConfiguration(true, 300000L, new DefaultEventLoop()); - - @Test - public void should_construct_json_event_startup_message() throws IOException { - // given - DefaultDriverContext context = mockDefaultDriverContext(); - PlatformInfoFinder platformInfoFinder = mock(PlatformInfoFinder.class); - OS os = new OS("linux", "1.2", "x64"); - CPUS cpus = new CPUS(8, "intel i7"); - Map javaDeps = - ImmutableMap.of("version", new RuntimeAndCompileTimeVersions("11.0.0", "11.0.0", false)); - Map> runtimeInfo = - ImmutableMap.of("java", javaDeps); - InsightsPlatformInfo insightsPlatformInfo = new InsightsPlatformInfo(os, cpus, runtimeInfo); - when(platformInfoFinder.getInsightsPlatformInfo()).thenReturn(insightsPlatformInfo); - - ConfigAntiPatternsFinder configAntiPatternsFinder = mock(ConfigAntiPatternsFinder.class); - when(configAntiPatternsFinder.findAntiPatterns(any(DefaultDriverContext.class))) - .thenReturn( - ImmutableMap.of( - "contactPointsMultipleDCs", - "Contact points contain hosts from multiple data centers")); - - DataCentersFinder dataCentersFinder = mock(DataCentersFinder.class); - when(dataCentersFinder.getDataCenters(any(DefaultDriverContext.class))) - .thenReturn(Sets.newHashSet("dc1", "dc2")); - ReconnectionPolicyInfoFinder reconnectionPolicyInfoFinder = - mock(ReconnectionPolicyInfoFinder.class); - when(reconnectionPolicyInfoFinder.getReconnectionPolicyInfo(any(), any())) - .thenReturn( - new ReconnectionPolicyInfo( - "reconnection-policy-a", ImmutableMap.of("opt-a", 1), "com.datastax.dse")); - - InsightsClient insightsClient = - new InsightsClient( - context, - MOCK_TIME_SUPPLIER, - INSIGHTS_CONFIGURATION, - platformInfoFinder, - reconnectionPolicyInfoFinder, - new ExecutionProfilesInfoFinder(), - configAntiPatternsFinder, - dataCentersFinder, - EMPTY_STACK_TRACE); - - // when - String startupMessage = insightsClient.createStartupMessage(); - Insight insight = - new ObjectMapper() - .readValue(startupMessage, new TypeReference>() {}); - - // then - assertThat(insight.getMetadata()) - .isEqualTo( - new InsightMetadata( - "driver.startup", - 1L, - ImmutableMap.of("language", "java"), - InsightType.EVENT, - "v1")); - - InsightsStartupData insightData = insight.getInsightData(); - assertThat(insightData.getClientId()).isEqualTo("client-id"); - assertThat(insightData.getSessionId()).isNotNull(); - assertThat(insightData.getDriverName()).isEqualTo("DataStax Enterprise Java Driver"); - assertThat(insightData.getDriverVersion()).isNotEmpty(); - assertThat(insightData.getApplicationName()).isEqualTo("app-name"); - assertThat(insightData.getApplicationVersion()).isEqualTo("1.0.0"); - assertThat(insightData.isApplicationNameWasGenerated()).isEqualTo(false); - assertThat(insightData.getContactPoints()) - .isEqualTo(ImmutableMap.of("localhost", Collections.singletonList("127.0.0.1:9999"))); - - assertThat(insightData.getInitialControlConnection()).isEqualTo("127.0.0.1:10"); - assertThat(insightData.getLocalAddress()).isEqualTo("127.0.0.1"); - assertThat(insightData.getHostName()).isNotEmpty(); - assertThat(insightData.getProtocolVersion()).isEqualTo(DSE_V2.getCode()); - assertThat(insightData.getExecutionProfiles()) - .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", - new SpecificExecutionProfile(50, null, null, null, null, null))); - assertThat(insightData.getPoolSizeByHostDistance()) - .isEqualTo(new PoolSizeByHostDistance(2, 1, 0)); - assertThat(insightData.getHeartbeatInterval()).isEqualTo(100); - assertThat(insightData.getCompression()).isEqualTo("none"); - assertThat(insightData.getReconnectionPolicy()) - .isEqualTo( - new ReconnectionPolicyInfo( - "reconnection-policy-a", ImmutableMap.of("opt-a", 1), "com.datastax.dse")); - assertThat(insightData.getSsl()).isEqualTo(new SSL(true, false)); - assertThat(insightData.getAuthProvider()) - .isEqualTo(new AuthProviderType("AuthProviderImpl", DEFAULT_AUTH_PROVIDER_PACKAGE)); - assertThat(insightData.getOtherOptions()).isEqualTo(EMPTY_OBJECT_MAP); - assertThat(insightData.getPlatformInfo()).isEqualTo(insightsPlatformInfo); - assertThat(insightData.getConfigAntiPatterns()) - .isEqualTo( - ImmutableMap.of( - "contactPointsMultipleDCs", - "Contact points contain hosts from multiple data centers")); - assertThat(insightData.getPeriodicStatusInterval()).isEqualTo(300); - assertThat(insightData.getDataCenters()).isEqualTo(Sets.newHashSet("dc1", "dc2")); - } - - @Test - public void should_group_contact_points_by_host_name() { - // given - Set contactPoints = - ImmutableSet.of( - InetSocketAddress.createUnresolved("127.0.0.1", 8080), - InetSocketAddress.createUnresolved("127.0.0.1", 8081), - InetSocketAddress.createUnresolved("127.0.0.2", 8081)); - - Map> expected = - ImmutableMap.of( - "127.0.0.1", - ImmutableList.of("127.0.0.1:8080", "127.0.0.1:8081"), - "127.0.0.2", - ImmutableList.of("127.0.0.2:8081")); - - // when - Map> resolvedContactPoints = - InsightsClient.getResolvedContactPoints(contactPoints); - - // then - assertThat(resolvedContactPoints).isEqualTo(expected); - } - - @Test - public void should_construct_json_event_status_message() throws IOException { - // given - InsightsClient insightsClient = - new InsightsClient( - mockDefaultDriverContext(), - MOCK_TIME_SUPPLIER, - INSIGHTS_CONFIGURATION, - null, - null, - null, - null, - null, - EMPTY_STACK_TRACE); - - // when - String statusMessage = insightsClient.createStatusMessage(); - - // then - Insight insight = - new ObjectMapper() - .readValue(statusMessage, new TypeReference>() {}); - assertThat(insight.getMetadata()) - .isEqualTo( - new InsightMetadata( - "driver.status", 1L, ImmutableMap.of("language", "java"), InsightType.EVENT, "v1")); - InsightsStatusData insightData = insight.getInsightData(); - assertThat(insightData.getClientId()).isEqualTo("client-id"); - assertThat(insightData.getSessionId()).isNotNull(); - assertThat(insightData.getControlConnection()).isEqualTo("127.0.0.1:10"); - assertThat(insightData.getConnectedNodes()) - .isEqualTo( - ImmutableMap.of( - "127.0.0.1:10", new SessionStateForNode(1, 10), - "127.0.0.1:20", new SessionStateForNode(2, 20))); - } - - @Test - public void should_schedule_task_with_initial_delay() { - // given - final AtomicInteger counter = new AtomicInteger(); - Runnable runnable = counter::incrementAndGet; - - // when - InsightsClient.scheduleInsightsTask(100L, Executors.newScheduledThreadPool(1), runnable); - - // then - await().atMost(1, SECONDS).until(() -> counter.get() >= 1); - } - - @Test - @UseDataProvider(value = "stackTraceProvider") - public void should_get_caller_of_create_cluster(StackTraceElement[] stackTrace, String expected) { - // when - String result = InsightsClient.getClusterCreateCaller(stackTrace); - - // then - assertThat(result).isEqualTo(expected); - } - - @Test - @SuppressWarnings("ResultOfMethodCallIgnored") - public void should_execute_should_send_event_check_only_once() - throws UnknownHostException, InterruptedException { - // given - InsightsConfiguration insightsConfiguration = mock(InsightsConfiguration.class); - when(insightsConfiguration.isMonitorReportingEnabled()).thenReturn(true); - when(insightsConfiguration.getStatusEventDelayMillis()).thenReturn(10L); - when(insightsConfiguration.getExecutor()).thenReturn(new DefaultEventLoop()); - - InsightsClient insightsClient = - new InsightsClient( - mockDefaultDriverContext(), - MOCK_TIME_SUPPLIER, - insightsConfiguration, - null, - null, - null, - null, - null, - EMPTY_STACK_TRACE); - - // when - insightsClient.scheduleStatusMessageSend(); - // emulate periodic calls to sendStatusMessage - insightsClient.sendStatusMessage(); - insightsClient.sendStatusMessage(); - insightsClient.sendStatusMessage(); - - // then - verify(insightsConfiguration, times(1)).isMonitorReportingEnabled(); - } - - @DataProvider - public static Object[][] stackTraceProvider() { - StackTraceElement[] onlyInitCall = - new StackTraceElement[] { - new StackTraceElement( - "com.datastax.oss.driver.internal.core.context.DefaultDriverContext", - "", - "DefaultDriverContext.java", - 94), - }; - - StackTraceElement[] stackTraceElementsWithoutInitCall = - new StackTraceElement[] { - new StackTraceElement("java.lang.Thread", "getStackTrace", "Thread.java", 1559), - new StackTraceElement( - "com.datastax.driver.core.InsightsClient", - "getClusterCreateCaller", - "InsightsClient.java", - 302) - }; - StackTraceElement[] stackTraceWithOneInitCall = - new StackTraceElement[] { - new StackTraceElement("java.lang.Thread", "getStackTrace", "Thread.java", 1559), - new StackTraceElement( - "com.datastax.oss.driver.internal.core.context.DefaultDriverContext", - "", - "DefaultDriverContext.java", - 243), - }; - StackTraceElement[] stackTraceWithOneInitCallAndCaller = - new StackTraceElement[] { - new StackTraceElement("java.lang.Thread", "getStackTrace", "Thread.java", 1559), - new StackTraceElement( - "com.datastax.oss.driver.internal.core.context.DefaultDriverContext", - "", - "DefaultDriverContext.java", - 243), - new StackTraceElement( - "com.example.ActualCallerNameApp", "main", "ActualCallerNameApp.java", 1) - }; - - StackTraceElement[] stackTraceWithTwoInitCallsAndCaller = - new StackTraceElement[] { - new StackTraceElement("java.lang.Thread", "getStackTrace", "Thread.java", 1559), - new StackTraceElement( - "com.datastax.oss.driver.internal.core.context.DefaultDriverContext", - "", - "DefaultDriverContext.java", - 243), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "buildDefaultSessionAsync", - "SessionBuilder.java", - 300), - new StackTraceElement( - "com.example.ActualCallerNameApp", "main", "ActualCallerNameApp.java", 1) - }; - StackTraceElement[] stackTraceWithChainOfInitCalls = - new StackTraceElement[] { - new StackTraceElement( - "com.datastax.oss.driver.internal.core.context.DefaultDriverContext", - "", - "DefaultDriverContext.java", - 243), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "buildDefaultSessionAsync", - "SessionBuilder.java", - 332), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "buildAsync", - "SessionBuilder.java", - 291), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "build", - "SessionBuilder.java", - 306) - }; - StackTraceElement[] stackTraceWithChainOfInitCallsAndCaller = - new StackTraceElement[] { - new StackTraceElement("java.lang.Thread", "getStackTrace", "Thread.java", 1559), - new StackTraceElement( - "com.datastax.oss.driver.internal.core.context.DefaultDriverContext", - "", - "DefaultDriverContext.java", - 243), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "buildContext", - "SessionBuilder.java", - 687), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "buildDefaultSessionAsync", - "SessionBuilder.java", - 332), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "buildAsync", - "SessionBuilder.java", - 291), - new StackTraceElement( - "com.datastax.oss.driver.api.core.session.SessionBuilder", - "build", - "SessionBuilder.java", - 306), - new StackTraceElement( - "com.example.ActualCallerNameApp", "main", "ActualCallerNameApp.java", 8) - }; - - return new Object[][] { - {new StackTraceElement[] {}, InsightsClient.DEFAULT_JAVA_APPLICATION}, - {stackTraceElementsWithoutInitCall, InsightsClient.DEFAULT_JAVA_APPLICATION}, - {stackTraceWithOneInitCall, InsightsClient.DEFAULT_JAVA_APPLICATION}, - {onlyInitCall, InsightsClient.DEFAULT_JAVA_APPLICATION}, - {stackTraceWithOneInitCallAndCaller, "com.example.ActualCallerNameApp"}, - {stackTraceWithTwoInitCallsAndCaller, "com.example.ActualCallerNameApp"}, - {stackTraceWithChainOfInitCalls, InsightsClient.DEFAULT_JAVA_APPLICATION}, - {stackTraceWithChainOfInitCallsAndCaller, "com.example.ActualCallerNameApp"} - }; - } - - private DefaultDriverContext mockDefaultDriverContext() throws UnknownHostException { - DefaultDriverContext context = mock(DefaultDriverContext.class); - mockConnectionPools(context); - MetadataManager manager = mock(MetadataManager.class); - when(context.getMetadataManager()).thenReturn(manager); - Metadata metadata = mock(Metadata.class); - when(manager.getMetadata()).thenReturn(metadata); - Node node = mock(Node.class); - when(node.getExtras()) - .thenReturn( - ImmutableMap.of( - DseNodeProperties.DSE_VERSION, Objects.requireNonNull(Version.parse("6.0.5")))); - when(metadata.getNodes()).thenReturn(ImmutableMap.of(UUID.randomUUID(), node)); - DriverExecutionProfile defaultExecutionProfile = mockDefaultExecutionProfile(); - DriverExecutionProfile nonDefaultExecutionProfile = - mockNonDefaultRequestTimeoutExecutionProfile(); - - Map startupOptions = new HashMap<>(); - startupOptions.put(StartupOptionsBuilder.CLIENT_ID_KEY, "client-id"); - startupOptions.put(StartupOptionsBuilder.APPLICATION_VERSION_KEY, "1.0.0"); - startupOptions.put(StartupOptionsBuilder.APPLICATION_NAME_KEY, "app-name"); - startupOptions.put(StartupOptionsBuilder.DRIVER_VERSION_KEY, "2.x"); - startupOptions.put(StartupOptionsBuilder.DRIVER_NAME_KEY, "DataStax Enterprise Java Driver"); - - when(context.getStartupOptions()).thenReturn(startupOptions); - when(context.getProtocolVersion()).thenReturn(DSE_V2); - DefaultNode contactPoint = mock(DefaultNode.class); - EndPoint contactEndPoint = mock(EndPoint.class); - when(contactEndPoint.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 9999)); - when(contactPoint.getEndPoint()).thenReturn(contactEndPoint); - when(manager.getContactPoints()).thenReturn(ImmutableSet.of(contactPoint)); - - DriverConfig driverConfig = mock(DriverConfig.class); - when(context.getConfig()).thenReturn(driverConfig); - Map profiles = - ImmutableMap.of( - "default", defaultExecutionProfile, "non-default", nonDefaultExecutionProfile); - Mockito.>when(driverConfig.getProfiles()) - .thenReturn(profiles); - when(driverConfig.getDefaultProfile()).thenReturn(defaultExecutionProfile); - - ControlConnection controlConnection = mock(ControlConnection.class); - DriverChannel channel = mock(DriverChannel.class); - EndPoint controlConnectionEndpoint = mock(EndPoint.class); - when(controlConnectionEndpoint.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 10)); - - when(channel.getEndPoint()).thenReturn(controlConnectionEndpoint); - when(channel.localAddress()).thenReturn(new InetSocketAddress("127.0.0.1", 10)); - when(controlConnection.channel()).thenReturn(channel); - when(context.getControlConnection()).thenReturn(controlConnection); - return context; - } - - private void mockConnectionPools(DefaultDriverContext driverContext) { - Node node1 = mock(Node.class); - EndPoint endPoint1 = mock(EndPoint.class); - when(endPoint1.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 10)); - when(node1.getEndPoint()).thenReturn(endPoint1); - when(node1.getOpenConnections()).thenReturn(1); - ChannelPool channelPool1 = mock(ChannelPool.class); - when(channelPool1.getInFlight()).thenReturn(10); - - Node node2 = mock(Node.class); - EndPoint endPoint2 = mock(EndPoint.class); - when(endPoint2.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 20)); - when(node2.getEndPoint()).thenReturn(endPoint2); - when(node2.getOpenConnections()).thenReturn(2); - ChannelPool channelPool2 = mock(ChannelPool.class); - when(channelPool2.getInFlight()).thenReturn(20); - - Map channelPools = ImmutableMap.of(node1, channelPool1, node2, channelPool2); - PoolManager poolManager = mock(PoolManager.class); - when(poolManager.getPools()).thenReturn(channelPools); - when(driverContext.getPoolManager()).thenReturn(poolManager); - } -} diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/InsightsSupportVerifierTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/InsightsSupportVerifierTest.java deleted file mode 100644 index 9edd4494bdd..00000000000 --- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/InsightsSupportVerifierTest.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 org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -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 com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList; -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.Collection; -import java.util.Collections; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(DataProviderRunner.class) -public class InsightsSupportVerifierTest { - - @Test - @UseDataProvider(value = "dseHostsProvider") - public void should_detect_DSE_versions_that_supports_insights( - Collection hosts, boolean expected) { - // when - boolean result = InsightsSupportVerifier.supportsInsights(hosts); - - // then - assertThat(result).isEqualTo(expected); - } - - @DataProvider - public static Object[][] dseHostsProvider() { - Node dse605 = mock(Node.class); - when(dse605.getExtras()) - .thenReturn(ImmutableMap.of(DseNodeProperties.DSE_VERSION, Version.parse("6.0.5"))); - Node dse604 = mock(Node.class); - when(dse604.getExtras()) - .thenReturn(ImmutableMap.of(DseNodeProperties.DSE_VERSION, Version.parse("6.0.4"))); - Node dse600 = mock(Node.class); - when(dse600.getExtras()) - .thenReturn(ImmutableMap.of(DseNodeProperties.DSE_VERSION, Version.parse("6.0.0"))); - Node dse5113 = mock(Node.class); - when(dse5113.getExtras()) - .thenReturn(ImmutableMap.of(DseNodeProperties.DSE_VERSION, Version.parse("5.1.13"))); - Node dse500 = mock(Node.class); - when(dse500.getExtras()) - .thenReturn(ImmutableMap.of(DseNodeProperties.DSE_VERSION, Version.parse("5.0.0"))); - Node nodeWithoutExtras = mock(Node.class); - when(nodeWithoutExtras.getExtras()).thenReturn(Collections.emptyMap()); - - return new Object[][] { - {ImmutableList.of(dse605), true}, - {ImmutableList.of(dse604), false}, - {ImmutableList.of(dse600), false}, - {ImmutableList.of(dse5113), true}, - {ImmutableList.of(dse500), false}, - {ImmutableList.of(dse5113, dse605), true}, - {ImmutableList.of(dse5113, dse600), false}, - {ImmutableList.of(dse500, dse600), false}, - {ImmutableList.of(), false}, - {ImmutableList.of(nodeWithoutExtras), false} - }; - } -} diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/PackageUtilTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/PackageUtilTest.java deleted file mode 100644 index 336f19184d3..00000000000 --- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/PackageUtilTest.java +++ /dev/null @@ -1,87 +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 org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(DataProviderRunner.class) -public class PackageUtilTest { - - private static final String DEFAULT_PACKAGE = "default.package"; - - @Test - public void should_find_package_name_for_class() { - // given - TestClass testClass = new TestClass(); - - // then - String namespace = PackageUtil.getNamespace(testClass.getClass()); - - // then - assertThat(namespace).isEqualTo("com.datastax.dse.driver.internal.core.insights"); - } - - @Test - @UseDataProvider("packagesProvider") - public void should_get_full_package_or_return_default(String fullClassSetting, String expected) { - // when - String result = PackageUtil.getFullPackageOrDefault(fullClassSetting, DEFAULT_PACKAGE); - - // then - assertThat(result).isEqualTo(expected); - } - - @Test - @UseDataProvider("classesProvider") - public void should_get_class_name_from_full_class_setting( - String fullClassSetting, String expected) { - // when - String result = PackageUtil.getClassName(fullClassSetting); - - // then - assertThat(result).isEqualTo(expected); - } - - @DataProvider - public static Object[][] packagesProvider() { - return new Object[][] { - {"com.P", "com"}, - {"ClassName", DEFAULT_PACKAGE}, - {"", DEFAULT_PACKAGE}, - {"com.p.a.2.x.12.Class", "com.p.a.2.x.12"}, - }; - } - - @DataProvider - public static Object[][] classesProvider() { - return new Object[][] { - {"com.P", "P"}, - {"ClassName", "ClassName"}, - {"", ""}, - {"com.p.a.2.x.12.Class", "Class"}, - }; - } - - private static class TestClass {} -} diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/PlatformInfoFinderTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/PlatformInfoFinderTest.java deleted file mode 100644 index 79818d906b6..00000000000 --- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/PlatformInfoFinderTest.java +++ /dev/null @@ -1,220 +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.PlatformInfoFinder.UNVERIFIED_RUNTIME_VERSION; -import static org.assertj.core.api.Assertions.assertThat; - -import com.datastax.dse.driver.internal.core.insights.schema.InsightsPlatformInfo.RuntimeAndCompileTimeVersions; -import java.io.InputStream; -import java.net.URL; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import org.junit.Test; - -public class PlatformInfoFinderTest { - - private URL nullUrlProvider(PlatformInfoFinder.DependencyFromFile d) { - return null; - } - - private URL nettyUrlProvider(PlatformInfoFinder.DependencyFromFile d) { - return this.getClass().getResource("/insights/pom.properties"); - } - - private URL malformedUrlProvider(PlatformInfoFinder.DependencyFromFile d) { - return this.getClass().getResource("/insights/malformed-pom.properties"); - } - - private URL nonExistingUrlProvider(PlatformInfoFinder.DependencyFromFile d) { - return this.getClass().getResource("/insights/non-existing.pom"); - } - - @Test - public void should_find_dependencies_from_file() { - // given - InputStream inputStream = - this.getClass().getResourceAsStream("/insights/test-dependencies.txt"); - Map expected = new HashMap<>(); - expected.put( - "io.netty:netty-transport-native-epoll", - withUnverifiedRuntimeVersionOptional("4.0.56.Final")); - expected.put("org.slf4j:slf4j-api", withUnverifiedRuntimeVersion("1.7.25")); - expected.put("org.ow2.asm:asm", withUnverifiedRuntimeVersion("5.0.3")); - expected.put("com.esri.geometry:esri-geometry-api", withUnverifiedRuntimeVersion("1.2.1")); - expected.put("io.netty:netty-transport", withUnverifiedRuntimeVersion("4.0.56.Final")); - expected.put("com.github.jnr:jnr-x86asm", withUnverifiedRuntimeVersion("1.0.2")); - expected.put("org.ow2.asm:asm-analysis", withUnverifiedRuntimeVersion("5.0.3")); - expected.put("com.github.jnr:jnr-constants", withUnverifiedRuntimeVersion("0.9.9")); - expected.put("io.netty:netty-common", withUnverifiedRuntimeVersion("4.0.56.Final")); - expected.put("com.google.guava:guava", withUnverifiedRuntimeVersion("19.0")); - expected.put("org.xerial.snappy:snappy-java", withUnverifiedRuntimeVersionOptional("1.1.2.6")); - expected.put("io.dropwizard.metrics:metrics-core", withUnverifiedRuntimeVersion("3.2.2")); - expected.put("org.ow2.asm:asm-tree", withUnverifiedRuntimeVersion("5.0.3")); - expected.put("com.github.jnr:jnr-posix", withUnverifiedRuntimeVersion("3.0.44")); - expected.put("org.codehaus.jackson:jackson-core-asl", withUnverifiedRuntimeVersion("1.9.12")); - expected.put( - "com.fasterxml.jackson.core:jackson-databind", withUnverifiedRuntimeVersion("2.7.9.3")); - expected.put("io.netty:netty-codec", withUnverifiedRuntimeVersion("4.0.56.Final")); - expected.put( - "com.fasterxml.jackson.core:jackson-annotations", withUnverifiedRuntimeVersion("2.8.11")); - expected.put("com.fasterxml.jackson.core:jackson-core", withUnverifiedRuntimeVersion("2.8.11")); - expected.put("io.netty:netty-handler", withUnverifiedRuntimeVersion("4.0.56.Final")); - expected.put("at.yawk.lz4:lz4-java", withUnverifiedRuntimeVersionOptional("1.8.1")); - expected.put("org.hdrhistogram:HdrHistogram", withUnverifiedRuntimeVersionOptional("2.1.10")); - expected.put("com.github.jnr:jffi", withUnverifiedRuntimeVersion("1.2.16")); - expected.put("io.netty:netty-buffer", withUnverifiedRuntimeVersion("4.0.56.Final")); - expected.put("org.ow2.asm:asm-commons", withUnverifiedRuntimeVersion("5.0.3")); - expected.put("org.json:json", withUnverifiedRuntimeVersion("20090211")); - expected.put("org.ow2.asm:asm-util", withUnverifiedRuntimeVersion("5.0.3")); - expected.put("com.github.jnr:jnr-ffi", withUnverifiedRuntimeVersion("2.1.7")); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::nullUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).hasSize(28); - assertThat(stringStringMap).isEqualTo(expected); - } - - @Test - public void should_find_dependencies_from_file_without_duplicate() { - // given - InputStream inputStream = - this.getClass().getResourceAsStream("/insights/duplicate-dependencies.txt"); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::nullUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).hasSize(1); - } - - @Test - public void should_keep_order_of_dependencies() { - // given - InputStream inputStream = - this.getClass().getResourceAsStream("/insights/ordered-dependencies.txt"); - Map expected = new LinkedHashMap<>(); - expected.put("b-org.com:art1", withUnverifiedRuntimeVersion("1.0")); - expected.put("a-org.com:art1", withUnverifiedRuntimeVersion("2.0")); - expected.put("c-org.com:art1", withUnverifiedRuntimeVersion("3.0")); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::nullUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).isEqualTo(expected); - Iterator iterator = expected.keySet().iterator(); - assertThat(iterator.next()).isEqualTo("b-org.com:art1"); - assertThat(iterator.next()).isEqualTo("a-org.com:art1"); - assertThat(iterator.next()).isEqualTo("c-org.com:art1"); - } - - @Test - public void should_add_information_about_java_platform() { - // given - Map> runtimeDependencies = new HashMap<>(); - - // when - new PlatformInfoFinder(this::nullUrlProvider).addJavaVersion(runtimeDependencies); - - // then - Map javaDependencies = runtimeDependencies.get("java"); - assertThat(javaDependencies.size()).isEqualTo(3); - } - - @Test - public void should_load_runtime_version_from_pom_properties_URL() { - // given - InputStream inputStream = this.getClass().getResourceAsStream("/insights/netty-dependency.txt"); - Map expected = new LinkedHashMap<>(); - expected.put( - "io.netty:netty-handler", - new RuntimeAndCompileTimeVersions("4.0.56.Final", "4.0.0.Final", false)); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::nettyUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).isEqualTo(expected); - } - - @Test - public void should_load_runtime_version_of_optional_dependency_from_pom_properties_URL() { - // given - InputStream inputStream = - this.getClass().getResourceAsStream("/insights/netty-dependency-optional.txt"); - Map expected = new LinkedHashMap<>(); - expected.put( - "io.netty:netty-handler", - new RuntimeAndCompileTimeVersions("4.0.56.Final", "4.0.0.Final", true)); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::nettyUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).isEqualTo(expected); - } - - @Test - public void should_not_load_runtime_dependency_from_malformed_pom_properties() { - // given - InputStream inputStream = this.getClass().getResourceAsStream("/insights/netty-dependency.txt"); - Map expected = new LinkedHashMap<>(); - expected.put("io.netty:netty-handler", withUnverifiedRuntimeVersion("4.0.0.Final")); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::malformedUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).isEqualTo(expected); - } - - @Test - public void should_not_load_runtime_dependency_from_non_existing_pom_properties() { - // given - InputStream inputStream = this.getClass().getResourceAsStream("/insights/netty-dependency.txt"); - Map expected = new LinkedHashMap<>(); - expected.put("io.netty:netty-handler", withUnverifiedRuntimeVersion("4.0.0.Final")); - - // when - Map stringStringMap = - new PlatformInfoFinder(this::nonExistingUrlProvider).fetchDependenciesFromFile(inputStream); - - // then - assertThat(stringStringMap).isEqualTo(expected); - } - - private RuntimeAndCompileTimeVersions withUnverifiedRuntimeVersion(String compileVersion) { - return new RuntimeAndCompileTimeVersions(UNVERIFIED_RUNTIME_VERSION, compileVersion, false); - } - - private RuntimeAndCompileTimeVersions withUnverifiedRuntimeVersionOptional( - String compileVersion) { - return new RuntimeAndCompileTimeVersions(UNVERIFIED_RUNTIME_VERSION, compileVersion, true); - } -} diff --git a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ReconnectionPolicyInfoFinderTest.java b/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ReconnectionPolicyInfoFinderTest.java deleted file mode 100644 index a076ca38b1c..00000000000 --- a/core/src/test/java/com/datastax/dse/driver/internal/core/insights/ReconnectionPolicyInfoFinderTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.datastax.dse.driver.internal.core.insights; - -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.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.time.Duration; -import org.assertj.core.data.MapEntry; -import org.junit.Test; - -public class ReconnectionPolicyInfoFinderTest { - - @Test - public void should_find_an_info_about_constant_reconnection_policy() { - // given - DriverExecutionProfile driverExecutionProfile = mock(DriverExecutionProfile.class); - when(driverExecutionProfile.getDuration(DefaultDriverOption.RECONNECTION_BASE_DELAY)) - .thenReturn(Duration.ofMillis(100)); - ReconnectionPolicy constantReconnectionPolicy = mock(ConstantReconnectionPolicy.class); - - // when - ReconnectionPolicyInfo reconnectionPolicyInfo = - new ReconnectionPolicyInfoFinder() - .getReconnectionPolicyInfo(constantReconnectionPolicy, driverExecutionProfile); - - // then - assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("delayMs", 100L)); - assertThat(reconnectionPolicyInfo.getType()).contains("ConstantReconnectionPolicy"); - } - - @Test - public void should_find_an_info_about_exponential_reconnection_policy() { - ExponentialReconnectionPolicy exponentialReconnectionPolicy = - mock(ExponentialReconnectionPolicy.class); - when(exponentialReconnectionPolicy.getBaseDelayMs()).thenReturn(100L); - when(exponentialReconnectionPolicy.getMaxAttempts()).thenReturn(10L); - when(exponentialReconnectionPolicy.getMaxDelayMs()).thenReturn(200L); - - // when - ReconnectionPolicyInfo reconnectionPolicyInfo = - new ReconnectionPolicyInfoFinder() - .getReconnectionPolicyInfo(exponentialReconnectionPolicy, null); - - // then - assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("baseDelayMs", 100L)); - assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("maxAttempts", 10L)); - assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("maxDelayMs", 200L)); - assertThat(reconnectionPolicyInfo.getType()).contains("ExponentialReconnectionPolicy"); - } -} diff --git a/core/src/test/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContextTest.java b/core/src/test/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContextTest.java index baf101508d4..346250fb2b1 100644 --- a/core/src/test/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContextTest.java +++ b/core/src/test/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContextTest.java @@ -19,12 +19,17 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import com.datastax.dse.driver.api.core.config.DseDriverOption; 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.protocol.Lz4Compressor; import com.datastax.oss.driver.internal.core.protocol.SnappyCompressor; +import com.datastax.oss.driver.internal.core.util.LoggerTest; import com.datastax.oss.protocol.internal.Compressor; import com.datastax.oss.protocol.internal.NoopCompressor; import com.tngtech.java.junit.dataprovider.DataProvider; @@ -79,4 +84,53 @@ public void should_create_noop_compressor_if_defined_as_none(String name) { doCreateCompressorTest(Optional.of(name), NoopCompressor.class); } + + @Test + @SuppressWarnings("deprecation") + public void should_warn_when_removed_insights_monitoring_is_enabled() { + DriverExecutionProfile defaultProfile = mock(DriverExecutionProfile.class); + when(defaultProfile.isDefined(DefaultDriverOption.SESSION_NAME)).thenReturn(true); + when(defaultProfile.getString(DefaultDriverOption.SESSION_NAME)).thenReturn("test"); + when(defaultProfile.getBoolean(DseDriverOption.MONITOR_REPORTING_ENABLED, false)) + .thenReturn(true); + LoggerTest.LoggerSetup logger = + LoggerTest.setupTestLogger(InternalDriverContext.class, Level.WARN); + try { + MockedDriverContextFactory.defaultDriverContext(Optional.of(defaultProfile)); + + verify(logger.appender).doAppend(logger.loggingEventCaptor.capture()); + assertThat(logger.loggingEventCaptor.getValue()) + .extracting(ILoggingEvent::getFormattedMessage) + .isEqualTo( + "[test] Configuration option advanced.monitor-reporting.enabled is deprecated and " + + "ignored; DataStax Insights monitoring is no longer supported"); + } finally { + logger.close(); + } + } + + @Test + @SuppressWarnings("deprecation") + public void should_ignore_invalid_removed_insights_monitoring_option() { + DriverExecutionProfile defaultProfile = mock(DriverExecutionProfile.class); + when(defaultProfile.isDefined(DefaultDriverOption.SESSION_NAME)).thenReturn(true); + when(defaultProfile.getString(DefaultDriverOption.SESSION_NAME)).thenReturn("test"); + when(defaultProfile.getBoolean(DseDriverOption.MONITOR_REPORTING_ENABLED, false)) + .thenThrow(new IllegalArgumentException("wrong type")); + LoggerTest.LoggerSetup logger = + LoggerTest.setupTestLogger(InternalDriverContext.class, Level.WARN); + try { + MockedDriverContextFactory.defaultDriverContext(Optional.of(defaultProfile)); + + verify(logger.appender).doAppend(logger.loggingEventCaptor.capture()); + assertThat(logger.loggingEventCaptor.getValue()) + .extracting(ILoggingEvent::getFormattedMessage) + .isEqualTo( + "[test] Could not read deprecated configuration option " + + "advanced.monitor-reporting.enabled; it will be ignored " + + "(IllegalArgumentException: wrong type)"); + } finally { + logger.close(); + } + } } diff --git a/core/src/test/resources/insights/duplicate-dependencies.txt b/core/src/test/resources/insights/duplicate-dependencies.txt deleted file mode 100644 index a808dff3f57..00000000000 --- a/core/src/test/resources/insights/duplicate-dependencies.txt +++ /dev/null @@ -1,2 +0,0 @@ -io.netty:netty-handler:jar:4.0.56.Final:compile -io.netty:netty-handler:jar:4.1.2.Final:compile \ No newline at end of file diff --git a/core/src/test/resources/insights/malformed-pom.properties b/core/src/test/resources/insights/malformed-pom.properties deleted file mode 100644 index 0a503062fbd..00000000000 --- a/core/src/test/resources/insights/malformed-pom.properties +++ /dev/null @@ -1,22 +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. -# - -#Created by Apache Maven 3.5.0 -#no version -groupId=io.netty -artifactId=netty-handler \ No newline at end of file diff --git a/core/src/test/resources/insights/netty-dependency-optional.txt b/core/src/test/resources/insights/netty-dependency-optional.txt deleted file mode 100644 index 2bd0cd21a0c..00000000000 --- a/core/src/test/resources/insights/netty-dependency-optional.txt +++ /dev/null @@ -1 +0,0 @@ -io.netty:netty-handler:jar:4.0.0.Final:compile (optional) \ No newline at end of file diff --git a/core/src/test/resources/insights/netty-dependency.txt b/core/src/test/resources/insights/netty-dependency.txt deleted file mode 100644 index 69c350c30e8..00000000000 --- a/core/src/test/resources/insights/netty-dependency.txt +++ /dev/null @@ -1 +0,0 @@ -io.netty:netty-handler:jar:4.0.0.Final:runtime \ No newline at end of file diff --git a/core/src/test/resources/insights/ordered-dependencies.txt b/core/src/test/resources/insights/ordered-dependencies.txt deleted file mode 100644 index a5518f89736..00000000000 --- a/core/src/test/resources/insights/ordered-dependencies.txt +++ /dev/null @@ -1,3 +0,0 @@ -b-org.com:art1:jar:1.0:compile -a-org.com:art1:jar:2.0:compile -c-org.com:art1:jar:3.0:compile \ No newline at end of file diff --git a/core/src/test/resources/insights/pom.properties b/core/src/test/resources/insights/pom.properties deleted file mode 100644 index e68a31c8fc7..00000000000 --- a/core/src/test/resources/insights/pom.properties +++ /dev/null @@ -1,23 +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. -# - -#Created by Apache Maven 3.5.0 -version=4.0.56.Final -groupId=io.netty -artifactId=netty-handler - diff --git a/core/src/test/resources/insights/test-dependencies.txt b/core/src/test/resources/insights/test-dependencies.txt deleted file mode 100644 index e7158ef055e..00000000000 --- a/core/src/test/resources/insights/test-dependencies.txt +++ /dev/null @@ -1,31 +0,0 @@ - -The following files have been resolved: - com.github.jnr:jffi:jar:1.2.16:compile - org.ow2.asm:asm:jar:5.0.3:compile - com.github.jnr:jnr-constants:jar:0.9.9:compile - com.esri.geometry:esri-geometry-api:jar:1.2.1:compile - com.google.guava:guava:jar:19.0:compile - com.fasterxml.jackson.core:jackson-annotations:jar:2.8.11:compile - com.github.jnr:jnr-posix:jar:3.0.44:compile - org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile - io.netty:netty-handler:jar:4.0.56.Final:compile - org.ow2.asm:asm-commons:jar:5.0.3:compile - org.ow2.asm:asm-util:jar:5.0.3:compile - org.xerial.snappy:snappy-java:jar:1.1.2.6:compile (optional) - io.netty:netty-buffer:jar:4.0.56.Final:compile - com.github.jnr:jnr-ffi:jar:2.1.7:compile - com.fasterxml.jackson.core:jackson-core:jar:2.8.11:compile - org.hdrhistogram:HdrHistogram:jar:2.1.10:compile (optional) - org.ow2.asm:asm-tree:jar:5.0.3:compile - at.yawk.lz4:lz4-java:jar:1.8.1:compile (optional) - io.netty:netty-transport:jar:4.0.56.Final:compile - io.dropwizard.metrics:metrics-core:jar:3.2.2:compile - io.netty:netty-common:jar:4.0.56.Final:compile - com.fasterxml.jackson.core:jackson-databind:jar:2.7.9.3:compile - org.slf4j:slf4j-api:jar:1.7.25:compile - io.netty:netty-transport-native-epoll:jar:4.0.56.Final:compile (optional) - org.ow2.asm:asm-analysis:jar:5.0.3:compile - com.github.jnr:jnr-x86asm:jar:1.0.2:compile - io.netty:netty-codec:jar:4.0.56.Final:compile - org.json:json:jar:20090211:compile - com.github.jnr:jffi:jar:native:1.2.16:runtime \ No newline at end of file diff --git a/core/src/test/resources/project.properties b/core/src/test/resources/project.properties deleted file mode 100644 index 66eab90b6e4..00000000000 --- a/core/src/test/resources/project.properties +++ /dev/null @@ -1,19 +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. -# - -project.basedir=${basedir} \ No newline at end of file diff --git a/integration-tests/src/test/java/com/datastax/dse/driver/api/core/insights/InsightsClientIT.java b/integration-tests/src/test/java/com/datastax/dse/driver/api/core/insights/InsightsClientIT.java deleted file mode 100644 index 0296908be44..00000000000 --- a/integration-tests/src/test/java/com/datastax/dse/driver/api/core/insights/InsightsClientIT.java +++ /dev/null @@ -1,87 +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.api.core.insights; - -import com.datastax.dse.driver.internal.core.insights.InsightsClient; -import com.datastax.dse.driver.internal.core.insights.configuration.InsightsConfiguration; -import com.datastax.oss.driver.api.core.CqlSession; -import com.datastax.oss.driver.api.testinfra.ccm.CustomCcmRule; -import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement; -import com.datastax.oss.driver.api.testinfra.requirement.BackendType; -import com.datastax.oss.driver.api.testinfra.session.SessionRule; -import com.datastax.oss.driver.internal.core.context.InternalDriverContext; -import io.netty.util.concurrent.DefaultEventExecutor; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.RuleChain; -import org.junit.rules.TestRule; - -@BackendRequirement( - type = BackendType.DSE, - minInclusive = "6.7.0", - description = "DSE 6.7.0 required for Insights support") -public class InsightsClientIT { - private static final StackTraceElement[] EMPTY_STACK_TRACE = {}; - - private static CustomCcmRule ccmRule = - CustomCcmRule.builder() - .withNodes(1) - .withJvmArgs( - "-Dinsights.service_options_enabled=true", - "-Dinsights.default_mode=ENABLED_WITH_LOCAL_STORAGE") - .build(); - - private static SessionRule sessionRule = SessionRule.builder(ccmRule).build(); - - @ClassRule public static TestRule chain = RuleChain.outerRule(ccmRule).around(sessionRule); - - @Test - public void should_send_insights_startup_event_using_client() - throws ExecutionException, InterruptedException, TimeoutException { - // given - InsightsClient insightsClient = - InsightsClient.createInsightsClient( - new InsightsConfiguration(true, 300000L, new DefaultEventExecutor()), - (InternalDriverContext) sessionRule.session().getContext(), - EMPTY_STACK_TRACE); - - // when - insightsClient.sendStartupMessage().toCompletableFuture().get(1000, TimeUnit.SECONDS); - - // then no exception - } - - @Test - public void should_send_insights_status_event_using_client() - throws ExecutionException, InterruptedException, TimeoutException { - // given - InsightsClient insightsClient = - InsightsClient.createInsightsClient( - new InsightsConfiguration(true, 300000L, new DefaultEventExecutor()), - (InternalDriverContext) sessionRule.session().getContext(), - EMPTY_STACK_TRACE); - - // when - insightsClient.sendStatusMessage().toCompletableFuture().get(1000, TimeUnit.SECONDS); - - // then no exception - } -} diff --git a/integration-tests/src/test/java/com/datastax/oss/driver/internal/core/util/concurrent/DriverBlockHoundIntegrationCcmIT.java b/integration-tests/src/test/java/com/datastax/oss/driver/internal/core/util/concurrent/DriverBlockHoundIntegrationCcmIT.java index e0f058b00d0..c6594e102f2 100644 --- a/integration-tests/src/test/java/com/datastax/oss/driver/internal/core/util/concurrent/DriverBlockHoundIntegrationCcmIT.java +++ b/integration-tests/src/test/java/com/datastax/oss/driver/internal/core/util/concurrent/DriverBlockHoundIntegrationCcmIT.java @@ -66,9 +66,6 @@ public class DriverBlockHoundIntegrationCcmIT extends ContinuousPagingITBase { private static final CustomCcmRule CCM_RULE = CustomCcmRule.builder().build(); - // Note: Insights monitoring will be detected by BlockHound, but the error is swallowed and - // logged by DefaultSession.SingleThreaded.notifyListeners, so it's not necessary to explicitly - // disable Insights here. private static final SessionRule SESSION_RULE = SessionRule.builder(CCM_RULE).build(); @ClassRule public static TestRule chain = RuleChain.outerRule(CCM_RULE).around(SESSION_RULE); diff --git a/manual/core/integration/README.md b/manual/core/integration/README.md index 964e8388347..c764449553e 100644 --- a/manual/core/integration/README.md +++ b/manual/core/integration/README.md @@ -472,7 +472,6 @@ dependency: [Jackson](https://github.com/FasterXML/jackson) is used: -* when Insights monitoring is enabled; * when [Json codecs](../custom_codecs) are being used; * when driver configuration reporting is enabled — `advanced.driver-config-reporting.enabled`, which **defaults to true**. The report is serialized to JSON with Jackson. diff --git a/manual/core/non_blocking/README.md b/manual/core/non_blocking/README.md index d6b98081645..a3284ff2947 100644 --- a/manual/core/non_blocking/README.md +++ b/manual/core/non_blocking/README.md @@ -248,16 +248,6 @@ detectors. If that is the case, it is advised to disable hot-reloading by settin [`DriverConfigLoader`]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/config/DriverConfigLoader.html [hot-reloading]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/config/DriverConfigLoader.html#supportsReloading-- -#### Driver lock-free guarantees when connecting to DSE - -When connecting to clusters running recent DSE versions, the driver automatically enables periodic -status reporting. When preparing the status report, the driver has to hit the local filesystem, and -because of that, the status reporting process does not qualify as lock-free. - -If lock-freedom is being enforced, then automatic status reporting must be disabled by setting the -`datastax-java-driver.advanced.monitor-reporting.enabled` property to false in the driver -configuration. - ### Driver mechanism for detection of blocking calls The driver has its own mechanism for detecting blocking calls happening on an internal driver @@ -297,7 +287,6 @@ The following items are NOT declared to be allowed and are likely to be reported used: * Request throttlers; -* Automatic status reporting; * `SafeInitNodeStateListener`. Note that other blocking startup steps, e.g. loading of configuration files, are also not declared diff --git a/mapper-processor/pom.xml b/mapper-processor/pom.xml index 063dbeb7928..0ec33e00745 100644 --- a/mapper-processor/pom.xml +++ b/mapper-processor/pom.xml @@ -122,22 +122,6 @@ META-INF - - - src/test/resources - - project.properties - - true - - - src/test/resources - - project.properties - - false - - maven-compiler-plugin @@ -192,24 +176,6 @@ true - - 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/mapper/processor/deps.txt - - - - diff --git a/mapper-processor/src/test/java/com/datastax/dse/driver/internal/mapper/processor/DependencyCheckTest.java b/mapper-processor/src/test/java/com/datastax/dse/driver/internal/mapper/processor/DependencyCheckTest.java deleted file mode 100644 index 7aa2accb1fe..00000000000 --- a/mapper-processor/src/test/java/com/datastax/dse/driver/internal/mapper/processor/DependencyCheckTest.java +++ /dev/null @@ -1,41 +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.mapper.processor; - -import com.datastax.dse.driver.internal.DependencyCheckTestBase; -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", - "mapper", - "processor", - "deps.txt"); - } -} diff --git a/mapper-processor/src/test/resources/project.properties b/mapper-processor/src/test/resources/project.properties deleted file mode 100644 index 66eab90b6e4..00000000000 --- a/mapper-processor/src/test/resources/project.properties +++ /dev/null @@ -1,19 +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. -# - -project.basedir=${basedir} \ No newline at end of file diff --git a/mapper-runtime/pom.xml b/mapper-runtime/pom.xml index 0456e0406a8..a34911948e5 100644 --- a/mapper-runtime/pom.xml +++ b/mapper-runtime/pom.xml @@ -104,22 +104,6 @@ META-INF - - - src/test/resources - - project.properties - - true - - - src/test/resources - - project.properties - - false - - maven-jar-plugin @@ -198,24 +182,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/mapper/deps.txt - - - - diff --git a/mapper-runtime/src/test/java/com/datastax/dse/driver/api/mapper/DependencyCheckTest.java b/mapper-runtime/src/test/java/com/datastax/dse/driver/api/mapper/DependencyCheckTest.java deleted file mode 100644 index 03c1e5bb24f..00000000000 --- a/mapper-runtime/src/test/java/com/datastax/dse/driver/api/mapper/DependencyCheckTest.java +++ /dev/null @@ -1,40 +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.api.mapper; - -import com.datastax.dse.driver.internal.DependencyCheckTestBase; -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", - "mapper", - "deps.txt"); - } -} diff --git a/mapper-runtime/src/test/resources/project.properties b/mapper-runtime/src/test/resources/project.properties deleted file mode 100644 index 66eab90b6e4..00000000000 --- a/mapper-runtime/src/test/resources/project.properties +++ /dev/null @@ -1,19 +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. -# - -project.basedir=${basedir} \ No newline at end of file diff --git a/query-builder/pom.xml b/query-builder/pom.xml index efc52b9de6b..67b16cc7360 100644 --- a/query-builder/pom.xml +++ b/query-builder/pom.xml @@ -99,22 +99,6 @@ META-INF - - - src/test/resources - - project.properties - - true - - - src/test/resources - - project.properties - - false - - maven-jar-plugin @@ -137,24 +121,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/querybuilder/deps.txt - - - - diff --git a/query-builder/src/test/java/com/datastax/dse/driver/internal/querybuilder/DependencyCheckTest.java b/query-builder/src/test/java/com/datastax/dse/driver/internal/querybuilder/DependencyCheckTest.java deleted file mode 100644 index ff5dd1e66a4..00000000000 --- a/query-builder/src/test/java/com/datastax/dse/driver/internal/querybuilder/DependencyCheckTest.java +++ /dev/null @@ -1,40 +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.querybuilder; - -import com.datastax.dse.driver.internal.DependencyCheckTestBase; -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", - "querybuilder", - "deps.txt"); - } -} diff --git a/query-builder/src/test/resources/project.properties b/query-builder/src/test/resources/project.properties deleted file mode 100644 index 66eab90b6e4..00000000000 --- a/query-builder/src/test/resources/project.properties +++ /dev/null @@ -1,19 +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. -# - -project.basedir=${basedir} \ No newline at end of file diff --git a/upgrade_guide/README.md b/upgrade_guide/README.md index 83963f94775..46e4f8c33e3 100644 --- a/upgrade_guide/README.md +++ b/upgrade_guide/README.md @@ -19,6 +19,15 @@ under the License. ## Upgrade guide +### 4.19.2.2 + +#### DataStax Insights monitoring has been removed + +The driver no longer sends DataStax Insights startup or status events. The legacy +`advanced.monitor-reporting.enabled` option and its public constants remain deprecated no-ops for +source and binary compatibility. The option now defaults to `false`; setting it to `true` logs a +warning and has no other effect. + ### 4.19.2.1 #### The driver reports a session identifier, and its configuration, at connection time