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 2020/10/09 03:30:31 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6119: Change Signature of Broker API in Controller

Jackie-Jiang commented on a change in pull request #6119:
URL: https://github.com/apache/incubator-pinot/pull/6119#discussion_r502132569



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
##########
@@ -474,6 +480,12 @@ public IdealState apply(@Nullable IdealState idealState) {
    * TODO: refactor code to use this method if applicable to reuse instance configs in order to reduce ZK accesses
    */
   public static Set<String> getBrokerInstancesForTenant(List<InstanceConfig> instanceConfigs, String tenant) {
-    return new HashSet<>(HelixHelper.getInstancesWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));
+    return getBrokerInstanceConfigsForTenant(instanceConfigs, tenant).stream().map(InstanceConfig::getInstanceName).collect(
+        Collectors.toSet());
   }
+
+  public static Set<InstanceConfig> getBrokerInstanceConfigsForTenant(List<InstanceConfig> instanceConfigs, String tenant) {
+    return new HashSet<>(HelixHelper.getInstancesConfigsWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));

Review comment:
       ```suggestion
       return new HashSet<>(getInstancesConfigsWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));
   ```

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
##########
@@ -474,6 +480,12 @@ public IdealState apply(@Nullable IdealState idealState) {
    * TODO: refactor code to use this method if applicable to reuse instance configs in order to reduce ZK accesses
    */
   public static Set<String> getBrokerInstancesForTenant(List<InstanceConfig> instanceConfigs, String tenant) {
-    return new HashSet<>(HelixHelper.getInstancesWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));
+    return getBrokerInstanceConfigsForTenant(instanceConfigs, tenant).stream().map(InstanceConfig::getInstanceName).collect(
+        Collectors.toSet());

Review comment:
       ```suggestion
       return new HashSet<>(getInstancesWithTag(instanceConfigs, TagNameUtils.getBrokerTagForTenant(tenant)));
   ```

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/ControllerBrokerResponse.java
##########
@@ -0,0 +1,55 @@
+/**
+ * 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.controller.api.resources;
+
+public class ControllerBrokerResponse {
+  private String _instanceName;

Review comment:
       You can change these variables to final and remove the setters as they are not needed

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
##########
@@ -422,10 +423,15 @@ public IdealState apply(@Nullable IdealState idealState) {
    * reuse instance configs in order to reduce ZK accesses
    */
   public static List<String> getInstancesWithTag(List<InstanceConfig> instanceConfigs, String tag) {
-    List<String> instancesWithTag = new ArrayList<>();
+    List<InstanceConfig> instancesWithTag = getInstancesConfigsWithTag(instanceConfigs, tag);
+    return instancesWithTag.stream().map(InstanceConfig::getInstanceName).collect(Collectors.toList());

Review comment:
       Can we keep the old implementation as there are performance differences

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/Constants.java
##########
@@ -36,6 +36,7 @@
   public static final String SCHEMA_TAG = "Schema";
   public static final String TENANT_TAG = "Tenant";
   public static final String BROKER_TAG = "Broker";
+  public static final String BROKER_V2_TAG = "BrokerV2";

Review comment:
       Is this used?

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
##########
@@ -348,6 +348,11 @@ public InstanceZKMetadata getInstanceZKMetadata(String instanceId) {
    * @return List of broker instance Ids
    */
   public List<String> getBrokerInstancesFor(String tableName) {
+    List<InstanceConfig> instanceConfigList = getBrokerInstancesConfigsFor(tableName);
+    return instanceConfigList.stream().map(InstanceConfig::getInstanceName).collect(Collectors.toList());

Review comment:
       Again suggest keeping the current logic for performance concern if this will be called frequently. You may extract a helper function for getting the `brokerTenantName` to avoid duplicate code

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/ControllerBrokerResponse.java
##########
@@ -0,0 +1,55 @@
+/**
+ * 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.controller.api.resources;
+
+public class ControllerBrokerResponse {

Review comment:
       Suggest renaming it to `InstanceInfo` so that it can be reused for server instances if necessary.




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

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