public void refresh() throws IOException { HostDetails hostDetails = current.get(); refresh(hostDetails.includesFile, hostDetails.excludesFile); }
public HostsFileReader(String inFile, String exFile) throws IOException { HostDetails hostDetails = new HostDetails( inFile, Collections.emptySet(), exFile, Collections.emptyMap()); current = new AtomicReference<>(hostDetails); refresh(inFile, exFile); }
@Private public HostsFileReader(String includesFile, InputStream inFileInputStream, String excludesFile, InputStream exFileInputStream) throws IOException { HostDetails hostDetails = new HostDetails( includesFile, Collections.emptySet(), excludesFile, Collections.emptyMap()); current = new AtomicReference<>(hostDetails); refresh(inFileInputStream, exFileInputStream); }
public void refresh() throws IOException { this.writeLock.lock(); try { refresh(includesFile, excludesFile); } finally { this.writeLock.unlock(); } }
public HostsFileReader(String inFile, String exFile) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); includesFile = inFile; excludesFile = exFile; refresh(); }
public HostsFileReader(String inFile, String exFile) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); includesFile = inFile; excludesFile = exFile; refresh(); }
public HostsFileReader(String inFile, String exFile) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); includesFile = inFile; excludesFile = exFile; refresh(); }
public HostsFileReader(String inFile, String exFile) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); includesFile = inFile; excludesFile = exFile; refresh(); }
public HostsFileReader(String inFile, String exFile) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); includesFile = inFile; excludesFile = exFile; refresh(); }
public HostsFileReader(String inFile, String exFile) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); includesFile = inFile; excludesFile = exFile; ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); this.writeLock = rwLock.writeLock(); this.readLock = rwLock.readLock(); refresh(); }
@Private public HostsFileReader(String includesFile, InputStream inFileInputStream, String excludesFile, InputStream exFileInputStream) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); this.includesFile = includesFile; this.excludesFile = excludesFile; ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); this.writeLock = rwLock.writeLock(); this.readLock = rwLock.readLock(); refresh(inFileInputStream, exFileInputStream); }
@Private public HostsFileReader(String includesFile, InputStream inFileInputStream, String excludesFile, InputStream exFileInputStream) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); this.includesFile = includesFile; this.excludesFile = excludesFile; refresh(inFileInputStream, exFileInputStream); }
@Private public HostsFileReader(String includesFile, InputStream inFileInputStream, String excludesFile, InputStream exFileInputStream) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); this.includesFile = includesFile; this.excludesFile = excludesFile; refresh(inFileInputStream, exFileInputStream); }
@Private public HostsFileReader(String includesFile, InputStream inFileInputStream, String excludesFile, InputStream exFileInputStream) throws IOException { includes = new HashSet<String>(); excludes = new HashSet<String>(); this.includesFile = includesFile; this.excludesFile = excludesFile; refresh(inFileInputStream, exFileInputStream); }
private synchronized void refreshHosts() throws IOException { // Reread the config to get HOSTS and HOSTS_EXCLUDE filenames. // Update the file names and refresh internal includes and excludes list LOG.info("Refreshing hosts information"); Configuration conf = new Configuration(); hostsReader.updateFileNames(conf.get(JTConfig.JT_HOSTS_FILENAME,""), conf.get(JTConfig.JT_HOSTS_EXCLUDE_FILENAME, "")); hostsReader.refresh(); Set<String> excludeSet = new HashSet<String>(); for(Map.Entry<String, TaskTracker> eSet : taskTrackers.entrySet()) { String trackerName = eSet.getKey(); TaskTrackerStatus status = eSet.getValue().getStatus(); // Check if not include i.e not in host list or in hosts list but excluded if (!inHostsList(status) || inExcludedHostsList(status)) { excludeSet.add(status.getHost()); // add to rejected trackers } } decommissionNodes(excludeSet); }
private synchronized void refreshHosts() throws IOException { // Reread the config to get mapred.hosts and mapred.hosts.exclude filenames. // Update the file names and refresh internal includes and excludes list LOG.info("Refreshing hosts information"); Configuration conf = new Configuration(); hostsReader.updateFileNames(conf.get("mapred.hosts",""), conf.get("mapred.hosts.exclude", "")); hostsReader.refresh(); Set<String> excludeSet = new HashSet<String>(); for(Map.Entry<String, TaskTracker> eSet : taskTrackers.entrySet()) { String trackerName = eSet.getKey(); TaskTrackerStatus status = eSet.getValue().getStatus(); // Check if not include i.e not in host list or in hosts list but excluded if (!inHostsList(status) || inExcludedHostsList(status)) { excludeSet.add(status.getHost()); // add to rejected trackers } } decommissionNodes(excludeSet); int totalExcluded = hostsReader.getExcludedHosts().size(); getInstrumentation().setDecommissionedTrackers(totalExcluded); }
private void refreshHostsReader( Configuration yarnConf, boolean graceful, Integer timeout) throws IOException, YarnException { // resolve the default timeout to the decommission timeout that is // configured at this moment if (null == timeout) { timeout = readDecommissioningTimeout(yarnConf); } if (null == yarnConf) { yarnConf = new YarnConfiguration(); } includesFile = yarnConf.get(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, YarnConfiguration.DEFAULT_RM_NODES_INCLUDE_FILE_PATH); excludesFile = yarnConf.get(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, YarnConfiguration.DEFAULT_RM_NODES_EXCLUDE_FILE_PATH); LOG.info("refreshNodes excludesFile " + excludesFile); hostsReader.refresh(includesFile, excludesFile); printConfiguredHosts(); LOG.info("hostsReader include:{" + StringUtils.join(",", hostsReader.getHosts()) + "} exclude:{" + StringUtils.join(",", hostsReader.getExcludedHosts()) + "}"); handleExcludeNodeList(graceful, timeout); }
@Test public void testRefreshHostFileReaderWithNonexistentFile() throws Exception { FileWriter efw = new FileWriter(excludesFile); FileWriter ifw = new FileWriter(includesFile); efw.close(); ifw.close(); HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile); assertTrue(INCLUDES_FILE.delete()); try { hfp.refresh(); Assert.fail("Should throw FileNotFoundException"); } catch (FileNotFoundException ex) { // Exception as expected } }
@Test public void testRefreshHostFileReaderWithNonexistentFile() throws Exception { FileWriter efw = new FileWriter(excludesFile); FileWriter ifw = new FileWriter(includesFile); efw.close(); ifw.close(); HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile); assertTrue(INCLUDES_FILE.delete()); try { hfp.refresh(); Assert.fail("Should throw FileNotFoundException"); } catch (FileNotFoundException ex) { // Exception as expected } }
public void refreshNodes(Configuration yarnConf) throws IOException, YarnException { synchronized (hostsReader) { if (null == yarnConf) { yarnConf = new YarnConfiguration(); } includesFile = yarnConf.get(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, YarnConfiguration.DEFAULT_RM_NODES_INCLUDE_FILE_PATH); excludesFile = yarnConf.get(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, YarnConfiguration.DEFAULT_RM_NODES_EXCLUDE_FILE_PATH); hostsReader.updateFileNames(includesFile, excludesFile); hostsReader.refresh( includesFile.isEmpty() ? null : this.rmContext .getConfigurationProvider().getConfigurationInputStream( this.conf, includesFile), excludesFile.isEmpty() ? null : this.rmContext.getConfigurationProvider() .getConfigurationInputStream(this.conf, excludesFile)); printConfiguredHosts(); } for (NodeId nodeId: rmContext.getRMNodes().keySet()) { if (!isValidNode(nodeId.getHost())) { this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeEvent(nodeId, RMNodeEventType.DECOMMISSION)); } } }