Skip to content

Commit

Permalink
0002520: Multi-master with multiple groups not showing hierarchy on
Browse files Browse the repository at this point in the history
nodes panel
  • Loading branch information
erilong committed Mar 8, 2016
1 parent 67b24f9 commit d58608a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Expand Up @@ -115,5 +115,7 @@ public interface IConfigurationService {
* @return
*/
public boolean isMasterToMaster();

public boolean isMasterToMasterOnly();

}
Expand Up @@ -104,6 +104,15 @@ public boolean isMasterToMaster() {
return masterToMaster;
}

public boolean isMasterToMasterOnly() {
boolean masterToMasterOnly = false;
Node me = nodeService.findIdentity();
if (me != null) {
masterToMasterOnly = sqlTemplate.queryForInt(getSql("countGroupLinksForSql"), me.getNodeGroupId(), me.getNodeGroupId()) == 1;
}
return masterToMasterOnly;
}

public boolean refreshFromDatabase() {
Date date1 = sqlTemplate.queryForObject(getSql("selectMaxChannelLastUpdateTime"),
Date.class);
Expand Down
Expand Up @@ -65,6 +65,8 @@ public ConfigurationServiceSqlMap(IDatabasePlatform platform,
"select source_node_group_id, target_node_group_id, data_event_action, sync_config_enabled, last_update_time, last_update_by, create_time from "
+ " $(node_group_link) where source_node_group_id = ? ");

putSql("countGroupLinksForSql","select count(*) from $(node_group_link) where source_node_group_id = ? or target_node_group_id = ?");

putSql("isChannelInUseSql", "select count(*) from $(trigger) where channel_id = ? ");

putSql("selectChannelsSql",
Expand Down
Expand Up @@ -540,8 +540,8 @@ protected String openRegistration(Node node, String remoteHost, String remoteAdd
node.setNodeId(nodeId);
node.setSyncEnabled(false);

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

// make sure there isn't a node security row lying around w/out
Expand All @@ -550,7 +550,7 @@ protected String openRegistration(Node node, String remoteHost, String remoteAdd
String password = extensionService.getExtensionPoint(INodeIdCreator.class).generatePassword(node);
password = filterPasswordOnSaveIfNeeded(password);
sqlTemplate.update(getSql("openRegistrationNodeSecuritySql"), new Object[] {
nodeId, password, masterToMaster ? null : me.getNodeId() });
nodeId, password, masterToMasterOnly ? 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

0 comments on commit d58608a

Please sign in to comment.