Skip to content

Commit

Permalink
0001124: Add support to use the jboss.binding.address system property…
Browse files Browse the repository at this point in the history
… in JBoss 7 for the cluster.server.id
  • Loading branch information
chenson42 committed Mar 19, 2013
1 parent dfcd791 commit b506f96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Expand Up @@ -32,6 +32,7 @@ public class SystemConstants {
public static final String SYSPROP_ENGINES_DIR = "symmetric.engines.dir";
public static final String SYSPROP_WEB_DIR = "symmetric.default.web.dir";
public static final String SYSPROP_SERVER_PROPERTIES_PATH = "symmetric.server.properties.path";
public static final String SYSPROP_CLUSTER_SERVER_ID = "runtime.symmetric.cluster.server.id";
public static final String SYSPROP_DEFAULT_HTTP_PORT = "symmetric.default.http.port";
public static final String SYSPROP_DEFAULT_HTTPS_PORT = "symmetric.default.https.port";
public static final String SYSPROP_DEFAULT_JMX_PORT = "symmetric.default.jmx.port";
Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.jumpmind.db.sql.Row;
import org.jumpmind.db.sql.UniqueKeyException;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.SystemConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.model.Lock;
import org.jumpmind.symmetric.service.IClusterService;
Expand Down Expand Up @@ -142,20 +143,30 @@ public String getServerId() {
if (StringUtils.isBlank(serverId)) {
serverId = parameterService.getString(ParameterConstants.CLUSTER_SERVER_ID);
if (StringUtils.isBlank(serverId)) {
serverId = System.getProperty("runtime.symmetric.cluster.server.id", null);
if (StringUtils.isBlank(serverId)) {
// JBoss uses this system property to identify a server in a
// cluster
serverId = System.getProperty("bind.address", null);
if (StringUtils.isBlank(serverId)) {
try {
serverId = AppUtils.getHostName();
} catch (Exception ex) {
serverId = "unknown";
}
}
}
serverId = System.getProperty(SystemConstants.SYSPROP_CLUSTER_SERVER_ID, null);
}

if (StringUtils.isBlank(serverId)) {
// JBoss uses this system property to identify a server in a
// cluster
serverId = System.getProperty("bind.address", null);
}

if (StringUtils.isBlank(serverId)) {
// JBoss uses this system property to identify a server in a
// cluster
serverId = System.getProperty("jboss.bind.address", null);
}

if (StringUtils.isBlank(serverId)) {
try {
serverId = AppUtils.getHostName();
} catch (Exception ex) {
serverId = "unknown";
}
}

log.info("This node picked a server id of {}", serverId);
}
return serverId;
}
Expand Down

0 comments on commit b506f96

Please sign in to comment.