public static AddonFilter allStarted() { return (addon) -> addon.getStatus().isStarted(); }
public static AddonFilter allLoaded() { return (addon) -> addon.getStatus().isLoaded(); }
/** * Waits until the specified {@link Addon} starts or is missing */ public static void waitUntilStartedOrMissing(Addon addon, int quantity, TimeUnit unit) throws TimeoutException { if (addon != null) { long start = System.currentTimeMillis(); long threshold = start + TimeUnit.MILLISECONDS.convert(quantity, unit); while (!addon.getStatus().isStarted() && !addon.getStatus().isMissing()) { if (System.currentTimeMillis() > threshold) { throw new TimeoutException("Timeout expired waiting for [" + addon + "] to load."); } try { Thread.sleep(10); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new ContainerException("Addon [" + addon + "] was not loaded.", e); } } } }
private void waitForDeploymentCompletion(Deployment deployment, final AddonId addonToDeploy, int quantity, TimeUnit unit) throws DeploymentException { AddonRegistry registry = runnable.getForge().getAddonRegistry(); Addon addon = registry.getAddon(addonToDeploy); try { Future<Void> future = addon.getFuture(); if (!future.isDone()) { future.get(); } Addons.waitUntilStartedOrMissing(addon, quantity, unit); } catch (Exception e) { deployment.deployedWithError(e); throw new DeploymentException("AddonDependency " + addonToDeploy + " failed to deploy.", e); } if (addon.getStatus().isFailed()) { DeploymentException e = new DeploymentException("AddonDependency " + addonToDeploy + " failed to deploy."); deployment.deployedWithError(e); throw new DeploymentException("AddonDependency " + addonToDeploy + " failed to deploy.", e); } }
public static AddonFilter allNotStarted() { return (addon) -> !addon.getStatus().isStarted(); }
if (addonToStop.getStatus().isLoaded()) ((MutableAddonRepository) addonToStop.getRepository()).disable(addonToUndeploy); Addons.waitUntilStopped(addonToStop);
public static void waitUntilStarted(Addon addon) { try { while (!addon.getStatus().isStarted()) { Thread.sleep(10); } } catch (Exception e) { throw new ContainerException("Addon [" + addon + "] was not started.", e); } }
public static void waitUntilStopped(Addon addon) { if (addon != null) { try { while (addon.getStatus().isStarted()) { Thread.sleep(10); } } catch (Exception e) { throw new ContainerException("Addon [" + addon + "] was not stopped.", e); } } }
public static void waitUntilStarted(Addon addon, int quantity, TimeUnit unit) throws TimeoutException { long start = System.currentTimeMillis(); long threshold = start + TimeUnit.MILLISECONDS.convert(quantity, unit); while (!addon.getStatus().isStarted()) { if (System.currentTimeMillis() > threshold) { throw new TimeoutException("Timeout expired waiting for [" + addon + "] to start."); } try { Thread.sleep(10); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new ContainerException("Addon [" + addon + "] was not started.", e); } } }
public static void waitUntilStopped(Addon addon, int quantity, TimeUnit unit) throws TimeoutException { if (addon != null) { long start = System.currentTimeMillis(); long threshold = start + TimeUnit.MILLISECONDS.convert(quantity, unit); while (addon.getStatus().isStarted()) { if (System.currentTimeMillis() > threshold) { throw new TimeoutException("Timeout expired waiting for [" + addon + "] to stop."); } try { Thread.sleep(10); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new ContainerException("Addon [" + addon + "] was not stopped.", e); } } } }
future.get(); if (addon.getStatus().isStarted())