Piotr Kliczewski has uploaded a new change for review.

Change subject: jsonrpc: client side heartbeat implementation
......................................................................

jsonrpc: client side heartbeat implementation

There is new vdsHeartBeat option in the database which default value is
10. This option is propageted donw to json client.

Change-Id: I9e8a20592542ce1a754dee1917ff9ebba6b8daf9
Signed-off-by: pkliczewski <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsProxyData.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcUtils.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/TransportFactory.java
M 
backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcIntegrationTest.java
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
7 files changed, 25 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/30165/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 6b48897..8ea3e46 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -49,6 +49,13 @@
     vdsRetries,
 
     /**
+     * Timeout in seconds how often we should receive heart-beat.
+     */
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("10")
+    vdsHeartBeat,
+
+    /**
      * Timeout for establishment of connections with hosts. This should be 
quite
      * small, a few seconds at most, as it the TCP handshake with hosts should
      * be very quick in most networks.
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java
index a4e7578..fd2dbc2 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java
@@ -196,8 +196,9 @@
         // Get the values of the timeouts:
         int clientTimeOut = Config.<Integer> getValue(ConfigValues.vdsTimeout) 
* 1000;
         int connectionTimeOut = Config.<Integer> 
getValue(ConfigValues.vdsConnectionTimeout) * 1000;
+        int heartBeat = Config.<Integer> getValue(ConfigValues.vdsHeartBeat) * 
1000;
         int clientRetries = Config.<Integer> getValue(ConfigValues.vdsRetries);
-        _vdsProxy = TransportFactory.createVdsServer(_vds.getProtocol(), 
_vds.getHostName(), _vds.getPort(), clientTimeOut, connectionTimeOut, 
clientRetries);
+        _vdsProxy = TransportFactory.createVdsServer(_vds.getProtocol(), 
_vds.getHostName(), _vds.getPort(), clientTimeOut, connectionTimeOut, 
clientRetries, heartBeat);
     }
 
     public void updateVmDynamic(VmDynamic vmDynamic) {
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsProxyData.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsProxyData.java
index 996b10b..aeed414 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsProxyData.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsProxyData.java
@@ -565,8 +565,9 @@
                     // Get the values of the timeouts:
                     int clientTimeOut = Config.<Integer> 
getValue(ConfigValues.vdsTimeout) * 1000;
                     int connectionTimeOut = Config.<Integer> 
getValue(ConfigValues.vdsConnectionTimeout) * 1000;
+                    int heartBeat = Config.<Integer> 
getValue(ConfigValues.vdsHeartBeat) * 1000;
                     int clientRetries = Config.<Integer> 
getValue(ConfigValues.vdsRetries);
-                    irsProxy = TransportFactory.createIrsServer(getProtocol(), 
host, getmIrsPort(), clientTimeOut, connectionTimeOut, clientRetries);
+                    irsProxy = TransportFactory.createIrsServer(getProtocol(), 
host, getmIrsPort(), clientTimeOut, connectionTimeOut, clientRetries, 
heartBeat);
                     runStoragePoolUpEvent(storagePool);
                 }
             }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcUtils.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcUtils.java
index 5f17b2c..a792c1b 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcUtils.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcUtils.java
@@ -18,8 +18,8 @@
     private static Log log = LogFactory.getLog(JsonRpcUtils.class);
 
     public static JsonRpcClient createStompClient(String hostname, int port, 
int connectionTimeout,
-            int clientTimeout, int connectionRetry, boolean isSecure) {
-        return createClient(hostname, port, connectionTimeout, clientTimeout, 
connectionRetry, isSecure, ReactorType.STOMP);
+            int clientTimeout, int connectionRetry, int heartBeat, boolean 
isSecure) {
+        return createClient(hostname, port, connectionTimeout, clientTimeout, 
connectionRetry, heartBeat, isSecure, ReactorType.STOMP);
     }
 
     private static ManagerProvider getManagerProvider(boolean isSecure) {
@@ -31,11 +31,11 @@
     }
 
     private static JsonRpcClient createClient(String hostname, int port, int 
connectionTimeout,
-            int clientTimeout, int connectionRetry, boolean isSecure, 
ReactorType type) {
+            int clientTimeout, int connectionRetry, int heartBeat, boolean 
isSecure, ReactorType type) {
         final ManagerProvider provider = getManagerProvider(isSecure);
         try {
             final Reactor reactor = ReactorFactory.getReactor(provider, type);
-            return getJsonClient(reactor, hostname, port, connectionTimeout, 
clientTimeout, connectionRetry);
+            return getJsonClient(reactor, hostname, port, connectionTimeout, 
clientTimeout, connectionRetry, heartBeat);
         } catch (ClientConnectionException e) {
             log.error("Exception occured during building ssl context or 
obtaining selector", e);
             throw new IllegalStateException(e);
@@ -43,12 +43,12 @@
     }
 
     private static JsonRpcClient getJsonClient(Reactor reactor, String 
hostName, int port, int connectionTimeOut,
-            int clientTimeOut, int connectionRetry) throws 
ClientConnectionException {
+            int clientTimeOut, int connectionRetry, int heartBeat) throws 
ClientConnectionException {
         final ReactorClient client = reactor.createClient(hostName, port);
-        client.setRetryPolicy(new RetryPolicy(connectionTimeOut, 
connectionRetry, IOException.class));
+        client.setRetryPolicy(new RetryPolicy(connectionTimeOut, 
connectionRetry, heartBeat, IOException.class));
         ResponseWorker worker = ReactorFactory.getWorker();
         JsonRpcClient jsonClient = worker.register(client);
-        jsonClient.setRetryPolicy(new RetryPolicy(clientTimeOut, 
connectionRetry, IOException.class));
+        jsonClient.setRetryPolicy(new RetryPolicy(clientTimeOut, 
connectionRetry, heartBeat, IOException.class));
         return jsonClient;
     }
 }
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 c85cd41..cc5566e 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
@@ -15,11 +15,11 @@
 
 public class TransportFactory {
     public static IIrsServer createIrsServer(VdsProtocol vdsProtocol, String 
hostname, int port, int clientTimeOut,
-            int connectionTimeOut, int clientRetries) {
+            int connectionTimeOut, int clientRetries, int heartBeat) {
         IIrsServer irsServer = null;
         if (VdsProtocol.STOMP == vdsProtocol) {
             irsServer = new 
JsonRpcIIrsServer(JsonRpcUtils.createStompClient(hostname,
-                    port, connectionTimeOut, clientTimeOut, clientRetries,
+                    port, connectionTimeOut, clientTimeOut, clientRetries, 
heartBeat,
                     Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication)));
         } else if (VdsProtocol.XML == vdsProtocol){
             Pair<IrsServerConnector, HttpClient> returnValue =
@@ -32,11 +32,11 @@
     }
 
     public static IVdsServer createVdsServer(VdsProtocol vdsProtocol, String 
hostname, int port, int clientTimeOut,
-            int connectionTimeOut, int clientRetries) {
+            int connectionTimeOut, int clientRetries, int heartBeat) {
         IVdsServer vdsServer = null;
         if (VdsProtocol.STOMP == vdsProtocol) {
             vdsServer = new 
JsonRpcVdsServer(JsonRpcUtils.createStompClient(hostname,
-                    port, connectionTimeOut, clientTimeOut, clientRetries,
+                    port, connectionTimeOut, clientTimeOut, clientRetries, 
heartBeat,
                     Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication)));
         } else if (VdsProtocol.XML == vdsProtocol) {
             Pair<VdsServerConnector, HttpClient> returnValue =
diff --git 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcIntegrationTest.java
 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcIntegrationTest.java
index c05d537..d4faefa 100644
--- 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcIntegrationTest.java
+++ 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcIntegrationTest.java
@@ -1,6 +1,6 @@
 package org.ovirt.engine.core.vdsbroker.jsonrpc;
 
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
@@ -27,7 +27,7 @@
 
     @Test
     public void testGetVdsCapabilities() throws InterruptedException, 
ExecutionException, ClientConnectionException {
-        JsonRpcClient client = JsonRpcUtils.createStompClient(HOST_ADDRESS, 
PORT, TIMEOUT, 0, TIMEOUT, true);
+        JsonRpcClient client = JsonRpcUtils.createStompClient(HOST_ADDRESS, 
PORT, TIMEOUT, 0, TIMEOUT, TIMEOUT, true);
         final JsonRpcRequest request = new 
RequestBuilder("Host.getCapabilities").build();
         Map<String, Object> map = new FutureMap(client, request);
         assertTrue(map.isEmpty());
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index e3855c9..66f8af0 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -646,6 +646,7 @@
 select fn_db_add_config_value('VdsRecoveryTimeoutInMinutes','3','general');
 select fn_db_add_config_value('VdsRefreshRate','2','general');
 select fn_db_add_config_value('vdsRetries','0','general');
+select fn_db_add_config_value('vdsHeartBeat','10','general');
 --Handling Host Selection Algorithm default for cluster
 select fn_db_add_config_value('VdsSelectionAlgorithm','None','general');
 select fn_db_add_config_value('vdsTimeout','180','general');


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e8a20592542ce1a754dee1917ff9ebba6b8daf9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to