Skip to content

Commit

Permalink
session disconnect delay configurable (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
nocvalight authored Oct 12, 2020
1 parent fb22342 commit e5d1e19
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public class DataServerConfig {

private int dataSyncNotifyRetry = 3;

private int sessionDisconnectDelayMs = 30000;

/**
* constructor
* @param commonConfig
Expand Down Expand Up @@ -848,6 +850,24 @@ public void setDataSyncNotifyRetry(int dataSyncNotifyRetry) {
this.dataSyncNotifyRetry = dataSyncNotifyRetry;
}

/**
* Getter method for property <tt>sessionDisconnectDelayMs</tt>.
*
* @return property value of sessionDisconnectDelayMs
*/
public int getSessionDisconnectDelayMs() {
return sessionDisconnectDelayMs;
}

/**
* Setter method for property <tt>sessionDisconnectDelayMs</tt>.
*
* @param sessionDisconnectDelayMs value to be assigned to property sessionDisconnectDelayMs
*/
public void setSessionDisconnectDelayMs(int sessionDisconnectDelayMs) {
this.sessionDisconnectDelayMs = sessionDisconnectDelayMs;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import com.alipay.sofa.registry.server.data.bootstrap.DataServerConfig;
import org.springframework.beans.factory.annotation.Autowired;

import com.alipay.remoting.Connection;
Expand All @@ -45,7 +46,6 @@ public class SessionServerConnectionFactory {
private static final Logger LOGGER = LoggerFactory
.getLogger(SessionServerConnectionFactory.class);

private static final int DELAY = 30 * 1000;
private static final Map EMPTY_MAP = new HashMap(0);

/**
Expand All @@ -69,6 +69,9 @@ public class SessionServerConnectionFactory {
@Autowired
private DisconnectEventHandler disconnectEventHandler;

@Autowired
private DataServerConfig dataServerConfig;

/**
* register connection
*
Expand Down Expand Up @@ -125,7 +128,7 @@ public void sessionDisconnected(String sessionConnAddress) {
// The SessionServerDisconnectEvent is triggered only when the last connection is broken
if (pair == null || pair.getConnections().isEmpty()) {
disconnectEventHandler.receive(new SessionServerDisconnectEvent(processId,
sessionConnAddress, DELAY));
sessionConnAddress, dataServerConfig.getSessionDisconnectDelayMs()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ data.server.metaServerPort=9611
data.server.storeNodes=3
data.server.numberOfReplicas=1000
data.server.datumTimeToLiveSec=900
data.server.sessionDisconnectDelayMs=30000

0 comments on commit e5d1e19

Please sign in to comment.