brianloss commented on a change in pull request #1891: URL: https://github.com/apache/accumulo/pull/1891#discussion_r567325973
########## File path: core/src/main/java/org/apache/accumulo/core/spi/balancer/TabletBalancer.java ########## @@ -0,0 +1,122 @@ +/* + * 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; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; + +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.TabletId; +import org.apache.accumulo.core.spi.balancer.data.TServerStatus; +import org.apache.accumulo.core.spi.balancer.data.TabletMigration; +import org.apache.accumulo.core.spi.balancer.data.TabletServerId; + +/** + * This class is responsible for managing the distribution of tablets throughout an Accumulo + * cluster. In most cases, users will want a balancer implementation which ensures a uniform + * distribution of tablets, so that no individual tablet server is handling significantly more work + * than any other. + * + * <p> + * 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}. + * + * @since 2.1.0 + */ +public interface TabletBalancer { + + /** + * An interface for grouping parameters required for the balancer to assign unassigned tablets. + * This interface allows for evolution of the parameter set without changing the balancer's method + * signature. + * + * @since 2.1.0 + */ + interface AssignmentParameters { + /** + * @return the current status for all tablet servers (read-only) + */ + SortedMap<TabletServerId,TServerStatus> currentStatus(); + + /** + * @return the tablets that need to be assigned, mapped to their previous known location + * (read-only) + */ + Map<TabletId,TabletServerId> unassignedTablets(); + + /** + * @return a write-only map for storing new assignments + */ + Map<TabletId,TabletServerId> assignmentsOut(); + } + + /** + * An interface for grouping parameters required for the balancer to balance tablets. This + * interface allows for evolution of the parameter set without changing the balancer's method + * signature. + * + * @since 2.1.0 + */ + interface BalanceParameters { + /** + * @return the current status for all tablet servers (read-only) + */ + SortedMap<TabletServerId,TServerStatus> currentStatus(); + + /** + * @return the migrations that are currently in progress (read-only) + */ + Set<TabletId> currentMigrations(); + + /** + * @return a write-only map for storing new assignments made by the balancer. It is important + * that any tablets found in {@link #currentMigrations()} are not included in the output + * migrations. + */ + List<TabletMigration> migrationsOut(); Review comment: This is done in the latest commit. ---------------------------------------------------------------- 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]
