File tree Expand file tree Collapse file tree 5 files changed +17
-28
lines changed
rocketmq-redis/src/main/java/org/apache/rocketmq/redis/replicator Expand file tree Collapse file tree 5 files changed +17
-28
lines changed Original file line number Diff line number Diff line change @@ -275,8 +275,13 @@ public void builtInCommandParserRegister() {
275
275
addCommandParser (CommandName .name ("RPOPLPUSH" ), new RPopLPushParser ());
276
276
}
277
277
278
+ @ Override
279
+ public void close () throws IOException {
280
+ this .connected .compareAndSet (CONNECTED , DISCONNECTING );
281
+ }
282
+
278
283
protected void doClose () throws IOException {
279
- if (! this .connected .compareAndSet (CONNECTED , DISCONNECTING )) return ;
284
+ this .connected .compareAndSet (CONNECTED , DISCONNECTING );
280
285
try {
281
286
if (inputStream != null ) {
282
287
this .inputStream .setRawByteListeners (null );
@@ -287,6 +292,5 @@ protected void doClose() throws IOException {
287
292
} finally {
288
293
this .connected .set (DISCONNECTED );
289
294
}
290
- doCloseListener (this );
291
295
}
292
296
}
Original file line number Diff line number Diff line change @@ -68,7 +68,8 @@ public void open() throws IOException {
68
68
if (!(e .getCause () instanceof EOFException ))
69
69
throw e .getCause ();
70
70
} finally {
71
- close ();
71
+ doClose ();
72
+ doCloseListener (this );
72
73
}
73
74
}
74
75
@@ -97,10 +98,4 @@ protected void doOpen() throws IOException {
97
98
}
98
99
}
99
100
}
100
-
101
- @ Override
102
- public void close () throws IOException {
103
- doClose ();
104
- }
105
-
106
101
}
Original file line number Diff line number Diff line change @@ -75,7 +75,8 @@ public void open() throws IOException {
75
75
if (!(e .getCause () instanceof EOFException ))
76
76
throw e .getCause ();
77
77
} finally {
78
- close ();
78
+ doClose ();
79
+ doCloseListener (this );
79
80
}
80
81
}
81
82
@@ -107,9 +108,4 @@ protected void doOpen() throws IOException {
107
108
}
108
109
}
109
110
}
110
-
111
- @ Override
112
- public void close () throws IOException {
113
- doClose ();
114
- }
115
111
}
Original file line number Diff line number Diff line change @@ -56,18 +56,13 @@ public void open() throws IOException {
56
56
if (!(e .getCause () instanceof EOFException ))
57
57
throw e .getCause ();
58
58
} finally {
59
- close ();
59
+ doClose ();
60
+ doCloseListener (this );
60
61
}
61
62
}
62
63
63
64
protected void doOpen () throws IOException {
64
65
RdbParser parser = new RdbParser (inputStream , this );
65
66
parser .parse ();
66
67
}
67
-
68
- @ Override
69
- public void close () throws IOException {
70
- doClose ();
71
- }
72
-
73
68
}
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public void open() throws IOException {
83
83
try {
84
84
doOpen ();
85
85
} finally {
86
- close ();
86
+ doClose ();
87
87
doCloseListener (this );
88
88
}
89
89
}
@@ -112,7 +112,7 @@ protected void doOpen() throws IOException {
112
112
heartbeat ();
113
113
} else if (syncMode == SyncMode .SYNC_LATER && getStatus () == CONNECTED ) {
114
114
i = 0 ;
115
- close ();
115
+ doClose ();
116
116
try {
117
117
Thread .sleep (configuration .getRetryTimeInterval ());
118
118
} catch (InterruptedException interrupt ) {
@@ -167,7 +167,7 @@ public void handle(long len) {
167
167
exception = (IOException ) e ;
168
168
}
169
169
LOGGER .error ("[redis-replicator] socket error" , exception );
170
- close ();
170
+ doClose ();
171
171
//retry psync in next loop.
172
172
if (LOGGER .isInfoEnabled ()) {
173
173
LOGGER .info ("reconnect to redis-server. retry times:" + (i + 1 ));
@@ -404,9 +404,8 @@ protected void connect() throws IOException {
404
404
}
405
405
406
406
@ Override
407
- public void close () {
408
- if (!connected .compareAndSet (CONNECTED , DISCONNECTING ))
409
- return ;
407
+ protected void doClose () throws IOException {
408
+ connected .compareAndSet (CONNECTED , DISCONNECTING );
410
409
411
410
try {
412
411
synchronized (this ) {
You can’t perform that action at this time.
0 commit comments