[
https://issues.apache.org/jira/browse/YARN-10763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17343152#comment-17343152
]
Peter Bacsko commented on YARN-10763:
-------------------------------------
Some further comments:
1. {{private volatile AtomicLong numContainersAssigned = new AtomicLong(0);}} -
this doesn't have to be "volatile".
2. "containersAssignedCounter" should be renamed to something else. If this is
an executor, then use the name "assignCounterExecutor" or something like that.
3. Also, "containersAssignedCounter" should be not be a static field. It's part
of an object which just happens to be a singleton.
4. Initialize "containersAssignedCounter" in the constructor.
5. Use something else for the thread name instead of
"ContainersAssigned_Counter", for example, "ContainerAssignmentCounterThread".
6. "numContainersAssignedLast" should be int and not long. Therefore, you don't
need to the type cast at {{numContainerAssignedPerSecond.set((int)n);}}.
7. Also, it would be best to reset the counter of "numContainersAssigned" to 0.
Now it's AtomicLong and I think it's unlikely to overflow, but if we're just
counting in an interval, it makes sense to reset it. Also, it does not have to
be long, but just int. So this is preferred: {{numContainersAssignedLast =
numContainersAssigned.getAndSet(0)}}.
8. {{containersAssignedCounter.shutdown();}} --> use {{shutdownNow()}} to
immediately stop the executor.
9. The test case:
{noformat}
@Test
public void testClusterMetrics() throws Exception {
assert(metrics != null);
Assert.assertTrue(!metrics.numContainerAssignedPerSecond.changed());
metrics.incrNumContainerAssigned();
Thread.sleep(2000);
Assert.assertEquals(metrics.getnumContainerAssignedPerSecond(),1L);
}
{noformat}
The first is the default Java "assert", which only takes effect with the "-ea"
cmd line switch. Just remove it.
Also, instead of a fixed {{Thread.sleep()}}, use:
{noformat}
GenericTestUtils.waitFor(new Supplier<Boolean>() {
@Override
public Boolean get() {
return metrics.getnumContainerAssignedPerSecond() == 1;
}
}, 500, 5000);
{noformat}
> add the speed of containers assigned metrics to ClusterMetrics
> ---------------------------------------------------------------
>
> Key: YARN-10763
> URL: https://issues.apache.org/jira/browse/YARN-10763
> Project: Hadoop YARN
> Issue Type: Improvement
> Reporter: chaosju
> Assignee: chaosju
> Priority: Minor
> Attachments: YARN-10763.001.patch, YARN-10763.002.patch,
> YARN-10763.003.patch, YARN-10763.004.patch, screenshot-1.png
>
>
> It'd be good to have ContainerAssignedNum/Second in ClusterMetrics for
> measuring cluster throughput.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]