You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2014/02/07 23:11:02 UTC

[13/19] git commit: updated refs/heads/4.3 to c1af92f

CLOUDSTACK-6001: Fixed hyperv vm console not working for 3 minutes after migration.
(cherry picked from commit fb87c85b2a313d75af7cd4b790118fea30a2dd1b)

Signed-off-by: Animesh Chaturvedi <an...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cf7b6274
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cf7b6274
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cf7b6274

Branch: refs/heads/4.3
Commit: cf7b62748d51d7be42e903d5e2a786b17e4bea09
Parents: 4961c13
Author: Anshul Gangwar <an...@citrix.com>
Authored: Fri Jan 31 13:04:36 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Fri Feb 7 13:23:11 2014 -0800

----------------------------------------------------------------------
 .../consoleproxy/ConsoleProxyRdpClient.java     | 147 ++++++++++---------
 1 file changed, 78 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cf7b6274/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
index d5a3fcd..7d49b19 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
@@ -19,7 +19,6 @@ package com.cloud.consoleproxy;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
-import java.io.IOException;
 import java.net.InetSocketAddress;
 
 import org.apache.log4j.Logger;
@@ -55,7 +54,8 @@ public class ConsoleProxyRdpClient extends ConsoleProxyClientBase {
     private RdpBufferedImageCanvas _canvas = null;
 
     private Thread _worker;
-    private volatile boolean _workerDone = false;
+    private volatile boolean _workerDone = true;
+    private volatile long _threadStopTime;
 
     private AwtMouseEventSource _mouseEventSource = null;
     private AwtKeyEventSource _keyEventSource = null;
@@ -231,77 +231,86 @@ public class ConsoleProxyRdpClient extends ConsoleProxyClientBase {
 
     @Override
     public void initClient(final ConsoleProxyClientParam param) {
-        _workerDone = false;
-
-        int canvasWidth = 1024;
-        int canvasHeight = 768;
-        setClientParam(param);
-
-        final String host = param.getHypervHost();
-        final String password = param.getPassword();
-        final String instanceId = param.getClientHostAddress();
-        final int port = param.getClientHostPort();
-
-        _screen = new ScreenDescription();
-        _canvas = new RdpBufferedImageCanvas(this, canvasWidth, canvasHeight);
-        onFramebufferSizeChange(canvasWidth, canvasHeight);
-
-        _screen.addSizeChangeListener(new SizeChangeListener() {
-            @Override
-            public void sizeChanged(int width, int height) {
-                if (_canvas != null) {
-                    _canvas.setCanvasSize(width, height);
-                }
-            }
-        });
+        if ((System.currentTimeMillis() - _threadStopTime) < 1000) {
+            return;
+        }
 
-        final SSLState sslState = new SSLState();
+        try {
+            int canvasWidth = 1024;
+            int canvasHeight = 768;
+            setClientParam(param);
+
+            final String host = param.getHypervHost();
+            final String password = param.getPassword();
+            final String instanceId = param.getClientHostAddress();
+            final int port = param.getClientHostPort();
+
+            final SSLState sslState = new SSLState();
+
+            final String username = param.getUsername();
+            String name = null;
+            String domain = null;
+            if (username.contains("\\")) {
+                String[] tokens = username.split("\\\\");
+                name = tokens[1];
+                domain = tokens[0];
+            } else {
+                name = username;
+                domain = "Workgroup";
+            }
 
-        final String username = param.getUsername();
-        String name = null;
-        String domain = null;
-        if (username.contains("\\")) {
-            String[] tokens = username.split("\\\\");
-            name = tokens[1];
-            domain = tokens[0];
-        } else {
-            name = username;
-            domain = "Workgroup";
-        }
+            _screen = new ScreenDescription();
+            _canvas = new RdpBufferedImageCanvas(this, canvasWidth, canvasHeight);
+            onFramebufferSizeChange(canvasWidth, canvasHeight);
 
-        _client = new RdpClient("client", host, domain, name, password, instanceId, _screen, _canvas,
-                sslState);
-
-        _mouseEventSource = _client.getMouseEventSource();
-        _keyEventSource = _client.getKeyEventSource();
-
-        _worker = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                _socket = new AprSocketWrapperImpl("socket", sslState);
-                Pipeline pipeline = new PipelineImpl("Client");
-                pipeline.add(_socket, _client);
-                pipeline.link("socket", _client.getId(), "socket");
-                pipeline.validate();
-
-                InetSocketAddress address = new InetSocketAddress(host, port);
-                ConsoleProxy.ensureRoute(host);
-
-                try {
-                    // Connect socket to remote server and run main loop(s)
-                    _socket.connect(address);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                } finally {
-                    shutdown();
+            _screen.addSizeChangeListener(new SizeChangeListener() {
+                @Override
+                public void sizeChanged(int width, int height) {
+                    if (_canvas != null) {
+                        _canvas.setCanvasSize(width, height);
+                    }
                 }
-
-                s_logger.info("Receiver thread stopped.");
-                _workerDone = true;
-            }
-        });
-        _worker.setDaemon(true);
-        _worker.start();
+            });
+
+            s_logger.info("connecting to instance " + instanceId + " on host " + host);
+            _client = new RdpClient("client", host, domain, name, password, instanceId, _screen, _canvas, sslState);
+
+            _mouseEventSource = _client.getMouseEventSource();
+            _keyEventSource = _client.getKeyEventSource();
+
+            _worker = new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    _socket = new AprSocketWrapperImpl("socket", sslState);
+                    Pipeline pipeline = new PipelineImpl("Client");
+                    pipeline.add(_socket, _client);
+                    pipeline.link("socket", _client.getId(), "socket");
+                    pipeline.validate();
+
+                    InetSocketAddress address = new InetSocketAddress(host, port);
+                    ConsoleProxy.ensureRoute(host);
+
+                    try {
+                        _workerDone = false;
+                        s_logger.info("Connecting socket to remote server and run main loop(s)");
+                        _socket.connect(address);
+                    } catch (Exception e) {
+                        s_logger.info(" error occurred in connecting to socket " + e.getMessage());
+                    } finally {
+                        shutdown();
+                    }
+
+                    _threadStopTime = System.currentTimeMillis();
+                    s_logger.info("Receiver thread stopped.");
+                    _workerDone = true;
+                }
+            });
+            _worker.setDaemon(true);
+            _worker.start();
+        } catch (Exception e) {
+            _workerDone = true;
+            s_logger.info("error occurred in initializing rdp client " + e.getMessage());
+        }
     }
 
     @Override