-
Notifications
You must be signed in to change notification settings - Fork 275
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
Conversation
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); |
There was a problem hiding this comment.
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.
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test added
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -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 = |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
freeing log segment succeeds or not, ensure that store exception is
correctly thrown in ensureCapacity method.
initialization rather than register them every time adaptive tracker is
created. This will avoid unnecessary overhead.