Search in sources :

Example 16 with Builder

use of org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder in project qpid-broker-j by apache.

the class RuleSetTest method testAppend_CountLimit.

private void testAppend_CountLimit(Duration duration, Integer frequencyLimit) {
    if (frequencyLimit != null && frequencyLimit < 3) {
        frequencyLimit = 3;
    }
    final Builder builder = RuleSet.newBuilder(LIMITER_NAME, duration);
    builder.addRule(Rule.newNonBlockingRule(RulePredicates.ALL_PORTS, TEST_USER, 200, 20000, duration));
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, OTHER_USER, 1, 1, duration));
    builder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
    final Builder secondaryBuilder = RuleSet.newBuilder(LIMITER_NAME, duration);
    secondaryBuilder.addRule(Rule.newNonBlockingRule(TEST_PORT, TEST_USER, 2, frequencyLimit, duration));
    secondaryBuilder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
    testConnectionCountLimit2((RuleSet) builder.build().append(secondaryBuilder.build()));
}
Also used : Builder(org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)

Example 17 with Builder

use of org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder in project qpid-broker-j by apache.

the class RuleSetTest method testBlockedUser.

private void testBlockedUser(Duration duration) {
    final Builder builder = RuleSet.newBuilder(LIMITER_NAME, duration);
    builder.addRule(Rule.newBlockingRule(TEST_PORT, TEST_USER));
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, OTHER_USER, 1000, 1000, duration));
    builder.addRule(Rule.newNonBlockingRule(RulePredicates.ALL_PORTS, OTHER_GROUP, 1000, 1000, duration));
    builder.addRule(Rule.newNonBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS, 1000, 1000, duration));
    testBlocked(builder.build());
    testBlocked(builder.logAllMessages(true).build());
    testBlocked(builder.logAllMessages(false).build());
}
Also used : Builder(org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)

Example 18 with Builder

use of org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder in project qpid-broker-j by apache.

the class RuleSetTest method testUserConnectionCountLimit_Concurrency.

private void testUserConnectionCountLimit_Concurrency(Duration duration, Integer connectionFrequency, int threadCount) {
    if (connectionFrequency != null) {
        if (connectionFrequency < 3) {
            connectionFrequency = 3;
        }
        if (connectionFrequency < threadCount) {
            connectionFrequency = threadCount;
        }
    }
    final Builder builder = RuleSet.newBuilder(LIMITER_NAME, duration);
    builder.addRule(Rule.newNonBlockingRule(RulePredicates.ALL_PORTS, TEST_USER, 2, null, duration));
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, TEST_USER, 2, connectionFrequency, duration));
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, OTHER_USER, 1, 1, duration));
    builder.addRule(Rule.newNonBlockingRule(RulePredicates.ALL_PORTS, OTHER_GROUP, 1, 1, duration));
    builder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
    testParallelThreads(threadCount, builder.build(), false);
}
Also used : Builder(org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)

Example 19 with Builder

use of org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder in project qpid-broker-j by apache.

the class RuleSetTest method testAppend_BlockedUser.

private void testAppend_BlockedUser(Duration duration) {
    final Builder builder = RuleSet.newBuilder(LIMITER_NAME, duration);
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, TEST_USER, 1000, 1000, duration));
    final Builder secondaryBuilder = RuleSet.newBuilder(LIMITER_NAME, Duration.ofDays(1L));
    secondaryBuilder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
    testBlocked((RuleSet) builder.build().append(secondaryBuilder.build()));
}
Also used : Builder(org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)

Example 20 with Builder

use of org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder in project qpid-broker-j by apache.

the class RuleSetTest method testUserConnectionFrequencyLimit_Concurrency.

private void testUserConnectionFrequencyLimit_Concurrency(Integer countLimit, int threadCount) {
    if (countLimit != null) {
        if (countLimit < 3) {
            countLimit = 3;
        }
        if (countLimit < threadCount) {
            countLimit = threadCount;
        }
    }
    final Duration frequencyPeriod = Duration.ofDays(3650L);
    final Builder builder = RuleSet.newBuilder(LIMITER_NAME, frequencyPeriod);
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, TEST_USER, countLimit, 2, frequencyPeriod));
    builder.addRule(Rule.newNonBlockingRule(TEST_PORT, OTHER_USER, 1, 1, frequencyPeriod));
    builder.addRule(Rule.newNonBlockingRule(RulePredicates.ALL_PORTS, OTHER_GROUP, 1, 1, frequencyPeriod));
    builder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
    testParallelThreads(threadCount, builder.build(), true);
}
Also used : Builder(org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder) Duration(java.time.Duration)

Aggregations

Builder (org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)22 Duration (java.time.Duration)7 ConnectionLimitException (org.apache.qpid.server.security.limit.ConnectionLimitException)4 Test (org.junit.Test)3 ConnectionSlot (org.apache.qpid.server.security.limit.ConnectionSlot)2 Instant (java.time.Instant)1