Permalink
Browse files

Applied patches from issue #48. Updated RMI server communication to h…

…opefully fix hudson server shutdown issues.

git-svn-id: http://red5.googlecode.com/svn/java/server/trunk@4259 1b6495e4-3631-0410-8e05-8f51eee8b9cc
  • Loading branch information...
1 parent 5e079a6 commit 67573688bae703a516dd268de9d191e95c35f1ab mondain committed Jul 28, 2011
View
2 red5-debug.bat
@@ -1,6 +1,6 @@
@echo off
-if NOT DEFINED RED5_HOME set RED5_HOME=%CD%
+if NOT DEFINED RED5_HOME set RED5_HOME=%~dp0
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
%RED5_HOME%\red5.bat
View
4 red5-highperf.bat
@@ -1,6 +1,6 @@
@echo off
-if NOT DEFINED RED5_HOME set RED5_HOME=.
+if NOT DEFINED RED5_HOME set RED5_HOME=%~dp0
REM Previous option set
REM -Xrs -Xms512M -Xmx768M -Xss128K -XX:PermSize=256M -XX:MaxPermSize=512M -XX:NewRatio=2 -XX:MinHeapFreeRatio=20 -XX:+AggressiveHeap -XX:+DisableExplicitGC -XX:ParallelGCThreads=2 -XX:+UseParallelOldGC -XX:+MaxFDLimit -Dsun.rmi.dgc.client.gcInterval=990000 -Dsun.rmi.dgc.server.gcInterval=990000 -Djava.net.preferIPv4Stack=true -Xverify:none
@@ -11,4 +11,4 @@ REM -Xmx768m -Xms256 -Xmn512m -Xss128k -XX:+AggressiveOpts -XX:+AggressiveHeap -
set JAVA_OPTS= -Xmx768m -Xms256 -Xmn512m -Xss256k -XX:+AggressiveOpts -XX:+DisableExplicitGC -XX:ParallelGCThreads=4 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=16 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=31 -Djava.net.preferIPv4Stack=true
echo Running High Performance Red5
-start cmd /c %RED5_HOME%\red5.bat >> %RED5_HOME%\log\jvm.stdout
+start cmd /c "%RED5_HOME%\red5.bat" >> "%RED5_HOME%\log\jvm.stdout"
View
4 red5-shutdown.bat
@@ -2,12 +2,12 @@
SETLOCAL
-if NOT DEFINED RED5_HOME set RED5_HOME=%CD%
+if NOT DEFINED RED5_HOME set RED5_HOME=%~dp0
set JAVA_OPTS=-Djavax.net.ssl.keyStore="%RED5_HOME%\conf\keystore.jmx" -Djavax.net.ssl.keyStorePassword=password
set RED5_MAINCLASS=org.red5.server.Shutdown
set RED5_OPTS=9999 red5user changeme
"%RED5_HOME%\red5.bat"
-ENDLOCAL
+ENDLOCAL
View
4 red5.bat
@@ -2,7 +2,7 @@
SETLOCAL
-if NOT DEFINED RED5_HOME set RED5_HOME=%CD%
+if NOT DEFINED RED5_HOME set RED5_HOME=%~dp0
if NOT DEFINED RED5_MAINCLASS set RED5_MAINCLASS=org.red5.server.Bootstrap
@@ -13,7 +13,7 @@ REM You can set JAVA_OPTS to add additional options if you want
REM Set up logging options
set LOGGING_OPTS=-Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true
REM Set up security options
-REM set SECURITY_OPTS= -Djava.security.debug=failure -Djava.security.manager -Djava.security.policy=%RED5_HOME%/conf/red5.policy
+REM set SECURITY_OPTS= -Djava.security.debug=failure -Djava.security.manager -Djava.security.policy="%RED5_HOME%/conf/red5.policy"
set SECURITY_OPTS=-Djava.security.debug=failure
set JAVA_OPTS=%LOGGING_OPTS% %SECURITY_OPTS% %JAVA_OPTS%
View
23 src/org/red5/server/Shutdown.java
@@ -48,13 +48,11 @@
@SuppressWarnings("cast")
public static void main(String[] args) {
try {
-
String policyFile = System.getProperty("java.security.policy");
if (policyFile == null) {
System.setProperty("java.security.debug", "failure");
System.setProperty("java.security.policy", "conf/red5.policy");
}
-
/*
try {
// Enable the security manager
@@ -64,31 +62,30 @@ public static void main(String[] args) {
System.err.println("Security manager already set");
}
*/
-
+ // check for the host name as a system prop
+ String rmiAdapterHost = System.getProperty("java.rmi.server.hostname");
+ if (rmiAdapterHost == null) {
+ rmiAdapterHost = "localhost";
+ }
JMXServiceURL url = null;
JMXConnector jmxc = null;
HashMap<String, Object> env = null;
-
if (null == args || args.length < 1) {
- System.out.println("Attempting to connect to RMI port: 9999");
- url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:9999/red5");
+ System.out.printf("Attempting to connect to RMI %s:9999\n", rmiAdapterHost);
+ url = new JMXServiceURL("service:jmx:rmi://" + rmiAdapterHost + ":9999/jndi/rmi://" + rmiAdapterHost + ":9999/red5");
} else {
- System.out.println("Attempting to connect to RMI port: " + args[0]);
- url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" + args[0] + "/red5");
-
+ System.out.printf("Attempting to connect to RMI %s:%s\n", rmiAdapterHost, args[0]);
+ url = new JMXServiceURL("service:jmx:rmi://" + rmiAdapterHost + ":" + args[0] + "/jndi/rmi://" + rmiAdapterHost + ":" + args[0] + "/red5");
if (args.length > 1) {
env = new HashMap<String, Object>(1);
String[] credentials = new String[] { args[1], args[2] };
env.put("jmx.remote.credentials", credentials);
}
}
-
jmxc = JMXConnectorFactory.connect(url, env);
MBeanServerConnection mbs = jmxc.getMBeanServerConnection();
-
//class supporting shutdown
ShutdownMXBean proxy = null;
-
//check for loader registration
ObjectName tomcatObjectName = new ObjectName("org.red5.server:type=TomcatLoader");
ObjectName jettyObjectName = new ObjectName("org.red5.server:type=JettyLoader");
@@ -100,7 +97,7 @@ public static void main(String[] args) {
System.out.println("Red5 Tomcat loader was found");
proxy = JMX.newMXBeanProxy(mbs, tomcatObjectName, ShutdownMXBean.class, true);
} else if (mbs.isRegistered(contextLoaderObjectName)) {
- System.out.println("Red5 Context loader was found");
+ System.out.println("Red5 Context loader was found");
proxy = JMX.newMXBeanProxy(mbs, contextLoaderObjectName, ShutdownMXBean.class, true);
} else {
System.out.println("Red5 Loader was not found, is the server running?");
View
2 src/org/red5/server/api/Red5.java
@@ -43,7 +43,7 @@
*
* @author The Red5 Project (red5@osflash.org)
* @author Luke Hubbard (luke@codegent.com)
- * @author Paul Gregoire (mondain@gmail.com)
+ * @author Paul Gregoire (mondain@gmail.com)
*/
public final class Red5 {
View
30 src/org/red5/server/jmx/JMXAgent.java
@@ -115,8 +115,7 @@ public static boolean registerMBean(Object instance, String className, Class int
cName = cName.substring(cName.lastIndexOf('.')).replaceFirst("[\\.]", "");
}
log.debug("Register name: {}", cName);
- mbs.registerMBean(new StandardMBean(instance, interfaceClass), new ObjectName(JMXFactory.getDefaultDomain()
- + ":type=" + cName));
+ mbs.registerMBean(new StandardMBean(instance, interfaceClass), new ObjectName(JMXFactory.getDefaultDomain() + ":type=" + cName));
status = true;
} catch (InstanceAlreadyExistsException iaee) {
log.debug("Already registered: {}", className);
@@ -154,8 +153,7 @@ public static boolean registerMBean(Object instance, String className, Class int
cName = cName.substring(cName.lastIndexOf('.')).replaceFirst("[\\.]", "");
}
log.debug("Register name: {}", cName);
- mbs.registerMBean(new StandardMBean(instance, interfaceClass), new ObjectName(JMXFactory.getDefaultDomain()
- + ":type=" + cName + ",name=" + name));
+ mbs.registerMBean(new StandardMBean(instance, interfaceClass), new ObjectName(JMXFactory.getDefaultDomain() + ":type=" + cName + ",name=" + name));
status = true;
} catch (InstanceAlreadyExistsException iaee) {
log.debug("Already registered: {}", className);
@@ -271,19 +269,16 @@ public void handleNotification(Notification notification, Object handback) {
log.debug("handleNotification {}", notification.getMessage());
}
- public void init() {
+ public void init() {
//environmental var holder
HashMap<String, Object> env = null;
if (enableRmiAdapter) {
// Create an RMI connector server
log.debug("Create an RMI connector server");
-
// bind the rmi hostname for systems with nat and multiple binded addresses !
System.setProperty("java.rmi.server.hostname", rmiAdapterHost);
-
try {
-
Registry r = null;
try {
//lookup the registry
@@ -303,26 +298,19 @@ public void init() {
r = LocateRegistry.createRegistry(Integer.valueOf(rmiAdapterPort));
}
}
-
JMXServiceURL url = null;
-
// Configure the remote objects exported port for firewalls !!
if (StringUtils.isNotEmpty(rmiAdapterRemotePort)) {
- url = new JMXServiceURL("service:jmx:rmi://" + rmiAdapterHost + ":" + rmiAdapterRemotePort
- + "/jndi/rmi://" + rmiAdapterHost + ":" + rmiAdapterPort + "/red5");
+ url = new JMXServiceURL("service:jmx:rmi://" + rmiAdapterHost + ":" + rmiAdapterRemotePort + "/jndi/rmi://" + rmiAdapterHost + ":" + rmiAdapterPort + "/red5");
} else {
- url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" + rmiAdapterPort + "/red5");
+ url = new JMXServiceURL("service:jmx:rmi://" + rmiAdapterHost + ":" + rmiAdapterPort + "/jndi/rmi://" + rmiAdapterHost + ":" + rmiAdapterPort + "/red5");
}
-
log.info("JMXServiceUrl is: {}", url);
-
//if SSL is requested to secure rmi connections
if (enableSsl) {
-
// Setup keystore for SSL transparently
System.setProperty("javax.net.ssl.keyStore", remoteSSLKeystore);
System.setProperty("javax.net.ssl.keyStorePassword", remoteSSLKeystorePass);
-
// Environment map
log.debug("Initialize the environment map");
env = new HashMap<String, Object>();
@@ -332,7 +320,6 @@ public void init() {
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
}
-
//if authentication is requested
if (StringUtils.isNotBlank(remoteAccessProperties)) {
//if ssl is not used this will be null
@@ -346,14 +333,12 @@ public void init() {
log.debug("Access file was not found on path, will prepend config_root");
//pre-pend the system property set in war startup
remoteAccessProperties = System.getProperty("red5.config_root") + '/' + remoteAccessProperties;
- remotePasswordProperties = System.getProperty("red5.config_root") + '/'
- + remotePasswordProperties;
+ remotePasswordProperties = System.getProperty("red5.config_root") + '/' + remotePasswordProperties;
}
//strip "file:" prefixing
env.put("jmx.remote.x.access.file", remoteAccessProperties.replace("file:", ""));
env.put("jmx.remote.x.password.file", remotePasswordProperties.replace("file:", ""));
}
-
// create the connector server
cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
// add a listener for shutdown
@@ -363,8 +348,7 @@ public void init() {
cs.start();
log.info("JMX RMI connector server successfully started");
} catch (ConnectException e) {
- log.warn("Could not establish RMI connection to port " + rmiAdapterPort
- + ", please make sure \"rmiregistry\" is running and configured to listen on this port.");
+ log.warn("Could not establish RMI connection to port " + rmiAdapterPort + ", please make sure \"rmiregistry\" is running and configured to listen on this port.");
} catch (IOException e) {
String errMsg = e.getMessage();
if (errMsg.indexOf("NameAlreadyBoundException") != -1) {

0 comments on commit 6757368

Please sign in to comment.