Updated Branches: refs/heads/object_store 09ba55103 -> b8229349f
Rename HypervisorHostEndPoint to RemoteHostEndPoint to accommodate ssvm as well. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b8229349 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b8229349 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b8229349 Branch: refs/heads/object_store Commit: b8229349f5e0ba3a81d2456380a05f04d8247708 Parents: 09ba551 Author: Min Chen <[email protected]> Authored: Fri Apr 19 17:46:33 2013 -0700 Committer: Min Chen <[email protected]> Committed: Fri Apr 19 17:46:33 2013 -0700 ---------------------------------------------------------------------- ...ockHostEndpointRpcServerDirectCallResource.java | 6 +- .../test/MockHypervsiorHostEndPointRpcServer.java | 6 +- .../cloudstack/storage/test/volumeServiceTest.java | 4 +- .../cloudstack/storage/HostEndpointRpcServer.java | 4 +- .../cloudstack/storage/HypervisorHostEndPoint.java | 75 --------------- .../storage/HypervsiorHostEndPointRpcServer.java | 4 +- .../cloudstack/storage/RemoteHostEndPoint.java | 75 +++++++++++++++ .../storage/endpoint/DefaultEndPointSelector.java | 8 +- 8 files changed, 91 insertions(+), 91 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java index 4ec2436..2e57ea9 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java @@ -26,7 +26,7 @@ import javax.inject.Inject; import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.storage.HostEndpointRpcServer; -import org.apache.cloudstack.storage.HypervisorHostEndPoint; +import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; @@ -46,7 +46,7 @@ public class MockHostEndpointRpcServerDirectCallResource implements HostEndpoint executor = Executors.newScheduledThreadPool(10); } - public void sendCommandAsync(HypervisorHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) { + public void sendCommandAsync(RemoteHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) { // new MockRpcCallBack(host.getHostId(), command, callback); MockRpcCallBack run = ComponentContext.inject(MockRpcCallBack.class); run.setCallback(callback); @@ -56,7 +56,7 @@ public class MockHostEndpointRpcServerDirectCallResource implements HostEndpoint } @Override - public Answer sendCommand(HypervisorHostEndPoint host, Command command) { + public Answer sendCommand(RemoteHostEndPoint host, Command command) { Answer answer; try { answer = agentMgr.send(host.getId(), command); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java index d698576..d55926c 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.storage.HostEndpointRpcServer; -import org.apache.cloudstack.storage.HypervisorHostEndPoint; +import org.apache.cloudstack.storage.RemoteHostEndPoint; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; @@ -60,12 +60,12 @@ public class MockHypervsiorHostEndPointRpcServer implements HostEndpointRpcServe } - public void sendCommandAsync(HypervisorHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) { + public void sendCommandAsync(RemoteHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) { executor.schedule(new MockRpcCallBack(command, callback), 10, TimeUnit.SECONDS); } @Override - public Answer sendCommand(HypervisorHostEndPoint host, Command command) { + public Answer sendCommand(RemoteHostEndPoint host, Command command) { // TODO Auto-generated method stub return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java index f8aacc0..86234c1 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java @@ -47,7 +47,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult; import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk; import org.apache.cloudstack.framework.async.AsyncCallFuture; -import org.apache.cloudstack.storage.HypervisorHostEndPoint; +import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.volume.db.VolumeDao2; @@ -200,7 +200,7 @@ public class volumeServiceTest extends CloudStackTestNGBase { Mockito.when(hostDao.findById(Mockito.anyLong())).thenReturn(host); Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results); List<EndPoint> eps = new ArrayList<EndPoint>(); - eps.add(HypervisorHostEndPoint.getHypervisorHostEndPoint(host.getId(), + eps.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress())); Mockito.when(selector.selectAll(Mockito.any(DataStore.class))).thenReturn(eps); Mockito.when(selector.select(Mockito.any(DataObject.class))).thenReturn(eps.get(0)); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/src/org/apache/cloudstack/storage/HostEndpointRpcServer.java ---------------------------------------------------------------------- diff --git a/engine/storage/src/org/apache/cloudstack/storage/HostEndpointRpcServer.java b/engine/storage/src/org/apache/cloudstack/storage/HostEndpointRpcServer.java index a316223..01611be 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/HostEndpointRpcServer.java +++ b/engine/storage/src/org/apache/cloudstack/storage/HostEndpointRpcServer.java @@ -24,6 +24,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; public interface HostEndpointRpcServer { - void sendCommandAsync(HypervisorHostEndPoint ep, final Command command, final AsyncCompletionCallback<Answer> callback); - Answer sendCommand(HypervisorHostEndPoint ep, final Command command); + void sendCommandAsync(RemoteHostEndPoint ep, final Command command, final AsyncCompletionCallback<Answer> callback); + Answer sendCommand(RemoteHostEndPoint ep, final Command command); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java ---------------------------------------------------------------------- diff --git a/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java b/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java deleted file mode 100644 index 6c49b1a..0000000 --- a/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.storage; - -import javax.inject.Inject; - -import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; -import org.apache.cloudstack.framework.async.AsyncCompletionCallback; -import org.apache.log4j.Logger; - -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.exception.AgentUnavailableException; -import com.cloud.exception.OperationTimedoutException; -import com.cloud.utils.component.ComponentContext; - -public class HypervisorHostEndPoint implements EndPoint { - private static final Logger s_logger = Logger.getLogger(HypervisorHostEndPoint.class); - private long hostId; - private String hostAddress; - @Inject - AgentManager agentMgr; - @Inject - HostEndpointRpcServer rpcServer; - - protected HypervisorHostEndPoint() { - - } - - private void configure(long hostId, String hostAddress) { - this.hostId = hostId; - this.hostAddress = hostAddress; - } - - public static HypervisorHostEndPoint getHypervisorHostEndPoint(long hostId, String hostAddress) { - HypervisorHostEndPoint ep = ComponentContext.inject(HypervisorHostEndPoint.class); - ep.configure(hostId, hostAddress); - return ep; - } - - public String getHostAddr() { - return this.hostAddress; - } - - public long getId() { - return this.hostId; - } - - @Override - public Answer sendMessage(Command cmd) { - return rpcServer.sendCommand(this, cmd); - } - - @Override - public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback) { - rpcServer.sendCommandAsync(this, cmd, callback); - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/src/org/apache/cloudstack/storage/HypervsiorHostEndPointRpcServer.java ---------------------------------------------------------------------- diff --git a/engine/storage/src/org/apache/cloudstack/storage/HypervsiorHostEndPointRpcServer.java b/engine/storage/src/org/apache/cloudstack/storage/HypervsiorHostEndPointRpcServer.java index f441f39..b6e5788 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/HypervsiorHostEndPointRpcServer.java +++ b/engine/storage/src/org/apache/cloudstack/storage/HypervsiorHostEndPointRpcServer.java @@ -56,7 +56,7 @@ public class HypervsiorHostEndPointRpcServer implements HostEndpointRpcServer { } @Override - public void sendCommandAsync(HypervisorHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) { + public void sendCommandAsync(RemoteHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) { rpcProvider.newCall(host.getHostAddr()).addCallbackListener(new RpcCallbackListener<Answer>() { @Override public void onSuccess(Answer result) { @@ -89,7 +89,7 @@ public class HypervsiorHostEndPointRpcServer implements HostEndpointRpcServer { } @Override - public Answer sendCommand(HypervisorHostEndPoint host, Command command) { + public Answer sendCommand(RemoteHostEndPoint host, Command command) { SendCommandContext<Answer> context = new SendCommandContext<Answer>(null); AsyncCallbackDispatcher<HypervsiorHostEndPointRpcServer, Answer> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().sendCommandCallback(null, null)) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/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 new file mode 100644 index 0000000..aec7b52 --- /dev/null +++ b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.storage; + +import javax.inject.Inject; + +import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; +import org.apache.cloudstack.framework.async.AsyncCompletionCallback; +import org.apache.log4j.Logger; + +import com.cloud.agent.AgentManager; +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.exception.AgentUnavailableException; +import com.cloud.exception.OperationTimedoutException; +import com.cloud.utils.component.ComponentContext; + +public class RemoteHostEndPoint implements EndPoint { + private static final Logger s_logger = Logger.getLogger(RemoteHostEndPoint.class); + private long hostId; + private String hostAddress; + @Inject + AgentManager agentMgr; + @Inject + HostEndpointRpcServer rpcServer; + + protected RemoteHostEndPoint() { + + } + + private void configure(long hostId, String hostAddress) { + this.hostId = hostId; + this.hostAddress = hostAddress; + } + + public static RemoteHostEndPoint getHypervisorHostEndPoint(long hostId, String hostAddress) { + RemoteHostEndPoint ep = ComponentContext.inject(RemoteHostEndPoint.class); + ep.configure(hostId, hostAddress); + return ep; + } + + public String getHostAddr() { + return this.hostAddress; + } + + public long getId() { + return this.hostId; + } + + @Override + public Answer sendMessage(Command cmd) { + return rpcServer.sendCommand(this, cmd); + } + + @Override + public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback) { + rpcServer.sendCommandAsync(this, cmd, callback); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8229349/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java ---------------------------------------------------------------------- diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java index d641f21..bda2995 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java +++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java @@ -32,7 +32,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector; import org.apache.cloudstack.engine.subsystem.api.storage.Scope; import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat; -import org.apache.cloudstack.storage.HypervisorHostEndPoint; +import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.cloudstack.storage.LocalHostEndpoint; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -130,7 +130,7 @@ public class DefaultEndPointSelector implements EndPointSelector { return null; } - return HypervisorHostEndPoint.getHypervisorHostEndPoint(host.getId(), + return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress()); } @@ -195,7 +195,7 @@ public class DefaultEndPointSelector implements EndPointSelector { List<EndPoint> endPoints = new ArrayList<EndPoint>(); if (store.getScope().getScopeType() == ScopeType.HOST) { HostVO host = hostDao.findById(store.getScope().getScopeId()); - endPoints.add(HypervisorHostEndPoint.getHypervisorHostEndPoint(host.getId(), + endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress())); } else if (store.getScope().getScopeType() == ScopeType.CLUSTER) { SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class); @@ -203,7 +203,7 @@ public class DefaultEndPointSelector implements EndPointSelector { sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up); List<HostVO> hosts = sc.find(); for (HostVO host : hosts) { - endPoints.add(HypervisorHostEndPoint.getHypervisorHostEndPoint(host.getId(), + endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress())); }
