You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2014/03/01 00:37:41 UTC

[21/33] git commit: updated refs/heads/master to 90262a8

Remove inner retry loop when CPVM tries to reconnect to host


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

Branch: refs/heads/master
Commit: dfb9f49117601de61c843bf57f1f372294696e5a
Parents: 38a1300
Author: Kelven Yang <ke...@gmail.com>
Authored: Fri Feb 7 13:53:22 2014 -0800
Committer: Kelven Yang <ke...@gmail.com>
Committed: Fri Feb 28 15:35:58 2014 -0800

----------------------------------------------------------------------
 .../consoleproxy/ConsoleProxyVncClient.java     | 89 ++++++++------------
 1 file changed, 36 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dfb9f491/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
index 5eb20ee..8fce978 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
@@ -82,45 +82,28 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
                 String tunnelUrl = getClientParam().getClientTunnelUrl();
                 String tunnelSession = getClientParam().getClientTunnelSession();
 
-                for (int i = 0; i < 15 && !workerDone; i++) {
-                    try {
-                        if (tunnelUrl != null && !tunnelUrl.isEmpty() && tunnelSession != null && !tunnelSession.isEmpty()) {
-                            URI uri = new URI(tunnelUrl);
-                            s_logger.info("Connect to VNC server via tunnel. url: " + tunnelUrl + ", session: " + tunnelSession);
-
-                            ConsoleProxy.ensureRoute(uri.getHost());
-                            client.connectTo(uri.getHost(), uri.getPort(), uri.getPath() + "?" + uri.getQuery(), tunnelSession,
-                                "https".equalsIgnoreCase(uri.getScheme()), getClientHostPassword());
-                        } else {
-                            s_logger.info("Connect to VNC server directly. host: " + getClientHostAddress() + ", port: " + getClientHostPort());
-                            ConsoleProxy.ensureRoute(getClientHostAddress());
-                            client.connectTo(getClientHostAddress(), getClientHostPort(), getClientHostPassword());
-                        }
-                    } catch (UnknownHostException e) {
-                        s_logger.error("Unexpected exception (will retry until timeout)", e);
-                    } catch (IOException e) {
-                        s_logger.error("Unexpected exception (will retry until timeout) ", e);
-                    } catch (Throwable e) {
-                        s_logger.error("Unexpected exception (will retry until timeout) ", e);
-                    }
-
-                    try {
-                        Thread.sleep(1000);
-                    } catch (InterruptedException e) {
-                    }
-
+                try {
                     if (tunnelUrl != null && !tunnelUrl.isEmpty() && tunnelSession != null && !tunnelSession.isEmpty()) {
-                        ConsoleProxyAuthenticationResult authResult = ConsoleProxy.reAuthenticationExternally(getClientParam());
-                        if (authResult != null && authResult.isSuccess()) {
-                            if (authResult.getTunnelUrl() != null && !authResult.getTunnelUrl().isEmpty() && authResult.getTunnelSession() != null &&
-                                !authResult.getTunnelSession().isEmpty()) {
-                                tunnelUrl = authResult.getTunnelUrl();
-                                tunnelSession = authResult.getTunnelSession();
-
-                                s_logger.info("Reset XAPI session. url: " + tunnelUrl + ", session: " + tunnelSession);
-                            }
-                        }
+                        URI uri = new URI(tunnelUrl);
+                        s_logger.info("Connect to VNC server via tunnel. url: " + tunnelUrl + ", session: " + tunnelSession);
+
+                        ConsoleProxy.ensureRoute(uri.getHost());
+                        client.connectTo(
+                                uri.getHost(), uri.getPort(),
+                                uri.getPath() + "?" + uri.getQuery(),
+                                tunnelSession, "https".equalsIgnoreCase(uri.getScheme()),
+                                getClientHostPassword());
+                    } else {
+                        s_logger.info("Connect to VNC server directly. host: " + getClientHostAddress() + ", port: " + getClientHostPort());
+                        ConsoleProxy.ensureRoute(getClientHostAddress());
+                        client.connectTo(getClientHostAddress(), getClientHostPort(), getClientHostPassword());
                     }
+                } catch (UnknownHostException e) {
+                    s_logger.error("Unexpected exception", e);
+                } catch (IOException e) {
+                    s_logger.error("Unexpected exception", e);
+                } catch (Throwable e) {
+                    s_logger.error("Unexpected exception", e);
                 }
 
                 s_logger.info("Receiver thread stopped.");
@@ -164,23 +147,23 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
 
         updateFrontEndActivityTime();
 
-        switch (event) {
-            case KEY_DOWN:
-                sendModifierEvents(modifiers);
-                client.sendClientKeyboardEvent(RfbConstants.KEY_DOWN, code, 0);
-                break;
+        switch(event) {
+        case KEY_DOWN :
+            sendModifierEvents(modifiers);
+            client.sendClientKeyboardEvent(RfbConstants.KEY_DOWN, code, 0);
+            break;
 
-            case KEY_UP:
-                client.sendClientKeyboardEvent(RfbConstants.KEY_UP, code, 0);
-                sendModifierEvents(0);
-                break;
+        case KEY_UP :
+            client.sendClientKeyboardEvent(RfbConstants.KEY_UP, code, 0);
+            sendModifierEvents(0);
+            break;
 
-            case KEY_PRESS:
-                break;
+        case KEY_PRESS :
+            break;
 
-            default:
-                assert (false);
-                break;
+        default :
+            assert(false);
+            break;
         }
     }
 
@@ -224,13 +207,13 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
         if ((modifiers & SHIFT_KEY_MASK) != (lastModifierStates & SHIFT_KEY_MASK))
             client.sendClientKeyboardEvent((modifiers & SHIFT_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_SHIFT, 0);
 
-        if ((modifiers & CTRL_KEY_MASK) != (lastModifierStates & CTRL_KEY_MASK))
+        if((modifiers & CTRL_KEY_MASK) != (lastModifierStates & CTRL_KEY_MASK))
             client.sendClientKeyboardEvent((modifiers & CTRL_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_CTRL, 0);
 
         if ((modifiers & META_KEY_MASK) != (lastModifierStates & META_KEY_MASK))
             client.sendClientKeyboardEvent((modifiers & META_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_META, 0);
 
-        if ((modifiers & ALT_KEY_MASK) != (lastModifierStates & ALT_KEY_MASK))
+        if((modifiers & ALT_KEY_MASK) != (lastModifierStates & ALT_KEY_MASK))
             client.sendClientKeyboardEvent((modifiers & ALT_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_ALT, 0);
 
         lastModifierStates = modifiers;