needlestack.balancers package¶
Submodules¶
needlestack.balancers.greedy module¶
-
class
needlestack.balancers.greedy.GreedyAlgorithm[source]¶ Bases:
needlestack.balancers.knapsack.AlgorithmGreedy algorithm that places the largest item in the lightest knapsack, then repeat until all items are placed somewhere.
needlestack.balancers.knapsack module¶
-
class
needlestack.balancers.knapsack.Algorithm[source]¶ Bases:
objectSuperclass for algorithm to place items in knapsacks
-
class
needlestack.balancers.knapsack.Item(collection, shard)[source]¶ Bases:
objectItem that goes into a knapsack
-
id¶ ID for item
-
collection¶
-
shard¶
-
quantity¶ How many of these item should exist
-
weight¶ How much this item weighs
-
property
id
-
property
quantity
-
property
weight
-
-
class
needlestack.balancers.knapsack.Knapsack(node, capacity=None)[source]¶ Bases:
objectKnapsack that can hold multiple items
-
id¶ ID for knapsack
-
node¶ Value this knapsack is representing
-
items¶ Set of items in knapsack
-
current_weight¶ Current weight in the knapsack
-
capacity¶ Max weight for knapsack
-
capacity= None
-
property
id
-
-
needlestack.balancers.knapsack.calculate_add(nodes, current_collections, add_collections, algorithm)[source]¶ Determine how to add a set of collections to an existing set of collections.
- Return type
List[Collection]
-
needlestack.balancers.knapsack.calculate_rebalance(nodes, current_collections, algorithm)[source]¶ - Return type
List[Collection]