| | |
| | | package org.opends.server.synchronization.plugin; |
| | | |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import static org.opends.server.util.ServerConstants. |
| | | TIME_UNIT_MILLISECONDS_ABBR; |
| | | import static org.opends.server.util.ServerConstants. |
| | | TIME_UNIT_MILLISECONDS_FULL; |
| | | import static org.opends.server.util.ServerConstants.TIME_UNIT_SECONDS_ABBR; |
| | | import static org.opends.server.util.ServerConstants.TIME_UNIT_SECONDS_FULL; |
| | | import static org.opends.server.synchronization.common.LogMessages.*; |
| | | import static org.opends.server.synchronization.plugin.Historical.*; |
| | | import static org.opends.server.synchronization.protocol.OperationContext.*; |
| | |
| | | import java.util.List; |
| | | import java.util.SortedMap; |
| | | import java.util.TreeMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | |
| | | import org.opends.server.config.DNConfigAttribute; |
| | | import org.opends.server.config.IntegerConfigAttribute; |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.config.IntegerWithUnitConfigAttribute; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | private int maxReceiveDelay = 0; |
| | | private int maxSendDelay = 0; |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the synchronization |
| | | * server. Zero means heartbeats are off. |
| | | */ |
| | | private long heartbeatInterval = 0; |
| | | |
| | | private short serverId; |
| | | |
| | | private BooleanConfigAttribute receiveStatusStub; |
| | |
| | | static String MAX_SEND_QUEUE = "ds-cfg-max-send-queue"; |
| | | static String MAX_SEND_DELAY = "ds-cfg-max-send-delay"; |
| | | static String WINDOW_SIZE = "ds-cfg-window-size"; |
| | | static String HEARTBEAT_INTERVAL = "ds-cfg-heartbeat-interval"; |
| | | |
| | | private static final StringConfigAttribute changelogStub = |
| | | new StringConfigAttribute(CHANGELOG_SERVER_ATTR, |
| | |
| | | true, false, false); |
| | | |
| | | /** |
| | | * The set of time units that will be used for expressing the heartbeat |
| | | * interval. |
| | | */ |
| | | private static final LinkedHashMap<String,Double> timeUnits = |
| | | new LinkedHashMap<String,Double>(); |
| | | |
| | | |
| | | |
| | | static |
| | | { |
| | | timeUnits.put(TIME_UNIT_MILLISECONDS_ABBR, 1D); |
| | | timeUnits.put(TIME_UNIT_MILLISECONDS_FULL, 1D); |
| | | timeUnits.put(TIME_UNIT_SECONDS_ABBR, 1000D); |
| | | timeUnits.put(TIME_UNIT_SECONDS_FULL, 1000D); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new SynchronizationDomain using configuration from configEntry. |
| | | * |
| | | * @param configEntry The ConfigEntry to use to read the configuration of this |
| | |
| | | configAttributes.add(windowAttr); |
| | | } |
| | | |
| | | IntegerWithUnitConfigAttribute heartbeatStub = |
| | | new IntegerWithUnitConfigAttribute(HEARTBEAT_INTERVAL, |
| | | "heartbeat interval", |
| | | false, timeUnits, true, 0, false, 0); |
| | | IntegerWithUnitConfigAttribute heartbeatAttr = |
| | | (IntegerWithUnitConfigAttribute) |
| | | configEntry.getConfigAttribute(heartbeatStub); |
| | | if (heartbeatAttr == null) |
| | | { |
| | | // Attribute is not present : use the default value |
| | | heartbeatInterval = 1000; |
| | | } |
| | | else |
| | | { |
| | | heartbeatInterval = heartbeatAttr.activeCalculatedValue(); |
| | | configAttributes.add(heartbeatAttr); |
| | | } |
| | | |
| | | configDn = configEntry.getDN(); |
| | | DirectoryServer.registerConfigurableComponent(this); |
| | | |
| | |
| | | try |
| | | { |
| | | broker = new ChangelogBroker(state, baseDN, serverId, maxReceiveQueue, |
| | | maxReceiveDelay, maxSendQueue, maxSendDelay, window); |
| | | maxReceiveDelay, maxSendQueue, maxSendDelay, window, |
| | | heartbeatInterval); |
| | | synchronized (broker) |
| | | { |
| | | broker.start(changelogServers); |
| | |
| | | { |
| | | return broker.getCurrentSendWindow(); |
| | | } |
| | | |
| | | /** |
| | | * Get the number of times the synchronization connection was lost. |
| | | * @return The number of times the synchronization connection was lost. |
| | | */ |
| | | public int getNumLostConnections() |
| | | { |
| | | return broker.getNumLostConnections(); |
| | | } |
| | | } |