| | |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | // Returns an error message to notify the sender |
| | | int msgID = de.getMessageID(); |
| | | ErrorMessage errorMsg = |
| | | new ErrorMessage(initMsg.getsenderID(), |
| | | msgID, de.getMessage()); |
| | | broker.publish(errorMsg); |
| | | // An error message has been sent to the peer |
| | | // Nothing more to do locally |
| | | } |
| | | } |
| | | else if (msg instanceof InitializeTargetMessage) |
| | |
| | | ((InitializeTask)ieContext.initializeTask). |
| | | setState(ieContext.updateTaskCompletionState(),ieContext.exception); |
| | | |
| | | ieContext = null; |
| | | releaseIEContext(); |
| | | } |
| | | } |
| | | } |
| | |
| | | try |
| | | { |
| | | source = Integer.decode(sourceString).shortValue(); |
| | | if (source >= -1) |
| | | if ((source >= -1) && (source != serverId)) |
| | | { |
| | | // TODO Verifies serverID is in the domain |
| | | // We shold check here that this is a server implied |
| | |
| | | public void initializeTarget(short target, short requestorID, Task initTask) |
| | | throws DirectoryException |
| | | { |
| | | // FIXME Temporary workaround - will probably be fixed when implementing |
| | | // dynamic config |
| | | retrievesBackendInfos(this.baseDN); |
| | | |
| | | acquireIEContext(); |
| | | |
| | | ieContext.exportTarget = target; |
| | | ieContext.initializeTask = initTask; |
| | | ieContext.initTaskCounters(backend.getEntryCount()); |
| | | if (initTask != null) |
| | | { |
| | | ieContext.initializeTask = initTask; |
| | | ieContext.initTaskCounters(backend.getEntryCount()); |
| | | } |
| | | |
| | | // Send start message |
| | | // Send start message to the peer |
| | | InitializeTargetMessage initializeMessage = new InitializeTargetMessage( |
| | | baseDN, serverId, ieContext.exportTarget, requestorID, |
| | | ieContext.entryLeftCount); |
| | | backend.getEntryCount()); |
| | | |
| | | log("SD : publishes " + initializeMessage + |
| | | " for #entries=" + ieContext.entryCount); |
| | | " for #entries=" + backend.getEntryCount() + ieContext.entryLeftCount); |
| | | |
| | | broker.publish(initializeMessage); |
| | | |
| | | // make an export and send entries |
| | | exportBackend(); |
| | | |
| | | // Successfull termnation |
| | | DoneMessage doneMsg = new DoneMessage(serverId, |
| | | initializeMessage.getDestination()); |
| | | broker.publish(doneMsg); |
| | | |
| | | if (ieContext != null) |
| | | try |
| | | { |
| | | ieContext.updateTaskCompletionState(); |
| | | ieContext = null; |
| | | exportBackend(); |
| | | |
| | | // Notify the peer of the success |
| | | DoneMessage doneMsg = new DoneMessage(serverId, |
| | | initializeMessage.getDestination()); |
| | | broker.publish(doneMsg); |
| | | |
| | | releaseIEContext(); |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | // Notify the peer of the failure |
| | | int msgID = de.getMessageID(); |
| | | ErrorMessage errorMsg = |
| | | new ErrorMessage(target, |
| | | msgID, de.getMessage()); |
| | | broker.publish(errorMsg); |
| | | |
| | | releaseIEContext(); |
| | | |
| | | throw(de); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @param baseDN The baseDN of the domain to retrieve |
| | | * @return The domain retrieved |
| | | * @throws DirectoryException When an error occured. |
| | | * @throws DirectoryException When an error occured or no domain |
| | | * match the provided baseDN. |
| | | */ |
| | | public static ReplicationDomain retrievesReplicationDomain(DN baseDN) |
| | | throws DirectoryException |
| | |
| | | MultimasterReplication.findDomain(baseDN, null); |
| | | if (sdomain == null) |
| | | { |
| | | int msgID = MSGID_NO_MATCHING_DOMAIN; |
| | | String message = getMessage(msgID) + " " + baseDN; |
| | | throw new DirectoryException(ResultCode.OTHER, |
| | | message, msgID); |
| | | break; |
| | | } |
| | | |
| | | if (replicationDomain != null) |
| | | { |
| | | // Should never happen |
| | |
| | | } |
| | | replicationDomain = sdomain; |
| | | } |
| | | |
| | | if (replicationDomain == null) |
| | | { |
| | | int msgID = MSGID_NO_MATCHING_DOMAIN; |
| | | String message = getMessage(msgID) + " " + baseDN; |
| | | throw new DirectoryException(ResultCode.OTHER, |
| | | message, msgID); |
| | | } |
| | | return replicationDomain; |
| | | } |
| | | |