This commit is contained in:
Noble Paul 2017-05-24 16:26:12 +09:30
parent ba670a0c2a
commit cfe5cffddd
1 changed files with 25 additions and 4 deletions

View File

@ -46,16 +46,25 @@ import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toList;
/*The class that reads, parses and applies policies specified in
* autoscaling.json
*
* Create one instance of this class per unique autoscaling.json.
* This is immutable and is thread-safe
*
* Create a fresh new session for each use
*
*/
public class Policy implements MapWriter {
public static final String EACH = "#EACH";
public static final String ANY = "#ANY";
public static final String CLUSTER_POLICY = "cluster-policy";
public static final String CLUSTER_PREFERENCE = "cluster-preferences";
public static final Set<String> GLOBAL_ONLY_TAGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("cores")));
Map<String, List<Clause>> policies = new HashMap<>();
List<Clause> clusterPolicy;
List<Preference> clusterPreferences;
List<String> params = new ArrayList<>();
final Map<String, List<Clause>> policies = new HashMap<>();
final List<Clause> clusterPolicy;
final List<Preference> clusterPreferences;
final List<String> params = new ArrayList<>();
public Policy(Map<String, Object> jsonMap) {
@ -121,6 +130,10 @@ public class Policy implements MapWriter {
}
/*This stores the logical state of the system, given a policy and
* a cluster state.
*
*/
public class Session implements MapWriter {
final List<String> nodes;
final ClusterDataProvider dataProvider;
@ -301,6 +314,14 @@ public class Policy implements MapWriter {
}
/* A suggester is capable of suggesting a collection operation
* given a particular session. Before it suggests a new operation,
* it ensures that ,
* a) the node that it lightens load on the 'most loaded node' and/or 'lightens load'
* on the least loaded node
* b) it causes no new violations
*
*/
public static abstract class Suggester {
protected final EnumMap<Hint, Object> hints = new EnumMap<>(Hint.class);
Policy.Session session;