/** * Retrieve a list of key value pairs from configuration, stored under the provided key * * @param conf configuration to retrieve kvps from * @param key key under which the key values are stored * @return the list of kvps stored under key in conf, or null if the key isn't present. * @see #setKeyValues(Configuration, String, Collection, char) */ public static List<Map.Entry<String, String>> getKeyValues(Configuration conf, String key) { return getKeyValues(conf, key, KVP_DELIMITER); }
/** * Store a collection of Map.Entry's in conf, with each entry separated by ',' * and key values delimited by {@link #KVP_DELIMITER} * * @param conf configuration to store the collection in * @param key overall key to store keyValues under * @param keyValues kvps to be stored under key in conf */ public static void setKeyValues(Configuration conf, String key, Collection<Map.Entry<String, String>> keyValues) { setKeyValues(conf, key, keyValues, KVP_DELIMITER); }
public List<Map.Entry<String, String>> callGetKeyValues() { return ConfigurationUtil.getKeyValues(conf, key); }
public void setSnapshotDirs(Configuration conf, Map<String, Path> snapshotDirs) { Map<String, String> toSet = Maps.newHashMap(); for (Map.Entry<String, Path> entry : snapshotDirs.entrySet()) { toSet.put(entry.getKey(), entry.getValue().toString()); } ConfigurationUtil.setKeyValues(conf, RESTORE_DIRS_KEY, toSet.entrySet()); }
/** * Retrieve the directories into which snapshots have been restored from * ({@link #RESTORE_DIRS_KEY}) * * @param conf Configuration to extract restore directories from * @return the directories into which snapshots have been restored from * @throws IOException */ public Map<String, Path> getSnapshotDirs(Configuration conf) throws IOException { List<Map.Entry<String, String>> kvps = ConfigurationUtil.getKeyValues(conf, RESTORE_DIRS_KEY); Map<String, Path> rtn = Maps.newHashMapWithExpectedSize(kvps.size()); for (Map.Entry<String, String> kvp : kvps) { rtn.put(kvp.getKey(), new Path(kvp.getValue())); } return rtn; }
public void callSetKeyValues() { ConfigurationUtil.setKeyValues(conf, key, keyValues.entrySet()); }
/** * Retrieve the snapshot name -> list<scan> mapping pushed to configuration by * {@link #setSnapshotToScans(org.apache.hadoop.conf.Configuration, java.util.Map)} * * @param conf Configuration to extract name -> list<scan> mappings from. * @return the snapshot name -> list<scan> mapping pushed to configuration * @throws IOException */ public Map<String, Collection<Scan>> getSnapshotsToScans(Configuration conf) throws IOException { Map<String, Collection<Scan>> rtn = Maps.newHashMap(); for (Map.Entry<String, String> entry : ConfigurationUtil .getKeyValues(conf, SNAPSHOT_TO_SCANS_KEY)) { String snapshotName = entry.getKey(); String scan = entry.getValue(); Collection<Scan> snapshotScans = rtn.get(snapshotName); if (snapshotScans == null) { snapshotScans = Lists.newArrayList(); rtn.put(snapshotName, snapshotScans); } snapshotScans.add(TableMapReduceUtil.convertStringToScan(scan)); } return rtn; }
/** * Push snapshotScans to conf (under the key {@link #SNAPSHOT_TO_SCANS_KEY}) * * @param conf * @param snapshotScans * @throws IOException */ public void setSnapshotToScans(Configuration conf, Map<String, Collection<Scan>> snapshotScans) throws IOException { // flatten out snapshotScans for serialization to the job conf List<Map.Entry<String, String>> snapshotToSerializedScans = Lists.newArrayList(); for (Map.Entry<String, Collection<Scan>> entry : snapshotScans.entrySet()) { String snapshotName = entry.getKey(); Collection<Scan> scans = entry.getValue(); // serialize all scans and map them to the appropriate snapshot for (Scan scan : scans) { snapshotToSerializedScans.add(new AbstractMap.SimpleImmutableEntry<>(snapshotName, TableMapReduceUtil.convertScanToString(scan))); } } ConfigurationUtil.setKeyValues(conf, SNAPSHOT_TO_SCANS_KEY, snapshotToSerializedScans); }
/** * Retrieve a list of key value pairs from configuration, stored under the provided key * * @param conf configuration to retrieve kvps from * @param key key under which the key values are stored * @return the list of kvps stored under key in conf, or null if the key isn't present. * @see #setKeyValues(Configuration, String, Collection, char) */ public static List<Map.Entry<String, String>> getKeyValues(Configuration conf, String key) { return getKeyValues(conf, key, KVP_DELIMITER); }
/** * Store a collection of Map.Entry's in conf, with each entry separated by ',' * and key values delimited by {@link #KVP_DELIMITER} * * @param conf configuration to store the collection in * @param key overall key to store keyValues under * @param keyValues kvps to be stored under key in conf */ public static void setKeyValues(Configuration conf, String key, Collection<Map.Entry<String, String>> keyValues) { setKeyValues(conf, key, keyValues, KVP_DELIMITER); }
public List<Map.Entry<String, String>> callGetKeyValues() { return ConfigurationUtil.getKeyValues(conf, key); }
public void setSnapshotDirs(Configuration conf, Map<String, Path> snapshotDirs) { Map<String, String> toSet = Maps.newHashMap(); for (Map.Entry<String, Path> entry : snapshotDirs.entrySet()) { toSet.put(entry.getKey(), entry.getValue().toString()); } ConfigurationUtil.setKeyValues(conf, RESTORE_DIRS_KEY, toSet.entrySet()); }
/** * Retrieve the directories into which snapshots have been restored from * ({@link #RESTORE_DIRS_KEY}) * * @param conf Configuration to extract restore directories from * @return the directories into which snapshots have been restored from * @throws IOException */ public Map<String, Path> getSnapshotDirs(Configuration conf) throws IOException { List<Map.Entry<String, String>> kvps = ConfigurationUtil.getKeyValues(conf, RESTORE_DIRS_KEY); Map<String, Path> rtn = Maps.newHashMapWithExpectedSize(kvps.size()); for (Map.Entry<String, String> kvp : kvps) { rtn.put(kvp.getKey(), new Path(kvp.getValue())); } return rtn; }
public void setSnapshotDirs(Configuration conf, Map<String, Path> snapshotDirs) { Map<String, String> toSet = Maps.newHashMap(); for (Map.Entry<String, Path> entry : snapshotDirs.entrySet()) { toSet.put(entry.getKey(), entry.getValue().toString()); } ConfigurationUtil.setKeyValues(conf, RESTORE_DIRS_KEY, toSet.entrySet()); }
/** * Retrieve the directories into which snapshots have been restored from * ({@link #RESTORE_DIRS_KEY}) * * @param conf Configuration to extract restore directories from * @return the directories into which snapshots have been restored from * @throws IOException */ public Map<String, Path> getSnapshotDirs(Configuration conf) throws IOException { List<Map.Entry<String, String>> kvps = ConfigurationUtil.getKeyValues(conf, RESTORE_DIRS_KEY); Map<String, Path> rtn = Maps.newHashMapWithExpectedSize(kvps.size()); for (Map.Entry<String, String> kvp : kvps) { rtn.put(kvp.getKey(), new Path(kvp.getValue())); } return rtn; }
public void setSnapshotDirs(Configuration conf, Map<String, Path> snapshotDirs) { Map<String, String> toSet = Maps.newHashMap(); for (Map.Entry<String, Path> entry : snapshotDirs.entrySet()) { toSet.put(entry.getKey(), entry.getValue().toString()); } ConfigurationUtil.setKeyValues(conf, RESTORE_DIRS_KEY, toSet.entrySet()); }
/** * Retrieve the directories into which snapshots have been restored from * ({@link #RESTORE_DIRS_KEY}) * * @param conf Configuration to extract restore directories from * @return the directories into which snapshots have been restored from * @throws IOException */ public Map<String, Path> getSnapshotDirs(Configuration conf) throws IOException { List<Map.Entry<String, String>> kvps = ConfigurationUtil.getKeyValues(conf, RESTORE_DIRS_KEY); Map<String, Path> rtn = Maps.newHashMapWithExpectedSize(kvps.size()); for (Map.Entry<String, String> kvp : kvps) { rtn.put(kvp.getKey(), new Path(kvp.getValue())); } return rtn; }
public void callSetKeyValues() { ConfigurationUtil.setKeyValues(conf, key, keyValues.entrySet()); }
/** * Retrieve the snapshot name -> list<scan> mapping pushed to configuration by * {@link #setSnapshotToScans(org.apache.hadoop.conf.Configuration, java.util.Map)} * * @param conf Configuration to extract name -> list<scan> mappings from. * @return the snapshot name -> list<scan> mapping pushed to configuration * @throws IOException */ public Map<String, Collection<Scan>> getSnapshotsToScans(Configuration conf) throws IOException { Map<String, Collection<Scan>> rtn = Maps.newHashMap(); for (Map.Entry<String, String> entry : ConfigurationUtil .getKeyValues(conf, SNAPSHOT_TO_SCANS_KEY)) { String snapshotName = entry.getKey(); String scan = entry.getValue(); Collection<Scan> snapshotScans = rtn.get(snapshotName); if (snapshotScans == null) { snapshotScans = Lists.newArrayList(); rtn.put(snapshotName, snapshotScans); } snapshotScans.add(TableMapReduceUtil.convertStringToScan(scan)); } return rtn; }
/** * Push snapshotScans to conf (under the key {@link #SNAPSHOT_TO_SCANS_KEY}) * * @param conf * @param snapshotScans * @throws IOException */ public void setSnapshotToScans(Configuration conf, Map<String, Collection<Scan>> snapshotScans) throws IOException { // flatten out snapshotScans for serialization to the job conf List<Map.Entry<String, String>> snapshotToSerializedScans = Lists.newArrayList(); for (Map.Entry<String, Collection<Scan>> entry : snapshotScans.entrySet()) { String snapshotName = entry.getKey(); Collection<Scan> scans = entry.getValue(); // serialize all scans and map them to the appropriate snapshot for (Scan scan : scans) { snapshotToSerializedScans.add(new AbstractMap.SimpleImmutableEntry<>(snapshotName, TableMapReduceUtil.convertScanToString(scan))); } } ConfigurationUtil.setKeyValues(conf, SNAPSHOT_TO_SCANS_KEY, snapshotToSerializedScans); }