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

Minor fixes in IOException catch and metrics registry #1170

Merged
merged 3 commits into from
May 13, 2019

Conversation

jsjtzyy
Copy link
Contributor

@jsjtzyy jsjtzyy commented May 9, 2019

  1. When log segment instantiation encounters IOException, no matter
    freeing log segment succeeds or not, ensure that store exception is
    correctly thrown in ensureCapacity method.
  2. Register the custom percentile metrics during RouterMetrics
    initialization rather than register them every time adaptive tracker is
    created. This will avoid unnecessary overhead.

1. When log segment instatiation encounters IOException, no matter
freeing log segment succeeds or not, ensure that store exception is
correclty thrown in ensureCapacity method.
2. Register the custom percentile metrics during RouterMetrics
initialization rather than register them every time adaptive tracker is
created. This will avoid unnecessary overhead.
@@ -69,7 +69,7 @@ public CryptoJobHandlerTest() throws IOException, GeneralSecurityException {
cryptoService = new GCMCryptoServiceFactory(verifiableProperties, REGISTRY).getCryptoService();
cryptoJobHandler = new CryptoJobHandler(DEFAULT_THREAD_COUNT);
referenceClusterMap = new MockClusterMap();
routerMetrics = new NonBlockingRouterMetrics(referenceClusterMap);
routerMetrics = new NonBlockingRouterMetrics(referenceClusterMap, null);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I purposely set RouterConfig = null when creating NonBlockingRouterMetrics in several tests. This is to verify that even if router config is mistakenly set to null in the ctor of NonBlockingRouterMetrics, there would be no failure during instantiation.

@jsjtzyy jsjtzyy self-assigned this May 9, 2019
@jsjtzyy jsjtzyy requested review from zzmao and cgtz May 9, 2019 19:30
@@ -470,17 +466,15 @@ private void ensureCapacity(long writeSize) throws StoreException {
new LogSegment(segmentNameAndFilename.getFirst(), newSegmentFile, segmentCapacity, metrics, true);
segmentsByName.put(segmentNameAndFilename.getFirst(), newSegment);
} catch (StoreException e) {
logger.error("Failed to create new log segment {} with store exception: ", segmentNameAndFilename.getFirst(), e);
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test for this block will be good, but its ok if its too cumbersome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test added

@codecov-io
Copy link

codecov-io commented May 9, 2019

Codecov Report

Merging #1170 into master will decrease coverage by 0.04%.
The diff coverage is 76.31%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1170      +/-   ##
============================================
- Coverage     69.96%   69.92%   -0.05%     
+ Complexity     5371     5358      -13     
============================================
  Files           427      427              
  Lines         32775    32770       -5     
  Branches       4152     4133      -19     
============================================
- Hits          22931    22914      -17     
- Misses         8706     8718      +12     
  Partials       1138     1138
Impacted Files Coverage Δ Complexity Δ
....github.ambry.router/AdaptiveOperationTracker.java 95.83% <ø> (-0.72%) 6 <0> (-3)
...ain/java/com.github.ambry.router/GetOperation.java 97.05% <ø> (ø) 27 <0> (ø) ⬇️
....github.ambry.router/NonBlockingRouterMetrics.java 93.91% <100%> (+0.07%) 41 <3> (+1) ⬆️
...n/java/com.github.ambry.store/PersistentIndex.java 92.36% <100%> (-0.02%) 196 <0> (-1)
....github.ambry.router/NonBlockingRouterFactory.java 81.25% <100%> (ø) 4 <0> (ø) ⬇️
...in/java/com.github.ambry/store/StoreException.java 100% <100%> (ø) 7 <3> (+3) ⬆️
...c/main/java/com.github.ambry.store/LogSegment.java 87.15% <28.57%> (+0.48%) 50 <0> (ø) ⬇️
.../main/java/com.github.ambry.store/HardDeleter.java 82.22% <66.66%> (+0.63%) 42 <0> (ø) ⬇️
...main/java/com.github.ambry.store/IndexSegment.java 86.52% <75%> (+0.41%) 103 <0> (-3) ⬇️
...tore/src/main/java/com.github.ambry.store/Log.java 99.01% <90%> (+5.91%) 60 <0> (ø) ⬇️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a11a53b...ff12a09. Read the comment docs.

@@ -13,6 +13,9 @@
*/
package com.github.ambry.store;

import java.util.Objects;


public class StoreException extends Exception {
public static final String INTERNAL_ERROR_STR =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be private or package-private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to package-private

@jsjtzyy
Copy link
Contributor Author

jsjtzyy commented May 10, 2019

./gradlew build && ./gradlew test succeeded. @cgtz @zzmao reminder to review.

Copy link
Contributor

@zzmao zzmao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cgtz cgtz merged commit 82cbfbe into linkedin:master May 13, 2019
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.

4 participants