@Test public void cleanup() throws Exception { AtomicInteger passed = new AtomicInteger(); Configuration conf = new Configuration(); conf.set("test", "OK"); RuntimeResourceManager manager = new RuntimeResourceManager(conf) { @Override protected List<RuntimeResource> load() throws IOException { return Arrays.asList(new RuntimeResource() { @Override public void cleanup(ResourceConfiguration configuration) { passed.incrementAndGet(); assertThat(configuration.get("test", null), is("OK")); } }); } }; manager.setup(); assertThat(passed.get(), is(0)); manager.cleanup(); assertThat(passed.get(), is(1)); }
public void cleanup() throws IOException, InterruptedException { int count = resources.size(); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloading {0} runtime plugins", count)); } try { for (RuntimeResource resource : resources) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Deactivating runtime plugin: {0}", resource.getClass().getName())); } resource.cleanup(configuration); } } finally { this.resources = Collections.emptyList(); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloaded {0} runtime plugins", count)); } }
RuntimeResourceManager extends Configured { public void cleanup() throws IOException, InterruptedException { int count = resources.size(); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloading {0} runtime plugins", count)); } try { for (RuntimeResource resource : resources) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Deactivating runtime plugin: {0}", resource.getClass().getName())); } resource.cleanup(configuration); } } finally { this.resources = Collections.emptyList(); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloaded {0} runtime plugins", count)); } } }
RuntimeResourceManager extends Configured { public void cleanup() throws IOException, InterruptedException { int count = resources.size(); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloading {0} runtime plugins", count)); } try { for (RuntimeResource resource : resources) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Deactivating runtime plugin: {0}", resource.getClass().getName())); } resource.cleanup(configuration); } } finally { this.resources = Collections.emptyList(); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloaded {0} runtime plugins", count)); } } RuntimeResourceManager(Configuration configuration); }
RuntimeResourceManager extends Configured { public void cleanup() throws IOException, InterruptedException { int count = resources.size(); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloading {0} runtime plugins", count)); } try { for (RuntimeResource resource : resources) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Deactivating runtime plugin: {0}", resource.getClass().getName())); } resource.cleanup(configuration); } } finally { this.resources = Collections.emptyList(); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloaded {0} runtime plugins", count)); } } RuntimeResourceManager(Configuration configuration); void setup(); void cleanup(); }
RuntimeResourceManager extends Configured { public void cleanup() throws IOException, InterruptedException { int count = resources.size(); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloading {0} runtime plugins", count)); } try { for (RuntimeResource resource : resources) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Deactivating runtime plugin: {0}", resource.getClass().getName())); } resource.cleanup(configuration); } } finally { this.resources = Collections.emptyList(); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unloaded {0} runtime plugins", count)); } } RuntimeResourceManager(Configuration configuration); void setup(); void cleanup(); static final String CONFIGURATION_FILE_NAME; static final String CONFIGURATION_FILE_PATH; }