Skip to content

Commit

Permalink
SYMMETRICDS-603- Add setting to allow a client to push an initial loa…
Browse files Browse the repository at this point in the history
…d back to the server after registration.
  • Loading branch information
chenson42 committed Apr 5, 2012
1 parent 66f2df8 commit 4497bea
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Expand Up @@ -68,6 +68,7 @@ private ParameterConstants() {

public final static String AUTO_REGISTER_ENABLED = "auto.registration";
public final static String AUTO_RELOAD_ENABLED = "auto.reload";
public final static String AUTO_RELOAD_REVERSE_ENABLED = "auto.reload.reverse";
public final static String AUTO_INSERT_REG_SVR_IF_NOT_FOUND = "auto.insert.registration.svr.if.not.found";
public final static String AUTO_SYNC_CONFIGURATION = "auto.sync.configuration";
public final static String AUTO_CONFIGURE_DATABASE = "auto.config.database";
Expand Down
Expand Up @@ -25,6 +25,7 @@
import java.net.ConnectException;
import java.net.UnknownHostException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
Expand All @@ -37,6 +38,7 @@
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeGroupLinkAction;
import org.jumpmind.symmetric.model.NodeSecurity;
import org.jumpmind.symmetric.model.RegistrationRequest;
import org.jumpmind.symmetric.model.RegistrationRequest.RegistrationStatus;
Expand Down Expand Up @@ -277,6 +279,7 @@ public void registerWithServer() {
Node node = nodeService.findIdentity();
if (node != null) {
log.info("Successfully registered node [id={}]", node.getNodeId());
sendInitialLoadFromRegisteredNode();
} else {
log.error("Node identity is missing after registration. The registration server may be misconfigured or have an error.");
registered = false;
Expand All @@ -294,6 +297,17 @@ public void registerWithServer() {
parameterService.getString(ParameterConstants.REGISTRATION_NUMBER_OF_ATTEMPTS)));
}
}

protected void sendInitialLoadFromRegisteredNode() {
if (parameterService.is(ParameterConstants.AUTO_RELOAD_REVERSE_ENABLED)) {
List<Node> nodes = new ArrayList<Node>();
nodes.addAll(nodeService.findTargetNodesFor(NodeGroupLinkAction.P));
nodes.addAll(nodeService.findTargetNodesFor(NodeGroupLinkAction.W));
for (Node node : nodes) {
nodeService.setInitialLoadEnabled(node.getNodeId(), true);
}
}
}

/**
* @see IRegistrationService#reOpenRegistration(String)
Expand Down
Expand Up @@ -395,6 +395,14 @@ auto.registration=false
# Type: boolean
auto.reload=false

# If this is true, a reload is automatically sent from a source node
# to all target nodes after the source node has registered.
#
# DatabaseOverridable: true
# Tags: general
# Type: boolean
auto.reload.reverse=false

# Set this if you want to give your server a unique name to be used to identify which server did what action. Typically useful when running in
# a clustered environment. This is currently used by the ClusterService when locking for a node.
#
Expand Down

0 comments on commit 4497bea

Please sign in to comment.