Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-9377. Call MutableStat.add(long x) method as a runnable task in a separate service executor #7708

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juncevich
Copy link
Contributor

What changes were proposed in this pull request?

Change synchronized metrics collect methods to read/write lock implementation.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-9377

How was this patch tested?

I wrote the JUnit test (I'm not sure I should add this test to this PR) to compare performance metric realization.

  @RepeatedTest(100)
  void testMyMetrics() throws InterruptedException {
    OzoneMutableRate rate = new OzoneMutableRate("Test name", "Test description", true);
    final MetricsRecordBuilder builder = getMetricsRecordBuilder();
    ExecutorService executor = Executors.newFixedThreadPool(10);
    for (int i = 0; i < 100; i++) {
      int finalI = i;

      executor.submit(() -> {
        rate.add(finalI);
        if (finalI % 100 == 0) {
          rate.snapshot(getMetricsRecordBuilder());
        }
      });
    }
    executor.awaitTermination(1, TimeUnit.SECONDS);
    rate.snapshot(builder);
    assertEquals(100, builder.metrics().get(0).value().intValue());
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant