本文整理匯總了Java中io.dropwizard.lifecycle.Managed.start方法的典型用法代碼示例。如果您正苦於以下問題:Java Managed.start方法的具體用法?Java Managed.start怎麽用?Java Managed.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.dropwizard.lifecycle.Managed
的用法示例。
在下文中一共展示了Managed.start方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newInboundReplication
import io.dropwizard.lifecycle.Managed; //導入方法依賴的package包/類
private Managed newInboundReplication(final DataCenter dataCenter) {
// Create a proxy for the remote data center.
final ReplicationSource replicationSource = newRemoteReplicationSource(dataCenter);
// Start asynchronously downloading events from the remote data center.
final Managed fanout = new GuavaServiceController(_replicationEnabled, new Supplier<Service>() {
@Override
public Service get() {
return _fanoutManager.newInboundReplicationFanout(dataCenter, replicationSource);
}
});
// Note: closing the replication source could also be done via a listener on the Guava service...
return new Managed() {
@Override
public void start() throws Exception {
fanout.start();
}
@Override
public void stop() throws Exception {
fanout.stop();
ServicePoolProxies.close(replicationSource);
}
};
}
示例2: start
import io.dropwizard.lifecycle.Managed; //導入方法依賴的package包/類
public void start() throws Exception {
// Start all the managed instances in dropwizard.
Set<Managed> managedObjects = ImmutableSet.copyOf(dropwizardModule.getManaged());
for (Managed managed : managedObjects) {
managed.start();
}
}
示例3: runOneIteration
import io.dropwizard.lifecycle.Managed; //導入方法依賴的package包/類
@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);
}
}
示例4: stopShouldCloseTheClient
import io.dropwizard.lifecycle.Managed; //導入方法依賴的package包/類
@Test
public void stopShouldCloseTheClient() throws Exception {
Client client = mock(Client.class);
Managed managed = new ManagedEsClient(client);
managed.start();
managed.stop();
verify(client).close();
}
示例5: lifecycleMethodsShouldStartAndCloseTheNode
import io.dropwizard.lifecycle.Managed; //導入方法依賴的package包/類
@Test
public void lifecycleMethodsShouldStartAndCloseTheNode() throws Exception {
Node node = mock(Node.class);
when(node.isClosed()).thenReturn(false);
Managed managed = new ManagedEsClient(node);
managed.start();
verify(node).start();
managed.stop();
verify(node).close();
}
示例6: start
import io.dropwizard.lifecycle.Managed; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
for (Managed managed : _managed) {
managed.start();
}
}