rename field

This commit is contained in:
wangshilong 2024-12-07 14:34:33 +08:00
parent f100573e82
commit 8af4dba748
1 changed files with 9 additions and 9 deletions

View File

@ -24,12 +24,13 @@ import java.util.concurrent.atomic.AtomicReference;
*/
@Slf4j
public class SyncPriorityChannel implements Runnable {
private static final int allowTimeout = 1;
private static final int allowRetryCount = 1;
private static final boolean isControl = true;
private final SocketChannel channel;
private int timeoutCount;
private int timeoutRetryCount = 0;
@Getter
private volatile String identifier;
@Getter
@ -65,7 +66,7 @@ public class SyncPriorityChannel implements Runnable {
}
public synchronized void sendNext() {
if (this.timeoutCount == 0) {
if (this.timeoutRetryCount == 0) {
this.currentMessageReference.setRelease(this.messageQueue.poll());
}
@ -79,7 +80,6 @@ public class SyncPriorityChannel implements Runnable {
int port = remoteAddress.getPort();
String ip = remoteAddress.getHostString();
this.channelPromiseReference.setRelease(this.channel.newPromise());
if (isControl || Objects.equals(CommandTypeComparable.CommandType.COLLECTION, this.getCurrentMessage().getType())) {
log.info("发送命令:{},长度:{},通道:{},IP:{},还有{}条命令待发送",
@ -97,13 +97,13 @@ public class SyncPriorityChannel implements Runnable {
boolean timeout;
try {
timeout = !this.getChannelPromise().await(3000, TimeUnit.MILLISECONDS);
timeout = !this.getChannelPromise().await(3, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error("channelPromise.await发生异常,", e);
return;
}
if (timeout && this.timeoutCount == (allowTimeout - 1)) {
if (timeout && this.timeoutRetryCount == (allowRetryCount - 1)) {
log.warn("#超时命令:{},长度:{},通道:{},IP:{},还有{}条命令待发送",
this.getCurrentMessage().getCommand(),
this.getCurrentMessage().getLength(),
@ -112,10 +112,10 @@ public class SyncPriorityChannel implements Runnable {
this.messageQueue.size());
}
if (timeout && this.timeoutCount < (allowTimeout - 1)) {
this.timeoutCount++;
if (timeout && this.timeoutRetryCount < (allowRetryCount - 1)) {
this.timeoutRetryCount++;
} else {
this.timeoutCount = 0;
this.timeoutRetryCount = 0;
}
try {