Skip to content

Commit abb049b

Browse files
committed
Remove some dead code
1 parent dcc288c commit abb049b

1 file changed

Lines changed: 6 additions & 83 deletions

File tree

agent/src/com/cloud/agent/AgentShell.java

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.io.InputStream;
2525
import java.lang.reflect.Constructor;
2626
import java.lang.reflect.InvocationTargetException;
27-
import java.lang.reflect.Method;
2827
import java.net.HttpURLConnection;
2928
import java.util.ArrayList;
3029
import java.util.Collections;
@@ -50,7 +49,6 @@
5049
import com.cloud.agent.Agent.ExitStatus;
5150
import com.cloud.agent.dao.StorageComponent;
5251
import com.cloud.agent.dao.impl.PropertiesStorage;
53-
import com.cloud.host.Host;
5452
import com.cloud.resource.ServerResource;
5553
import com.cloud.utils.LogUtils;
5654
import com.cloud.utils.NumbersUtil;
@@ -82,7 +80,6 @@ public class AgentShell implements IAgentShell, Daemon {
8280
private int _nextAgentId = 1;
8381
private volatile boolean _exit = false;
8482
private int _pingRetries;
85-
private Thread _consoleProxyMain = null;
8683
private final List<Agent> _agents = new ArrayList<Agent>();
8784

8885
public AgentShell() {
@@ -415,11 +412,13 @@ public void init(String[] args) throws ConfigurationException {
415412
loadProperties();
416413
parseCommand(args);
417414

418-
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
419-
for (String property:properties){
420-
s_logger.debug("Found property: " + property);
415+
if (s_logger.isDebugEnabled()) {
416+
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
417+
for (String property:properties){
418+
s_logger.debug("Found property: " + property);
419+
}
421420
}
422-
421+
423422
s_logger.info("Defaulting to using properties file for storage");
424423
_storage = new PropertiesStorage();
425424
_storage.configure("Storage", new HashMap<String, Object>());
@@ -447,71 +446,6 @@ private void launchAgent() throws ConfigurationException {
447446
launchAgentFromTypeInfo();
448447
}
449448

450-
private boolean needConsoleProxy() {
451-
for (Agent agent : _agents) {
452-
if (agent.getResource().getType().equals(Host.Type.ConsoleProxy)
453-
|| agent.getResource().getType().equals(Host.Type.Routing))
454-
return true;
455-
}
456-
return false;
457-
}
458-
459-
private int getConsoleProxyPort() {
460-
int port = NumbersUtil.parseInt(
461-
getProperty(null, "consoleproxy.httpListenPort"), 443);
462-
return port;
463-
}
464-
465-
private void openPortWithIptables(int port) {
466-
// TODO
467-
}
468-
469-
private void launchConsoleProxy() throws ConfigurationException {
470-
if (!needConsoleProxy()) {
471-
if (s_logger.isInfoEnabled())
472-
s_logger.info("Storage only agent, no need to start console proxy on it");
473-
return;
474-
}
475-
476-
int port = getConsoleProxyPort();
477-
openPortWithIptables(port);
478-
479-
_consoleProxyMain = new Thread(new Runnable() {
480-
@Override
481-
public void run() {
482-
try {
483-
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
484-
485-
try {
486-
Method method = consoleProxyClazz.getMethod("start",
487-
Properties.class);
488-
method.invoke(null, _properties);
489-
} catch (SecurityException e) {
490-
s_logger.error("Unable to launch console proxy due to SecurityException");
491-
System.exit(ExitStatus.Error.value());
492-
} catch (NoSuchMethodException e) {
493-
s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
494-
System.exit(ExitStatus.Error.value());
495-
} catch (IllegalArgumentException e) {
496-
s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
497-
System.exit(ExitStatus.Error.value());
498-
} catch (IllegalAccessException e) {
499-
s_logger.error("Unable to launch console proxy due to IllegalAccessException");
500-
System.exit(ExitStatus.Error.value());
501-
} catch (InvocationTargetException e) {
502-
s_logger.error("Unable to launch console proxy due to InvocationTargetException");
503-
System.exit(ExitStatus.Error.value());
504-
}
505-
} catch (final ClassNotFoundException e) {
506-
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
507-
System.exit(ExitStatus.Error.value());
508-
}
509-
}
510-
}, "Console-Proxy-Main");
511-
_consoleProxyMain.setDaemon(true);
512-
_consoleProxyMain.start();
513-
}
514-
515449
private void launchAgentFromClassInfo(String resourceClassNames)
516450
throws ConfigurationException {
517451
String[] names = resourceClassNames.split("\\|");
@@ -604,14 +538,6 @@ public void start() {
604538

605539
launchAgent();
606540

607-
//
608-
// For both KVM & Xen-Server hypervisor, we have switched to
609-
// VM-based console proxy solution, disable launching
610-
// of console proxy here
611-
//
612-
// launchConsoleProxy();
613-
//
614-
615541
try {
616542
while (!_exit)
617543
Thread.sleep(1000);
@@ -631,9 +557,6 @@ public void start() {
631557

632558
public void stop() {
633559
_exit = true;
634-
if (_consoleProxyMain != null) {
635-
_consoleProxyMain.interrupt();
636-
}
637560
}
638561

639562
public void destroy() {

0 commit comments

Comments
 (0)