Search in sources :

Example 1 with MetricRecordingValidatorApiChannel

use of tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel in project teku by ConsenSys.

the class RemoteBeaconNodeApi method create.

public static BeaconNodeApi create(final ServiceConfig serviceConfig, final AsyncRunner asyncRunner, final URI beaconNodeApiEndpoint, final Spec spec, final boolean generateEarlyAttestations) {
    final OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().readTimeout(READ_TIMEOUT);
    HttpUrl apiEndpoint = HttpUrl.get(beaconNodeApiEndpoint);
    Preconditions.checkNotNull(apiEndpoint, String.format("Failed to convert remote api endpoint (%s) to a valid url", UrlSanitizer.sanitizePotentialUrl(beaconNodeApiEndpoint.toString())));
    OkHttpClientAuthLoggingIntercepter.addAuthenticator(apiEndpoint, httpClientBuilder);
    // Strip any authentication info from the URL to ensure it doesn't get logged.
    apiEndpoint = apiEndpoint.newBuilder().username("").password("").build();
    final OkHttpClient okHttpClient = httpClientBuilder.build();
    final OkHttpValidatorRestApiClient apiClient = new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient);
    final ValidatorApiChannel validatorApiChannel = new MetricRecordingValidatorApiChannel(serviceConfig.getMetricsSystem(), new RemoteValidatorApiHandler(spec, apiClient, asyncRunner));
    final ValidatorTimingChannel validatorTimingChannel = serviceConfig.getEventChannels().getPublisher(ValidatorTimingChannel.class);
    final BeaconChainEventAdapter beaconChainEventAdapter = new EventSourceBeaconChainEventAdapter(apiEndpoint, okHttpClient, new TimeBasedEventAdapter(new GenesisDataProvider(asyncRunner, validatorApiChannel), new RepeatingTaskScheduler(asyncRunner, serviceConfig.getTimeProvider()), serviceConfig.getTimeProvider(), validatorTimingChannel, spec), validatorTimingChannel, serviceConfig.getMetricsSystem(), generateEarlyAttestations);
    return new RemoteBeaconNodeApi(beaconChainEventAdapter, validatorApiChannel);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) ValidatorTimingChannel(tech.pegasys.teku.validator.api.ValidatorTimingChannel) MetricRecordingValidatorApiChannel(tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel) ValidatorApiChannel(tech.pegasys.teku.validator.api.ValidatorApiChannel) RepeatingTaskScheduler(tech.pegasys.teku.infrastructure.async.timed.RepeatingTaskScheduler) GenesisDataProvider(tech.pegasys.teku.validator.beaconnode.GenesisDataProvider) TimeBasedEventAdapter(tech.pegasys.teku.validator.beaconnode.TimeBasedEventAdapter) HttpUrl(okhttp3.HttpUrl) OkHttpValidatorRestApiClient(tech.pegasys.teku.validator.remote.apiclient.OkHttpValidatorRestApiClient) MetricRecordingValidatorApiChannel(tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel) BeaconChainEventAdapter(tech.pegasys.teku.validator.beaconnode.BeaconChainEventAdapter)

Example 2 with MetricRecordingValidatorApiChannel

use of tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel in project teku by ConsenSys.

the class InProcessBeaconNodeApi method create.

public static BeaconNodeApi create(final ServiceConfig services, final AsyncRunner asyncRunner, final boolean generateEarlyAttestations, final Spec spec) {
    final MetricsSystem metricsSystem = services.getMetricsSystem();
    final EventChannels eventChannels = services.getEventChannels();
    final ValidatorApiChannel validatorApiChannel = new MetricRecordingValidatorApiChannel(metricsSystem, eventChannels.getPublisher(ValidatorApiChannel.class, asyncRunner));
    final ValidatorTimingChannel validatorTimingChannel = eventChannels.getPublisher(ValidatorTimingChannel.class);
    final TimeBasedEventAdapter timeBasedEventAdapter = new TimeBasedEventAdapter(new GenesisDataProvider(asyncRunner, validatorApiChannel), new RepeatingTaskScheduler(asyncRunner, services.getTimeProvider()), services.getTimeProvider(), validatorTimingChannel, spec);
    final BeaconChainEventAdapter beaconChainEventAdapter = new IndependentTimerEventChannelEventAdapter(eventChannels, generateEarlyAttestations, timeBasedEventAdapter, validatorTimingChannel);
    return new InProcessBeaconNodeApi(validatorApiChannel, beaconChainEventAdapter);
}
Also used : MetricRecordingValidatorApiChannel(tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel) BeaconChainEventAdapter(tech.pegasys.teku.validator.beaconnode.BeaconChainEventAdapter) ValidatorTimingChannel(tech.pegasys.teku.validator.api.ValidatorTimingChannel) EventChannels(tech.pegasys.teku.infrastructure.events.EventChannels) MetricRecordingValidatorApiChannel(tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel) ValidatorApiChannel(tech.pegasys.teku.validator.api.ValidatorApiChannel) RepeatingTaskScheduler(tech.pegasys.teku.infrastructure.async.timed.RepeatingTaskScheduler) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) GenesisDataProvider(tech.pegasys.teku.validator.beaconnode.GenesisDataProvider) TimeBasedEventAdapter(tech.pegasys.teku.validator.beaconnode.TimeBasedEventAdapter)

Aggregations

RepeatingTaskScheduler (tech.pegasys.teku.infrastructure.async.timed.RepeatingTaskScheduler)2 ValidatorApiChannel (tech.pegasys.teku.validator.api.ValidatorApiChannel)2 ValidatorTimingChannel (tech.pegasys.teku.validator.api.ValidatorTimingChannel)2 BeaconChainEventAdapter (tech.pegasys.teku.validator.beaconnode.BeaconChainEventAdapter)2 GenesisDataProvider (tech.pegasys.teku.validator.beaconnode.GenesisDataProvider)2 TimeBasedEventAdapter (tech.pegasys.teku.validator.beaconnode.TimeBasedEventAdapter)2 MetricRecordingValidatorApiChannel (tech.pegasys.teku.validator.beaconnode.metrics.MetricRecordingValidatorApiChannel)2 HttpUrl (okhttp3.HttpUrl)1 OkHttpClient (okhttp3.OkHttpClient)1 MetricsSystem (org.hyperledger.besu.plugin.services.MetricsSystem)1 EventChannels (tech.pegasys.teku.infrastructure.events.EventChannels)1 OkHttpValidatorRestApiClient (tech.pegasys.teku.validator.remote.apiclient.OkHttpValidatorRestApiClient)1