Search in sources :

Example 1 with Service

use of tech.pegasys.teku.service.serviceutils.Service in project teku by ConsenSys.

the class ServiceController method doStart.

@Override
protected SafeFuture<?> doStart() {
    final Iterator<Service> iterator = services.iterator();
    SafeFuture<?> startupFuture = iterator.next().start();
    while (iterator.hasNext()) {
        final Service nextService = iterator.next();
        startupFuture = startupFuture.thenCompose(__ -> nextService.start());
    }
    return startupFuture;
}
Also used : Service(tech.pegasys.teku.service.serviceutils.Service) List(java.util.List) Iterator(java.util.Iterator) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) ServiceFacade(tech.pegasys.teku.service.serviceutils.ServiceFacade) ArrayList(java.util.ArrayList) Service(tech.pegasys.teku.service.serviceutils.Service)

Example 2 with Service

use of tech.pegasys.teku.service.serviceutils.Service in project teku by ConsenSys.

the class MetricsPublisherManager method doStart.

@Override
protected SafeFuture<?> doStart() {
    if (metricsUrl.isEmpty()) {
        return SafeFuture.COMPLETE;
    }
    AsyncRunner asyncRunner = asyncRunnerFactory.create("MetricPublisher", 1);
    publisherTask = asyncRunner.runWithFixedDelay(this::publishMetrics, Duration.ofSeconds(intervalBetweenPublications), (err) -> LOG.error("Error while attempting to publish metrics to remote service", err));
    return SafeFuture.COMPLETE;
}
Also used : Service(tech.pegasys.teku.service.serviceutils.Service) MetricsEndpoint(tech.pegasys.teku.infrastructure.metrics.MetricsEndpoint) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) Cancellable(tech.pegasys.teku.infrastructure.async.Cancellable) TimeProvider(tech.pegasys.teku.infrastructure.time.TimeProvider) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) IOException(java.io.IOException) File(java.io.File) List(java.util.List) OkHttpClient(okhttp3.OkHttpClient) Logger(org.apache.logging.log4j.Logger) AsyncRunnerFactory(tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory) Duration(java.time.Duration) JsonProvider(tech.pegasys.teku.provider.JsonProvider) Optional(java.util.Optional) HttpUrl(okhttp3.HttpUrl) LogManager(org.apache.logging.log4j.LogManager) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner)

Aggregations

List (java.util.List)2 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)2 Service (tech.pegasys.teku.service.serviceutils.Service)2 File (java.io.File)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Optional (java.util.Optional)1 HttpUrl (okhttp3.HttpUrl)1 OkHttpClient (okhttp3.OkHttpClient)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 AsyncRunner (tech.pegasys.teku.infrastructure.async.AsyncRunner)1 AsyncRunnerFactory (tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory)1 Cancellable (tech.pegasys.teku.infrastructure.async.Cancellable)1 MetricsEndpoint (tech.pegasys.teku.infrastructure.metrics.MetricsEndpoint)1 TimeProvider (tech.pegasys.teku.infrastructure.time.TimeProvider)1 JsonProvider (tech.pegasys.teku.provider.JsonProvider)1 ServiceFacade (tech.pegasys.teku.service.serviceutils.ServiceFacade)1