throw new TransactionFailure(localStrings.getLocalString(
"noSuchConfig", "Configuration {0} does not exist.", configRef));
}
}
Property gmsListenerPort = instance.getProperty("GMS_LISTENER_PORT");
boolean needToAddGmsListenerPort = false;
if (gmsListenerPort == null) {
needToAddGmsListenerPort = true;
gmsListenerPort = instance.createChild(Property.class);
gmsListenerPort.setName("GMS_LISTENER_PORT");
gmsListenerPort.setValue(String.format("${GMS_LISTENER_PORT-%s}", instanceName));
// do not add gmsListenerPort until know whether it needs to be fixed or symbolic.
// for non-multicast with generate or list of ip addresses, port needs to be a fixed value
// all members of cluster. for non-multicast with list of uri, the GMS_LISTENER_PORT is
// set to symbolic system environment variable that is set different for each instance of cluster.
}
// handle generation of udp multicast and non-multicast mode for DAS managed cluster.
// inspect cluster attribute broadcast and cluster property GMS_DISCOVERY_URI_LIST.
String DEFAULT_BROADCAST = "udpmulticast";
String broadcastProtocol = instance.getBroadcast();
Property discoveryUriListProp = instance.getProperty("GMS_DISCOVERY_URI_LIST");
String discoveryUriList = discoveryUriListProp != null ? discoveryUriListProp.getValue() : null;
if (discoveryUriList != null && DEFAULT_BROADCAST.equals(broadcastProtocol)) {
// override default broadcast protocol of udp multicast when GMS_DISCOVERY_URI_LIST has been set.
instance.setBroadcast("tcp");
broadcastProtocol = "tcp";
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,ConfigApiLoggerInfo.clusterGSMBroadCast, instance.getBroadcast());
logger.log(Level.FINE, ConfigApiLoggerInfo.clusterGSMDeliveryURI , discoveryUriList);
}
if (DEFAULT_BROADCAST.equals(broadcastProtocol)) {
// only generate these values when they are not set AND broadcastProtocol is set to enable UDP multicast.
// Note: that this is the default for DAS controlled clusters.
if (instance.getGmsMulticastAddress() == null) {
instance.setGmsMulticastAddress(generateHeartbeatAddress());
}
if (instance.getGmsMulticastPort() == null) {
instance.setGmsMulticastPort(generateHeartbeatPort());
}
if (needToAddGmsListenerPort) {
instance.getProperty().add(gmsListenerPort);
}
} else {
final String GENERATE = "generate";
// cover case that broadcast is set to non-multicast and no
// cluster property GMS_DISCOVERY_URI_LIST exists.
// create the property and set to "generate".
// gms-adapter will handle generation of the list when needed
if (discoveryUriListProp == null) {
discoveryUriListProp = instance.createChild(Property.class);
discoveryUriListProp.setName("GMS_DISCOVERY_URI_LIST");
discoveryUriListProp.setValue(GENERATE);
instance.getProperty().add(discoveryUriListProp);
}
String TCPPORT = gmsListenerPort.getValue();
if (GENERATE.equals(discoveryUriListProp.getValue())) {
// TODO: implement UDP unicast.
// Only tcp mode is supported now.
// So either "udpunicast" or "tcp" for broadcast mode is treated the same.