16
16
import static com .google .common .base .Preconditions .checkArgument ;
17
17
import static com .google .common .base .Preconditions .checkNotNull ;
18
18
19
- import com .google .common .collect .Maps ;
20
19
import io .netty .bootstrap .ServerBootstrap ;
21
20
import io .netty .channel .Channel ;
22
21
import io .netty .channel .EventLoopGroup ;
23
22
import io .netty .util .concurrent .DefaultThreadFactory ;
24
23
import java .io .Closeable ;
25
24
import java .io .IOException ;
26
- import java .util .Map ;
27
- import java .util .Set ;
28
25
import lombok .Getter ;
29
26
import lombok .extern .slf4j .Slf4j ;
30
27
import org .apache .pulsar .broker .PulsarService ;
37
34
public class ProxyService implements Closeable {
38
35
39
36
@ Getter
40
- private ProxyConfiguration proxyConfig ;
37
+ private final ProxyConfiguration proxyConfig ;
41
38
@ Getter
42
- private PulsarService pulsarService ;
39
+ private final PulsarService pulsarService ;
43
40
@ Getter
44
41
private LookupHandler lookupHandler ;
45
42
46
43
private Channel listenChannel ;
47
- private EventLoopGroup acceptorGroup ;
44
+ private final EventLoopGroup acceptorGroup ;
48
45
@ Getter
49
- private EventLoopGroup workerGroup ;
46
+ private final EventLoopGroup workerGroup ;
50
47
51
- private DefaultThreadFactory acceptorThreadFactory = new DefaultThreadFactory ("amqp-redirect-acceptor" );
52
- private DefaultThreadFactory workerThreadFactory = new DefaultThreadFactory ("amqp-redirect-io" );
53
- private static final int numThreads = Runtime .getRuntime ().availableProcessors ();
54
-
55
- @ Getter
56
- private static final Map <String , Set <ProxyConnection >> vhostConnectionMap = Maps .newConcurrentMap ();
48
+ private static final int NUM_THREADS = Runtime .getRuntime ().availableProcessors ();
57
49
58
50
private String tenant ;
59
51
@@ -63,8 +55,10 @@ public ProxyService(ProxyConfiguration proxyConfig, PulsarService pulsarService)
63
55
this .proxyConfig = proxyConfig ;
64
56
this .pulsarService = pulsarService ;
65
57
this .tenant = this .proxyConfig .getAmqpTenant ();
66
- acceptorGroup = EventLoopUtil .newEventLoopGroup (1 , false , acceptorThreadFactory );
67
- workerGroup = EventLoopUtil .newEventLoopGroup (numThreads , false , workerThreadFactory );
58
+ this .acceptorGroup = EventLoopUtil .newEventLoopGroup (1 , false ,
59
+ new DefaultThreadFactory ("amqp-redirect-acceptor" ));
60
+ this .workerGroup = EventLoopUtil .newEventLoopGroup (NUM_THREADS , false ,
61
+ new DefaultThreadFactory ("amqp-redirect-io" ));
68
62
}
69
63
70
64
private void configValid (ProxyConfiguration proxyConfig ) {
@@ -89,16 +83,6 @@ public void start() throws Exception {
89
83
this .lookupHandler = new PulsarServiceLookupHandler (proxyConfig , pulsarService );
90
84
}
91
85
92
- private void releaseConnection (String namespaceName ) {
93
- log .info ("release connection" );
94
- if (vhostConnectionMap .containsKey (namespaceName )) {
95
- Set <ProxyConnection > proxyConnectionSet = vhostConnectionMap .get (namespaceName );
96
- for (ProxyConnection proxyConnection : proxyConnectionSet ) {
97
- proxyConnection .close ();
98
- }
99
- }
100
- }
101
-
102
86
@ Override
103
87
public void close () throws IOException {
104
88
if (lookupHandler != null ) {
0 commit comments