You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/06 11:24:03 UTC

[GitHub] [pinot] KKcorps commented on a diff in pull request #8467: pinot-java-client controller based broker selector

KKcorps commented on code in PR #8467:
URL: https://github.com/apache/pinot/pull/8467#discussion_r843826091


##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/ControllerBasedBrokerSelector.java:
##########
@@ -0,0 +1,56 @@
+/**
+ * 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.client;
+
+import java.util.List;
+
+
+/**
+ * Maintains broker cache using controller APIs
+ */
+public class ControllerBasedBrokerSelector implements BrokerSelector {
+    private final UpdatableBrokerCache _brokerCache;
+
+    public ControllerBasedBrokerSelector(String scheme, String controllerHost,
+        int controllerPort, long brokerUpdateFreqInMillis) {
+        // TODO pass the broker cache type via props
+        _brokerCache = new ScheduledBrokerCache(scheme, controllerHost, controllerPort, brokerUpdateFreqInMillis);
+        _brokerCache.init();
+    }
+
+    @Override
+    public String selectBroker(String table) {

Review Comment:
   Add a way to fetch broker list using tenant as well. The table name won't be available in case the selector is used in JDBC.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/PollingBasedBrokerCache.java:
##########
@@ -0,0 +1,104 @@
+/**
+ * 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.client;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.Future;
+import org.asynchttpclient.AsyncHttpClient;
+import org.asynchttpclient.BoundRequestBuilder;
+import org.asynchttpclient.Dsl;
+import org.asynchttpclient.Response;
+
+
+/**
+ * Maintains table -> list of brokers, supports update
+ * TODO can we introduce a simple websocket based controller endpoint to make the update reactive in the client?
+ */
+public class PollingBasedBrokerCache {

Review Comment:
   Some minor refactoring -
   * PollingBasedBrokerCache should just be BrokerCache since there is no polling logic there.
   * ScheduledBrokerCache should be BrokerCacheUpdatorPeriodic since it just updates and isn't concerned with how the cache stores the data.
   * ManuallyUpdatableBrokerCache to SyncBrokerCache (or a better name)



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org