Search in sources :

Example 1 with AggregatedMetricsCollectionService

use of io.cdap.cdap.metrics.collect.AggregatedMetricsCollectionService in project cdap by caskdata.

the class TaskWorkerMetricsTest method beforeTest.

@Before
public void beforeTest() {
    CConfiguration cConf = createCConf();
    SConfiguration sConf = SConfiguration.create();
    published = new ArrayList<>();
    AggregatedMetricsCollectionService mockMetricsCollector = new AggregatedMetricsCollectionService(1000L) {

        @Override
        protected void publish(Iterator<MetricValues> metrics) {
            Iterators.addAll(published, metrics);
        }
    };
    mockMetricsCollector.startAndWait();
    taskWorkerService = new TaskWorkerService(cConf, sConf, new InMemoryDiscoveryService(), (namespaceId, retryStrategy) -> null, mockMetricsCollector);
    taskWorkerStateFuture = TaskWorkerTestUtil.getServiceCompletionFuture(taskWorkerService);
    // start the service
    taskWorkerService.startAndWait();
    InetSocketAddress addr = taskWorkerService.getBindAddress();
    this.uri = URI.create(String.format("http://%s:%s", addr.getHostName(), addr.getPort()));
}
Also used : HttpURLConnection(java.net.HttpURLConnection) AggregatedMetricsCollectionService(io.cdap.cdap.metrics.collect.AggregatedMetricsCollectionService) InMemoryDiscoveryService(org.apache.twill.discovery.InMemoryDiscoveryService) HttpResponse(io.cdap.common.http.HttpResponse) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultHttpRequestConfig(io.cdap.cdap.common.http.DefaultHttpRequestConfig) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) RunnableTaskRequest(io.cdap.cdap.api.service.worker.RunnableTaskRequest) Gson(com.google.gson.Gson) After(org.junit.After) MetricValues(io.cdap.cdap.api.metrics.MetricValues) HttpRequests(io.cdap.common.http.HttpRequests) URI(java.net.URI) RunnableTaskContext(io.cdap.cdap.api.service.worker.RunnableTaskContext) Before(org.junit.Before) Iterator(java.util.Iterator) Test(org.junit.Test) IOException(java.io.IOException) InetSocketAddress(java.net.InetSocketAddress) Service(com.google.common.util.concurrent.Service) List(java.util.List) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) RunnableTask(io.cdap.cdap.api.service.worker.RunnableTask) Constants(io.cdap.cdap.common.conf.Constants) Assert(org.junit.Assert) MetricValue(io.cdap.cdap.api.metrics.MetricValue) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) HttpRequest(io.cdap.common.http.HttpRequest) InetSocketAddress(java.net.InetSocketAddress) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) AggregatedMetricsCollectionService(io.cdap.cdap.metrics.collect.AggregatedMetricsCollectionService) Iterator(java.util.Iterator) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) InMemoryDiscoveryService(org.apache.twill.discovery.InMemoryDiscoveryService) Before(org.junit.Before)

Example 2 with AggregatedMetricsCollectionService

use of io.cdap.cdap.metrics.collect.AggregatedMetricsCollectionService in project cdap by caskdata.

the class RemoteTaskExecutorTest method beforeTest.

@Before
public void beforeTest() {
    published = new ArrayList<>();
    mockMetricsCollector = new AggregatedMetricsCollectionService(1000L) {

        @Override
        protected void publish(Iterator<MetricValues> metrics) {
            Iterators.addAll(published, metrics);
        }
    };
    mockMetricsCollector.startAndWait();
    registered = discoveryService.register(URIScheme.createDiscoverable(Constants.Service.TASK_WORKER, httpService));
}
Also used : AggregatedMetricsCollectionService(io.cdap.cdap.metrics.collect.AggregatedMetricsCollectionService) MetricValues(io.cdap.cdap.api.metrics.MetricValues) Before(org.junit.Before)

Aggregations

MetricValues (io.cdap.cdap.api.metrics.MetricValues)2 AggregatedMetricsCollectionService (io.cdap.cdap.metrics.collect.AggregatedMetricsCollectionService)2 Before (org.junit.Before)2 Iterators (com.google.common.collect.Iterators)1 Service (com.google.common.util.concurrent.Service)1 Gson (com.google.gson.Gson)1 MetricValue (io.cdap.cdap.api.metrics.MetricValue)1 RunnableTask (io.cdap.cdap.api.service.worker.RunnableTask)1 RunnableTaskContext (io.cdap.cdap.api.service.worker.RunnableTaskContext)1 RunnableTaskRequest (io.cdap.cdap.api.service.worker.RunnableTaskRequest)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 Constants (io.cdap.cdap.common.conf.Constants)1 SConfiguration (io.cdap.cdap.common.conf.SConfiguration)1 DefaultHttpRequestConfig (io.cdap.cdap.common.http.DefaultHttpRequestConfig)1 HttpRequest (io.cdap.common.http.HttpRequest)1 HttpRequests (io.cdap.common.http.HttpRequests)1 HttpResponse (io.cdap.common.http.HttpResponse)1 IOException (java.io.IOException)1 HttpURLConnection (java.net.HttpURLConnection)1 InetSocketAddress (java.net.InetSocketAddress)1