From f81ffa5377b082e35b52cd4135812ae7eef110e0 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 7 Oct 2015 08:28:17 +0000 Subject: [PATCH] refs #579: Use Persistence to persist Scheduled Task configuration on smart-executor https://support.d4science.org/issues/579 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@119470 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../couchdb/CouchDBPersistenceConnector.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java index af05fe8..a76795d 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java @@ -208,11 +208,9 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect startKey.add(scope); ArrayNode endKey = new ObjectMapper().createArrayNode(); endKey.add(scope); - - String pluginName = pluginDeclaration.getName(); - if(pluginName!=null && pluginName.compareTo("")!=0){ - startKey.add(pluginName); - endKey.add(pluginName); + if(pluginDeclaration!=null && pluginDeclaration.getName()!=null && pluginDeclaration.getName().compareTo("")!=0){ + startKey.add(pluginDeclaration.getName()); + endKey.add(pluginDeclaration.getName()); query = query.viewName(PLUGIN_STATE_VIEW_ABANDONED); }else{ query = query.viewName(PLUGIN_STATE); @@ -224,15 +222,20 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect if(iterationNumber != LAST){ startKey.add(iterationNumber); endKey.add(iterationNumber); + + startKey.add(1); + endKey.add("{}"); + }else{ + // Adding time interval + startKey.add(1); + endKey.add("{}"); } - - // Adding time interval - startKey.add(1); - endKey.add("{}"); query.startKey(startKey); query.endKey(endKey); + query.reduce(false); + PluginState pluginState = null; ViewResult viewResult = query(query); for (ViewResult.Row row : viewResult) {