bbeaudreault commented on code in PR #5666:
URL: https://github.com/apache/hbase/pull/5666#discussion_r1480558838
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaUtil.java:
##########
@@ -321,6 +344,34 @@ public void visitUserQuotas(String userName, Quotas
quotas) {
return userQuotas;
}
+ protected static UserQuotaState buildDefaultUserQuotaState(Configuration
conf) {
+ QuotaProtos.Throttle.Builder throttleBuilder =
QuotaProtos.Throttle.newBuilder();
+
+ buildDefaultTimedQuota(conf, QUOTA_DEFAULT_USER_MACHINE_READ_SIZE)
+ .ifPresent(throttleBuilder::setReadSize);
+ buildDefaultTimedQuota(conf, QUOTA_DEFAULT_USER_MACHINE_READ_NUM)
+ .ifPresent(throttleBuilder::setReadNum);
+ buildDefaultTimedQuota(conf, QUOTA_DEFAULT_USER_MACHINE_REQUEST_NUM)
+ .ifPresent(throttleBuilder::setReqNum);
+ buildDefaultTimedQuota(conf, QUOTA_DEFAULT_USER_MACHINE_WRITE_NUM)
+ .ifPresent(throttleBuilder::setWriteNum);
+
+ UserQuotaState state = new UserQuotaState();
+ QuotaProtos.Quotas defaultQuotas =
+
QuotaProtos.Quotas.newBuilder().setThrottle(throttleBuilder.build()).build();
+ state.setQuotas(defaultQuotas);
+ return state;
+ }
+
+ private static Optional<TimedQuota> buildDefaultTimedQuota(Configuration
conf, String key) {
+ int defaultSoftLimit = conf.getInt(key, -1);
+ if (defaultSoftLimit == -1) {
+ return Optional.empty();
+ }
+ return Optional.of(ProtobufUtil.toTimedQuota(defaultSoftLimit,
+ java.util.concurrent.TimeUnit.SECONDS,
org.apache.hadoop.hbase.quotas.QuotaScope.MACHINE));
Review Comment:
Is there a reason we need these fully qualified names instead of importing?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]