diff --git a/keyname-hash-generator/java/.classpath b/keyname-hash-generator/java/.classpath deleted file mode 100644 index 7397c6e..0000000 --- a/keyname-hash-generator/java/.classpath +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/keyname-hash-generator/java/.gitignore b/keyname-hash-generator/java/.gitignore deleted file mode 100644 index e283089..0000000 --- a/keyname-hash-generator/java/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -/.idea/ -/keyname-hash-generator.iml diff --git a/keyname-hash-generator/java/pom.xml b/keyname-hash-generator/java/pom.xml deleted file mode 100644 index 8526d73..0000000 --- a/keyname-hash-generator/java/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - 4.0.0 - cloud.benchflow.commons - keyname-hash-generator - 0.1.0 - benchflow-keyname-hash-generator - - - benchflow-keyname-hash-generator - UTF-8 - 1.8 - - - - - - - - maven-compiler-plugin - 3.3 - - ${java.version} - ${java.version} - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - ${project.name} - - - true - - - - - - - - - - diff --git a/keyname-hash-generator/java/src/main/java/cloud/benchflow/commons/hashing/Hashing.java b/keyname-hash-generator/java/src/main/java/cloud/benchflow/commons/hashing/Hashing.java deleted file mode 100644 index 4bb6b7d..0000000 --- a/keyname-hash-generator/java/src/main/java/cloud/benchflow/commons/hashing/Hashing.java +++ /dev/null @@ -1,28 +0,0 @@ -package cloud.benchflow.commons.hashing; - -import java.io.UnsupportedEncodingException; -import java.math.BigInteger; -import java.security.*; - -//Class for the hashing -public class Hashing { - - //Number of characters for the hash - private static int numOfCharacters = 4; - - //Hash with MD5 - public static String hashKey(String key) throws UnsupportedEncodingException, NoSuchAlgorithmException { - return Hashing.MD5(key); - } - - //Function to hash using MD5 - public static String MD5(String key) throws UnsupportedEncodingException, NoSuchAlgorithmException { - byte[] bytesOfMessage = key.getBytes("UTF-8"); - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] hashBytes = md.digest(bytesOfMessage); - String hashString = new BigInteger(1,hashBytes).toString(16); - hashString = hashString.substring(0, numOfCharacters); - return(hashString+"/"+key); - } - -} diff --git a/minio/java/.classpath b/minio/java/.classpath deleted file mode 100644 index d46faf1..0000000 --- a/minio/java/.classpath +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/minio/java/.gitignore b/minio/java/.gitignore deleted file mode 100644 index c154c89..0000000 --- a/minio/java/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -/lib/ -/.settings/ -/.idea/ diff --git a/minio/java/.project b/minio/java/.project deleted file mode 100644 index 1989071..0000000 --- a/minio/java/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - benchflow-minio-client - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/minio/java/.settings/org.eclipse.core.resources.prefs b/minio/java/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index cdfe4f1..0000000 --- a/minio/java/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/minio/java/.settings/org.eclipse.jdt.core.prefs b/minio/java/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 714351a..0000000 --- a/minio/java/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/minio/java/.settings/org.eclipse.m2e.core.prefs b/minio/java/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/minio/java/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/minio/java/Makefile b/minio/java/Makefile deleted file mode 100644 index 1df1718..0000000 --- a/minio/java/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -REPONAME = commons -NAME = minio -VERSION = dev -KEYNAME_HASH_GENERATOR_RELEASE_VERSION=v-dev -JAVA_VERSION_FOR_COMPILATION = (^|/)java-8-oracle($|\s) -UNAME = $(shell uname) - -find_java: -ifeq ($(UNAME), Darwin) - $(eval JAVA_HOME := $(shell /usr/libexec/java_home)) -else ifeq ($(UNAME),Linux) -ifndef TRAVIS - $(eval JAVA_HOME := $(shell update-java-alternatives -l | cut -d' ' -f3 | egrep '$(JAVA_VERSION_FOR_COMPILATION)')) -endif -endif - -.PHONY: all build_release - -all: build_release - -clean: - rm -Rf lib - mvn clean - -get_external_dependencies: - # get keyname-hash-generator as dependency - ./bin/get-dependencies.sh - -build: find_java get_external_dependencies - mvn package - -build_release: find_java - mvn package - -install: find_java get_external_dependencies - mvn validate - mvn package - -test: find_java - mvn test -B diff --git a/minio/java/bin/get-dependencies.sh b/minio/java/bin/get-dependencies.sh deleted file mode 100755 index 673cf01..0000000 --- a/minio/java/bin/get-dependencies.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -RELEASE_VERSION=v-dev - -mkdir lib -wget -q --no-check-certificate -O ./lib/benchflow-keyname-hash-generator.jar \ - http://github.com/benchflow/commons/releases/download/${RELEASE_VERSION}/benchflow-keyname-hash-generator.jar diff --git a/minio/java/client.iml b/minio/java/client.iml deleted file mode 100644 index ff3f356..0000000 --- a/minio/java/client.iml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/minio/java/pom.xml b/minio/java/pom.xml deleted file mode 100644 index 1311567..0000000 --- a/minio/java/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - - cloud.benchflow.minio - client - 0.1.0 - benchflow-minio-client - - - benchflow-minio-client - UTF-8 - 1.8 - 2.0.1 - 2.5 - - - - - - io.minio - minio - ${minio.java.version} - - - - commons-io - commons-io - ${commons.io.version} - - - - cloud.benchflow.commons - keyname-hash-generator - 0.1.0 - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - ${java.version} - ${java.version} - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - - - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - ${project.name} - - - true - - - - - - - - diff --git a/minio/java/src/main/java/cloud/benchflow/minio/BenchFlowMinioClient.java b/minio/java/src/main/java/cloud/benchflow/minio/BenchFlowMinioClient.java deleted file mode 100644 index 58e91f3..0000000 --- a/minio/java/src/main/java/cloud/benchflow/minio/BenchFlowMinioClient.java +++ /dev/null @@ -1,367 +0,0 @@ -package cloud.benchflow.minio; - -import cloud.benchflow.commons.hashing.Hashing; -import io.minio.ErrorCode; -import io.minio.MinioClient; -import io.minio.ObjectStat; -import io.minio.Result; -import io.minio.errors.*; -import io.minio.messages.Item; -import org.apache.commons.io.IOUtils; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.LinkedList; -import java.util.List; - -/** - * @author Simone D'Avico (simonedavico@gmail.com) - * - * Created on 26/02/16. - */ -@SuppressWarnings("unused") -public class BenchFlowMinioClient { - - private MinioClient mc; - private static final String TESTS_BUCKET = "tests"; - private static final String DEPLOYMENT_DESCRIPTOR_NAME = "docker-compose.yml"; - private static final String TEST_CONFIGURATION_NAME = "benchflow-test.yml"; - private static final String GENERATED_BENCHMARK_FILENAME = "benchflow-benchmark.jar"; - - public BenchFlowMinioClient(final String address, final String accessKey, final String privateKey) - throws InvalidPortException, InvalidEndpointException { -// System.out.println("Access key: " + accessKey); -// System.out.println("Secret key: " + privateKey); -// System.out.println("Address: " + address); - this.mc = new MinioClient(address, accessKey, privateKey); - } - - - /*** - * Removes object at - * tests/{id}, if it exists - */ - protected void removeIfExists(final String id) { - try { - mc.removeObject(TESTS_BUCKET, id); - } catch (ErrorResponseException e) { - /* happens if the object to remove doesn't exist, do nothing */ - } catch (MinioException | XmlPullParserException | NoSuchAlgorithmException | - InvalidKeyException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - } - - /** - * - */ - protected String hashKey(String key) { - try { - return Hashing.hashKey(key); - } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) { - throw new BenchFlowMinioClientException("Error while hashing key " + key, e); - } - } - - - /*** - * Retrieves object at key {id} and returns it as a string - */ - protected String getTextFile(final String id) { - try { - InputStream in = mc.getObject(TESTS_BUCKET, id); - return IOUtils.toString(in, StandardCharsets.UTF_8); - } catch (MinioException | InvalidKeyException | NoSuchAlgorithmException | XmlPullParserException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(),e); - } - } - - - /*** - * Saves content at tests/{id} - */ - protected void saveTextFile(final String content, final String id) { - byte[] toSave = content.getBytes(StandardCharsets.UTF_8); - try { - mc.putObject(TESTS_BUCKET, id, new ByteArrayInputStream(toSave), toSave.length, "application/octet-stream"); - } catch (MinioException | NoSuchAlgorithmException | XmlPullParserException | InvalidKeyException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - } - - - /*** - * Saves an inputstream at - * tests/{id} - */ - protected void saveInputStream(final InputStream content, final String id) { - try { - byte[] bytes = IOUtils.toByteArray(content); - InputStream stream = new ByteArrayInputStream(bytes); - mc.putObject(TESTS_BUCKET, id, stream, bytes.length, "application/octet-stream"); - } catch (MinioException | InvalidKeyException | NoSuchAlgorithmException | - XmlPullParserException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - } - - - /*** - * Returns file at tests/{id} - */ - protected InputStream getFile(final String id) { - try { - return mc.getObject(TESTS_BUCKET, id); - } catch (MinioException | NoSuchAlgorithmException | XmlPullParserException | - InvalidKeyException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - } - - - /*** - * Returns the deployment descriptor sent at deploy time, - * saved at tests/{testId}/original/docker-compose.yml - */ - public String getOriginalDeploymentDescriptor(final String testId) { - String id = hashKey(testId) + "/original/" + DEPLOYMENT_DESCRIPTOR_NAME; - return getTextFile(id); - } - - - /*** - * Returns the test configuration sent at deploy time, - * saved at tests/{testId}/original/benchflow-test.yml - */ - public String getOriginalTestConfiguration(final String testId) { - String id = hashKey(testId) + "/original/" + TEST_CONFIGURATION_NAME; - return getTextFile(id); - } - - - /*** - * Saves the original deployment descriptor for a test, - * at tests/{testId}/original/docker-compose.yml - */ - public void saveOriginalDeploymentDescriptor(final String testId, final String deploymentDescriptor) { - String id = hashKey(testId) + "/original/" + DEPLOYMENT_DESCRIPTOR_NAME; - saveTextFile(deploymentDescriptor, id); - } - - - /*** - * Saves the deployment descriptor for a given experiment - * at tests/{testId}/{experimentNumber}/docker-compose.yml - */ - public void saveDeploymentDescriptorForExperiment(final String testId, - final long experimentNumber, - final String deploymentDescriptor) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + DEPLOYMENT_DESCRIPTOR_NAME; - saveTextFile(deploymentDescriptor, id); - } - - - /*** - * Saves the configuration for an experiment - * at tests/{testId}/{experimentNumber}/benchflow-benchmark.yml - */ - public void saveTestConfigurationForExperiment(final String testId, - final long experimentNumber, - final String experimentConfiguration) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + TEST_CONFIGURATION_NAME; - saveTextFile(experimentConfiguration, id); - } - - - /*** - * Saves the original test configuration for a test, - * at tests/{testId}/original/benchflow-benchmark.yml - */ - public void saveOriginalTestConfiguration(final String testId, final String testConfiguration) { - String id = hashKey(testId) + "/original/" + TEST_CONFIGURATION_NAME; - saveTextFile(testConfiguration, id); - } - - - /*** - * Returns the deployment descriptor for an experiment - * from tests/{testId}/{experimentNumber}/docker-compose.yml - */ - public String getDeploymentDescriptorForExperiment(final String testId, final long experimentNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + DEPLOYMENT_DESCRIPTOR_NAME; - return getTextFile(id); - } - - - /*** - * Returns the deployment descriptor for a trial, - * from tests/{testId}/{experimentNumber}/{trialNumber}/docker-compose.yml - */ - public String getDeploymentDescriptorForTrial(final String testId, final long experimentNumber, final int trialNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + trialNumber + "/" + DEPLOYMENT_DESCRIPTOR_NAME; - return getTextFile(id); - } - - - /*** - * Returns the benchmark configuration for an experiment, - * at tests/{testId}/original/benchflow-test.yml - */ - public String getTestConfigurationForExperiment(final String testId, final long experimentNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + TEST_CONFIGURATION_NAME; - return getTextFile(id); - } - - - /*** - * Saves the deployment descriptor generated for a trial at - * tests/{testId}/{experimentNumber}/{trialNumber}/docker-compose.yml - */ - public void saveDeploymentDescriptorForTrial(final String testId, final long experimentNumber, - final int trialNumber, final String descriptor) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + trialNumber + "/" + DEPLOYMENT_DESCRIPTOR_NAME; - saveTextFile(descriptor, id); - } - - - /*** - * Removes the deployment descriptor for a trial, - * from tests/{testId}/{experimentNumber}/{trialNumber}/docker-compose.yml - */ - public void removeDeploymentDescriptorForTrial(final String testId, final long experimentNumber, - final int trialNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + trialNumber + "/" + DEPLOYMENT_DESCRIPTOR_NAME; - removeIfExists(id); - } - - - /*** - * Removes the configuration for an experiment, - * from tests/{testId}/{experimentNumber}/benchflow-test.yml - */ - public void removeTestConfigurationForExperiment(final String testId, final long experimentNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + TEST_CONFIGURATION_NAME; - removeIfExists(id); - } - - - /*** - * Saves the generated Faban configuration for a trial, - * at tests/{testId}/{experimentNumber}/{trialNumber}/run.xml - */ - public void saveFabanConfiguration(final String testId, final long experimentNumber, - final int trialNumber, final String configuration) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + trialNumber + "/run.xml"; - saveTextFile(configuration, id); - } - - - /*** - * Returns the Faban configuration for a trial, - * from tests/{testId}/{experimentNumber}/{trialNumber}/run.xml - */ - public String getFabanConfiguration(final String testId, final long experimentNumber, final int trialNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + trialNumber + "/run.xml"; - return getTextFile(id); - } - - - /*** - * Removes the Faban configuration for a trial, - * from tests/{testId}/{experimentNumber}/{trialNumber}/run.xml - */ - public void removeFabanConfiguration(final String testId, final long experimentNumber, final int trialNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + trialNumber + "/run.xml"; - removeIfExists(id); - } - - - /*** - * Returns the driver generated for an experiment, - * from tests/{testId}/{experimentNumber}/driver.jar - */ - public InputStream getGeneratedBenchmark(final String testId, final long experimentNumber) { - String id = hashKey(testId) + "/" + experimentNumber + "/" + GENERATED_BENCHMARK_FILENAME; - return getFile(id); - } - - - /*** - * Saves generated driver for an experiment, - * at tests/{testId}/{experimentNumber}/benchflow-benchmark.jar - */ - public void saveGeneratedBenchmark(final String testId, final long experimentNUmber, final String driverPath) { - try { - String id = hashKey(testId) + "/" + experimentNUmber + "/" + GENERATED_BENCHMARK_FILENAME; - mc.putObject(TESTS_BUCKET, id, driverPath); - } catch (MinioException | NoSuchAlgorithmException | InvalidKeyException | IOException | XmlPullParserException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - } - - - /*** - * Saves a model, - * at tests/{testId}/models/{modelName} - */ - public void saveModel(final String testId, final String modelName, final InputStream model) throws IOException { - String modelContent = IOUtils.toString(model, "UTF-8"); - String id = hashKey(testId) + "/models/" + modelName; - saveTextFile(modelContent, id); - } - - - /*** - * Removes all models at tests/{testId}/models - */ - public void removeModels(final String testId) { - try { - String id = hashKey(testId) + "/models"; - for(Result item : mc.listObjects(TESTS_BUCKET, id)) { - mc.removeObject(TESTS_BUCKET, item.get().objectName()); - } - } catch (MinioException | XmlPullParserException | NoSuchAlgorithmException | - InvalidKeyException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - } - - - /*** - * Returns all models at tests/{testId}/models - */ - public List listModels(final String testId) { - List modelNames = new LinkedList<>(); - try { - String id = hashKey(testId) + "/models/"; - - for(Result item : mc.listObjects(TESTS_BUCKET, id)) { - modelNames.add(item.get().objectName().replace(id, "")); - } - - } catch (MinioException | XmlPullParserException | NoSuchAlgorithmException | - InvalidKeyException | IOException e) { - throw new BenchFlowMinioClientException(e.getMessage(), e); - } - return modelNames; - } - - - /*** - * Returns a model for a benchmark, - * from tests/{testId}/models/{modelName} - */ - public String getModel(final String testId, final String modelName) { - String id = hashKey(testId) + "/models/" + modelName; - return getTextFile(id); - } - -} - - diff --git a/minio/java/src/main/java/cloud/benchflow/minio/BenchFlowMinioClientException.java b/minio/java/src/main/java/cloud/benchflow/minio/BenchFlowMinioClientException.java deleted file mode 100644 index 8ceadac..0000000 --- a/minio/java/src/main/java/cloud/benchflow/minio/BenchFlowMinioClientException.java +++ /dev/null @@ -1,14 +0,0 @@ -package cloud.benchflow.minio; - -/** - * @author Simone D'Avico (simonedavico@gmail.com) - * - * Created on 26/07/16. - */ -public class BenchFlowMinioClientException extends RuntimeException { - - public BenchFlowMinioClientException(String msg, Throwable e) { - super(msg, e); - } - -}