hangc0276 commented on a change in pull request #13316:
URL: https://github.com/apache/pulsar/pull/13316#discussion_r778594720



##########
File path: 
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/AutoClusterFailoverBuilder.java
##########
@@ -0,0 +1,147 @@
+/**
+ * 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 org.apache.pulsar.client.api;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.apache.pulsar.common.classification.InterfaceAudience;
+import org.apache.pulsar.common.classification.InterfaceStability;
+
+/**
+ * {@link AutoClusterFailoverBuilder} is used to configure and create instance 
of {@link ServiceUrlProvider}
+ *
+ * @since 2.10.0
+ */
[email protected]
[email protected]
+public interface AutoClusterFailoverBuilder {
+    /**
+     * Set the primary service url.
+     *
+     * @param primary
+     * @return
+     */
+    AutoClusterFailoverBuilder primary(String primary);
+
+    /**
+     * Set the secondary service url.
+     *
+     * @param secondary
+     * @return
+     */
+    AutoClusterFailoverBuilder secondary(List<String> secondary);
+
+    /**
+     * Set primary authentication.
+     *
+     * @param authentication
+     * @return
+     */
+    AutoClusterFailoverBuilder primaryAuthentication(Authentication 
authentication);
+
+    /**
+     * Set secondary authentication.
+     *
+     * @param authentication
+     * @return
+     */
+    AutoClusterFailoverBuilder secondaryAuthentication(List<Authentication> 
authentication);

Review comment:
       done

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AutoClusterFailover.java
##########
@@ -0,0 +1,423 @@
+/**
+ * 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 org.apache.pulsar.client.impl;
+
+import static 
org.apache.pulsar.common.util.Runnables.catchingAndLoggingThrowables;
+import com.google.common.base.Strings;
+import io.netty.util.concurrent.DefaultThreadFactory;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import lombok.Data;
+import lombok.NonNull;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.client.api.Authentication;
+import org.apache.pulsar.client.api.AutoClusterFailoverBuilder;
+import org.apache.pulsar.client.api.PulsarClient;
+import org.apache.pulsar.client.api.ServiceUrlProvider;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+@Slf4j
+@Data
+public class AutoClusterFailover implements ServiceUrlProvider {
+    private PulsarClient pulsarClient;
+    private volatile String currentPulsarServiceUrl;
+    private final String primary;
+    private final List<String> secondary;
+    private final Authentication primaryAuthentication;
+    private final List<Authentication> secondaryAuthentications;
+    private final String primaryTlsTrustCertsFilePath;
+    private final List<String> secondaryTlsTrustCertsFilePaths;
+    private String primaryTlsTrustStorePath;
+    private List<String> secondaryTlsTrustStorePaths;
+    private String primaryTlsTrustStorePassword;
+    private List<String> secondaryTlsTrustStorePasswords;
+    private final long failoverDelayNs;
+    private final long switchBackDelayNs;
+    private final ScheduledExecutorService executor;
+    private long recoverTimestamp;
+    private long failedTimestamp;
+    private final long intervalMs;
+    private static final int TIMEOUT = 30_000;
+
+    private AutoClusterFailover(String primary, List<String> secondary, long 
failoverDelayNs, long switchBackDelayNs,

Review comment:
       done




-- 
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]


Reply via email to