Skip to content

Commit

Permalink
Add GUI for hazelcast config managing TCPIP vs MULTICAST
Browse files Browse the repository at this point in the history
  • Loading branch information
ngaud committed Dec 1, 2020
1 parent eed92c7 commit c711f01
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 10 deletions.
Expand Up @@ -29,6 +29,7 @@
import static org.eclipse.debug.internal.ui.SWTFactory.createWrapLabel;

import java.text.MessageFormat;

import javax.inject.Inject;

import org.arakhne.afc.bootique.variables.VariableNames;
Expand All @@ -44,6 +45,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
Expand All @@ -56,6 +58,7 @@
import io.sarl.eclipse.launching.config.LaunchConfigurationUtils.OutputExtraJreArguments;
import io.sarl.lang.util.CliUtilities;
import io.sarl.sre.eclipse.JanusEclipsePlugin;
import io.sarl.sre.network.boot.configs.JoinMethod;
import io.sarl.sre.network.boot.configs.SreNetworkConfig;
import io.sarl.sre.network.boot.configs.SreNetworkConfigModule;

Expand Down Expand Up @@ -89,6 +92,12 @@ public class JanusLaunchNetworkTab extends JavaLaunchTab {
private Spinner minClusterSizeSpinner;

private Button portAutoIncrementButton;

private Group hazelcastMulticastGroup;

private Button singlePCRadioButton;

private Button multiplePCRadioButton;

private final WidgetListener defaultListener = new WidgetListener();

Expand Down Expand Up @@ -166,6 +175,23 @@ public void createControl(Composite parent) {
null, false, 2);
this.portAutoIncrementButton.addSelectionListener(this.defaultListener);



this.hazelcastMulticastGroup = SWTFactory.createGroup(topComp, Messages.JanusLaunchNetworkTab_11, 1, 1, GridData.FILL_HORIZONTAL);
this.singlePCRadioButton = createRadioButton(hazelcastMulticastGroup, Messages.JanusLaunchNetworkTab_12);
this.singlePCRadioButton.addSelectionListener(this.defaultListener);
this.multiplePCRadioButton = createRadioButton(hazelcastMulticastGroup, Messages.JanusLaunchNetworkTab_13);
this.multiplePCRadioButton.addSelectionListener(this.defaultListener);

final String noOpt = CliUtilities.getCommandLineLastOptionPrefix();
switch(JoinMethod.getDefault()) {
case MULTICAST : this.singlePCRadioButton.setSelection(false);this.multiplePCRadioButton.setSelection(true); break;
case TCP_IP : this.singlePCRadioButton.setSelection(true);this.multiplePCRadioButton.setSelection(false); break;
}




setControl(topComp);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpContextId());
updateComponentStates();
Expand All @@ -180,6 +206,7 @@ protected void updateComponentStates() {
this.minClusterSizeLabel.setEnabled(enable);
this.minClusterSizeSpinner.setEnabled(enable);
this.portAutoIncrementButton.setEnabled(enable);
this.hazelcastMulticastGroup.setEnabled(enable);
}

@Override
Expand All @@ -192,6 +219,14 @@ public void initializeFrom(ILaunchConfiguration configuration) {
this.clusterNameText.setText(arguments.arg(SreNetworkConfig.CLUSTER_NAME_NAME, SreNetworkConfig.DEFAULT_CLUSTER_NAME_VALUE));
this.minClusterSizeSpinner.setSelection(arguments.arg(SreNetworkConfig.MIN_CLUSTER_SIZE_NAME, SreNetworkConfig.DEFAULT_MIN_CLUSTER_SIZE_VALUE));
this.portAutoIncrementButton.setSelection(arguments.arg(SreNetworkConfig.PORT_AUTO_INCREMENT_NAME, SreNetworkConfig.DEFAULT_PORT_AUTO_INCREMENT_VALUE));


switch(JoinMethod.valueOfCaseInsensitive(arguments.arg(SreNetworkConfig.JOIN_METHOD_NAME, JoinMethod.getDefault().toJsonString()))) {
case MULTICAST : this.singlePCRadioButton.setSelection(false);this.multiplePCRadioButton.setSelection(true); break;
case TCP_IP : this.singlePCRadioButton.setSelection(true);this.multiplePCRadioButton.setSelection(false); break;
}


updateComponentStates();
}

Expand All @@ -208,6 +243,8 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
} else {
this.configurator.setExtraClasspathProvider(configuration, CONTRIBUTOR_ID, null);
}

arguments.resetArg(SreNetworkConfig.JOIN_METHOD_NAME);
arguments.apply(configuration, this.configurator);
}

Expand All @@ -225,6 +262,16 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
} else {
this.configurator.setExtraClasspathProvider(configuration, CONTRIBUTOR_ID, null);
}

if (this.singlePCRadioButton.getSelection()) {
arguments.arg(SreNetworkConfig.JOIN_METHOD_NAME, JoinMethod.TCP_IP.toJsonString(), JoinMethod.getDefault().toJsonString());
}

if (this.multiplePCRadioButton.getSelection()) {
arguments.arg(SreNetworkConfig.JOIN_METHOD_NAME, JoinMethod.MULTICAST.toJsonString(), JoinMethod.getDefault().toJsonString());
}


arguments.apply(configuration, this.configurator);
}

Expand Down
Expand Up @@ -36,7 +36,6 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$
public static String JanusLaunchNetworkTab_0;
public static String JanusLaunchNetworkTab_1;
public static String JanusLaunchNetworkTab_10;
public static String JanusLaunchNetworkTab_2;
public static String JanusLaunchNetworkTab_3;
public static String JanusLaunchNetworkTab_4;
Expand All @@ -45,6 +44,11 @@ public class Messages extends NLS {
public static String JanusLaunchNetworkTab_7;
public static String JanusLaunchNetworkTab_8;
public static String JanusLaunchNetworkTab_9;
public static String JanusLaunchNetworkTab_10;
public static String JanusLaunchNetworkTab_11;
public static String JanusLaunchNetworkTab_12;
public static String JanusLaunchNetworkTab_13;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Expand Down
@@ -1,14 +1,5 @@
JanusLaunchNetworkTab_0=Networking
JanusLaunchNetworkTab_1=Enable SRE communication over the computer network ({0} or {1})
JanusLaunchNetworkTab_10=Each SRE kernel is an Hazelcast node.\n\
These nodes may interact with the other nodes over a computer\n\
network when they are inside the single Hazelcast group, named\n\
cluster. The minimal number of members in a cluster is a strict\n\
constraint that indicates the Hazelcast infrastructure is waiting\n\
for the given number of cluster members before starting. A consequence\n\
of this constraint is that a SRE is blocked until the Hazelcast framework\n\
has built a cluster with the given amount of members.\n\
The default value for the minimal number of members is {1}.
JanusLaunchNetworkTab_2=Cluster name ({0}):
JanusLaunchNetworkTab_3=Minimal size of the cluster ({0}):
JanusLaunchNetworkTab_4=Auto-incrementation of the socket port numbers ({0})
Expand All @@ -32,3 +23,15 @@ JanusLaunchNetworkTab_5=This panel enables the configuration of the networking f
exchanged messages.
JanusLaunchNetworkTab_8=<name>
JanusLaunchNetworkTab_9=<nb>
JanusLaunchNetworkTab_10=Each SRE kernel is an Hazelcast node.\n\
These nodes may interact with the other nodes over a computer\n\
network when they are inside the single Hazelcast group, named\n\
cluster. The minimal number of members in a cluster is a strict\n\
constraint that indicates the Hazelcast infrastructure is waiting\n\
for the given number of cluster members before starting. A consequence\n\
of this constraint is that a SRE is blocked until the Hazelcast framework\n\
has built a cluster with the given amount of members.\n\
The default value for the minimal number of members is {1}.
JanusLaunchNetworkTab_11=Distributed or Local
JanusLaunchNetworkTab_12=Multiple SREs on a single computer (TCP_IP)
JanusLaunchNetworkTab_13=Multiple SREs on different computers within a given subnetwork (Multicast)

0 comments on commit c711f01

Please sign in to comment.