Skip to content

Commit

Permalink
0005427: Creating a Parameter That, Upon Registration, Will
Browse files Browse the repository at this point in the history
Automatically Create A Group Link Between Nodes if None Exist
  • Loading branch information
catherinequamme committed Aug 26, 2022
1 parent 02611bc commit 68f3a34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Expand Up @@ -106,6 +106,7 @@ private ParameterConstants() {
public final static String REGISTRATION_REQUIRE_NODE_GROUP_LINK = "registration.require.node.group.link";
public final static String REGISTRATION_REQUIRE_INITIAL_LOAD = "registration.require.initial.load";
public final static String REGISTRATION_PUSH_CONFIG_ALLOWED = "registration.push.config.allowed";
public final static String REGISTRATION_AUTO_CREATE_GROUP_LINK = "registration.auto.create.group.link";
public final static String REGISTRATION_URL = "registration.url";
public final static String SYNC_URL = "sync.url";
public final static String ENGINE_NAME = "engine.name";
Expand Down
Expand Up @@ -149,7 +149,7 @@ protected void extractConfiguration(OutputStream out, Node registeredNode) {
protected Node processRegistration(Node nodePriorToRegistration, String remoteHost,
String remoteAddress, String userId, String password, boolean isRequestedRegistration)
throws IOException {
Node processedNode = new Node();
Node processedNode = new Node();
processedNode.setSyncEnabled(false);
if (!allowClientRegistration) {
log.warn("Cannot register a client node until this node has synced triggers");
Expand Down Expand Up @@ -203,7 +203,7 @@ protected Node processRegistration(Node nodePriorToRegistration, String remoteHo
identity.getNodeGroupId(), nodePriorToRegistration.getNodeGroupId(), false);
if (link == null
&& parameterService.is(ParameterConstants.REGISTRATION_REQUIRE_NODE_GROUP_LINK,
true)) {
true) && !parameterService.is(ParameterConstants.REGISTRATION_AUTO_CREATE_GROUP_LINK)) {
RegistrationRequest req = new RegistrationRequest(nodePriorToRegistration,
RegistrationStatus.ER, remoteHost, remoteAddress);
req.setErrorMessage(String.format(
Expand Down Expand Up @@ -238,6 +238,15 @@ protected Node processRegistration(Node nodePriorToRegistration, String remoteHo
RegistrationStatus.RQ, remoteHost, remoteAddress));
return processedNode;
}
if (link == null && parameterService.is(ParameterConstants.REGISTRATION_AUTO_CREATE_GROUP_LINK)) {
link = new NodeGroupLink(identity.getNodeGroupId(), nodePriorToRegistration.getNodeGroupId());
configurationService.saveNodeGroupLink(link);
link = configurationService.getNodeGroupLinkFor(nodePriorToRegistration.getNodeGroupId(), identity.getNodeGroupId(), false);
if (link == null) {
link = new NodeGroupLink(identity.getNodeGroupId(), nodePriorToRegistration.getNodeGroupId(), NodeGroupLinkAction.P);
configurationService.saveNodeGroupLink(link);
}
}
// TODO: since we send sym_node in registration batch, save this record with source_node_id = node_id
foundNode.setSyncEnabled(true);
foundNode.setSyncUrl(nodePriorToRegistration.getSyncUrl());
Expand Down
Expand Up @@ -769,6 +769,13 @@ registration.require.initial.load=true
# Type: boolean
registration.push.config.allowed=true

# When this is set to true a group link will be created by default between two groups even if the user does not explicitly set one up.
#
# DatabaseOverridable: true
# Tags: registration
# Type: boolean
registration.auto.create.group.link=true

# Initial load and reload events should normally block other channels to ensure each table
# is loaded first followed by changes captured during the initial load. Setting this to false
# will allow all channels to load in priority order even when reload events or
Expand Down

0 comments on commit 68f3a34

Please sign in to comment.