Piotr Kliczewski has uploaded a new change for review.

Change subject: upload stream fails due to explicit cast
......................................................................

upload stream fails due to explicit cast

Code assumes that we all the time use xmlrpc and explicitly casts it to
VdsServerWrapper to get http client. When host uses jsonrpc it fails
with class cast excpetion.

This patch uses existing code to build http client and passes it to
JsonRpcVdsServer implementation. getHttpClient method is promoted to
IVdsServer interface so jsonrpc implementation can expose http client as
well.


Change-Id: I81c1dbb50727172647da10ec4b74f2950057c4bb
Signed-off-by: pkliczewski <piotr.kliczew...@gmail.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/HttpImageTaskVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/TransportFactory.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
5 files changed, 20 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/32513/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/HttpImageTaskVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/HttpImageTaskVDSCommand.java
index f56ba90..0f9e66a 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/HttpImageTaskVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/HttpImageTaskVDSCommand.java
@@ -65,7 +65,7 @@
     protected void executeHttpMethod(final T method) {
         int responseCode = -1;
         VdsManager manager = 
ResourceManager.getInstance().GetVdsManager(getParameters().getVdsId());
-        final HttpClient httpclient = ((VdsServerWrapper) 
manager.getVdsProxy()).getHttpClient();
+        final HttpClient httpclient = manager.getVdsProxy().getHttpClient();
         try {
             FutureTask<Integer> futureTask = new FutureTask(new 
Callable<Integer>() {
                 @Override
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
index cca3ab1..d55f3e0 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
@@ -8,6 +8,7 @@
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 
+import org.apache.commons.httpclient.HttpClient;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil;
 import 
org.ovirt.engine.core.vdsbroker.gluster.GlusterHookContentInfoReturnForXmlRpc;
@@ -63,15 +64,22 @@
 public class JsonRpcVdsServer implements IVdsServer {
 
     private final JsonRpcClient client;
+    private final HttpClient httpClient;
 
-    public JsonRpcVdsServer(JsonRpcClient client) {
+    public JsonRpcVdsServer(JsonRpcClient client, HttpClient httpClient) {
         this.client = client;
+        this.httpClient = httpClient;
     }
 
     public void close() {
         this.client.close();
     }
 
+    @Override
+    public HttpClient getHttpClient() {
+        return this.httpClient;
+    }
+
     @SuppressWarnings("rawtypes")
     private String getVmId(Map map) {
         return (String) map.get(VdsProperties.vm_guid);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/TransportFactory.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/TransportFactory.java
index 75bed03..7f9d146 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/TransportFactory.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/TransportFactory.java
@@ -34,15 +34,16 @@
     public static IVdsServer createVdsServer(VdsProtocol vdsProtocol, String 
hostname, int port, int clientTimeOut,
             int connectionTimeOut, int clientRetries, int heartbeat) {
         IVdsServer vdsServer = null;
+        Pair<VdsServerConnector, HttpClient> returnValue =
+                XmlRpcUtils.getConnection(hostname, port, clientTimeOut, 
connectionTimeOut,
+                        clientRetries, VdsServerConnector.class,
+                        Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication));
+
         if (VdsProtocol.STOMP == vdsProtocol) {
             vdsServer = new 
JsonRpcVdsServer(JsonRpcUtils.createStompClient(hostname,
                     port, connectionTimeOut, clientTimeOut, clientRetries, 
heartbeat,
-                    Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication)));
+                    Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication)), returnValue.getSecond());
         } else if (VdsProtocol.XML == vdsProtocol) {
-            Pair<VdsServerConnector, HttpClient> returnValue =
-                    XmlRpcUtils.getConnection(hostname, port, clientTimeOut, 
connectionTimeOut,
-                            clientRetries, VdsServerConnector.class,
-                            Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication));
             vdsServer = new VdsServerWrapper(returnValue.getFirst(), 
returnValue.getSecond());
         }
         return vdsServer;
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
index ff27a06..478a05b 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
@@ -4,6 +4,7 @@
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 
+import org.apache.commons.httpclient.HttpClient;
 import org.ovirt.engine.core.compat.Guid;
 import 
org.ovirt.engine.core.vdsbroker.gluster.GlusterHookContentInfoReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.gluster.GlusterHooksListReturnForXmlRpc;
@@ -22,6 +23,8 @@
 
 
 public interface IVdsServer {
+    HttpClient getHttpClient();
+
     OneVmReturnForXmlRpc create(Map createInfo);
 
     StatusOnlyReturnForXmlRpc destroy(String vmId);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
index 82e28e0..a061795 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
@@ -34,6 +34,7 @@
         this.httpClient = httpClient;
     }
 
+    @Override
     public HttpClient getHttpClient() {
         return httpClient;
     }


-- 
To view, visit http://gerrit.ovirt.org/32513
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I81c1dbb50727172647da10ec4b74f2950057c4bb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczew...@gmail.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to