| | |
| | | */ |
| | | private int assuredTimeoutTimerPurgeCounter = 0; |
| | | |
| | | private ServerState ctHeartbeatState; |
| | | |
| | | /** |
| | | * Creates a new ReplicationServerDomain associated to the baseDN. |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * Return the state that contain for each server the time of eligibility. |
| | | * @return the state. |
| | | */ |
| | | public ServerState getChangeTimeHeartbeatState() |
| | | { |
| | | if (ctHeartbeatState == null) |
| | | { |
| | | ctHeartbeatState = getLatestServerState().duplicate(); |
| | | } |
| | | return ctHeartbeatState; |
| | | } |
| | | |
| | | /** |
| | | * Returns the oldest known state for the domain, made of the oldest CSN |
| | | * stored for each serverId. |
| | | * <p> |
| | |
| | | * |
| | | * @return the eligible CSN. |
| | | */ |
| | | public CSN getEligibleCSN() |
| | | CSN getEligibleCSN() |
| | | { |
| | | CSN eligibleCSN = null; |
| | | |
| | | final ServerState newestCSNs = domainDB.getDomainNewestCSNs(baseDN); |
| | | for (final CSN replicaNewestCSN : newestCSNs) |
| | | for (final CSN lastAliveCSN : domainDB.getDomainLastAliveCSNs(baseDN)) |
| | | { |
| | | // Should it be considered for eligibility ? |
| | | int serverId = replicaNewestCSN.getServerId(); |
| | | CSN heartbeatLastCSN = getChangeTimeHeartbeatState().getCSN(serverId); |
| | | |
| | | // If the most recent UpdateMsg or CLHeartbeatMsg received is very old |
| | | // then the domain is considered down and not considered for eligibility |
| | | /* |
| | | if ((heartbeatLastDN != null) && |
| | | (TimeThread.getTime()- heartbeatLastDN.getTime() > 5000)) |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("In " + this.getName() + |
| | | " Server " + sid |
| | | + " is not considered for eligibility ... potentially down"); |
| | | continue; |
| | | } |
| | | */ |
| | | |
| | | final int serverId = lastAliveCSN.getServerId(); |
| | | if (!isServerConnected(serverId)) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (eligibleCSN == null || replicaNewestCSN.isNewerThan(eligibleCSN)) |
| | | if (eligibleCSN == null || lastAliveCSN.isNewerThan(eligibleCSN)) |
| | | { |
| | | eligibleCSN = replicaNewestCSN; |
| | | } |
| | | if (heartbeatLastCSN != null && heartbeatLastCSN.isNewerThan(eligibleCSN)) |
| | | { |
| | | eligibleCSN = heartbeatLastCSN; |
| | | eligibleCSN = lastAliveCSN; |
| | | } |
| | | } |
| | | |
| | |
| | | * @param msg The message to process. |
| | | */ |
| | | public void processChangeTimeHeartbeatMsg(ServerHandler senderHandler, |
| | | ChangeTimeHeartbeatMsg msg ) |
| | | ChangeTimeHeartbeatMsg msg) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | storeReceivedCTHeartbeat(msg.getCSN()); |
| | | domainDB.replicaHeartbeat(baseDN, msg.getCSN()); |
| | | if (senderHandler.isDataServer()) |
| | | { |
| | | // If we are the first replication server warned, |
| | |
| | | } |
| | | |
| | | /** |
| | | * Store a change time value received from a data server. |
| | | * @param csn The provided change time. |
| | | */ |
| | | public void storeReceivedCTHeartbeat(CSN csn) |
| | | { |
| | | // TODO:Maybe we can spare processing by only storing CSN (timestamp) |
| | | // instead of a server state. |
| | | getChangeTimeHeartbeatState().update(csn); |
| | | } |
| | | |
| | | /** |
| | | * This methods count the changes, server by server : |
| | | * - from a serverState start point |
| | | * - to (inclusive) an end point (the provided endCSN). |