minor fix on close

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-data-indexer-se-plugin@129795 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-01 18:58:04 +00:00
parent b8e535d842
commit 185c295828
1 changed files with 11 additions and 13 deletions

View File

@ -81,7 +81,7 @@ public class SocialDataIndexerPlugin extends Plugin<SocialDataIndexerPluginDecla
public void launch(Map<String, Object> inputs){
try{
// TODO auth 2.0 doesn't allow scope set anymore, we will need to pass a valid token
// for the scope in which we would like the plugin to be run
@ -92,7 +92,7 @@ public class SocialDataIndexerPlugin extends Plugin<SocialDataIndexerPluginDecla
scope = (String) inputs.get("scope");
else
logger.error("Scope variable is not set. The context will be evaluated later...");
// connection to cassandra
store = new DBCassandraAstyanaxImpl(scope);
@ -158,10 +158,10 @@ public class SocialDataIndexerPlugin extends Plugin<SocialDataIndexerPluginDecla
}
logger.info("Inserted " + count + " docs into the index");
// refresh data (note that the index must be refreshed according to the new value of _timestamp)
client.admin().indices().prepareRefresh().execute().actionGet();
// delete documents with timestamp lower than init
deleteDocumentsWithTimestampLowerThan(init);
@ -173,16 +173,14 @@ public class SocialDataIndexerPlugin extends Plugin<SocialDataIndexerPluginDecla
logger.error("Error while synchronizing data.", e);
}
}
}finally{
@Override
protected void finalize(){
// close connection
if(client != null){
// close connection
if(client != null){
logger.debug("Closing connection to elasticsearch cluster. " + client.toString());
client.close();
logger.debug("Closing connection to elasticsearch cluster. " + client.toString());
client.close();
}
}
}
@ -249,7 +247,7 @@ public class SocialDataIndexerPlugin extends Plugin<SocialDataIndexerPluginDecla
IndexRequest ind = new IndexRequest(IndexFields.INDEX_NAME, IndexFields.EF_FEEDS_TABLE, enhFeedUUID)// set timestamp
.timestamp(String.valueOf(init)) // add json object
.source(json);
// add
bulkProcessor.add(ind);