-
Notifications
You must be signed in to change notification settings - Fork 388
/
Copy pathNoopLimiter.java
65 lines (53 loc) · 1.38 KB
/
NoopLimiter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright 2024, AutoMQ HK Limited.
*
* The use of this file is governed by the Business Source License,
* as detailed in the file "/LICENSE.S3Stream" included in this repository.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0
*/
package kafka.server;
/**
* A limiter that does nothing.
*/
public class NoopLimiter implements Limiter {
public static final NoopLimiter INSTANCE = new NoopLimiter();
@Override
public Handler acquire(int permit) throws InterruptedException {
return new NoopHandler();
}
@Override
public Handler acquire(int permit, long timeoutMs) throws InterruptedException {
return new NoopHandler();
}
@Override
public int maxPermits() {
return Integer.MAX_VALUE;
}
@Override
public int availablePermits() {
return Integer.MAX_VALUE;
}
@Override
public int waitingThreads() {
return 0;
}
@Override
public String name() {
return "noop";
}
public static class NoopHandler implements Handler {
@Override
public void close() {
}
@Override
public void release(int permits) {
}
@Override
public int permitsHeld() {
return 0;
}
}
}