Alessandro Pieve 2017-02-17 16:00:15 +00:00
parent a5547401de
commit 6e983c0474
1 changed files with 8 additions and 6 deletions

View File

@ -55,7 +55,7 @@ public class AccountingInsertStoragePlugin extends Plugin<AccountingInsertStorag
public void launch(Map<String, Object> inputs) throws Exception { public void launch(Map<String, Object> inputs) throws Exception {
String context=ScopeProvider.instance.get(); String context=ScopeProvider.instance.get();
logger.debug("launch on context:{}",context); logger.debug("AccountingInsertStoragePlugin: launch on context:{}",context);
String url=null; String url=null;
String password =null; String password =null;
String bucket=null; String bucket=null;
@ -68,10 +68,11 @@ public class AccountingInsertStoragePlugin extends Plugin<AccountingInsertStorag
} }
catch (Exception e) { catch (Exception e) {
logger.error("launch",e.getLocalizedMessage()); logger.error("AccountingInsertStoragePlugin: launch",e.getLocalizedMessage());
throw e; throw e;
} }
Cluster cluster = CouchbaseCluster.create(ENV, url); Cluster cluster = CouchbaseCluster.create(ENV, url);
logger.debug("AccountingInsertStoragePlugin: create cluster");
Bucket accountingBucket = cluster.openBucket(bucket,password); Bucket accountingBucket = cluster.openBucket(bucket,password);
String urlService=null; String urlService=null;
@ -138,19 +139,20 @@ public class AccountingInsertStoragePlugin extends Plugin<AccountingInsertStorag
JsonDocument doc = JsonDocument.create(docId, content); JsonDocument doc = JsonDocument.create(docId, content);
JsonDocument response = accountingBucket.upsert(doc); JsonDocument response = accountingBucket.upsert(doc);
logger.debug("upsert doc:{}",doc.toString()); logger.debug("AccountingInsertStoragePlugin: upsert doc:{}",doc.toString());
Thread.sleep(timeWait); Thread.sleep(timeWait);
} }
catch(Exception e){ catch(Exception e){
logger.error("doc:{} not insert ({}), problem with exist bucket",document.id(),document.toString(),e); logger.error("AccountingInsertStoragePlugin: doc:{} not insert ({}), problem with exist bucket",document.id(),document.toString(),e);
logger.error("force insert into list for insert"); logger.error("AccountingInsertStoragePlugin: force insert into list for insert");
} }
} }
cluster.disconnect(); cluster.disconnect();
logger.debug("AccountingInsertStoragePlugin: insert complete");
} }
@ -160,7 +162,7 @@ public class AccountingInsertStoragePlugin extends Plugin<AccountingInsertStorag
/**{@inheritDoc}*/ /**{@inheritDoc}*/
@Override @Override
protected void onStop() throws Exception { protected void onStop() throws Exception {
logger.trace("{} onStop() function", this.getClass().getSimpleName()); logger.trace("AccountingInsertStoragePlugin: {} onStop() function", this.getClass().getSimpleName());
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }