From 50d40af0ad6cafccc36ba7c7bf3bc67a3a3c3f2f Mon Sep 17 00:00:00 2001 From: Alessandro Pieve Date: Wed, 26 Apr 2017 13:05:57 +0000 Subject: [PATCH] first release git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-insert-rstudio-se-plugin@147148 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 36 +++ .project | 23 ++ .settings/org.eclipse.core.resources.prefs | 6 + .settings/org.eclipse.jdt.core.prefs | 5 + .settings/org.eclipse.m2e.core.prefs | 4 + ...nsert-rstudio-se-plugin-1.0.0-SNAPSHOT.jar | Bin 0 -> 13317 bytes distro/LICENSE | 4 + distro/README | 65 ++++++ distro/changelog.xml | 5 + distro/descriptor.xml | 31 +++ distro/profile.xml | 27 +++ pom.xml | 164 ++++++++++++++ .../AggregatorPersistenceBackendQuery.java | 17 ++ ...rPersistenceBackendQueryConfiguration.java | 30 +++ .../plugin/AccountingInsertRstudioPlugin.java | 210 ++++++++++++++++++ ...ountingInsertRstudioPluginDeclaration.java | 80 +++++++ .../insert/rstudio/plugin/Utility.java | 44 ++++ .../utils/ConfigurationServiceEndpoint.java | 17 ++ .../insert/rstudio/utils/Constant.java | 16 ++ ...nagement.executor.plugin.PluginDeclaration | 1 + .../insert/rstudio/plugin/Tests.java | 62 ++++++ 21 files changed, 847 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 accounting-insert-rstudio-se-plugin-1.0.0-SNAPSHOT.jar create mode 100644 distro/LICENSE create mode 100644 distro/README create mode 100644 distro/changelog.xml create mode 100644 distro/descriptor.xml create mode 100644 distro/profile.xml create mode 100644 pom.xml create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQuery.java create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQueryConfiguration.java create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPlugin.java create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPluginDeclaration.java create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/plugin/Utility.java create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/utils/ConfigurationServiceEndpoint.java create mode 100644 src/main/java/org/gcube/accounting/insert/rstudio/utils/Constant.java create mode 100644 src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration create mode 100644 src/test/java/org/gcube/accounting/insert/rstudio/plugin/Tests.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..dcb2dc5 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..aa8f5d2 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + accounting-insert-rstudio-se-plugin + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec4300d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/accounting-insert-rstudio-se-plugin-1.0.0-SNAPSHOT.jar b/accounting-insert-rstudio-se-plugin-1.0.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..a8d31f53b8982b681b8809330b9e4a7c528e9c03 GIT binary patch literal 13317 zcmcJ01yml%)-9T#!5u^gn=RGqGktOO_+6wtRr*E3xFx0~O8K|WrkgcSLx#H593WPfi40i^ZV zOyu3^=Ih5l`#he=e{LqlCoLu{q@YMGC443|JR~VWMLhv4K}9|~JXRx5JI%1VWlKIX zOg7_2=K+aa!NbNO3=ZRO^bjYMWcoG;58VwrI4{kueaeJim#{u?uXJu>r2m8Ob_%`%! zEsPBu^a20U4&^WH^b8EF94zfkE&mM~`#*ItwX_4++W(6&!vCSCt)0Dtp{dosAdvqe zf`h%Ox!u3u(EcKhHNe)+)XpAYY4C4Or1(`da|dHn%RkZ5{3$dMAA$Y|%|~ZCni>F} zhVeZ{@uN`(N`ZlZRzZM(B!AKHcXtR_SsIxdJJ{;kn_5{ad`B0uG_!^`I}%?1}w#j%&8QS~ABU-g-e60FCHQ(~-t&QQjo5NvLwKp@wxg^BYTxgEnG`qp?zH+kQ?4XM>e%MUe3u0B)Va0 z$2rUri*Dwv^+T;{Xm<);fOd~;tZAp{zCv@3H!3ZG=z*2LOWDittpPmwi?8_y zavAR&4v!uV-`{-QAn{6^Gs*D|l;Z5%cxHIc2E$rv}QNPgTdZxun=&Z62WCN zlD!tD8Gv%o&2drNA8MR}vC}~*s>8r|IALw8+xT1rrsYfJz@_L4gY)?u>j@-OotC#;|-Xl3eDL44H;=ruhH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Q0?ukAVJ@ zi1tVSf0ohypjPWW^ozuPRaE=rl7E(JK3QISd_jK2;eS~ElW_BAD?dy4o~+P3|1~Rr zeysmDg1(;_{j4K|{}rR}8;w7c_*qr;M55*~*ZdNRf6!R{Y~^RQ$deVm z7yp%&|4uvdGmW43aGz+&ZCymR# TNdf_(KmMFR00BMxHbwp);XEG4 literal 0 HcmV?d00001 diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..cdf50bd --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1,4 @@ +gCube System - License +------------------------------------------------------------ + +${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..a941085 --- /dev/null +++ b/distro/README @@ -0,0 +1,65 @@ +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${gcube.description} + +${gcube.funding} + + +Version +-------------------------------------------------- + +${version} (${buildDate}) + +Please see the file named "changelog.xml" in this directory for the release notes. + + +Authors +-------------------------------------------------- + +* Alessandro Pieve (alessandro.pieve-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + +Maintainers +----------- + +* Alessandro Pieve (alessandro.pieve-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + + +Download information +-------------------------------------------------- + +Source code is available from SVN: + ${scm.url} + +Binaries can be downloaded from the gCube website: + ${gcube.website} + + +Installation +-------------------------------------------------- + +Installation documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/SmartExecutor + + +Documentation +-------------------------------------------------- + +Documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/SmartExecutor + + +Support +-------------------------------------------------- + +Bugs and support requests can be reported in the gCube issue tracking tool: + ${gcube.issueTracking} + + +Licensing +-------------------------------------------------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..c13315d --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,5 @@ + + + First Release + + \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..089683d --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,31 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + changelog.xml + profile.xml + + 755 + true + + + + + target/${build.finalName}.jar + /${artifactId} + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..940b176 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,27 @@ + + + + Plugin + + {description} + ${serviceClass} + ${artifactId} + 1.0.0 + + + {description} + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + Plugin + + ${build.finalName}.jar + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..234b1e3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,164 @@ + + 4.0.0 + + org.gcube.tools + maven-parent + 1.0.0 + + org.gcube.accounting + accounting-insert-rstudio-se-plugin + 1.0.0-SNAPSHOT + Accounting Insert RStudio + Accounting Insert RStudio + + + UTF-8 + distro + Accounting + + + + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/${project.artifactId} + https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/${project.artifactId} + + + + + org.gcube.distribution + maven-smartgears-bom + LATEST + pom + import + + + + + + + org.gcube.vremanagement + smart-executor-api + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided + + + + + + org.gcube.common + common-authorization + + + + + org.gcube.common + authorization-client + + + + + org.gcube.core + common-scope + provided + + + + + org.gcube.common + common-authorization + + + + org.gcube.common + authorization-client + provided + + + + org.slf4j + slf4j-api + provided + + + + + com.couchbase.client + java-client + 2.2.3 + + + com.couchbase.client + core-io + [1.2.3,2.0.0) + compile + + + + + org.gcube.data.publishing + document-store-lib-couchbase + [1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT) + + + org.gcube.data.publishing + document-store-lib + provided + + + + org.gcube.accounting + accounting-lib + provided + + + + + junit + junit + 4.11 + test + + + ch.qos.logback + logback-classic + 1.0.13 + test + + + org.gcube.core + common-encryption + test + + + org.gcube.vremanagement + smart-executor-client + 1.3.0-4.1.0-132087 + test + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + + package + + single + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQuery.java b/src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQuery.java new file mode 100644 index 0000000..79f50cf --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQuery.java @@ -0,0 +1,17 @@ +package org.gcube.accounting.insert.rstudio.persistence; + + + +/** + * @author Alessandro Pieve (ISTI - CNR) + * + */ +public interface AggregatorPersistenceBackendQuery { + + public static final int KEY_VALUES_LIMIT = 25; + + public void prepareConnection( + AggregatorPersistenceBackendQueryConfiguration configuration) + throws Exception; + +} diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQueryConfiguration.java b/src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQueryConfiguration.java new file mode 100644 index 0000000..810ffaa --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/persistence/AggregatorPersistenceBackendQueryConfiguration.java @@ -0,0 +1,30 @@ +package org.gcube.accounting.insert.rstudio.persistence; + + +import org.gcube.accounting.persistence.AccountingPersistenceConfiguration; + +/** + * @author Alessandro Pieve (ISTI - CNR) + * + */ +public class AggregatorPersistenceBackendQueryConfiguration extends AccountingPersistenceConfiguration { + + /** + * Default Constructor + */ + public AggregatorPersistenceBackendQueryConfiguration(){ + super(); + } + + /** + * @param class1 The class of the persistence to instantiate + * @throws Exception if fails + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public AggregatorPersistenceBackendQueryConfiguration(Class persistence) throws Exception{ + super((Class) persistence); + } + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPlugin.java b/src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPlugin.java new file mode 100644 index 0000000..9ac32cf --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPlugin.java @@ -0,0 +1,210 @@ +package org.gcube.accounting.insert.rstudio.plugin; + + + +import java.io.BufferedReader; +import java.io.FileReader; +import java.net.InetAddress; +import java.util.Map; +import java.util.UUID; + +import org.gcube.accounting.insert.rstudio.persistence.AggregatorPersistenceBackendQueryConfiguration; +import org.gcube.accounting.insert.rstudio.utils.ConfigurationServiceEndpoint; +import org.gcube.accounting.insert.rstudio.utils.Constant; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.documentstore.persistence.PersistenceCouchBase; +import org.gcube.vremanagement.executor.plugin.Plugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.couchbase.client.java.Bucket; +import com.couchbase.client.java.Cluster; +import com.couchbase.client.java.CouchbaseCluster; +import com.couchbase.client.java.document.JsonDocument; +import com.couchbase.client.java.document.json.JsonObject; +import com.couchbase.client.java.env.CouchbaseEnvironment; +import com.couchbase.client.java.env.DefaultCouchbaseEnvironment; + + + +/** + * @author Alessandro Pieve (ISTI - CNR) + * + */ +public class AccountingInsertRstudioPlugin extends Plugin { + + private static Logger logger = LoggerFactory.getLogger(AccountingInsertRstudioPlugin.class); + + + + public AccountingInsertRstudioPlugin(AccountingInsertRstudioPluginDeclaration pluginDeclaration) { + super(pluginDeclaration); + } + + /* The environment configuration */ + protected static final CouchbaseEnvironment ENV = + DefaultCouchbaseEnvironment.builder() + .connectTimeout(Constant.CONNECTION_TIMEOUT * 1000) + .maxRequestLifetime(Constant.MAX_REQUEST_LIFE_TIME * 1000) + .queryTimeout(Constant.CONNECTION_TIMEOUT * 1000) //15 Seconds in milliseconds + .viewTimeout(Constant.VIEW_TIMEOUT_BUCKET * 1000)//120 Seconds in milliseconds + .keepAliveInterval(3600 * 1000) // 3600 Seconds in milliseconds + .kvTimeout(5000) //in ms + .build(); + + /**{@inheritDoc}*/ + @Override + public void launch(Map inputs) throws Exception { + + String context=ScopeProvider.instance.get(); + logger.debug("AccountingInsertRstudioPlugin launch on context:{}",context); + String url=null; + String password =null; + String bucket=null; + AggregatorPersistenceBackendQueryConfiguration configuration; + try{ + configuration = new AggregatorPersistenceBackendQueryConfiguration(PersistenceCouchBase.class); + url = configuration.getProperty(ConfigurationServiceEndpoint.URL_PROPERTY_KEY); + password = configuration.getProperty(ConfigurationServiceEndpoint.PASSWORD_PROPERTY_KEY); + bucket=configuration.getProperty(ConfigurationServiceEndpoint.BUCKET_STORAGE_NAME_PROPERTY_KEY); + + } + catch (Exception e) { + logger.error("AccountingInsertRstudioPlugin launch",e.getLocalizedMessage()); + throw e; + } + + logger.debug("AccountingInsertRstudioPlugin open cluster:{}",context); + Cluster cluster = CouchbaseCluster.create(ENV, url); + Bucket accountingBucket = cluster.openBucket(bucket,password); + + String dataServiceClass="content-management"; + if (inputs.containsKey("dataServiceClass")) + dataServiceClass=(String) inputs.get("dataServiceClass"); + + String dataServiceName="storage-manager"; + if (inputs.containsKey("dataServiceName")) + dataServiceName=(String) inputs.get("dataServiceName"); + + String dataServiceId=""; + + String uri="RStudio"; + if (inputs.containsKey("uri")) + uri=(String) inputs.get("uri"); + + String dataType="STORAGE"; + if (inputs.containsKey("dataType")) + dataType=(String) inputs.get("dataType"); + + Integer timeWait=1000; + if (inputs.containsKey("timeWait")) + timeWait=(Integer) inputs.get("timeWait"); + + String pathFile=null; + if (inputs.containsKey("pathFile")) + pathFile=(String) inputs.get("pathFile"); + + if (pathFile==null){ + throw new IllegalArgumentException( + "Path File is null!!"); + } + + JsonDocument document=null; + JsonObject content=null; + + BufferedReader reader = new BufferedReader(new FileReader(pathFile)); + String line; + while ((line = reader.readLine()) != null) + { + line=line.trim(); + logger.debug("AccountingInsertRstudioPlugin line :{}",line); + + String[] infoUser=line.split("\\s+"); + String user=infoUser[1]; + Long dataVolume= Long.parseLong(infoUser[0]); + if (inputs.containsKey("unitVolume")){ + + switch ((String) inputs.get("unitVolume")) { + case "Kilobyte": + dataVolume=kilToByte(dataVolume); + break; + case "Megabyte": + dataVolume=megaToByte(dataVolume); + break; + + } + } + + try{ + String docId=UUID.randomUUID().toString(); + logger.debug("AccountingInsertRstudioPlugin User:{} dataVolume:{} KB",user,bytesToKil(dataVolume)); + logger.debug("AccountingInsertRstudioPlugin User:{} dataVolume:{} bytes",user,dataVolume); + dataServiceId=InetAddress.getLocalHost().getHostName(); + Long dataCount=0l; + Long timeStamp= System.currentTimeMillis(); + content = JsonObject.empty().put("scope", context); + content.put("operationCount", 1); + content.put("dataCount", dataCount); + content.put("endTime", timeStamp); + content.put("consumerId", user); + content.put("startTime", timeStamp); + content.put("id", docId); + content.put("dataVolume", dataVolume); + content.put("dataType", dataType); + content.put("operationResult", "SUCCESS"); + content.put("dataServiceClass", dataServiceClass); + content.put("dataServiceName", dataServiceName); + content.put("dataServiceId", dataServiceId); + content.put("aggregated", true); + content.put("providerId", uri); + content.put("creationTime", timeStamp); + content.put("recordType", "StorageStatusRecord"); + document = JsonDocument.create("docId", content); + + JsonDocument doc = JsonDocument.create(docId, content); + JsonDocument response = accountingBucket.upsert(doc); + logger.debug("upsert doc:{}",doc.toString()); + Thread.sleep(timeWait); + } + catch(Exception e){ + logger.error("doc:{} not insert ({}), problem with exist bucket",document.id(),document.toString(),e); + logger.error("force insert into list for insert"); + } + + } + logger.trace("AccountingInsertRstudioPlugin close"); + reader.close(); + cluster.disconnect(); + } + + + + /**{@inheritDoc}*/ + @Override + protected void onStop() throws Exception { + logger.trace("{} onStop() function", this.getClass().getSimpleName()); + Thread.currentThread().interrupt(); + } + + private static long bytesToMeg(long bytes) { + return bytes / Constant.MEGABYTE; + } + + private static long bytesToKil(long bytes) { + return bytes / Constant.KILOBYTE ; + } + + private static long kilToByte(long kilobytes) { + return kilobytes * Constant.KILOBYTE; + } + + private Long megaToByte(Long megaToByte) { + return megaToByte * Constant.MEGABYTE; + } + + + +} + + + diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPluginDeclaration.java b/src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPluginDeclaration.java new file mode 100644 index 0000000..6a9941a --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/plugin/AccountingInsertRstudioPluginDeclaration.java @@ -0,0 +1,80 @@ +/** + * + */ +package org.gcube.accounting.insert.rstudio.plugin; + +import java.util.HashMap; +import java.util.Map; + +import org.gcube.vremanagement.executor.plugin.Plugin; +import org.gcube.vremanagement.executor.plugin.PluginDeclaration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Alessandro Pieve (ISTI - CNR) + * + */ +public class AccountingInsertRstudioPluginDeclaration implements PluginDeclaration { + /** + * Logger + */ + private static Logger logger = LoggerFactory.getLogger(AccountingInsertRstudioPlugin.class); + + /** + * Plugin name used by the Executor to retrieve this class + */ + public static final String NAME = "Accounting-Insert-RStudio"; + + public static final String DESCRIPTION = "This plugin is used to insert RStudio storage record"; + + public static final String VERSION = "1.0.0"; + + /**{@inheritDoc}*/ + @Override + public void init() { + logger.debug(String.format("%s initialized", AccountingInsertRstudioPlugin.class.getSimpleName())); + } + + /**{@inheritDoc}*/ + @Override + public String getName() { + return NAME; + } + + /**{@inheritDoc}*/ + @Override + public String getDescription() { + return DESCRIPTION; + } + + /**{@inheritDoc}*/ + @Override + public String getVersion() { + return VERSION; + } + + /**{@inheritDoc}*/ + @Override + public Map getSupportedCapabilities() { + Map discoveredCapabilities = new HashMap(); + return discoveredCapabilities; + } + + /**{@inheritDoc}*/ + @Override + public Class> getPluginImplementation() { + return AccountingInsertRstudioPlugin.class; + } + + @Override + public String toString() { + return "AccountingInsertRstudioPluginDeclaration [getName()=" + getName() + + ", getDescription()=" + getDescription() + ", getVersion()=" + + getVersion() + ", getSupportedCapabilities()=" + + getSupportedCapabilities() + ", getPluginImplementation()=" + + getPluginImplementation() + "]"; + } + + +} diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/plugin/Utility.java b/src/main/java/org/gcube/accounting/insert/rstudio/plugin/Utility.java new file mode 100644 index 0000000..7c8c99c --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/plugin/Utility.java @@ -0,0 +1,44 @@ +package org.gcube.accounting.insert.rstudio.plugin; + +import com.couchbase.client.java.document.json.JsonArray; +import com.couchbase.client.java.document.json.JsonObject; + +/** + * @author Alessandro Pieve (ISTI - CNR) + * + */ + +public class Utility { + /** + * Generate a key for map-reduce + * @param key + * @return + */ + protected static JsonArray generateKey(String scope,String key){ + JsonArray generateKey = JsonArray.create(); + if (scope!=null){ + generateKey.add(scope); + } + for (String value: key.split(",")){ + if (!value.toString().isEmpty()) + generateKey.add(Integer.parseInt(value)); + } + return generateKey; + + } + /** + * Verify a record aggregated for insert into bucket + * @param item + * @return + */ + public static boolean checkType(Object item) { + return item == null + || item instanceof String + || item instanceof Integer + || item instanceof Long + || item instanceof Double + || item instanceof Boolean + || item instanceof JsonObject + || item instanceof JsonArray; + } +} diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/utils/ConfigurationServiceEndpoint.java b/src/main/java/org/gcube/accounting/insert/rstudio/utils/ConfigurationServiceEndpoint.java new file mode 100644 index 0000000..0ab7e4b --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/utils/ConfigurationServiceEndpoint.java @@ -0,0 +1,17 @@ +package org.gcube.accounting.insert.rstudio.utils; + +/** + * @author Alessandro Pieve (ISTI - CNR) + * + */ + +public class ConfigurationServiceEndpoint { + + //Static Key for Configuration from service end point + public static final String URL_PROPERTY_KEY = "URL"; + public static final String PASSWORD_PROPERTY_KEY = "password"; + public static final String BUCKET_NAME_PROPERTY_KEY = "bucketName"; + public static final String BUCKET_STORAGE_NAME_PROPERTY_KEY="AggregatedStorageStatusRecord"; + public static final String BUCKET_STORAGE_TYPE="StorageStatusRecord"; + +} diff --git a/src/main/java/org/gcube/accounting/insert/rstudio/utils/Constant.java b/src/main/java/org/gcube/accounting/insert/rstudio/utils/Constant.java new file mode 100644 index 0000000..285a4fc --- /dev/null +++ b/src/main/java/org/gcube/accounting/insert/rstudio/utils/Constant.java @@ -0,0 +1,16 @@ +package org.gcube.accounting.insert.rstudio.utils; +public class Constant { + + //CONSTANT for connection Db + public static final Integer CONNECTION_TIMEOUT=15; + public static final Integer NUM_RETRY=6; + public static final Integer CONNECTION_TIMEOUT_BUCKET=15; + public static final Integer VIEW_TIMEOUT_BUCKET=120; + public static final Integer MAX_REQUEST_LIFE_TIME=120; + + + + public static final long GIGABYTE = 1024L * 1024L * 1024L; + public static final long MEGABYTE = 1024L * 1024L; + public static final long KILOBYTE = 1024L; +} \ No newline at end of file diff --git a/src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration b/src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration new file mode 100644 index 0000000..cb8bd52 --- /dev/null +++ b/src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration @@ -0,0 +1 @@ +org.gcube.accounting.insert.rstudio.plugin.AccountingInsertRstudioPluginDeclaration \ No newline at end of file diff --git a/src/test/java/org/gcube/accounting/insert/rstudio/plugin/Tests.java b/src/test/java/org/gcube/accounting/insert/rstudio/plugin/Tests.java new file mode 100644 index 0000000..9b11af0 --- /dev/null +++ b/src/test/java/org/gcube/accounting/insert/rstudio/plugin/Tests.java @@ -0,0 +1,62 @@ +package org.gcube.accounting.insert.rstudio.plugin; + +import java.util.HashMap; +import java.util.Map; + +import org.gcube.accounting.insert.rstudio.plugin.AccountingInsertRstudioPlugin; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.scope.api.ScopeProvider; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +public class Tests { + + /** + * Logger + */ + private static Logger logger = LoggerFactory.getLogger(Tests.class); + + @Before + public void beforeTest(){ + + } + + @Test + public void testLaunch() throws Exception { + + //SecurityTokenProvider.instance.set("36501a0d-a205-4bf1-87ad-4c7185faa0d6-98187548"); + SecurityTokenProvider.instance.set("3acdde42-6883-4564-b3ba-69f6486f6fe0-98187548"); + + //FOR DEBUG + String scopeDebug="/gcube"; + ScopeProvider.instance.set(scopeDebug); + // END FOR DEBUG + + Map inputs = new HashMap(); + //type aggregation + + /*optional*/ + //inputs.put("urlService","http://socialnetworking-d-d4s.d4science.org/social-networking-library-ws/rest/"); + inputs.put("dataServiceClass","content-management"); + inputs.put("dataServiceName","storage-manager"); + inputs.put("dataServiceId","identifier"); + inputs.put("uri","Rstudio"); + inputs.put("dataType","STORAGE"); + inputs.put("unitVolume","Kilobyte"); + inputs.put("pathFile","/home/pieve/home_disk_space"); + + + + AccountingInsertRstudioPlugin plugin = new AccountingInsertRstudioPlugin(null); + plugin.launch(inputs); + logger.debug("-------------- launch test finished"); + + } + + @After + public void after(){ + + } +}