private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final String regionServer, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<>(); if (quotas.hasThrottle()) { settings .addAll(fromThrottle(userName, tableName, namespace, regionServer, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings .add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, regionServer, true)); } if (quotas.hasSpace()) { settings.add(fromSpace(tableName, namespace, quotas.getSpace())); } return settings; }
@Override public List<QuotaSettings> getQuotaSettings() { // Very similar to QuotaSettingsFactory List<QuotaSettings> settings = new ArrayList<>(); if (throttleProto != null) { settings.addAll(QuotaSettingsFactory.fromThrottle(getUserName(), getTableName(), getNamespace(), getRegionServer(), throttleProto)); } if (bypassGlobals != null && bypassGlobals.booleanValue()) { settings.add(new QuotaGlobalsSettingsBypass(getUserName(), getTableName(), getNamespace(), getRegionServer(), true)); } if (spaceProto != null) { settings.add(QuotaSettingsFactory.fromSpace(getTableName(), getNamespace(), spaceProto)); } return settings; }
"SetQuotaRequest has multiple limits: " + TextFormat.shortDebugString(request)); return new QuotaGlobalsSettingsBypass( username, tableName, namespace, regionServer, request.getBypassGlobals()); } else if (request.hasSpaceLimit()) {
"SetQuotaRequest has multiple limits: " + TextFormat.shortDebugString(request)); return new QuotaGlobalsSettingsBypass( username, tableName, namespace, request.getBypassGlobals()); } else if (request.hasSpaceLimit()) {
private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<>(); if (quotas.hasThrottle()) { settings.addAll(fromThrottle(userName, tableName, namespace, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } if (quotas.hasSpace()) { settings.add(fromSpace(tableName, namespace, quotas.getSpace())); } return settings; }
private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<QuotaSettings>(); if (quotas.hasThrottle()) { settings.addAll(fromThrottle(userName, tableName, namespace, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } return settings; }
/** * Set the "bypass global settings" for the specified user * @param userName the user to throttle * @param bypassGlobals true if the global settings should be bypassed * @return the quota settings */ public static QuotaSettings bypassGlobals(final String userName, final boolean bypassGlobals) { return new QuotaGlobalsSettingsBypass(userName, null, null, bypassGlobals); } }
/** * Set the "bypass global settings" for the specified user * * @param userName the user to throttle * @param bypassGlobals true if the global settings should be bypassed * @return the quota settings */ public static QuotaSettings bypassGlobals(final String userName, final boolean bypassGlobals) { return new QuotaGlobalsSettingsBypass(userName, null, null, bypassGlobals); }
"SetQuotaRequest has multiple limits: " + TextFormat.shortDebugString(request)); return new QuotaGlobalsSettingsBypass( username, tableName, namespace, request.getBypassGlobals()); } else if (request.hasSpaceLimit()) {
@Test public void testInvalidMerges() throws IOException { QuotaGlobalsSettingsBypass userBypass = new QuotaGlobalsSettingsBypass( "joe", null, null, true); QuotaGlobalsSettingsBypass tableBypass = new QuotaGlobalsSettingsBypass( null, TableName.valueOf("table"), null, true); QuotaGlobalsSettingsBypass namespaceBypass = new QuotaGlobalsSettingsBypass( null, null, "ns", true); QuotaGlobalsSettingsBypass userOnTableBypass = new QuotaGlobalsSettingsBypass( "joe", TableName.valueOf("table"), null, true); QuotaGlobalsSettingsBypass userOnNamespaceBypass = new QuotaGlobalsSettingsBypass( "joe", null, "ns", true); expectFailure(userBypass, new QuotaGlobalsSettingsBypass("frank", null, null, false)); expectFailure(userBypass, tableBypass); expectFailure(userBypass, namespaceBypass); expectFailure(tableBypass, new QuotaGlobalsSettingsBypass( null, TableName.valueOf("foo"), null, false)); expectFailure(tableBypass, namespaceBypass); expectFailure(namespaceBypass, userBypass); expectFailure(namespaceBypass, tableBypass); expectFailure(namespaceBypass, new QuotaGlobalsSettingsBypass(null, null, "sn", false)); expectFailure(namespaceBypass, userOnTableBypass); expectFailure(namespaceBypass, userOnNamespaceBypass); expectFailure(userOnTableBypass, new QuotaGlobalsSettingsBypass( "frank", TableName.valueOf("foo"), null, false));
private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<>(); if (quotas.hasThrottle()) { settings.addAll(fromThrottle(userName, tableName, namespace, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } if (quotas.hasSpace()) { settings.add(fromSpace(tableName, namespace, quotas.getSpace())); } return settings; }
/** * Set the "bypass global settings" for the specified user * * @param userName the user to throttle * @param bypassGlobals true if the global settings should be bypassed * @return the quota settings */ public static QuotaSettings bypassGlobals(final String userName, final boolean bypassGlobals) { return new QuotaGlobalsSettingsBypass(userName, null, null, bypassGlobals); }
@Test public void testMerge() throws IOException { QuotaGlobalsSettingsBypass orig = new QuotaGlobalsSettingsBypass("joe", null, null, true); assertFalse(orig.merge(new QuotaGlobalsSettingsBypass( "joe", null, null, false)).getBypass()); }
@Test public void testInvalidMerges() throws IOException { QuotaGlobalsSettingsBypass userBypass = new QuotaGlobalsSettingsBypass("joe", null, null, null, true); QuotaGlobalsSettingsBypass tableBypass = new QuotaGlobalsSettingsBypass(null, TableName.valueOf("table"), null, null, true); QuotaGlobalsSettingsBypass namespaceBypass = new QuotaGlobalsSettingsBypass(null, null, "ns", null, true); QuotaGlobalsSettingsBypass regionServerBypass = new QuotaGlobalsSettingsBypass(null, null, null, "all", true); QuotaGlobalsSettingsBypass userOnTableBypass = new QuotaGlobalsSettingsBypass("joe", TableName.valueOf("table"), null, null, true); QuotaGlobalsSettingsBypass userOnNamespaceBypass = new QuotaGlobalsSettingsBypass("joe", null, "ns", null, true); QuotaGlobalsSettingsBypass userOnRegionServerBypass = new QuotaGlobalsSettingsBypass("joe", null, null, "all", true); expectFailure(userBypass, new QuotaGlobalsSettingsBypass("frank", null, null, null, false)); expectFailure(userBypass, tableBypass); expectFailure(userBypass, namespaceBypass); expectFailure(tableBypass, userBypass); expectFailure(tableBypass, new QuotaGlobalsSettingsBypass(null, TableName.valueOf("foo"), null, null, false)); expectFailure(tableBypass, namespaceBypass); expectFailure(tableBypass, regionServerBypass); expectFailure(namespaceBypass, tableBypass); expectFailure(namespaceBypass, regionServerBypass); expectFailure(namespaceBypass, new QuotaGlobalsSettingsBypass(null, null, "sn", null, false));
/** * Set the "bypass global settings" for the specified user * * @param userName the user to throttle * @param bypassGlobals true if the global settings should be bypassed * @return the quota settings */ public static QuotaSettings bypassGlobals(final String userName, final boolean bypassGlobals) { return new QuotaGlobalsSettingsBypass(userName, null, null, null, bypassGlobals); }
@Test public void testMerge() throws IOException { QuotaGlobalsSettingsBypass orig = new QuotaGlobalsSettingsBypass("joe", null, null, null, true); assertFalse( orig.merge(new QuotaGlobalsSettingsBypass("joe", null, null, null, false)).getBypass()); }