15
15
/**
16
16
* @author chenxiaofan
17
17
*/
18
- public class BatchFlushEndPointContext {
18
+ public class AutoBatchFlushEndPointContext {
19
19
20
- private static final InternalLogger logger = InternalLoggerFactory .getInstance (BatchFlushEndPointContext .class );
20
+ private static final InternalLogger logger = InternalLoggerFactory .getInstance (AutoBatchFlushEndPointContext .class );
21
21
22
22
public static class HasOngoingSendLoop {
23
23
@@ -51,26 +51,26 @@ public void exit() {
51
51
52
52
}
53
53
54
- BatchFlushEndPointContext () {
54
+ AutoBatchFlushEndPointContext () {
55
55
}
56
56
57
57
/**
58
- * Tasks that failed to send (probably due to connection errors)
58
+ * Commands that failed to send (probably due to connection errors)
59
59
*/
60
60
@ Nullable
61
- Deque <RedisCommand <?, ?, ?>> retryableFailedToSendTasks = null ;
61
+ Deque <RedisCommand <?, ?, ?>> retryableFailedToSendCommands = null ;
62
62
63
63
Throwable firstDiscontinueReason = null ;
64
64
65
65
public Throwable getFirstDiscontinueReason () {
66
66
return firstDiscontinueReason ;
67
67
}
68
68
69
- private int flyingTaskNum ;
69
+ private int flyingCmdNum ;
70
70
71
71
@ SuppressWarnings ("unused" )
72
- public int getFlyingTaskNum () {
73
- return flyingTaskNum ;
72
+ public int getFlyingCmdNum () {
73
+ return flyingCmdNum ;
74
74
}
75
75
76
76
private int total = 0 ;
@@ -83,47 +83,48 @@ public int getTotal() {
83
83
84
84
public void add (int n ) {
85
85
this .total += n ;
86
- this .flyingTaskNum += n ;
86
+ this .flyingCmdNum += n ;
87
87
}
88
88
89
- public @ Nullable Deque <RedisCommand <?, ?, ?>> getAndClearRetryableFailedToSendTasks () {
90
- final Deque <RedisCommand <?, ?, ?>> old = this .retryableFailedToSendTasks ;
91
- // don't set to null so give us a chance to expose potential bugs if there is addRetryableFailedToSendTask() afterwards
92
- this .retryableFailedToSendTasks = UnmodifiableDeque .emptyDeque ();
89
+ public @ Nullable Deque <RedisCommand <?, ?, ?>> getAndClearRetryableFailedToSendCommands () {
90
+ final Deque <RedisCommand <?, ?, ?>> old = this .retryableFailedToSendCommands ;
91
+ // don't set to null so give us a chance to expose potential bugs if there is addRetryableFailedToSendCommand()
92
+ // afterwards
93
+ this .retryableFailedToSendCommands = UnmodifiableDeque .emptyDeque ();
93
94
return old ;
94
95
}
95
96
96
97
public void done (int n ) {
97
- this .flyingTaskNum -= n ;
98
+ this .flyingCmdNum -= n ;
98
99
}
99
100
100
101
public boolean isDone () {
101
- if (this .flyingTaskNum < 0 ) {
102
- logger .error ("[unexpected] flyingTaskNum < 0, flyingTaskNum : {}, total: {}" , this .flyingTaskNum , this .total );
102
+ if (this .flyingCmdNum < 0 ) {
103
+ logger .error ("[unexpected] flyingCmdNum < 0, flyingCmdNum : {}, total: {}" , this .flyingCmdNum , this .total );
103
104
return true ;
104
105
}
105
- return this .flyingTaskNum == 0 ;
106
+ return this .flyingCmdNum == 0 ;
106
107
}
107
108
108
- public boolean hasRetryableFailedToSendTasks () {
109
- return retryableFailedToSendTasks != null ;
109
+ public boolean hasRetryableFailedToSendCommands () {
110
+ return retryableFailedToSendCommands != null ;
110
111
}
111
112
112
113
/**
113
- * @param retryableTask retryable task
114
+ * @param retryableCommand retryable command
114
115
* @param cause fail reason
115
- * @return true if this is the first retryable failed task
116
+ * @return true if this is the first retryable failed command
116
117
*/
117
- public boolean addRetryableFailedToSendTask (RedisCommand <?, ?, ?> retryableTask , @ Nonnull Throwable cause ) {
118
- if (retryableFailedToSendTasks == null ) {
119
- retryableFailedToSendTasks = new ArrayDeque <>();
120
- retryableFailedToSendTasks .add (retryableTask );
118
+ public boolean addRetryableFailedToSendCommand (RedisCommand <?, ?, ?> retryableCommand , @ Nonnull Throwable cause ) {
119
+ if (retryableFailedToSendCommands == null ) {
120
+ retryableFailedToSendCommands = new ArrayDeque <>();
121
+ retryableFailedToSendCommands .add (retryableCommand );
121
122
122
123
firstDiscontinueReason = cause ;
123
124
return true ;
124
125
}
125
126
126
- retryableFailedToSendTasks .add (retryableTask );
127
+ retryableFailedToSendCommands .add (retryableCommand );
127
128
return false ;
128
129
}
129
130
0 commit comments