-
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
Add parameter to GET /accounts API to ignore containers information #2998
Add parameter to GET /accounts API to ignore containers information #2998
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2998 +/- ##
============================================
+ Coverage 64.24% 70.03% +5.79%
- Complexity 10398 12136 +1738
============================================
Files 840 884 +44
Lines 71755 74786 +3031
Branches 8611 8966 +355
============================================
+ Hits 46099 52378 +6279
+ Misses 23004 19682 -3322
- Partials 2652 2726 +74 ☔ View full report in Codecov by Sentry. |
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.
minor questions + style .. if you think they can be disregarded -- let me know and i can approve
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.
maybe serializedAccounts might be better variable name?
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.
Sure. Done..
RestResponseChannel restResponseChannel = new MockRestResponseChannel(); | ||
ReadableStreamChannel channel = sendRequestGetResponse(request, restResponseChannel); | ||
assertNotNull("There should be a response", channel); | ||
Assert.assertNotNull("Date has not been set", restResponseChannel.getHeader(RestUtils.Headers.DATE)); |
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.
why does line 181 not have "Assert." like line 182
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.
Yeah.. made it consistent
*/ | ||
public static byte[] serializeAccountsInJsonNoContainers(Collection<Account> accounts) throws IOException { | ||
Map<String, Collection<Account>> resultObj = new HashMap<>(); | ||
resultObj.put(ACCOUNTS_KEY, accounts); |
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.
im still new to concurrency but assuming concurrency is involved, do you see any issues that could occur with having a non-concurrent hashmap here? will the different threads not overwrite anything or have race condition ?
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.
There is no concurrency involved with this method. This map is created in this method, which makes it a local variable to this method. If we have multiple threads executing this method, they would just create multiple map objects.
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.
+1
boolean ignoreContainers = | ||
RestUtils.getBooleanHeader(restRequest.getArgs(), RestUtils.Headers.IGNORE_CONTAINERS, false); | ||
if (ignoreContainers) { | ||
serialized = AccountCollectionSerde.serializeAccountsInJsonNoContainers(getAccounts()); | ||
} else { | ||
serialized = AccountCollectionSerde.serializeAccountsInJson(getAccounts()); | ||
} |
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 we merge these two methods to one method with extra parameter? Something like
serialized = AccountCollectionSerde.serializeAccountsInJson(getAccountsI(), RestUtils.getBooleanHeader(restRequest.getArgs(), RestUtils.Headers.IGNORE_CONTAINERS, false));
Basically move the boolean logic to AccountCollectionSerde.
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.
Sure. Done..
*/ | ||
public static byte[] serializeAccountsInJsonNoContainers(Collection<Account> accounts) throws IOException { | ||
Map<String, Collection<Account>> resultObj = new HashMap<>(); | ||
resultObj.put(ACCOUNTS_KEY, accounts); |
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.
There is no concurrency involved with this method. This map is created in this method, which makes it a local variable to this method. If we have multiple threads executing this method, they would just create multiple map objects.
Summary
Add parameter in GET /accounts API to ignore containers information. This is useful for fetching fields of Account (such as quotaResourceType, aclInheritedByContainer) without overhead of containers information.
Testing Done
Tested in locally deployed Ambry