You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by se...@apache.org on 2014/06/17 14:57:27 UTC
git commit: updated refs/heads/4.3 to 1772fcf
Repository: cloudstack
Updated Branches:
refs/heads/4.3 f304df0be -> 1772fcffc
CLOUDSTACK-6478: Failed to download Template when having 3 SSVM's in one
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1772fcff
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1772fcff
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1772fcff
Branch: refs/heads/4.3
Commit: 1772fcffc3d605ca571e54e61b65954fdf60ba1b
Parents: f304df0
Author: Min Chen <mi...@citrix.com>
Authored: Tue Apr 22 19:14:55 2014 -0700
Committer: Sebastien Goasguen <ru...@gmail.com>
Committed: Tue Jun 17 14:56:55 2014 +0200
----------------------------------------------------------------------
.../cloudstack/storage/RemoteHostEndPoint.java | 44 +++++++++++++++-----
1 file changed, 33 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1772fcff/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 3788272..6ddd5ae 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
@@ -24,8 +24,8 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
-import com.cloud.vm.SecondaryStorageVmVO;
-import com.cloud.vm.dao.SecondaryStorageVmDao;
+import org.apache.log4j.Logger;
+
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 +43,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 +64,8 @@ public class RemoteHostEndPoint implements EndPoint {
protected HypervisorGuruManager _hvGuruMgr;
@Inject
protected SecondaryStorageVmDao vmDao;
+ @Inject
+ protected HostDao _hostDao;
private ScheduledExecutorService executor;
public RemoteHostEndPoint() {
@@ -67,14 +73,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 +93,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 +119,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 +144,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 +200,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);
}