|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.pulsar.client.api; |
| 20 | + |
| 21 | +import java.util.List; |
| 22 | +import java.util.Map; |
| 23 | +import java.util.concurrent.TimeUnit; |
| 24 | +import org.apache.pulsar.common.classification.InterfaceAudience; |
| 25 | +import org.apache.pulsar.common.classification.InterfaceStability; |
| 26 | + |
| 27 | +/** |
| 28 | + * {@link AutoClusterFailoverBuilder} is used to configure and create instance of {@link ServiceUrlProvider}. |
| 29 | + * |
| 30 | + * @since 2.10.0 |
| 31 | + */ |
| 32 | +@InterfaceAudience.Public |
| 33 | +@InterfaceStability.Evolving |
| 34 | +public interface AutoClusterFailoverBuilder { |
| 35 | + |
| 36 | + @SuppressWarnings("checkstyle:javadoctype") |
| 37 | + enum FailoverPolicy { |
| 38 | + ORDER |
| 39 | + } |
| 40 | + /** |
| 41 | + * Set the primary service url. |
| 42 | + * |
| 43 | + * @param primary |
| 44 | + * @return |
| 45 | + */ |
| 46 | + AutoClusterFailoverBuilder primary(String primary); |
| 47 | + |
| 48 | + /** |
| 49 | + * Set the secondary service url. |
| 50 | + * |
| 51 | + * @param secondary |
| 52 | + * @return |
| 53 | + */ |
| 54 | + AutoClusterFailoverBuilder secondary(List<String> secondary); |
| 55 | + |
| 56 | + /** |
| 57 | + * Set secondary choose policy. The default secondary choose policy is `ORDER`. |
| 58 | + * @param policy |
| 59 | + * @return |
| 60 | + */ |
| 61 | + AutoClusterFailoverBuilder failoverPolicy(FailoverPolicy policy); |
| 62 | + |
| 63 | + /** |
| 64 | + * Set secondary authentication. |
| 65 | + * |
| 66 | + * @param authentication |
| 67 | + * @return |
| 68 | + */ |
| 69 | + AutoClusterFailoverBuilder secondaryAuthentication(Map<String, Authentication> authentication); |
| 70 | + |
| 71 | + /** |
| 72 | + * Set secondary tlsTrustCertsFilePath. |
| 73 | + * |
| 74 | + * @param tlsTrustCertsFilePath |
| 75 | + * @return |
| 76 | + */ |
| 77 | + AutoClusterFailoverBuilder secondaryTlsTrustCertsFilePath(Map<String, String> tlsTrustCertsFilePath); |
| 78 | + |
| 79 | + /** |
| 80 | + * Set secondary tlsTrustStorePath. |
| 81 | + * |
| 82 | + * @param tlsTrustStorePath |
| 83 | + * @return |
| 84 | + */ |
| 85 | + AutoClusterFailoverBuilder secondaryTlsTrustStorePath(Map<String, String> tlsTrustStorePath); |
| 86 | + |
| 87 | + /** |
| 88 | + * Set secondary tlsTrustStorePassword. |
| 89 | + * |
| 90 | + * @param tlsTrustStorePassword |
| 91 | + * @return |
| 92 | + */ |
| 93 | + AutoClusterFailoverBuilder secondaryTlsTrustStorePassword(Map<String, String> tlsTrustStorePassword); |
| 94 | + /** |
| 95 | + * Set the switch failoverDelay. When one cluster failed longer than failoverDelay, it will trigger cluster switch. |
| 96 | + * |
| 97 | + * @param failoverDelay |
| 98 | + * @param timeUnit |
| 99 | + * @return |
| 100 | + */ |
| 101 | + AutoClusterFailoverBuilder failoverDelay(long failoverDelay, TimeUnit timeUnit); |
| 102 | + |
| 103 | + /** |
| 104 | + * Set the switchBackDelay. When switched to the secondary cluster, and after the primary cluster comes back, |
| 105 | + * it will wait for switchBackDelay to switch back to the primary cluster. |
| 106 | + * |
| 107 | + * @param switchBackDelay |
| 108 | + * @param timeUnit |
| 109 | + * @return |
| 110 | + */ |
| 111 | + AutoClusterFailoverBuilder switchBackDelay(long switchBackDelay, TimeUnit timeUnit); |
| 112 | + |
| 113 | + /** |
| 114 | + * Set the checkInterval for probe. |
| 115 | + * |
| 116 | + * @param interval |
| 117 | + * @param timeUnit |
| 118 | + * @return |
| 119 | + */ |
| 120 | + AutoClusterFailoverBuilder checkInterval(long interval, TimeUnit timeUnit); |
| 121 | + |
| 122 | + /** |
| 123 | + * Build the ServiceUrlProvider instance. |
| 124 | + * |
| 125 | + * @return |
| 126 | + */ |
| 127 | + ServiceUrlProvider build(); |
| 128 | +} |
0 commit comments