Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.apache.helix.controller.rebalancer;
 * 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
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.

Allows one to come up with custom implementation of a rebalancer.
This will be invoked on all changes that happen in the cluster.
Simply return the resource assignment for a resource in this method.
public interface HelixRebalancer {
Initialize the rebalancer with a HelixManager if necessary

  public void init(HelixManager helixManager);

Given an ideal state for a resource and liveness of participants, compute a assignment of instances and states to each partition of a resource. This method provides all the relevant information needed to rebalance a resource. If you need additional information use manager.getAccessor to read and write the cluster data. This allows one to compute the ResourceAssignment according to app-specific requirements.

Say that you have:
 class MyRebalancerContext implements RebalancerContext
as your rebalancer context. To extract it from a RebalancerConfig, do the following:
 MyRebalancerContext context = rebalancerConfig.getRebalancerContext(MyRebalancerContext.class);

rebalancerConfig the properties of the resource for which a mapping will be computed
cluster complete snapshot of the cluster
currentState the current states of all partitions
      Cluster clusterResourceCurrentState currentState);
New to GrepCode? Check out our FAQ X