@Test public void testGetAllocationFileFromClasspath() { Configuration conf = new Configuration(); conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, "test-fair-scheduler.xml"); AllocationFileLoaderService allocLoader = new AllocationFileLoaderService(); File allocationFile = allocLoader.getAllocationFile(conf); assertEquals("test-fair-scheduler.xml", allocationFile.getName()); assertTrue(allocationFile.exists()); }
public File getAllocationFile(Configuration conf) { String allocFilePath = conf.get(FairSchedulerConfiguration.ALLOCATION_FILE, FairSchedulerConfiguration.DEFAULT_ALLOCATION_FILE); File allocFile = new File(allocFilePath); if (!allocFile.isAbsolute()) { URL url = Thread.currentThread().getContextClassLoader() .getResource(allocFilePath); if (url == null) { LOG.warn(allocFilePath + " not found on the classpath."); allocFile = null; } else if (!url.getProtocol().equalsIgnoreCase("file")) { throw new RuntimeException("Allocation file " + url + " found on the classpath is not on the local filesystem."); } else { allocFile = new File(url.getPath()); } } return allocFile; }
AllocationFileLoaderService extends AbstractService { public File getAllocationFile(Configuration conf) { String allocFilePath = conf.get(FairSchedulerConfiguration.ALLOCATION_FILE, FairSchedulerConfiguration.DEFAULT_ALLOCATION_FILE); File allocFile = new File(allocFilePath); if (!allocFile.isAbsolute()) { URL url = Thread.currentThread().getContextClassLoader() .getResource(allocFilePath); if (url == null) { LOG.warn(allocFilePath + " not found on the classpath."); allocFile = null; } else if (!url.getProtocol().equalsIgnoreCase("file")) { throw new RuntimeException("Allocation file " + url + " found on the classpath is not on the local filesystem."); } else { allocFile = new File(url.getPath()); } } return allocFile; } }
AllocationFileLoaderService extends AbstractService { public File getAllocationFile(Configuration conf) { String allocFilePath = conf.get(FairSchedulerConfiguration.ALLOCATION_FILE, FairSchedulerConfiguration.DEFAULT_ALLOCATION_FILE); File allocFile = new File(allocFilePath); if (!allocFile.isAbsolute()) { URL url = Thread.currentThread().getContextClassLoader() .getResource(allocFilePath); if (url == null) { LOG.warn(allocFilePath + " not found on the classpath."); allocFile = null; } else if (!url.getProtocol().equalsIgnoreCase("file")) { throw new RuntimeException("Allocation file " + url + " found on the classpath is not on the local filesystem."); } else { allocFile = new File(url.getPath()); } } return allocFile; } AllocationFileLoaderService();  AllocationFileLoaderService(Clock clock); }
AllocationFileLoaderService extends AbstractService { public File getAllocationFile(Configuration conf) { String allocFilePath = conf.get(FairSchedulerConfiguration.ALLOCATION_FILE, FairSchedulerConfiguration.DEFAULT_ALLOCATION_FILE); File allocFile = new File(allocFilePath); if (!allocFile.isAbsolute()) { URL url = Thread.currentThread().getContextClassLoader() .getResource(allocFilePath); if (url == null) { LOG.warn(allocFilePath + " not found on the classpath."); allocFile = null; } else if (!url.getProtocol().equalsIgnoreCase("file")) { throw new RuntimeException("Allocation file " + url + " found on the classpath is not on the local filesystem."); } else { allocFile = new File(url.getPath()); } } return allocFile; } AllocationFileLoaderService();  AllocationFileLoaderService(Clock clock); @Override void serviceInit(Configuration conf); @Override void serviceStart(); @Override void serviceStop(); File getAllocationFile(Configuration conf); synchronized void setReloadListener(Listener reloadListener); synchronized void reloadAllocations(); }
AllocationFileLoaderService extends AbstractService { public File getAllocationFile(Configuration conf) { String allocFilePath = conf.get(FairSchedulerConfiguration.ALLOCATION_FILE, FairSchedulerConfiguration.DEFAULT_ALLOCATION_FILE); File allocFile = new File(allocFilePath); if (!allocFile.isAbsolute()) { URL url = Thread.currentThread().getContextClassLoader() .getResource(allocFilePath); if (url == null) { LOG.warn(allocFilePath + " not found on the classpath."); allocFile = null; } else if (!url.getProtocol().equalsIgnoreCase("file")) { throw new RuntimeException("Allocation file " + url + " found on the classpath is not on the local filesystem."); } else { allocFile = new File(url.getPath()); } } return allocFile; } AllocationFileLoaderService();  AllocationFileLoaderService(Clock clock); @Override void serviceInit(Configuration conf); @Override void serviceStart(); @Override void serviceStop(); File getAllocationFile(Configuration conf); synchronized void setReloadListener(Listener reloadListener); synchronized void reloadAllocations(); static final Log LOG; static final long ALLOC_RELOAD_INTERVAL_MS; static final long ALLOC_RELOAD_WAIT_MS; static final long THREAD_JOIN_TIMEOUT_MS; }