diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java new file mode 100644 index 0000000..1bae2d1 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java @@ -0,0 +1,92 @@ +package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * YarnConfigurationStore exposes the methods needed for retrieving and + * persisting {@link CapacityScheduler} configuration via key-value. + * Each configuration mutation is associated with an incrementing id, which + * is used for sequencing the audit logs as well as write-ahead + * logging/recovery. + */ +public interface YarnConfigurationStore { + + /** + * LogItem encapsulates the fields needed for configuration mutation + * audit logging and recovery. + */ + class LogItem { + private Map updates; + private Collection removes; + private String user; + private int id; + + public LogItem(Map updates, Collection removes, + String user, int id) { + this.updates = updates; + this.removes = removes; + this.user = user; + this.id = id; + } + + public Map getUpdates() { + return updates; + } + + public Collection getRemoves() { + return removes; + } + + public String getUser() { + return user; + } + + public int getId() { + return id; + } + } + + /** + * Initialize the configuration store. + * @param conf + * @param schedConf Initial key-value configuration to persist + */ + void initialize(Configuration conf, Map schedConf); + + /** + * Retrieve the configuration in the store. + * @return Configuration as key-value + */ + Map retrieve(); + + /** + * Persist the configuration modifications to the store. + * @param updates Configuration key-value pairs to add/update. + * @param removes Configuration keys to remove from store. + */ + void store(Map updates, Collection removes); + + /** + * Read the id of the configuration change to be stored next. + * @return Next configuration change transaction id + */ + int readPersistedId(); + + /** + * Get an ordered list of mutations with transaction id >= {@code id}. + * @param id The min id to retrieve + * @return List of logged configuration changes, in sequential id order + */ + List getMutations(int id); + + /** + * Logs the configuration change and associated metadata to backing store. + * @param logItem + */ + void logMutations(LogItem logItem); +}