shauryachats commented on code in PR #17421:
URL: https://github.com/apache/pinot/pull/17421#discussion_r2646127830


##########
pinot-broker/src/main/java/org/apache/pinot/broker/broker/helix/MultiClusterHelixBrokerStarter.java:
##########
@@ -0,0 +1,358 @@
+/**
+ * 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.pinot.broker.broker.helix;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.helix.HelixConstants.ChangeType;
+import org.apache.helix.HelixManager;
+import org.apache.helix.HelixManagerFactory;
+import org.apache.helix.InstanceType;
+import org.apache.pinot.broker.routing.manager.MultiClusterRoutingManager;
+import 
org.apache.pinot.broker.routing.manager.RemoteClusterBrokerRoutingManager;
+import org.apache.pinot.common.config.provider.TableCache;
+import org.apache.pinot.common.config.provider.ZkTableCache;
+import org.apache.pinot.core.routing.MultiClusterRoutingContext;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.CommonConstants.Helix;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Multi-cluster broker starter that extends the base Helix broker 
functionality
+ * to support federation across multiple Pinot clusters.
+ *
+ * This class handles:
+ * - Connection to remote clusters via separate ZooKeeper instances
+ * - Federated routing across primary and remote clusters
+ * - Cross-cluster query federation
+ * - Cluster change monitoring for remote clusters
+ */
+@SuppressWarnings("unused")
+public class MultiClusterHelixBrokerStarter extends BaseBrokerStarter {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(MultiClusterHelixBrokerStarter.class);
+
+  // Remote cluster configuration
+  protected List<String> _remoteClusterNames;
+  protected Map<String, String> _remoteZkServers;
+  protected String _remoteInstanceId;
+
+  // Remote cluster Helix managers and routing
+  protected Map<String, HelixManager> _remoteSpectatorHelixManager;
+  protected Map<String, RemoteClusterBrokerRoutingManager> 
_remoteRoutingManagers;
+  protected MultiClusterRoutingManager _multiClusterRoutingManager;
+  protected MultiClusterRoutingContext _multiClusterRoutingContext;
+  protected Map<String, ClusterChangeMediator> _remoteClusterChangeMediator;
+
+  public MultiClusterHelixBrokerStarter() {
+  }
+
+  @Override
+  public void init(PinotConfiguration brokerConf)
+      throws Exception {
+    super.init(brokerConf);
+    _remoteInstanceId = _instanceId + "_remote";
+    initRemoteClusterNamesAndZk(brokerConf);
+  }
+
+  @Override
+  public void start()
+      throws Exception {
+    LOGGER.info("[multi-cluster] Starting multi-cluster broker");
+    super.start();
+    // build routing tables for remote clusters
+    initRemoteClusterRouting();
+    LOGGER.info("[multi-cluster] Multi-cluster broker started successfully");
+  }
+
+  @Override
+  protected void initSpectatorHelixManager() throws Exception {
+    super.initSpectatorHelixManager();
+    try {
+      initRemoteClusterSpectatorHelixManagers();
+    } catch (Exception e) {
+      LOGGER.error("[multi-cluster] Failed to initialize remote cluster 
spectator Helix managers", e);

Review Comment:
   Good call. Will make the change.



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

Reply via email to