Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add a metric for task duration in the pending queue (#12492)
This PR is to measure how long a task stays in the pending queue and emits the value with the metric task/pending/time. The metric is measured in RemoteTaskRunner and HttpRemoteTaskRunner. An example of the metric: ``` 2022-04-26T21:59:09,488 INFO [rtr-pending-tasks-runner-0] org.apache.druid.java.util.emitter.core.LoggingEmitter - {"feed":"metrics","timestamp":"2022-04-26T21:59:09.487Z","service":"druid/coordinator","host":"localhost:8081","version":"2022.02.0-iap-SNAPSHOT","metric":"task/pending/time","value":8,"dataSource":"wikipedia","taskId":"index_parallel_wikipedia_gecpcglg_2022-04-26T21:59:09.432Z","taskType":"index_parallel"} ``` ------------------------------------------ Key changed/added classes in this PR Emit metric task/pending/time in classes RemoteTaskRunner and HttpRemoteTaskRunner. Update related factory classes and tests.
- Loading branch information
Showing
8 changed files
with
146 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,72 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.indexing.overlord; | ||
|
||
import org.apache.curator.framework.CuratorFramework; | ||
import org.apache.druid.indexing.overlord.autoscaling.NoopProvisioningStrategy; | ||
import org.apache.druid.indexing.overlord.autoscaling.ProvisioningSchedulerConfig; | ||
import org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig; | ||
import org.apache.druid.server.initialization.IndexerZkConfig; | ||
import org.apache.druid.server.initialization.ZkPathsConfig; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
public class RemoteTaskRunnerFactoryTest | ||
{ | ||
@Test | ||
public void testBuildWithAutoScale() | ||
{ | ||
ProvisioningSchedulerConfig provisioningSchedulerConfig = Mockito.mock(ProvisioningSchedulerConfig.class); | ||
Mockito.when(provisioningSchedulerConfig.isDoAutoscale()).thenReturn(true); | ||
|
||
RemoteTaskRunnerFactory remoteTaskRunnerFactory = getTestRemoteTaskRunnerFactory(provisioningSchedulerConfig); | ||
|
||
Assert.assertNull(remoteTaskRunnerFactory.build().getProvisioningStrategy()); | ||
} | ||
|
||
@Test | ||
public void testBuildWithoutAutoScale() | ||
{ | ||
ProvisioningSchedulerConfig provisioningSchedulerConfig = Mockito.mock(ProvisioningSchedulerConfig.class); | ||
Mockito.when(provisioningSchedulerConfig.isDoAutoscale()).thenReturn(false); | ||
|
||
RemoteTaskRunnerFactory remoteTaskRunnerFactory = getTestRemoteTaskRunnerFactory(provisioningSchedulerConfig); | ||
|
||
Assert.assertTrue(remoteTaskRunnerFactory.build().getProvisioningStrategy() instanceof NoopProvisioningStrategy); | ||
} | ||
|
||
private RemoteTaskRunnerFactory getTestRemoteTaskRunnerFactory(ProvisioningSchedulerConfig provisioningSchedulerConfig) | ||
{ | ||
CuratorFramework curator = Mockito.mock(CuratorFramework.class); | ||
Mockito.when(curator.newWatcherRemoveCuratorFramework()).thenReturn(null); | ||
return new RemoteTaskRunnerFactory( | ||
curator, | ||
new RemoteTaskRunnerConfig(), | ||
new IndexerZkConfig(new ZkPathsConfig(), null, null, null, null), | ||
null, | ||
null, | ||
null, | ||
provisioningSchedulerConfig, | ||
null, | ||
null | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.