Skip to content

Instantly share code, notes, and snippets.

@varokas
Created June 27, 2018 23:11
Show Gist options
  • Save varokas/23b2ebde620aee0d681fb62988a26245 to your computer and use it in GitHub Desktop.
Save varokas/23b2ebde620aee0d681fb62988a26245 to your computer and use it in GitHub Desktop.
private static final Map<Long, PartitionResult> getPartitionsForUsersPrivate(List<Long> dsids)
throws AccountAPIException {
BatchLookupPartitionRequest batchLookupPartitionRequest = new BatchLookupPartitionRequest();
for (Long dsid : dsids) {
batchLookupPartitionRequest.addDsidServiceTypePair(dsid, ServiceType.CloudDB);
}
BatchPartitionResponse batchPartitionResponse =
PartitionAssignmentAPIFactory.partitionAssignmentAPI().batchLookupDatastore(
batchLookupPartitionRequest);
Map<Long, PartitionResult> partitionAssignments = new HashMap<>();
for (PartitionResponse partitionResponse : batchPartitionResponse.getPartitionResponses()) {
if (partitionResponse.isSuccess()) {
DatastoreAssignment assignment = partitionResponse.getPartitionAssignment();
if (assignment != null) {
partitionAssignments.put(assignment.getDsid(),
PartitionResult.createSuccess(assignment.getAssignedPartitionId(), Method.LOOKUP));
} else {
log.warn(new SplunkMessage(
"PartitionLookup: PartitionResponse with a success with no assignment",
"statusCode", partitionResponse.getStatus(),
"errorMsg", partitionResponse.getError()));
}
} else {
log.info(new SplunkMessage("PartitionLookup: PartitionResponse failure",
"statusCode", partitionResponse.getStatus(),
"errorMsg", partitionResponse.getError()));
}
}
return partitionAssignments;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment