ctubbsii commented on a change in pull request #1891:
URL: https://github.com/apache/accumulo/pull/1891#discussion_r567098221



##########
File path: 
core/src/main/java/org/apache/accumulo/core/client/PluginEnvironment.java
##########
@@ -122,6 +121,16 @@
      */
     @Override
     Iterator<Entry<String,String>> iterator();
+
+    /**
+     * Returns a derived value from this Configuration. The returned value 
supplier is thread-safe
+     * and attempts to avoid re-computation of the response. The intended use 
for a derived value is
+     * to ensure that configuration changes that may be made in Zookeeper, for 
example, are always
+     * reflected in the returned value.
+     *
+     * @since 2.1.0

Review comment:
       This actually doesn't need the since tag, since the entire class is new 
in 2.1.

##########
File path: 
core/src/main/java/org/apache/accumulo/core/client/PluginEnvironment.java
##########
@@ -158,6 +167,18 @@
    */
   <T> T instantiate(String className, Class<T> base) throws Exception;
 
+  /**
+   * Loads a class using Accumulo's system classloader.
+   *
+   * @param className
+   *          Fully qualified name of the class.
+   * @param base
+   *          The expected super type of the class.
+   *
+   * @since 2.1.0
+   */
+  <T> Class<? extends T> loadClass(String className, Class<T> base) throws 
ClassNotFoundException;

Review comment:
       What's the use case for this being in the public API?
   Note: we're transitioning how we do class loading, and phasing out some 
internal class loading stuffs. We should avoid exposing stuff like this to the 
public API. The user should be able to just load the class themselves, using 
their own object's classloader, if they need to.

##########
File path: 
core/src/main/java/org/apache/accumulo/core/client/PluginEnvironment.java
##########
@@ -33,10 +35,7 @@
  */
 public interface PluginEnvironment {
 
-  /**
-   * @since 2.1.0
-   */

Review comment:
       Should preserve the since tag, since it's an inner-interface, and has 
its own apidoc page as a separate type.

##########
File path: 
core/src/main/java/org/apache/accumulo/core/manager/balancer/TServerStatusImpl.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.accumulo.core.manager.balancer;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import org.apache.accumulo.core.master.thrift.TabletServerStatus;
+import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
+import org.apache.accumulo.core.spi.balancer.data.TableStatistics;
+
+public class TServerStatusImpl implements TServerStatus {
+  private final TabletServerStatus thriftStatus;
+  private Map<String,TableStatistics> tableInfoMap;
+
+  public static TServerStatusImpl fromThrift(TabletServerStatus tss) {
+    return (tss == null) ? null : new TServerStatusImpl(tss);
+  }
+
+  public TServerStatusImpl(TabletServerStatus thriftStatus) {
+    Objects.requireNonNull(thriftStatus);
+
+    this.thriftStatus = thriftStatus;

Review comment:
       This is cleanest with a static import of `requireNonNull`:
   ```suggestion
       this.thriftStatus = requireNonNull(thriftStatus);
   ```
   But, even without a static import, you can still one-line this:
   ```suggestion
       this.thriftStatus = Objects.requireNonNull(thriftStatus);
   ```
   

##########
File path: 
server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java
##########
@@ -56,7 +56,11 @@
  * Implementations may wish to store configuration in Accumulo's system 
configuration using the
  * {@link Property#GENERAL_ARBITRARY_PROP_PREFIX}. They may also benefit from 
using per-table
  * configuration using {@link Property#TABLE_ARBITRARY_PROP_PREFIX}.
+ *
+ * @deprecated since 2.1.0. Use {@link 
org.apache.accumulo.core.spi.balancer.TabletBalancer}
+ *             instead.
  */
+@Deprecated(since = "2.1.0")
 public abstract class TabletBalancer {

Review comment:
       Is there any way we can make this implement or extend the SPI version, 
so we automatically support compatibility with any implementations of the old 
interface, without two code paths in the manager?

##########
File path: 
core/src/main/java/org/apache/accumulo/core/spi/balancer/data/TabletMigration.java
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.accumulo.core.spi.balancer.data;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TabletId;
+
+/**
+ * @since 2.1.0
+ */
+public class TabletMigration {
+  private final TabletId tabletId;
+  private final TabletServerId oldTabletServer;
+  private final TabletServerId newTabletServer;
+
+  public TabletMigration(TabletId tabletId, TabletServerId oldTabletServer,
+      TabletServerId newTabletServer) {
+    requireNonNull(tabletId);
+    requireNonNull(oldTabletServer);
+    requireNonNull(newTabletServer);
+
+    this.tabletId = tabletId;
+    this.oldTabletServer = oldTabletServer;
+    this.newTabletServer = newTabletServer;

Review comment:
       ```suggestion
       this.tabletId = requireNonNull(tabletId);
       this.oldTabletServer = requireNonNull(oldTabletServer);
       this.newTabletServer = requireNonNull(newTabletServer);
   ```

##########
File path: server/manager/src/main/java/org/apache/accumulo/master/Master.java
##########
@@ -1686,4 +1741,56 @@ public boolean isActiveService() {
     return masterInitialized.get();
   }
 
+  @SuppressWarnings("deprecation")
+  void initializeBalancer() {
+
+    // Try to initialize the defined balancer as the updated TabletBalancer 
class first. If that
+    // fails with a ClassCastException, it means the property is specified as 
the deprecated
+    // balancer type, so initialize it instead. If we still end up with no 
balancer, then use
+    // DefaultLoadBalancer.
+    try {
+      tabletBalancer = 
Property.createInstanceFromPropertyName(getConfiguration(),
+          Property.TABLE_LOAD_BALANCER, TabletBalancer.class, null);
+    } catch (ClassCastException e) {
+      // ignore -- this means that the deprecated balancer type was used
+      deprecatedTabletBalancer = 
Property.createInstanceFromPropertyName(getConfiguration(),
+          Property.MANAGER_TABLET_BALANCER,
+          org.apache.accumulo.server.master.balancer.TabletBalancer.class, 
null);
+    }

Review comment:
       If the old were made to implement or extend the new SPI, then we 
wouldn't need to have two code paths here.




----------------------------------------------------------------
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:
[email protected]


Reply via email to