Updated Branches: refs/heads/1.5.x d432028cd -> ac52c7613
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ac52c761/demos/speedtest-azurequeue/src/main/java/org/jclouds/azure/azurequeue/SpeedTest.java ---------------------------------------------------------------------- diff --git a/demos/speedtest-azurequeue/src/main/java/org/jclouds/azure/azurequeue/SpeedTest.java b/demos/speedtest-azurequeue/src/main/java/org/jclouds/azure/azurequeue/SpeedTest.java deleted file mode 100644 index e5b3b7c..0000000 --- a/demos/speedtest-azurequeue/src/main/java/org/jclouds/azure/azurequeue/SpeedTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.azurequeue; - -import static org.jclouds.concurrent.FutureIterables.awaitCompletion; - -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.concurrent.Future; - -import org.jclouds.azure.storage.options.ListOptions; -import org.jclouds.azure.storage.queue.AzureQueueAsyncClient; -import org.jclouds.azure.storage.queue.AzureQueueClient; -import org.jclouds.azure.storage.queue.domain.QueueMetadata; -import org.jclouds.concurrent.MoreExecutors; -import org.jclouds.enterprise.config.EnterpriseConfigurationModule; -import org.jclouds.logging.ConsoleLogger; -import org.jclouds.logging.Logger; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.inject.Module; - -/** - * This the Main class of an Application that tests your response time to amazon AzureQueue. - * - * Usage is: java org.jclouds.aws.sqs.SpeedTest \"account\" \"encodedKey\" \"queueName\" - * \"messageCount\" - * - * @author Adrian Cole - */ -public class SpeedTest { - - public static int PARAMETERS = 4; - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"account\" \"encodedKey\" \"queueName\" \"messageCount\" "; - private static final Logger logger = Logger.CONSOLE; - - private static final Logger traceLogger = new ConsoleLogger() { - - @Override - public boolean isTraceEnabled() { - return true; - } - - @Override - public void trace(String message, Object... args) { - super.info(message, args); - } - - }; - - public static void main(String[] args) throws InterruptedException { - - if (args.length < PARAMETERS) - throw new IllegalArgumentException(INVALID_SYNTAX); - - boolean isEnterprise = System.getProperties().containsKey("jclouds.enterprise"); - // Args - String account = args[0]; - String encodedKey = args[1]; - String queueName = args[2]; - int messageCount = Integer.parseInt(args[3]); - - Set<Module> modules = isEnterprise ? ImmutableSet.<Module> of(new NullLoggingModule(), - new EnterpriseConfigurationModule()) : ImmutableSet - .<Module> of(new NullLoggingModule()); - - RestContext<AzureQueueClient, AzureQueueAsyncClient> context = new RestContextFactory() - .createContext("azurequeue", account, encodedKey, modules); - - try { - if (purgeQueues(queueName, context)) { - logger.info("pausing 60 seconds before recreating queues"); - Thread.sleep(60 * 1000); - } - createQueue(queueName, context); - runTests(queueName, messageCount, isEnterprise ? "enterprise" : "default", context); - } finally { - purgeQueues(queueName, context); - // Close connections - context.close(); - System.exit(0); - } - - } - - private static class QueueMessage { - final String queue; - final String message; - - QueueMessage(String queue, String message) { - this.queue = queue; - this.message = message; - } - - @Override - public String toString() { - return "[queue=" + queue + ", message=" + message + "]"; - } - } - - private static void runTests(String queueName, int messageCount, String contextName, - RestContext<AzureQueueClient, AzureQueueAsyncClient> context) - throws InterruptedException { - String message = "1"; - long timeOut = messageCount * 200; // minimum rate should be at least 5/second - - logger.info("context: %s, queueName: %s", contextName, queueName); - - // fire off all the messages for the test - Map<QueueMessage, Future<Void>> responses = Maps.newHashMap(); - for (int i = 0; i < messageCount; i++) { - responses.put(new QueueMessage(queueName, message), context.getAsyncApi().putMessage( - queueName, message)); - } - - Map<QueueMessage, Exception> exceptions = awaitCompletion(responses, MoreExecutors.sameThreadExecutor(), - timeOut, traceLogger, String.format("context: %s", contextName)); - - if (exceptions.size() > 0) - logger.error("problems in context: %s: %s", contextName, exceptions); - - System.gc(); - logger.info("pausing 5 seconds before the next run"); - Thread.sleep(5000);// let the network quiet down - } - - private static void createQueue(String queueName, - RestContext<AzureQueueClient, AzureQueueAsyncClient> nullLoggingDefaultContext) { - logger.info("creating queue: %s", queueName); - nullLoggingDefaultContext.getApi().createQueue(queueName); - } - - private static boolean purgeQueues(String queueName, - RestContext<AzureQueueClient, AzureQueueAsyncClient> nullLoggingDefaultContext) { - boolean deleted = false; - try { - SortedSet<QueueMetadata> result = Sets.newTreeSet(nullLoggingDefaultContext.getApi() - .listQueues(ListOptions.Builder.prefix(queueName))); - if (result.size() >= 1) { - nullLoggingDefaultContext.getApi().deleteQueue(result.last().getName()); - System.out.printf("deleted queue: %s%n", queueName); - deleted = true; - } - } catch (Exception e) { - - } - return deleted; - } -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ac52c761/demos/speedtest-sqs/README.txt ---------------------------------------------------------------------- diff --git a/demos/speedtest-sqs/README.txt b/demos/speedtest-sqs/README.txt deleted file mode 100644 index c290b98..0000000 --- a/demos/speedtest-sqs/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -==== - Licensed to jclouds, Inc. (jclouds) under one or more - contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. jclouds licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -==== - -# -# this is a simple example command line client that creates a queue in all regions, then tracks performance of it -# 1. execute 'mvn install' to build the sample -# 2. invoke the jar, passing your aws credentials and the bucket you wish to create -# ex. -# java -jar target/jclouds-speedtest-sqs-jar-with-dependencies.jar $AWS_USER $AWS_PWD testqueue 1000 http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ac52c761/demos/speedtest-sqs/pom.xml ---------------------------------------------------------------------- diff --git a/demos/speedtest-sqs/pom.xml b/demos/speedtest-sqs/pom.xml deleted file mode 100644 index 29d35c3..0000000 --- a/demos/speedtest-sqs/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - -Licensed to jclouds, Inc. (jclouds) under one or more -contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. jclouds licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - ---> -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-demos-project</artifactId> - <version>1.5.0-SNAPSHOT</version> - </parent> - <artifactId>jclouds-demo-speedtest-sqs</artifactId> - <name>Speed tests of SQS across regions</name> - <description>Creates a queue in all amazon regions and then tests performance against it</description> - - <dependencies> - <dependency> - <groupId>org.apache.jclouds.api</groupId> - <artifactId>sqs</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.jclouds.driver</groupId> - <artifactId>jclouds-enterprise</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - - <build> - <finalName>${project.artifactId}</finalName> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <mainClass>org.jclouds.aws.sqs.SpeedTest</mainClass> - </manifest> - </archive> - </configuration> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <archive> - <manifest> - <mainClass>org.jclouds.aws.sqs.SpeedTest</mainClass> - </manifest> - </archive> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ac52c761/demos/speedtest-sqs/src/main/java/org/jclouds/aws/sqs/SpeedTest.java ---------------------------------------------------------------------- diff --git a/demos/speedtest-sqs/src/main/java/org/jclouds/aws/sqs/SpeedTest.java b/demos/speedtest-sqs/src/main/java/org/jclouds/aws/sqs/SpeedTest.java deleted file mode 100644 index 019c3bd..0000000 --- a/demos/speedtest-sqs/src/main/java/org/jclouds/aws/sqs/SpeedTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.sqs; - -import static org.jclouds.concurrent.FutureIterables.awaitCompletion; -import static org.jclouds.sqs.options.ListQueuesOptions.Builder.queuePrefix; - -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.concurrent.Future; - -import org.jclouds.aws.domain.Region; -import org.jclouds.concurrent.MoreExecutors; -import org.jclouds.enterprise.config.EnterpriseConfigurationModule; -import org.jclouds.logging.ConsoleLogger; -import org.jclouds.logging.Logger; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.sqs.SQSAsyncClient; -import org.jclouds.sqs.SQSClient; -import org.jclouds.sqs.domain.Queue; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.inject.Module; - -/** - * This the Main class of an Application that tests your response time to amazon SQS. - * - * Usage is: java org.jclouds.aws.sqs.SpeedTest \"accesskeyid\" \"secretkey\" \"queueName\" - * \"messageCount\" - * - * @author Adrian Cole - */ -public class SpeedTest { - private static final ImmutableSet<String> REGIONS = ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, - Region.US_WEST_1, Region.AP_SOUTHEAST_1); - public static final int PARAMETERS = 4; - public static final String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"accesskeyid\" \"secretkey\" \"queueName\" \"messageCount\" "; - - private static final Logger logger = Logger.CONSOLE; - - private static final Logger traceLogger = new ConsoleLogger() { - - @Override - public boolean isTraceEnabled() { - return true; - } - - @Override - public void trace(String message, Object... args) { - super.info(message, args); - } - - }; - - public static void main(String[] args) throws InterruptedException { - - if (args.length < PARAMETERS) - throw new IllegalArgumentException(INVALID_SYNTAX); - - boolean isEnterprise = System.getProperties().containsKey("jclouds.enterprise"); - // Args - String accesskeyid = args[0]; - String secretkey = args[1]; - String queueName = args[2]; - int messageCount = Integer.parseInt(args[3]); - - Set<Module> modules = isEnterprise ? ImmutableSet.<Module> of(new NullLoggingModule(), - new EnterpriseConfigurationModule()) : ImmutableSet.<Module> of(new NullLoggingModule()); - - RestContext<SQSClient, SQSAsyncClient> context = new RestContextFactory().createContext("sqs", accesskeyid, - secretkey, modules); - - try { - Set<Queue> queues = Sets.newHashSet(); - if (purgeQueues(queueName, context)) { - logger.info("pausing 60 seconds before recreating queues"); - Thread.sleep(60 * 1000); - } - createQueues(queueName, context, queues); - runTests(messageCount, isEnterprise ? "enterprise" : "default", context, queues); - } finally { - purgeQueues(queueName, context); - // Close connections - context.close(); - System.exit(0); - } - - } - - private static class QueueMessage { - final Queue queue; - final String message; - - QueueMessage(Queue queue, String message) { - this.queue = queue; - this.message = message; - } - - @Override - public String toString() { - return "[queue=" + queue + ", message=" + message + "]"; - } - } - - private static void runTests(int messageCount, String contextName, RestContext<SQSClient, SQSAsyncClient> context, - Set<Queue> queues) throws InterruptedException { - String message = "1"; - long timeOut = messageCount * 200; // minimum rate should be at least 5/second - - for (Queue queue : queues) { - logger.info("context: %s, region: %s, queueName: %s", contextName, queue.getRegion(), queue.getName()); - - // fire off all the messages for the test - Map<QueueMessage, Future<byte[]>> responses = Maps.newHashMap(); - for (int i = 0; i < messageCount; i++) { - responses.put(new QueueMessage(queue, message), context.getAsyncApi().sendMessage(queue, message)); - } - - Map<QueueMessage, Exception> exceptions = awaitCompletion(responses, MoreExecutors.sameThreadExecutor(), - timeOut, traceLogger, String.format("context: %s, region: %s", contextName, queue.getRegion())); - - if (exceptions.size() > 0) - logger.error("problems in context: %s, region: %s: %s", contextName, queue.getRegion(), exceptions); - - System.gc(); - logger.info("pausing 5 seconds before the next run"); - Thread.sleep(5000);// let the network quiet down - } - } - - private static void createQueues(String queueName, RestContext<SQSClient, SQSAsyncClient> nullLoggingDefaultContext, - Set<Queue> queues) { - for (String region : REGIONS) { - logger.info("creating queue: %s in region %s", queueName, region); - queues.add(nullLoggingDefaultContext.getApi().createQueueInRegion(region, queueName)); - } - } - - private static boolean purgeQueues(String queueName, RestContext<SQSClient, SQSAsyncClient> nullLoggingDefaultContext) { - boolean deleted = false; - for (String region : REGIONS) { - try { - SortedSet<Queue> result = Sets.newTreeSet(nullLoggingDefaultContext.getApi().listQueuesInRegion(region, - queuePrefix(queueName))); - if (result.size() >= 1) { - nullLoggingDefaultContext.getApi().deleteQueue(result.last()); - logger.info("deleted queue: %s in region %s", queueName, region); - deleted = true; - } - } catch (Exception e) { - - } - } - return deleted; - } -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ac52c761/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index c371bcc..5a053e1 100644 --- a/pom.xml +++ b/pom.xml @@ -33,8 +33,6 @@ under the License. <modules> <module>project</module> <module>resources</module> - <module>assemblies</module> - <module>archetypes</module> <module>core</module> <module>common</module> <module>compute</module>
