@Override public void update(GlobalQuotaSettingsImpl quotaPojo) throws IOException { QuotaUtil.addNamespaceQuota(masterServices.getConnection(), namespace, ((GlobalQuotaSettingsImpl) quotaPojo).toQuotas()); } @Override
@Test public void testNamespaceQuotaUtil() throws Exception { final String namespace = "testNamespaceQuotaUtilNS"; Quotas quota = Quotas.newBuilder() .setThrottle(Throttle.newBuilder() .setReqNum(ProtobufUtil.toTimedQuota(1000, TimeUnit.SECONDS, QuotaScope.MACHINE)) .setWriteNum(ProtobufUtil.toTimedQuota(600, TimeUnit.SECONDS, QuotaScope.MACHINE)) .setReadSize(ProtobufUtil.toTimedQuota(8192, TimeUnit.SECONDS, QuotaScope.MACHINE)) .build()) .build(); // Add user quota and verify it QuotaUtil.addNamespaceQuota(this.connection, namespace, quota); Quotas resQuota = QuotaUtil.getNamespaceQuota(this.connection, namespace); assertEquals(quota, resQuota); // Remove user quota and verify it QuotaUtil.deleteNamespaceQuota(this.connection, namespace); resQuota = QuotaUtil.getNamespaceQuota(this.connection, namespace); assertEquals(null, resQuota); }
@Override public void update(final Quotas quotas) throws IOException { QuotaUtil.addNamespaceQuota(masterServices.getConnection(), namespace, quotas); }
@Test public void testNamespaceQuotaUtil() throws Exception { final String namespace = "testNamespaceQuotaUtilNS"; Quotas quota = Quotas.newBuilder() .setThrottle(Throttle.newBuilder() .setReqNum(ProtobufUtil.toTimedQuota(1000, TimeUnit.SECONDS, QuotaScope.MACHINE)) .setWriteNum(ProtobufUtil.toTimedQuota(600, TimeUnit.SECONDS, QuotaScope.MACHINE)) .setReadSize(ProtobufUtil.toTimedQuota(8192, TimeUnit.SECONDS, QuotaScope.MACHINE)) .build()) .build(); // Add user quota and verify it QuotaUtil.addNamespaceQuota(this.connection, namespace, quota); Quotas resQuota = QuotaUtil.getNamespaceQuota(this.connection, namespace); assertEquals(quota, resQuota); // Remove user quota and verify it QuotaUtil.deleteNamespaceQuota(this.connection, namespace); resQuota = QuotaUtil.getNamespaceQuota(this.connection, namespace); assertEquals(null, resQuota); }