Branching in my private branch
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/GenerateMapReduceCouchbase@152519 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
commit
175bde198c
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>GenerateMapReduceCouchbase</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,12 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -0,0 +1,38 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.influxdb</groupId>
|
||||
<artifactId>db-ttest</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>influxdbTest</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>couchbase</id>
|
||||
<name>Couchbase Maven Repository</name>
|
||||
<layout>default</layout>
|
||||
<url>http://files.couchbase.com/maven2/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.influxdb</groupId>
|
||||
<artifactId>influxdb-java</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couchbase.client</groupId>
|
||||
<artifactId>java-client</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,81 @@
|
|||
package org.gcube.dbtest;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
import com.couchbase.client.java.Cluster;
|
||||
import com.couchbase.client.java.CouchbaseCluster;
|
||||
import com.couchbase.client.java.bucket.BucketManager;
|
||||
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
import com.couchbase.client.java.view.DefaultView;
|
||||
import com.couchbase.client.java.view.DesignDocument;
|
||||
|
||||
public class dbtest {
|
||||
|
||||
protected static final String DEFAULT_DB = "accounting";
|
||||
|
||||
protected static final String DEFAULT_DB_SERVICE = "accounting_service";
|
||||
protected static final String DEFAULT_DB_STORAGE = "accounting_storage";
|
||||
|
||||
protected static final String MAP_REDUCE_PATH_IMPORT = "/home/pieve/Documents/AccountingAnalyticsListMapReduceCouchbase/couchbase/2.0.0/_design/ServiceUsageRecord";
|
||||
|
||||
protected static final String URL="http://couchbase01-d-d4s.d4science.org";
|
||||
protected static final String PASSWORD="accounting";
|
||||
|
||||
/* The environment configuration */
|
||||
protected static final CouchbaseEnvironment ENV = DefaultCouchbaseEnvironment
|
||||
.builder().queryEnabled(true).build();
|
||||
public static void main(String[] args) throws Exception{
|
||||
createMapReduceCouchBase();
|
||||
}
|
||||
|
||||
|
||||
private static void createMapReduceCouchBase() throws Exception{
|
||||
|
||||
Cluster cluster = CouchbaseCluster.create(ENV, URL);
|
||||
Bucket bucket = cluster.openBucket(DEFAULT_DB_SERVICE,PASSWORD);
|
||||
BucketManager bucketManager = bucket.bucketManager();
|
||||
File file = new File(MAP_REDUCE_PATH_IMPORT);
|
||||
|
||||
File[] filesInDir = file.listFiles();
|
||||
Arrays.sort(filesInDir);
|
||||
Map<String, List> mappe = new HashMap<String, List>();
|
||||
|
||||
for(File fs : filesInDir)
|
||||
{
|
||||
String nameMapReduce=fs.getName();
|
||||
String nameViewCustom=fs.getName().split("__")[0];
|
||||
if (!fs.getName().equals("Invalid")){
|
||||
|
||||
String stringMap= new String (Files.readAllBytes(Paths.get(fs.toString()+"/map.js")));
|
||||
String stringReduce= new String (Files.readAllBytes(Paths.get(fs.toString()+"/reduce.js")));
|
||||
|
||||
if (!mappe.containsKey(nameViewCustom))
|
||||
mappe.put(nameViewCustom, new ArrayList());
|
||||
System.out.println("add view:"+nameViewCustom+" and map:"+nameMapReduce);
|
||||
mappe.get(nameViewCustom).add(DefaultView.create(nameMapReduce,stringMap,stringReduce));
|
||||
}
|
||||
}
|
||||
|
||||
for(Map.Entry<String, List> entry : mappe.entrySet()) {
|
||||
|
||||
String key = entry.getKey();
|
||||
System.out.println("key"+key);
|
||||
DesignDocument designDoc = DesignDocument.create(key,entry.getValue());
|
||||
bucketManager.insertDesignDocument(designDoc);
|
||||
|
||||
|
||||
}
|
||||
|
||||
cluster.disconnect();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue