Skip to content

Commit

Permalink
0001836: The removal of a node isn't synchronized to other nodes in a…
Browse files Browse the repository at this point in the history
… master to master scenario
  • Loading branch information
chenson42 committed Jul 28, 2014
1 parent 8a1c4ca commit cbb749d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
Expand Up @@ -107,5 +107,11 @@ public interface IConfigurationService {
* @return a map of nodes to redirect to that is keyed by a list of external_ids that should be redirected.
*/
public Map<String,String> getRegistrationRedirectMap();

/**
* Indicates that this node participates in a master to master link
* @return
*/
public boolean isMasterToMaster();

}
Expand Up @@ -34,6 +34,7 @@
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.ChannelMap;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeChannel;
import org.jumpmind.symmetric.model.NodeGroup;
import org.jumpmind.symmetric.model.NodeGroupChannelWindow;
Expand Down Expand Up @@ -90,6 +91,15 @@ public ConfigurationService(IParameterService parameterService, ISymmetricDialec
setSqlMap(new ConfigurationServiceSqlMap(symmetricDialect.getPlatform(),
createSqlReplacementTokens()));
}

public boolean isMasterToMaster() {
boolean masterToMaster = false;
Node me = nodeService.findIdentity();
if (me != null) {
masterToMaster = getNodeGroupLinkFor(me.getNodeGroupId(), me.getNodeGroupId(), false) != null;
}
return masterToMaster;
}

public boolean refreshFromDatabase() {
Date date1 = sqlTemplate.queryForObject(getSql("selectMaxChannelLastUpdateTime"),
Expand Down
Expand Up @@ -278,7 +278,7 @@ public void insertNodeSecurity(String id) {
String password = nodeIdCreator.generatePassword(new Node(id, null, null));
password = filterPasswordOnSaveIfNeeded(password);
sqlTemplate.update(getSql("insertNodeSecuritySql"), new Object[] { id, password,
findIdentity().getNodeId() });
null });
}

public void insertNodeIdentity(String nodeId) {
Expand Down
Expand Up @@ -506,7 +506,9 @@ protected String openRegistration(Node node, String remoteHost, String remoteAdd
if (existingNode == null) {
node.setNodeId(nodeId);
node.setSyncEnabled(false);
node.setCreatedAtNodeId(me.getNodeId());

boolean masterToMaster = configurationService.isMasterToMaster();
node.setCreatedAtNodeId(masterToMaster ? null: me.getNodeId());
nodeService.save(node);

// make sure there isn't a node security row lying around w/out
Expand All @@ -515,7 +517,7 @@ protected String openRegistration(Node node, String remoteHost, String remoteAdd
String password = nodeService.getNodeIdCreator().generatePassword(node);
password = filterPasswordOnSaveIfNeeded(password);
sqlTemplate.update(getSql("openRegistrationNodeSecuritySql"), new Object[] {
nodeId, password, me.getNodeId() });
nodeId, password, masterToMaster ? null : me.getNodeId() });
nodeService.insertNodeGroup(node.getNodeGroupId(), null);
log.info(
"Just opened registration for external id of {} and a node group of {} and a node id of {}",
Expand Down
Expand Up @@ -425,10 +425,10 @@ protected Trigger buildTriggerForSymmetricTable(String tableName) {
boolean syncChanges = !TableConstants.getTablesThatDoNotSync(tablePrefix).contains(
tableName)
&& parameterService.is(ParameterConstants.AUTO_SYNC_CONFIGURATION);
boolean syncOnIncoming = parameterService.is(
boolean syncOnIncoming = !configurationService.isMasterToMaster() && (parameterService.is(
ParameterConstants.AUTO_SYNC_CONFIGURATION_ON_INCOMING, true)
|| tableName.equals(TableConstants.getTableName(tablePrefix,
TableConstants.SYM_TABLE_RELOAD_REQUEST));
TableConstants.SYM_TABLE_RELOAD_REQUEST)));
Trigger trigger = new Trigger();
trigger.setTriggerId(tableName);
trigger.setSyncOnDelete(syncChanges);
Expand Down
2 changes: 1 addition & 1 deletion symmetric-core/src/main/resources/symmetric-schema.xml
Expand Up @@ -487,7 +487,7 @@
<column name="rev_initial_load_time" type="TIMESTAMP" required="false" description="The timestamp when this node last sent an initial load." />
<column name="rev_initial_load_id" type="BIGINT" description="A reference to the load_id in outgoing_batch for the last reverse load that occurred." />
<column name="rev_initial_load_create_by" type="VARCHAR" size="255" description="The user that created the reverse initial load. A null value means that the system created the batch." />
<column name="created_at_node_id" type="VARCHAR" size="50" required="true" description="The node_id of the node where this node was created. This is typically filled automatically with the node_id found in node_identity where registration was opened for the node. " />
<column name="created_at_node_id" type="VARCHAR" size="50" description="The node_id of the node where this node was created. This is typically filled automatically with the node_id found in node_identity where registration was opened for the node. " />
<foreign-key foreignTable="node" name="fk_sec_2_node">
<reference local="node_id" foreign="node_id" />
</foreign-key>
Expand Down

0 comments on commit cbb749d

Please sign in to comment.