Java Code Examples for io.dropwizard.lifecycle.Managed#start()

The following examples show how to use io.dropwizard.lifecycle.Managed#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultReplicationManager.java    From emodb with Apache License 2.0 5 votes vote down vote up
@Override
protected void runOneIteration() throws Exception {
    try {
        // Start replication for all new data centers.
        Map<String, Managed> active = Maps.newHashMap(_dataCenterFanout);
        DataCenter self = _dataCenters.getSelf();
        for (DataCenter dataCenter : _dataCenters.getAll()) {
            if (dataCenter.equals(self)) {
                continue;
            }
            Managed fanout = active.remove(dataCenter.getName());
            if (fanout == null) {
                fanout = newInboundReplication(dataCenter);
                try {
                    fanout.start();
                } catch (Exception e) {
                    _log.error("Unexpected exception starting replication service: {}", dataCenter.getName());
                    continue;
                }
                _dataCenterFanout.put(dataCenter.getName(), fanout);
            }
        }

        // If a DataCenter has been removed, stop replicating from it.
        stopAll(active);

    } catch (Throwable t) {
        _log.error("Unexpected exception polling data center changes.", t);
    }
}
 
Example 2
Source File: SimpleLifeCycleRegistry.java    From emodb with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws Exception {
    for (Managed managed : _managed) {
        managed.start();
    }
}