Skip to content

Commit

Permalink
Tidy BrooklynLauncher
Browse files Browse the repository at this point in the history
  • Loading branch information
aledsage committed Feb 4, 2014
1 parent c7ba27f commit bf422d7
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import brooklyn.entity.basic.Entities;
import brooklyn.entity.basic.StartableApplication;
import brooklyn.entity.proxying.EntitySpec;
import brooklyn.entity.rebind.RebindManager;
import brooklyn.entity.rebind.RebindManagerImpl;
import brooklyn.entity.rebind.persister.BrooklynMementoPersisterToMultiFile;
import brooklyn.entity.trait.Startable;
Expand All @@ -41,6 +42,7 @@
import brooklyn.rest.security.BrooklynPropertiesSecurityFilter;
import brooklyn.util.exceptions.CompoundRuntimeException;
import brooklyn.util.exceptions.Exceptions;
import brooklyn.util.exceptions.RuntimeInterruptedException;
import brooklyn.util.net.Networking;
import brooklyn.util.stream.Streams;
import brooklyn.util.time.Duration;
Expand Down Expand Up @@ -436,14 +438,16 @@ protected void initPersistence() {
}
}

RebindManager rebindManager = managementContext.getRebindManager();
BrooklynMementoPersister persister = new BrooklynMementoPersisterToMultiFile(persistenceDir, managementContext.getCatalog().getRootClassLoader());
((RebindManagerImpl)managementContext.getRebindManager()).setPeriodicPersistPeriod(persistPeriod);
managementContext.getRebindManager().setPersister(persister);
((RebindManagerImpl)rebindManager).setPeriodicPersistPeriod(persistPeriod);
rebindManager.setPersister(persister);

if (rebinding) {
ClassLoader classLoader = managementContext.getCatalog().getRootClassLoader();
managementContext.getRebindManager().rebind(classLoader);
rebindManager.rebind(classLoader);
}
rebindManager.start();
}
} catch (Exception e) {
throw Exceptions.propagate(e);
Expand Down Expand Up @@ -508,6 +512,8 @@ public void terminate() {
Stopwatch stopwatch = Stopwatch.createStarted();
managementContext.getRebindManager().waitForPendingComplete(10, TimeUnit.SECONDS);
LOG.info("Finished waiting for persist; took "+Time.makeTimeStringRounded(stopwatch));
} catch (RuntimeInterruptedException e) {
Thread.currentThread().interrupt(); // keep going with shutdown
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // keep going with shutdown
} catch (TimeoutException e) {
Expand Down

0 comments on commit bf422d7

Please sign in to comment.