JeetKunDoug commented on code in PR #74: URL: https://github.com/apache/cassandra-sidecar/pull/74#discussion_r1379257243
########## common/src/main/java/com/datastax/driver/core/DriverExtensions.java: ########## @@ -0,0 +1,67 @@ +/* + * 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.driver.core; + +import java.net.InetSocketAddress; + +/** + * A collection of methods that require access to package-private members in the datastax driver. + */ + +public class DriverExtensions +{ + /** + * Check if a host has active connections + * + * @param host the host to check + * @return true if the host has active connections, false otherwise + */ + public static boolean hasActiveConnections(Host host) + { + return host.convictionPolicy.hasActiveConnections(); + } + + /** + * Start attempting to reconnect to the given host, as hosts with `IGNORED` distance aren't attempted + * and the SidecarLoadBalancingPolicy marks non-selected nodes as IGNORED until they need to rotate in. + * + * @param cluster The cluster object + * @param host the host to which reconnect attempts will be made + */ + public static void startPeriodicReconnectionAttempt(Cluster cluster, Host host) + { + cluster.manager.startPeriodicReconnectionAttempt(host, false); + } + + /** + * Gets a Host instance from metadata based on the native Review Comment: "native transport address" to be consistent with renaming the broadcastRpcAddress member/variable everywhere, but yeah. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

