private Map<String, String> load() { Map<String, String> loadMap = new HashMap<String, String>(); String filename = getConf().get(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY, null); if (StringUtils.isBlank(filename)) { LOG.warn(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY + " not configured. "); return null; } try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(filename), StandardCharsets.UTF_8))) { String line = reader.readLine(); while (line != null) { line = line.trim(); if (line.length() != 0 && line.charAt(0) != '#') { String[] columns = line.split("\\s+"); if (columns.length == 2) { loadMap.put(columns[0], columns[1]); } else { LOG.warn("Line does not have two columns. Ignoring. " + line); } } line = reader.readLine(); } } catch (Exception e) { LOG.warn(filename + " cannot be read.", e); return null; } return loadMap; }
@Override public synchronized List<String> resolve(List<String> names) { if (map == null) { map = load(); if (map == null) { LOG.warn("Failed to read topology table. " + NetworkTopology.DEFAULT_RACK + " will be used for all nodes."); map = new HashMap<String, String>(); } } List<String> results = new ArrayList<String>(names.size()); for (String name : names) { String result = map.get(name); if (result != null) { results.add(result); } else { results.add(NetworkTopology.DEFAULT_RACK); } } return results; }
private Map<String, String> load() { Map<String, String> loadMap = new HashMap<String, String>(); String filename = getConf().get(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY, null); if (StringUtils.isBlank(filename)) { LOG.warn(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY + " not configured. "); return null; } try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(filename), Charsets.UTF_8))) { String line = reader.readLine(); while (line != null) { line = line.trim(); if (line.length() != 0 && line.charAt(0) != '#') { String[] columns = line.split("\\s+"); if (columns.length == 2) { loadMap.put(columns[0], columns[1]); } else { LOG.warn("Line does not have two columns. Ignoring. " + line); } } line = reader.readLine(); } } catch (Exception e) { LOG.warn(filename + " cannot be read.", e); return null; } return loadMap; }
private Map<String, String> load() { Map<String, String> loadMap = new HashMap<String, String>(); String filename = getConf().get(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY, null); if (StringUtils.isBlank(filename)) { LOG.warn(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY + " not configured. "); return null; } try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(filename), Charsets.UTF_8))) { String line = reader.readLine(); while (line != null) { line = line.trim(); if (line.length() != 0 && line.charAt(0) != '#') { String[] columns = line.split("\\s+"); if (columns.length == 2) { loadMap.put(columns[0], columns[1]); } else { LOG.warn("Line does not have two columns. Ignoring. " + line); } } line = reader.readLine(); } } catch (Exception e) { LOG.warn(filename + " cannot be read.", e); return null; } return loadMap; }
private Map<String, String> load() { Map<String, String> loadMap = new HashMap<String, String>(); String filename = getConf().get(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY, null); if (StringUtils.isBlank(filename)) { LOG.warn(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY + " not configured. "); return null; } try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(filename), Charsets.UTF_8))) { String line = reader.readLine(); while (line != null) { line = line.trim(); if (line.length() != 0 && line.charAt(0) != '#') { String[] columns = line.split("\\s+"); if (columns.length == 2) { loadMap.put(columns[0], columns[1]); } else { LOG.warn("Line does not have two columns. Ignoring. " + line); } } line = reader.readLine(); } } catch (Exception e) { LOG.warn(filename + " cannot be read.", e); return null; } return loadMap; }
private Map<String, String> load() { Map<String, String> loadMap = new HashMap<String, String>(); String filename = getConf().get(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY, null); if (StringUtils.isBlank(filename)) { LOG.warn(NET_TOPOLOGY_TABLE_MAPPING_FILE_KEY + " not configured. "); return null; } try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(filename), StandardCharsets.UTF_8))) { String line = reader.readLine(); while (line != null) { line = line.trim(); if (line.length() != 0 && line.charAt(0) != '#') { String[] columns = line.split("\\s+"); if (columns.length == 2) { loadMap.put(columns[0], columns[1]); } else { LOG.warn("Line does not have two columns. Ignoring. " + line); } } line = reader.readLine(); } } catch (Exception e) { LOG.warn(filename + " cannot be read.", e); return null; } return loadMap; }
@Override public synchronized List<String> resolve(List<String> names) { if (map == null) { map = load(); if (map == null) { LOG.warn("Failed to read topology table. " + NetworkTopology.DEFAULT_RACK + " will be used for all nodes."); map = new HashMap<String, String>(); } } List<String> results = new ArrayList<String>(names.size()); for (String name : names) { String result = map.get(name); if (result != null) { results.add(result); } else { results.add(NetworkTopology.DEFAULT_RACK); } } return results; }
@Override public synchronized List<String> resolve(List<String> names) { if (map == null) { map = load(); if (map == null) { LOG.warn("Failed to read topology table. " + NetworkTopology.DEFAULT_RACK + " will be used for all nodes."); map = new HashMap<String, String>(); } } List<String> results = new ArrayList<String>(names.size()); for (String name : names) { String result = map.get(name); if (result != null) { results.add(result); } else { results.add(NetworkTopology.DEFAULT_RACK); } } return results; }
@Override public synchronized List<String> resolve(List<String> names) { if (map == null) { map = load(); if (map == null) { LOG.warn("Failed to read topology table. " + NetworkTopology.DEFAULT_RACK + " will be used for all nodes."); map = new HashMap<String, String>(); } } List<String> results = new ArrayList<String>(names.size()); for (String name : names) { String result = map.get(name); if (result != null) { results.add(result); } else { results.add(NetworkTopology.DEFAULT_RACK); } } return results; }
@Override public synchronized List<String> resolve(List<String> names) { if (map == null) { map = load(); if (map == null) { LOG.warn("Failed to read topology table. " + NetworkTopology.DEFAULT_RACK + " will be used for all nodes."); map = new HashMap<String, String>(); } } List<String> results = new ArrayList<String>(names.size()); for (String name : names) { String result = map.get(name); if (result != null) { results.add(result); } else { results.add(NetworkTopology.DEFAULT_RACK); } } return results; }
public TableMapping() { super(new RawTableMapping()); }
public TableMapping() { super(new RawTableMapping()); }
public TableMapping() { super(new RawTableMapping()); }
public TableMapping() { super(new RawTableMapping()); }
@Override public Configuration getConf() { return getRawMapping().getConf(); }
@Override public Configuration getConf() { return getRawMapping().getConf(); }
@Override public void reloadCachedMappings() { Map<String, String> newMap = load(); if (newMap == null) { LOG.error("Failed to reload the topology table. The cached " + "mappings will not be cleared."); } else { synchronized(this) { map = newMap; } } }
@Override public void reloadCachedMappings(List<String> names) { // TableMapping has to reload all mappings at once, so no chance to // reload mappings on specific nodes reloadCachedMappings(); } }
@Override public void reloadCachedMappings(List<String> names) { // TableMapping has to reload all mappings at once, so no chance to // reload mappings on specific nodes reloadCachedMappings(); } }
@Override public Configuration getConf() { return getRawMapping().getConf(); }