From abb049bc0bd5502e4153ee501bbb8a237b90e94e Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 13 May 2013 17:05:40 +0200 Subject: [PATCH] Remove some dead code --- agent/src/com/cloud/agent/AgentShell.java | 89 ++--------------------- 1 file changed, 6 insertions(+), 83 deletions(-) diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 3796f3b1f5f..cf454b8c89c 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.util.ArrayList; import java.util.Collections; @@ -50,7 +49,6 @@ import org.apache.log4j.xml.DOMConfigurator; import com.cloud.agent.Agent.ExitStatus; import com.cloud.agent.dao.StorageComponent; import com.cloud.agent.dao.impl.PropertiesStorage; -import com.cloud.host.Host; import com.cloud.resource.ServerResource; import com.cloud.utils.LogUtils; import com.cloud.utils.NumbersUtil; @@ -82,7 +80,6 @@ public class AgentShell implements IAgentShell, Daemon { private int _nextAgentId = 1; private volatile boolean _exit = false; private int _pingRetries; - private Thread _consoleProxyMain = null; private final List _agents = new ArrayList(); public AgentShell() { @@ -415,11 +412,13 @@ public class AgentShell implements IAgentShell, Daemon { loadProperties(); parseCommand(args); - List properties = Collections.list((Enumeration)_properties.propertyNames()); - for (String property:properties){ - s_logger.debug("Found property: " + property); + if (s_logger.isDebugEnabled()) { + List properties = Collections.list((Enumeration)_properties.propertyNames()); + for (String property:properties){ + s_logger.debug("Found property: " + property); + } } - + s_logger.info("Defaulting to using properties file for storage"); _storage = new PropertiesStorage(); _storage.configure("Storage", new HashMap()); @@ -447,71 +446,6 @@ public class AgentShell implements IAgentShell, Daemon { launchAgentFromTypeInfo(); } - private boolean needConsoleProxy() { - for (Agent agent : _agents) { - if (agent.getResource().getType().equals(Host.Type.ConsoleProxy) - || agent.getResource().getType().equals(Host.Type.Routing)) - return true; - } - return false; - } - - private int getConsoleProxyPort() { - int port = NumbersUtil.parseInt( - getProperty(null, "consoleproxy.httpListenPort"), 443); - return port; - } - - private void openPortWithIptables(int port) { - // TODO - } - - private void launchConsoleProxy() throws ConfigurationException { - if (!needConsoleProxy()) { - if (s_logger.isInfoEnabled()) - s_logger.info("Storage only agent, no need to start console proxy on it"); - return; - } - - int port = getConsoleProxyPort(); - openPortWithIptables(port); - - _consoleProxyMain = new Thread(new Runnable() { - @Override - public void run() { - try { - Class consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy"); - - try { - Method method = consoleProxyClazz.getMethod("start", - Properties.class); - method.invoke(null, _properties); - } catch (SecurityException e) { - s_logger.error("Unable to launch console proxy due to SecurityException"); - System.exit(ExitStatus.Error.value()); - } catch (NoSuchMethodException e) { - s_logger.error("Unable to launch console proxy due to NoSuchMethodException"); - System.exit(ExitStatus.Error.value()); - } catch (IllegalArgumentException e) { - s_logger.error("Unable to launch console proxy due to IllegalArgumentException"); - System.exit(ExitStatus.Error.value()); - } catch (IllegalAccessException e) { - s_logger.error("Unable to launch console proxy due to IllegalAccessException"); - System.exit(ExitStatus.Error.value()); - } catch (InvocationTargetException e) { - s_logger.error("Unable to launch console proxy due to InvocationTargetException"); - System.exit(ExitStatus.Error.value()); - } - } catch (final ClassNotFoundException e) { - s_logger.error("Unable to launch console proxy due to ClassNotFoundException"); - System.exit(ExitStatus.Error.value()); - } - } - }, "Console-Proxy-Main"); - _consoleProxyMain.setDaemon(true); - _consoleProxyMain.start(); - } - private void launchAgentFromClassInfo(String resourceClassNames) throws ConfigurationException { String[] names = resourceClassNames.split("\\|"); @@ -604,14 +538,6 @@ public class AgentShell implements IAgentShell, Daemon { launchAgent(); - // - // For both KVM & Xen-Server hypervisor, we have switched to - // VM-based console proxy solution, disable launching - // of console proxy here - // - // launchConsoleProxy(); - // - try { while (!_exit) Thread.sleep(1000); @@ -631,9 +557,6 @@ public class AgentShell implements IAgentShell, Daemon { public void stop() { _exit = true; - if (_consoleProxyMain != null) { - _consoleProxyMain.interrupt(); - } } public void destroy() {