From 6e14a8394d193af0fa32b83d3cc424787d41eadd Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 26 Jun 2014 13:19:57 +0000
Subject: [PATCH] OPENDJ-1453 (CR-3870) Replica offline messages should be synced with updates
---
opends/src/server/org/opends/server/replication/server/changelog/file/ReplicationEnvironment.java | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/file/ReplicationEnvironment.java b/opends/src/server/org/opends/server/replication/server/changelog/file/ReplicationEnvironment.java
index 1e658c7..0f8c88e 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/file/ReplicationEnvironment.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/file/ReplicationEnvironment.java
@@ -334,9 +334,13 @@
*/
void clearGenerationId(final DN domainDN) throws ChangelogException
{
- synchronized(domainLock)
+ synchronized (domainLock)
{
final String domainId = domains.get(domainDN);
+ if (domainId == null)
+ {
+ return; // unknow domain => no-op
+ }
final File idFile = retrieveGenerationIdFile(getDomainPath(domainId));
if (idFile != null)
{
@@ -365,6 +369,10 @@
{
clearGenerationId(baseDN);
final String domainId = domains.get(baseDN);
+ if (domainId == null)
+ {
+ return; // unknow domain => no-op
+ }
final File generationIdPath = getGenerationIdPath(domainId, NO_GENERATION_ID);
ensureGenerationIdFileExists(generationIdPath);
}
@@ -386,11 +394,14 @@
synchronized (domainLock)
{
final String domainId = domains.get(domainDN);
+ if (domainId == null)
+ {
+ return; // unknow domain => no-op
+ }
final File serverIdPath = getServerIdPath(domainId, offlineCSN.getServerId());
if (!serverIdPath.exists())
{
- throw new ChangelogException(ERR_CHANGELOG_UNABLE_TO_ADD_REPLICA_OFFLINE_WRONG_PATH.get(
- domainDN.toString(), offlineCSN.getServerId(), serverIdPath.getPath()));
+ return; // no serverId anymore => no-op
}
final File offlineFile = new File(serverIdPath, REPLICA_OFFLINE_STATE_FILENAME);
Writer writer = null;
@@ -428,6 +439,10 @@
synchronized (domainLock)
{
final String domainId = domains.get(domainDN);
+ if (domainId == null)
+ {
+ return; // unknow domain => no-op
+ }
final File offlineFile = new File(getServerIdPath(domainId, serverId), REPLICA_OFFLINE_STATE_FILENAME);
if (offlineFile.exists())
{
@@ -512,14 +527,12 @@
throws ChangelogException
{
final File domainDirectory = getDomainPath(domainEntry.getValue());
- final String generationId = retrieveGenerationId(domainDirectory);
- if (generationId == null)
- {
- throw new ChangelogException(ERR_CHANGELOG_READ_STATE_NO_GENERATION_ID_FOUND.get(
- replicationRootPath, domainDirectory.getPath()));
- }
final DN domainDN = domainEntry.getKey();
- state.setDomainGenerationId(domainDN, toGenerationId(generationId));
+ final String generationId = retrieveGenerationId(domainDirectory);
+ if (generationId != null)
+ {
+ state.setDomainGenerationId(domainDN, toGenerationId(generationId));
+ }
final File[] serverIds = domainDirectory.listFiles(SERVER_ID_FILE_FILTER);
if (serverIds == null)
--
Gitblit v1.10.0