cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/4.4-forward to f3e9c84
Date Wed, 23 Apr 2014 02:23:56 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward be10b32b2 -> f3e9c84cd


CLOUDSTACK-6478: Failed to download Template when having 3 SSVM's in one
zone on Vmware.

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

Branch: refs/heads/4.4-forward
Commit: f3e9c84cddbc0ab7b89f8000dd0db42ba1570d28
Parents: be10b32
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Apr 22 19:14:55 2014 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Apr 22 19:14:55 2014 -0700

----------------------------------------------------------------------
 .../cloudstack/storage/RemoteHostEndPoint.java  | 43 +++++++++++++++-----
 1 file changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f3e9c84c/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
index 34f9c9d..c54430f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
@@ -25,8 +25,7 @@ import java.util.concurrent.TimeUnit;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-import com.cloud.vm.SecondaryStorageVmVO;
-import com.cloud.vm.dao.SecondaryStorageVmDao;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
@@ -43,11 +42,15 @@ import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.ConnectionException;
 import com.cloud.exception.OperationTimedoutException;
 import com.cloud.host.Host;
+import com.cloud.host.HostVO;
 import com.cloud.host.Status;
+import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.HypervisorGuruManager;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.SecondaryStorageVmVO;
+import com.cloud.vm.dao.SecondaryStorageVmDao;
 
 public class RemoteHostEndPoint implements EndPoint {
     private static final Logger s_logger = Logger.getLogger(RemoteHostEndPoint.class);
@@ -60,6 +63,8 @@ public class RemoteHostEndPoint implements EndPoint {
     protected HypervisorGuruManager _hvGuruMgr;
     @Inject
     protected SecondaryStorageVmDao vmDao;
+    @Inject
+    protected HostDao _hostDao;
     private ScheduledExecutorService executor;
 
     public RemoteHostEndPoint() {
@@ -67,14 +72,14 @@ public class RemoteHostEndPoint implements EndPoint {
     }
 
     private void configure(Host host) {
-        this.hostId = host.getId();
-        this.hostAddress = host.getPrivateIpAddress();
-        this.publicAddress = host.getPublicIpAddress();
+        hostId = host.getId();
+        hostAddress = host.getPrivateIpAddress();
+        publicAddress = host.getPublicIpAddress();
         if (Host.Type.SecondaryStorageVM == host.getType()) {
             String vmName = host.getName();
             SecondaryStorageVmVO ssvm = vmDao.findByInstanceName(vmName);
             if (ssvm != null) {
-                this.publicAddress = ssvm.getPublicIpAddress();
+                publicAddress = ssvm.getPublicIpAddress();
             }
         }
     }
@@ -87,17 +92,25 @@ public class RemoteHostEndPoint implements EndPoint {
 
     @Override
     public String getHostAddr() {
-        return this.hostAddress;
+        return hostAddress;
     }
 
     @Override
     public String getPublicAddr() {
-        return this.publicAddress;
+        return publicAddress;
     }
 
     @Override
     public long getId() {
-        return this.hostId;
+        return hostId;
+    }
+
+    // used when HypervisorGuruManager choose a different host to send command
+    private void setId(long id) {
+        HostVO host = _hostDao.findById(hostId);
+        if (host != null) {
+            configure(host);
+        }
     }
 
     @Override
@@ -105,6 +118,10 @@ public class RemoteHostEndPoint implements EndPoint {
         String errMsg = null;
         try {
             long newHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(hostId, cmd);
+            if (newHostId != hostId) {
+                // update endpoint with new host if changed
+                setId(newHostId);
+            }
             return agentMgr.send(newHostId, cmd);
         } catch (AgentUnavailableException e) {
             errMsg = e.toString();
@@ -126,7 +143,7 @@ public class RemoteHostEndPoint implements EndPoint {
 
         @Override
         public boolean processAnswers(long agentId, long seq, Answer[] answers) {
-            this.answer = answers[0];
+            answer = answers[0];
             executor.schedule(this, 10, TimeUnit.SECONDS);
             return true;
         }
@@ -182,7 +199,11 @@ public class RemoteHostEndPoint implements EndPoint {
     @Override
     public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback)
{
         try {
-            long newHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(this.hostId, cmd);
+            long newHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(hostId, cmd);
+            if (newHostId != hostId) {
+                // update endpoint with new host if changed
+                setId(newHostId);
+            }
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Sending command " + cmd.toString() + " to host: " + newHostId);
             }


Mime
View raw message