| | |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.replication.protocol.StartECLSessionMsg |
| | | .ECLRequestType.*; |
| | |
| | | */ |
| | | private void computeNextEligibleMessageForDomain(String opId) |
| | | { |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo(opId, "ctxt=" + this); |
| | | |
| | | assert(nextMsg == null); |
| | |
| | | { |
| | | final boolean hasBecomeEligible = isEligible(nextNonEligibleMsg); |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo(opId, "stored nonEligibleMsg " + nextNonEligibleMsg |
| | | + " has now become eligible regarding the eligibleCSN (" |
| | | + eligibleCSN + " ): " + hasBecomeEligible); |
| | |
| | | return; |
| | | } |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo(opId, "got new message : [newMsg=" + newMsg + "] " |
| | | + dumpState()); |
| | | |
| | | final boolean isEligible = isEligible(newMsg); |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo(opId, "newMsg isEligible=" + isEligible + " since " |
| | | + "newMsg=[" + toString(newMsg.getCSN()) + "] eligibleCSN=[" |
| | | + toString(eligibleCSN) + "] " + dumpState()); |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | private void debugInfo(String opId, String message) |
| | | { |
| | | TRACER.debugInfo("In ECLServerHandler, for baseDN=" |
| | | logger.trace("In ECLServerHandler, for baseDN=" |
| | | + mh.getBaseDNString() + " getNextEligibleMessageForDomain(" + opId |
| | | + ") " + message); |
| | | } |
| | |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, de); |
| | | logger.traceException(de); |
| | | releaseCursor(); |
| | | throw de; |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | releaseCursor(); |
| | | throw new DirectoryException( |
| | | ResultCode.OPERATIONS_ERROR, |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | // FIXME:ECL do not publish internal exception plumb to the client |
| | | throw new DirectoryException( |
| | | ResultCode.OPERATIONS_ERROR, |
| | |
| | | e), |
| | | e); |
| | | } |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("initializeChangelogDomainCtxts() ends with " |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("initializeChangelogDomainCtxts() ends with " |
| | | + dumpState()); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void shutdown() |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(this + " shutdown()"); |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace(this + " shutdown()"); |
| | | releaseCursor(); |
| | | for (DomainContext domainCtxt : domainCtxts) { |
| | | if (!domainCtxt.unRegisterHandler()) { |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | ERR_INVALID_COOKIE_SYNTAX.get(cookie)); |
| | | } |
| | |
| | | |
| | | registerIntoDomain(); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(getClass().getCanonicalName() + " " + getOperationId() |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace(getClass().getCanonicalName() + " " + getOperationId() |
| | | + " initialized: " + " " + dumpState() + " " + " " |
| | | + domaimCtxtsToString("")); |
| | | } |
| | |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, de); |
| | | logger.traceException(de); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | */ |
| | | public ECLUpdateMsg getNextECLUpdate() throws DirectoryException |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("In cn=changelog" + this + |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("In cn=changelog" + this + |
| | | " getNextECLUpdate starts: " + dumpState()); |
| | | |
| | | ECLUpdateMsg oldestChange = null; |
| | |
| | | |
| | | if (searchPhase == PERSISTENT_PHASE) |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(domaimCtxtsToString( |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace(domaimCtxtsToString( |
| | | "In getNextECLUpdate (persistent): " |
| | | + "looking for the generalized oldest change")); |
| | | |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | throw new DirectoryException( |
| | | ResultCode.OPERATIONS_ERROR, |
| | | LocalizableMessage.raw("Exception raised: "), |
| | |
| | | if (oldestChange != null) |
| | | { |
| | | final CSN csn = oldestChange.getUpdateMsg().getCSN(); |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("getNextECLUpdate updates previousCookie:" + csn); |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("getNextECLUpdate updates previousCookie:" + csn); |
| | | |
| | | previousCookie.update(oldestChange.getBaseDN(), csn); |
| | | oldestChange.setCookie(previousCookie); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("getNextECLUpdate returns result oldestChange=" |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("getNextECLUpdate returns result oldestChange=" |
| | | + oldestChange); |
| | | } |
| | | return oldestChange; |
| | |
| | | final CSN csnFromCNIndexDB = currentRecord.getCSN(); |
| | | final DN baseDNFromCNIndexDB = currentRecord.getBaseDN(); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("assignChangeNumber() comparing the replicaDB's and" |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("assignChangeNumber() comparing the replicaDB's and" |
| | | + " CNIndexDB's baseDNs :" + baseDNFromReplicaDB + "?=" |
| | | + baseDNFromCNIndexDB + " timestamps:" + asDate(csnFromReplicaDB) |
| | | + " ?older" + asDate(csnFromCNIndexDB)); |
| | |
| | | { |
| | | // We matched the ReplicaDB change with a record in the CNIndexDB |
| | | // => set the changeNumber in memory and return the change to the client |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("assignChangeNumber() assigning changeNumber=" |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("assignChangeNumber() assigning changeNumber=" |
| | | + currentRecord.getChangeNumber() + " to change=" |
| | | + replicaDBChange); |
| | | |
| | |
| | | // the change from the replicaDB is older |
| | | // it should have been stored lately |
| | | // let's continue to traverse the replicaDBs |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("assignChangeNumber() will skip " + csnFromReplicaDB |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("assignChangeNumber() will skip " + csnFromReplicaDB |
| | | + " and read next change from the regular changelog."); |
| | | return false; // TO BE CHECKED |
| | | } |
| | |
| | | try |
| | | { |
| | | // keep traversing the CNIndexDB searching for the replicaDB change |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("assignChangeNumber() will skip " + csnFromCNIndexDB |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("assignChangeNumber() will skip " + csnFromCNIndexDB |
| | | + " and read next change from the CNIndexDB."); |
| | | |
| | | isEndOfCNIndexDBReached = !cnIndexDBCursor.next(); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("assignChangeNumber() has skipped to changeNumber=" |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("assignChangeNumber() has skipped to changeNumber=" |
| | | + currentRecord.getChangeNumber() + " csn=" |
| | | + currentRecord.getCSN() + " End of CNIndexDB ?" |
| | | + isEndOfCNIndexDBReached); |
| | | } |
| | | catch (ChangelogException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | // FIXME There is an opportunity for an infinite loop here if the DB |
| | | // continuously throws ChangelogExceptions |
| | | } |
| | |
| | | { |
| | | // starvation of changelog messages |
| | | // all domain have been unactived means are covered |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("In cn=changelog" + "," + this + " closeInitPhase(): " |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("In cn=changelog" + "," + this + " closeInitPhase(): " |
| | | + dumpState()); |
| | | |
| | | // go to persistent phase if one |
| | |
| | | } |
| | | } |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo("In cn=changelog," + this |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("In cn=changelog," + this |
| | | + " findDomainCtxtWithOldestChange() returns " |
| | | + ((oldestCtxt != null) ? oldestCtxt.nextMsg : "-1")); |
| | | |