| | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | |
| | | import java.io.File; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.ChangelogServerCfg; |
| | | import org.opends.server.admin.std.server.ReplicationServerCfg; |
| | | import org.opends.server.api.ConfigurableComponent; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.config.ConfigAttribute; |
| | |
| | | */ |
| | | public class ReplicationServer |
| | | implements Runnable, ConfigurableComponent, |
| | | ConfigurationChangeListener<ChangelogServerCfg> |
| | | ConfigurationChangeListener<ReplicationServerCfg> |
| | | { |
| | | private short serverId; |
| | | private String serverURL; |
| | |
| | | |
| | | private String localURL = "null"; |
| | | private boolean shutdown = false; |
| | | private short changelogServerId; |
| | | private short replicationServerId; |
| | | private DN configDn; |
| | | private List<ConfigAttribute> configAttributes = |
| | | new ArrayList<ConfigAttribute>(); |
| | |
| | | * @param configuration The configuration of this replication server. |
| | | * @throws ConfigException When Configuration is invalid. |
| | | */ |
| | | public ReplicationServer(ChangelogServerCfg configuration) |
| | | public ReplicationServer(ReplicationServerCfg configuration) |
| | | throws ConfigException |
| | | { |
| | | shutdown = false; |
| | | runListen = true; |
| | | int changelogPort = configuration.getChangelogPort(); |
| | | changelogServerId = (short) configuration.getChangelogServerId(); |
| | | replicationServers = configuration.getChangelogServer(); |
| | | int replicationPort = configuration.getReplicationPort(); |
| | | replicationServerId = (short) configuration.getReplicationServerId(); |
| | | replicationServers = configuration.getReplicationServer(); |
| | | if (replicationServers == null) |
| | | replicationServers = new ArrayList<String>(); |
| | | queueSize = configuration.getQueueSize(); |
| | | trimAge = configuration.getChangelogPurgeDelay(); |
| | | dbDirname = configuration.getChangelogDbDirectory(); |
| | | trimAge = configuration.getReplicationPurgeDelay(); |
| | | dbDirname = configuration.getReplicationDbDirectory(); |
| | | rcvWindow = configuration.getWindowSize(); |
| | | if (dbDirname == null) |
| | | { |
| | |
| | | e.getMessage() + " " + getFileForPath(dbDirname)); |
| | | } |
| | | |
| | | initialize(changelogServerId, changelogPort); |
| | | initialize(replicationServerId, replicationPort); |
| | | configuration.addChangeListener(this); |
| | | } |
| | | |
| | |
| | | */ |
| | | for (ReplicationCache replicationCache: baseDNs.values()) |
| | | { |
| | | Set<String> connectedChangelogs = replicationCache.getChangelogs(); |
| | | Set<String> connectedReplServers = replicationCache.getChangelogs(); |
| | | /* |
| | | * check that all replication server in the config are in the connected |
| | | * Set. If not create the connection |
| | |
| | | for (String serverURL : replicationServers) |
| | | { |
| | | if ((serverURL.compareTo(this.serverURL) != 0) && |
| | | (!connectedChangelogs.contains(serverURL))) |
| | | (!connectedReplServers.contains(serverURL))) |
| | | { |
| | | this.connect(serverURL, replicationCache.getBaseDn()); |
| | | } |
| | |
| | | * @return true if the configuration is acceptable, false other wise. |
| | | */ |
| | | public static boolean isConfigurationAcceptable( |
| | | ChangelogServerCfg configuration, List<String> unacceptableReasons) |
| | | ReplicationServerCfg configuration, List<String> unacceptableReasons) |
| | | { |
| | | int port = configuration.getChangelogPort(); |
| | | int port = configuration.getReplicationPort(); |
| | | |
| | | try |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | ChangelogServerCfg configuration) |
| | | ReplicationServerCfg configuration) |
| | | { |
| | | // TODO : implement this |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | ChangelogServerCfg configuration, List<String> unacceptableReasons) |
| | | ReplicationServerCfg configuration, List<String> unacceptableReasons) |
| | | { |
| | | // TODO : implement this |
| | | return true; |