You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2014/04/23 05:18:20 UTC
git commit: updated refs/heads/master to 8e28699
Repository: cloudstack
Updated Branches:
refs/heads/master 9c4d20cb6 -> 8e286996c
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/8e286996
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8e286996
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8e286996
Branch: refs/heads/master
Commit: 8e286996c8cdb58255a631b3bd977ad4b4baebd2
Parents: 9c4d20c
Author: Min Chen <mi...@citrix.com>
Authored: Tue Apr 22 19:14:55 2014 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Tue Apr 22 20:11:09 2014 -0700
----------------------------------------------------------------------
.../cloudstack/storage/RemoteHostEndPoint.java | 43 +++++++++++++++-----
1 file changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8e286996/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);
}