class DeploymentExpirer extends ControllerMaintainer {

    @Override
    protected boolean maintain() {
        boolean success = true;
        for (Application application : controller().applications().readable())
            for (Instance instance : application.instances().values())
                for (Deployment deployment : instance.deployments().values()) {
                    if ( ! isExpired(deployment)) continue;

                    try {
                        log.log(Level.INFO, "Expiring deployment of " + instance.id() + " in " + deployment.zone());
                        controller().applications().deactivate(instance.id(), deployment.zone());
                    } catch (Exception e) {
                        success = false;
                        log.log(Level.WARNING, "Could not expire " + deployment + " of " + instance +
                                               ": " + Exceptions.toMessageString(e) + ". Retrying in " +
                                               interval());
                    }
                }
        return success;
    }

    public  DeploymentExpirer(Controller controller, Duration interval);

}