opends/src/server/org/opends/server/changelog/Changelog.java
@@ -81,7 +81,7 @@ private static boolean runListen = true; /* The list of changelog servers configured by the administrator */ private List<String> configuredChangelogs; private List<String> changelogServers; /* This table is used to store the list of dn for which we are currently * handling servers. @@ -92,15 +92,75 @@ private String localhostname = "null"; private String localURL = "null"; private static boolean shutdown = false; private List<String> changelogServers = null; private short changelogServerId; private DN configDn; private List<ConfigAttribute> configAttributes = new ArrayList<ConfigAttribute>(); static String CHANGELOG_SERVER_ATTR = "ds-cfg-changelog-server"; static String SERVER_ID_ATTR = "ds-cfg-changelog-server-id"; static String CHANGELOG_PORT_ATTR = "ds-cfg-changelog-port"; static final String CHANGELOG_SERVER_ATTR = "ds-cfg-changelog-server"; static final String SERVER_ID_ATTR = "ds-cfg-changelog-server-id"; static final String CHANGELOG_PORT_ATTR = "ds-cfg-changelog-port"; static final IntegerConfigAttribute changelogPortStub = new IntegerConfigAttribute(CHANGELOG_PORT_ATTR, "changelog port", true, false, false, true, 0, true, 65535); static final IntegerConfigAttribute serverIdStub = new IntegerConfigAttribute(SERVER_ID_ATTR, "server ID", true, false, false, true, 0, true, 65535); static final StringConfigAttribute changelogStub = new StringConfigAttribute(CHANGELOG_SERVER_ATTR, "changelog server information", true, true, false); /** * Check if a ConfigEntry is valid. * @param config The config entry that needs to be checked. * @param unacceptableReason A description of the reason why the config entry * is not acceptable (if return is false). * @return a boolean indicating if the configEntry is valid. */ public static boolean checkConfigEntry(ConfigEntry config, StringBuilder unacceptableReason) { try { IntegerConfigAttribute changelogPortAttr; changelogPortAttr = (IntegerConfigAttribute) config.getConfigAttribute(changelogPortStub); /* The config must provide a changelog port number */ if (changelogPortAttr == null) { unacceptableReason.append( MessageHandler.getMessage(MSGID_NEED_CHANGELOG_PORT, config.getDN().toString()) ); } /* * read the server Id information * this is a single valued integer, its value must fit on a * short integer */ IntegerConfigAttribute serverIdAttr = (IntegerConfigAttribute) config.getConfigAttribute(serverIdStub); if (serverIdAttr == null) { unacceptableReason.append( MessageHandler.getMessage(MSGID_NEED_SERVER_ID, config.getDN().toString()) ); } return true; } catch (ConfigException e) { return false; } } /** * Creates a new Changelog using the provided configuration entry. @@ -110,10 +170,6 @@ */ public Changelog(ConfigEntry config) throws ConfigException { IntegerConfigAttribute changelogPortStub = new IntegerConfigAttribute(CHANGELOG_PORT_ATTR, "changelog port", true, false, false, true, 0, true, 65535); IntegerConfigAttribute changelogPortAttr = (IntegerConfigAttribute) config.getConfigAttribute(changelogPortStub); /* if there is no changelog port configured, this process must not be a @@ -133,9 +189,6 @@ * this is a single valued integer, its value must fit on a * short integer */ IntegerConfigAttribute serverIdStub = new IntegerConfigAttribute(SERVER_ID_ATTR, "server ID", true, false, false, true, 0, true, 65535); IntegerConfigAttribute serverIdAttr = (IntegerConfigAttribute) config.getConfigAttribute(serverIdStub); @@ -152,19 +205,16 @@ * read the centralized changelog server configuration * this is a multivalued attribute */ StringConfigAttribute changelogStub = new StringConfigAttribute(CHANGELOG_SERVER_ATTR, "changelog server information", true, true, false); StringConfigAttribute changelogServer = (StringConfigAttribute) config.getConfigAttribute(changelogStub); if (changelogServer == null) { throw new ConfigException(MSGID_NEED_CHANGELOG_SERVER, MessageHandler.getMessage(MSGID_NEED_CHANGELOG_SERVER, config.getDN().toString()) ); changelogServers = new ArrayList<String>(); } changelogServers = changelogServer.activeValues(); else { changelogServers = changelogServer.activeValues(); } configAttributes.add(changelogServer); initialize(changelogServerId, changelogPort, changelogServers); @@ -275,7 +325,7 @@ * check that all changelog in the config are in the connected Set * if not create the connection */ for (String serverURL : configuredChangelogs) for (String serverURL : changelogServers) { if ((serverURL.compareTo(localURL) != 0) && (!connectedChangelogs.contains(serverURL))) @@ -353,7 +403,6 @@ /* * create changelog cache */ configuredChangelogs = changelogServers; serverId = changelogId; /* opends/src/server/org/opends/server/core/SynchronizationProviderConfigManager.java
@@ -788,7 +788,7 @@ // NYI return false; return true; } @@ -835,7 +835,7 @@ // NYI return false; return true; } opends/src/server/org/opends/server/synchronization/MultimasterSynchronization.java
@@ -67,6 +67,7 @@ static String SYNCHRONIZATION_CLASS = "ds-cfg-synchronization-provider-config"; private DN changelogConfigEntryDn = null; private Changelog changelog = null; private static Map<DN, SynchronizationDomain> domains = new HashMap<DN, SynchronizationDomain>() ; @@ -92,8 +93,6 @@ public void initializeSynchronizationProvider(ConfigEntry configEntry) throws ConfigException { DN configEntryDn = null; SynchMessages.registerMessages(); configEntry.registerAddListener(this); @@ -104,8 +103,9 @@ */ try { configEntryDn = DN.decode(CHANGELOG_DN); ConfigEntry config = DirectoryServer.getConfigEntry(configEntryDn); changelogConfigEntryDn = DN.decode(CHANGELOG_DN); ConfigEntry config = DirectoryServer.getConfigEntry(changelogConfigEntryDn); /* * If there is no such entry, this process must not be a changelog server */ @@ -128,9 +128,7 @@ { if (domainEntry.hasObjectClass(SYNCHRONIZATION_CLASS)) { SynchronizationDomain domain = new SynchronizationDomain(domainEntry); domains.put(domain.getBaseDN(), domain); domain.start(); createNewSynchronizationDomain(domainEntry); } } } @@ -176,7 +174,28 @@ public boolean configAddIsAcceptable(ConfigEntry configEntry, StringBuilder unacceptableReason) { // TODO Auto-generated method stub // Check if the added entry is the changelog config entry try { if (configEntry.getDN().equals(DN.decode(CHANGELOG_DN))) { return Changelog.checkConfigEntry(configEntry, unacceptableReason); } } catch (DirectoryException e) { /* never happens */ unacceptableReason.append("Invalid Changelog configuration DN"); return false; } // otherwise it must be a Synchronization domain, check for // presence of the Synchronization configuration object class if (configEntry.hasObjectClass(SYNCHRONIZATION_CLASS)) { return SynchronizationDomain.checkConfigEntry(configEntry, unacceptableReason); } return false; } @@ -185,8 +204,56 @@ */ public ConfigChangeResult applyConfigurationAdd(ConfigEntry configEntry) { // TODO Auto-generated method stub return null; // check if the entry is the changelog configuration entry if (configEntry.getDN().equals(changelogConfigEntryDn)) { try { changelog = new Changelog(configEntry); return new ConfigChangeResult(ResultCode.SUCCESS, false); } catch (ConfigException e) { // we should never get to this point because the configEntry has // already been validated in configAddisAcceptable return new ConfigChangeResult(ResultCode.SUCCESS, false); } } // otherwise it must be a synchronization domain, check for // presence of the Synchronization configuration object class if (configEntry.hasObjectClass(SYNCHRONIZATION_CLASS)) { try { createNewSynchronizationDomain(configEntry); return new ConfigChangeResult(ResultCode.SUCCESS, false); } catch (ConfigException e) { // we should never get to this point because the configEntry has // already been validated in configAddisAcceptable return new ConfigChangeResult(ResultCode.SUCCESS, false); } } // we should never get to this point because the configEntry has // already been validated in configAddisAcceptable return new ConfigChangeResult(ResultCode.SUCCESS, false); } /** * Creates a New Synchronization domain from its configEntry, do the * necessary initialization and starts it so that it is * fully operational when this method returns. * @param configEntry The entry whith the configuration of this domain. * @throws ConfigException When the configuration is not valid. */ private void createNewSynchronizationDomain(ConfigEntry configEntry) throws ConfigException { SynchronizationDomain domain; domain = new SynchronizationDomain(configEntry); domains.put(domain.getBaseDN(), domain); domain.start(); } /** @@ -195,6 +262,7 @@ public boolean configDeleteIsAcceptable(ConfigEntry configEntry, StringBuilder unacceptableReason) { // TODO Auto-generated method stub return false; } opends/src/server/org/opends/server/synchronization/SynchronizationDomain.java
@@ -113,7 +113,6 @@ private BooleanConfigAttribute receiveStatusStub; private int listenerThreadNumber = 10; private StringConfigAttribute changelogStub; private boolean receiveStatus = true; private List<String> changelogServers; @@ -138,6 +137,17 @@ static String MAX_SEND_QUEUE = "ds-cfg-max-send-queue"; static String MAX_SEND_DELAY = "ds-cfg-max-send-delay"; private static final StringConfigAttribute changelogStub = new StringConfigAttribute(CHANGELOG_SERVER_ATTR, "changelog server information", true, true, false); private static final IntegerConfigAttribute serverIdStub = new IntegerConfigAttribute(SERVER_ID_ATTR, "server ID", true, false, false, true, 0, true, 65535); private static final DNConfigAttribute baseDnStub = new DNConfigAttribute(BASE_DN_ATTR, "synchronization base DN", true, false, false); /** * Creates a new SynchronizationDomain using configuration from configEntry. @@ -153,8 +163,6 @@ * read the centralized changelog server configuration * this is a multivalued attribute */ changelogStub = new StringConfigAttribute(CHANGELOG_SERVER_ATTR, "changelog server information", true, true, false); StringConfigAttribute changelogServer = (StringConfigAttribute) configEntry.getConfigAttribute(changelogStub); @@ -171,9 +179,6 @@ * read the server Id information * this is a single valued integer, its value must fit on a short integer */ IntegerConfigAttribute serverIdStub = new IntegerConfigAttribute(SERVER_ID_ATTR, "server ID", true, false, false, true, 0, true, 65535); IntegerConfigAttribute serverIdAttr = (IntegerConfigAttribute) configEntry.getConfigAttribute(serverIdStub); if (serverIdAttr == null) @@ -188,9 +193,6 @@ /* * read the base DN */ DNConfigAttribute baseDnStub = new DNConfigAttribute(BASE_DN_ATTR, "synchronization base DN", true, false, false); DNConfigAttribute baseDn = (DNConfigAttribute) configEntry.getConfigAttribute(baseDnStub); if (baseDn == null) @@ -1583,4 +1585,48 @@ } } /** * Check if a ConfigEntry is valid. * @param configEntry The config entry that needs to be checked. * @param unacceptableReason A description of the reason why the config entry * is not acceptable (if return is false). * @return a boolean indicating if the configEntry is valid. */ public static boolean checkConfigEntry(ConfigEntry configEntry, StringBuilder unacceptableReason) { try { StringConfigAttribute changelogServer = (StringConfigAttribute) configEntry.getConfigAttribute(changelogStub); if (changelogServer == null) { unacceptableReason.append( MessageHandler.getMessage(MSGID_NEED_CHANGELOG_SERVER, configEntry.getDN().toString()) ); return false; } /* * read the server Id information * this is a single valued integer, its value must fit on a short integer */ IntegerConfigAttribute serverIdAttr = (IntegerConfigAttribute) configEntry.getConfigAttribute(serverIdStub); if (serverIdAttr == null) { unacceptableReason.append( MessageHandler.getMessage(MSGID_NEED_SERVER_ID, configEntry.getDN().toString()) ); return false; } } catch (ConfigException e) { unacceptableReason.append(e.getMessage()); return false; } return true; } }