Line endings

This commit is contained in:
Andrew Phillips 2010-09-27 11:11:58 +02:00
parent fc1782b536
commit c08b50e860
11 changed files with 2131 additions and 2131 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +1,124 @@
#
#
# Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
#
# ====================================================================
# Licensed 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.
# ====================================================================
#
azurequeue.contextbuilder=org.jclouds.azure.storage.AzureStorageContextBuilder
azurequeue.sync=org.jclouds.azure.storage.queue.AzureQueueClient
azurequeue.async=org.jclouds.azure.storage.queue.AzureQueueAsyncClient
azurequeue.propertiesbuilder=org.jclouds.azure.storage.AzureStoragePropertiesBuilder
azurequeue.endpoint=https://{identity}.queue.core.windows.net
azureblob.contextbuilder=org.jclouds.azure.storage.blob.AzureBlobContextBuilder
azureblob.propertiesbuilder=org.jclouds.azure.storage.AzureStoragePropertiesBuilder
azureblob.endpoint=https://{identity}.blob.core.windows.net
pcs.contextbuilder=org.jclouds.mezeo.pcs2.PCSContextBuilder
pcs.apiVersion=unknown
sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder
sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder
sqs.contextbuilder=org.jclouds.aws.sqs.SQSContextBuilder
sqs.propertiesbuilder=org.jclouds.aws.sqs.SQSPropertiesBuilder
elb.contextbuilder=org.jclouds.aws.elb.ELBContextBuilder
elb.propertiesbuilder=org.jclouds.aws.elb.ELBPropertiesBuilder
cloudwatch.contextbuilder=org.jclouds.aws.cloudwatch.CloudWatchContextBuilder
cloudwatch.propertiesbuilder=org.jclouds.aws.cloudwatch.CloudWatchPropertiesBuilder
s3.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder
ec2.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
ec2.propertiesbuilder=org.jclouds.aws.ec2.EC2PropertiesBuilder
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder
slicehost.contextbuilder=org.jclouds.slicehost.SlicehostContextBuilder
slicehost.propertiesbuilder=org.jclouds.slicehost.SlicehostPropertiesBuilder
trmk-vcloudexpress.contextbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudExpressContextBuilder
trmk-vcloudexpress.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudExpressPropertiesBuilder
trmk-ecloud.contextbuilder=org.jclouds.vcloud.terremark.TerremarkECloudContextBuilder
trmk-ecloud.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkECloudPropertiesBuilder
chef.contextbuilder=org.jclouds.chef.ChefContextBuilder
chef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder
transientchef.contextbuilder=org.jclouds.chef.test.TransientChefContextBuilder
transientchef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder
opscodeplatform.contextbuilder=org.jclouds.opscodeplatform.OpscodePlatformContextBuilder
opscodeplatform.propertiesbuilder=org.jclouds.opscodeplatform.OpscodePlatformPropertiesBuilder
vcloud.contextbuilder=org.jclouds.vcloud.VCloudContextBuilder
vcloud.propertiesbuilder=org.jclouds.vcloud.VCloudPropertiesBuilder
vcloudexpress.contextbuilder=org.jclouds.vcloud.VCloudExpressContextBuilder
vcloudexpress.propertiesbuilder=org.jclouds.vcloud.VCloudExpressPropertiesBuilder
eucalyptus.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
eucalyptus.propertiesbuilder=org.jclouds.aws.ec2.EucalyptusPropertiesBuilder
nova.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
nova.propertiesbuilder=org.jclouds.aws.ec2.NovaPropertiesBuilder
cloudservers.contextbuilder=org.jclouds.rackspace.cloudservers.CloudServersContextBuilder
cloudservers.propertiesbuilder=org.jclouds.rackspace.RackspacePropertiesBuilder
bluelock-vcdirector.contextbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudDirectorContextBuilder
bluelock-vcdirector.propertiesbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudDirectorPropertiesBuilder
gogrid.propertiesbuilder=org.jclouds.gogrid.GoGridPropertiesBuilder
gogrid.contextbuilder=org.jclouds.gogrid.GoGridContextBuilder
ibmdev.propertiesbuilder=org.jclouds.ibmdev.IBMDeveloperCloudPropertiesBuilder
ibmdev.contextbuilder=org.jclouds.ibmdev.IBMDeveloperCloudContextBuilder
stub.propertiesbuilder=org.jclouds.compute.stub.StubComputeServicePropertiesBuilder
stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder
# example of where to change your endpoint
# bluelock.endpoint=https://express3.bluelock.com/api
atmosonline.contextbuilder=org.jclouds.atmosonline.saas.AtmosStorageContextBuilder
atmosonline.endpoint=https://accesspoint.atmosonline.com
atmosonline.apiversion=1.3.0
synaptic.contextbuilder=org.jclouds.atmosonline.saas.AtmosStorageContextBuilder
synaptic.endpoint=https://storage.synaptic.att.com
synaptic.apiversion=1.3.0
# TODO peer1 and hostedsolutions use atmos
cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesContextBuilder
cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder
walrus.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
walrus.propertiesbuilder=org.jclouds.aws.s3.WalrusPropertiesBuilder
googlestorage.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
googlestorage.propertiesbuilder=org.jclouds.aws.s3.GoogleStoragePropertiesBuilder
transient.contextbuilder=org.jclouds.blobstore.TransientBlobStoreContextBuilder
transient.propertiesbuilder=org.jclouds.blobstore.TransientBlobStorePropertiesBuilder
filesystem.contextbuilder=org.jclouds.filesystem.FilesystemBlobStoreContextBuilder
filesystem.propertiesbuilder=org.jclouds.filesystem.FilesystemBlobStorePropertiesBuilder
#
#
# Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
#
# ====================================================================
# Licensed 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.
# ====================================================================
#
azurequeue.contextbuilder=org.jclouds.azure.storage.AzureStorageContextBuilder
azurequeue.sync=org.jclouds.azure.storage.queue.AzureQueueClient
azurequeue.async=org.jclouds.azure.storage.queue.AzureQueueAsyncClient
azurequeue.propertiesbuilder=org.jclouds.azure.storage.AzureStoragePropertiesBuilder
azurequeue.endpoint=https://{identity}.queue.core.windows.net
azureblob.contextbuilder=org.jclouds.azure.storage.blob.AzureBlobContextBuilder
azureblob.propertiesbuilder=org.jclouds.azure.storage.AzureStoragePropertiesBuilder
azureblob.endpoint=https://{identity}.blob.core.windows.net
pcs.contextbuilder=org.jclouds.mezeo.pcs2.PCSContextBuilder
pcs.apiVersion=unknown
sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder
sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder
sqs.contextbuilder=org.jclouds.aws.sqs.SQSContextBuilder
sqs.propertiesbuilder=org.jclouds.aws.sqs.SQSPropertiesBuilder
elb.contextbuilder=org.jclouds.aws.elb.ELBContextBuilder
elb.propertiesbuilder=org.jclouds.aws.elb.ELBPropertiesBuilder
cloudwatch.contextbuilder=org.jclouds.aws.cloudwatch.CloudWatchContextBuilder
cloudwatch.propertiesbuilder=org.jclouds.aws.cloudwatch.CloudWatchPropertiesBuilder
s3.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder
ec2.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
ec2.propertiesbuilder=org.jclouds.aws.ec2.EC2PropertiesBuilder
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder
slicehost.contextbuilder=org.jclouds.slicehost.SlicehostContextBuilder
slicehost.propertiesbuilder=org.jclouds.slicehost.SlicehostPropertiesBuilder
trmk-vcloudexpress.contextbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudExpressContextBuilder
trmk-vcloudexpress.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudExpressPropertiesBuilder
trmk-ecloud.contextbuilder=org.jclouds.vcloud.terremark.TerremarkECloudContextBuilder
trmk-ecloud.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkECloudPropertiesBuilder
chef.contextbuilder=org.jclouds.chef.ChefContextBuilder
chef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder
transientchef.contextbuilder=org.jclouds.chef.test.TransientChefContextBuilder
transientchef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder
opscodeplatform.contextbuilder=org.jclouds.opscodeplatform.OpscodePlatformContextBuilder
opscodeplatform.propertiesbuilder=org.jclouds.opscodeplatform.OpscodePlatformPropertiesBuilder
vcloud.contextbuilder=org.jclouds.vcloud.VCloudContextBuilder
vcloud.propertiesbuilder=org.jclouds.vcloud.VCloudPropertiesBuilder
vcloudexpress.contextbuilder=org.jclouds.vcloud.VCloudExpressContextBuilder
vcloudexpress.propertiesbuilder=org.jclouds.vcloud.VCloudExpressPropertiesBuilder
eucalyptus.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
eucalyptus.propertiesbuilder=org.jclouds.aws.ec2.EucalyptusPropertiesBuilder
nova.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
nova.propertiesbuilder=org.jclouds.aws.ec2.NovaPropertiesBuilder
cloudservers.contextbuilder=org.jclouds.rackspace.cloudservers.CloudServersContextBuilder
cloudservers.propertiesbuilder=org.jclouds.rackspace.RackspacePropertiesBuilder
bluelock-vcdirector.contextbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudDirectorContextBuilder
bluelock-vcdirector.propertiesbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudDirectorPropertiesBuilder
gogrid.propertiesbuilder=org.jclouds.gogrid.GoGridPropertiesBuilder
gogrid.contextbuilder=org.jclouds.gogrid.GoGridContextBuilder
ibmdev.propertiesbuilder=org.jclouds.ibmdev.IBMDeveloperCloudPropertiesBuilder
ibmdev.contextbuilder=org.jclouds.ibmdev.IBMDeveloperCloudContextBuilder
stub.propertiesbuilder=org.jclouds.compute.stub.StubComputeServicePropertiesBuilder
stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder
# example of where to change your endpoint
# bluelock.endpoint=https://express3.bluelock.com/api
atmosonline.contextbuilder=org.jclouds.atmosonline.saas.AtmosStorageContextBuilder
atmosonline.endpoint=https://accesspoint.atmosonline.com
atmosonline.apiversion=1.3.0
synaptic.contextbuilder=org.jclouds.atmosonline.saas.AtmosStorageContextBuilder
synaptic.endpoint=https://storage.synaptic.att.com
synaptic.apiversion=1.3.0
# TODO peer1 and hostedsolutions use atmos
cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesContextBuilder
cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder
walrus.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
walrus.propertiesbuilder=org.jclouds.aws.s3.WalrusPropertiesBuilder
googlestorage.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
googlestorage.propertiesbuilder=org.jclouds.aws.s3.GoogleStoragePropertiesBuilder
transient.contextbuilder=org.jclouds.blobstore.TransientBlobStoreContextBuilder
transient.propertiesbuilder=org.jclouds.blobstore.TransientBlobStorePropertiesBuilder
filesystem.contextbuilder=org.jclouds.filesystem.FilesystemBlobStoreContextBuilder
filesystem.propertiesbuilder=org.jclouds.filesystem.FilesystemBlobStorePropertiesBuilder

View File

@ -1,202 +1,202 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.demo.tweetstore.config;
import static com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.demo.tweetstore.controller.AddTweetsController;
import org.jclouds.demo.tweetstore.controller.StoreTweetsController;
import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses;
import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.ServletConfigAware;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.SimpleServletHandlerAdapter;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import com.google.appengine.api.labs.taskqueue.Queue;
import com.google.appengine.api.labs.taskqueue.QueueFactory;
import com.google.appengine.api.labs.taskqueue.TaskOptions.Method;
import com.google.appengine.repackaged.com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.io.Closeables;
import com.google.inject.Module;
/**
* Creates servlets (using resources from the {@link SpringAppConfig}) and mappings.
*
* @author Andrew Phillips
* @see SpringAppConfig
*/
@Configuration
public class SpringServletConfig extends LoggingConfig implements ServletConfigAware {
public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts";
private ServletConfig servletConfig;
private Map<String, BlobStoreContext> providerTypeToBlobStoreMap;
private Twitter twitterClient;
private String container;
@PostConstruct
public void initialize() throws IOException {
BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory();
Properties props = loadJCloudsProperties();
logger.trace("About to initialize members.");
Module googleModule = new GoogleAppEngineConfigurationModule();
Set<Module> modules = ImmutableSet.<Module> of(googleModule);
// shared across all blobstores and used to retrieve tweets
try {
twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
.getProperty("credential"));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
}
// common namespace for storing tweets
container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER);
// instantiate and store references to all blobstores by provider name
providerTypeToBlobStoreMap = Maps.newHashMap();
for (String hint : Splitter.on(',').split(
checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) {
providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props));
}
// get a queue for submitting store tweet requests
Queue queue = QueueFactory.getQueue("twitter");
// submit a job to store tweets for each configured blobstore
for (String name : providerTypeToBlobStoreMap.keySet()) {
queue.add(url("/store/do").header("context", name).method(Method.GET));
}
logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient,
container, providerTypeToBlobStoreMap.keySet());
}
private Properties loadJCloudsProperties() {
logger.trace("About to read properties from '%s'", "/WEB-INF/jclouds.properties");
Properties props = new Properties();
InputStream input = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/jclouds.properties");
try {
props.load(input);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
Closeables.closeQuietly(input);
}
logger.trace("Properties successfully read.");
return props;
}
@Bean
public StoreTweetsController storeTweetsController() {
StoreTweetsController controller = new StoreTweetsController(providerTypeToBlobStoreMap, container, twitterClient);
injectServletConfig(controller);
return controller;
}
@Bean
public AddTweetsController addTweetsController() {
AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap,
serviceToStoredTweetStatuses());
injectServletConfig(controller);
return controller;
}
private void injectServletConfig(Servlet servlet) {
logger.trace("About to inject servlet config '%s'", servletConfig);
try {
servlet.init(checkNotNull(servletConfig));
} catch (ServletException exception) {
throw new BeanCreationException("Unable to instantiate " + servlet, exception);
}
logger.trace("Successfully injected servlet config.");
}
@Bean
ServiceToStoredTweetStatuses serviceToStoredTweetStatuses() {
return new ServiceToStoredTweetStatuses(providerTypeToBlobStoreMap, container);
}
@Bean
public HandlerMapping handlerMapping() {
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
Map<String, Object> urlMap = Maps.newHashMapWithExpectedSize(2);
urlMap.put("/store/*", storeTweetsController());
urlMap.put("/tweets/*", addTweetsController());
mapping.setUrlMap(urlMap);
/*
* "/store" and "/tweets" are part of the servlet mapping and thus stripped by the mapping if
* using default settings.
*/
mapping.setAlwaysUseFullPath(true);
return mapping;
}
@Bean
public HandlerAdapter servletHandlerAdapter() {
return new SimpleServletHandlerAdapter();
}
@PreDestroy
public void destroy() throws Exception {
logger.trace("About to close contexts.");
for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) {
context.close();
}
logger.trace("Contexts closed.");
}
/*
* (non-Javadoc)
*
* @see
* org.springframework.web.context.ServletConfigAware#setServletConfig(javax.servlet.ServletConfig
* )
*/
@Override
public void setServletConfig(ServletConfig servletConfig) {
this.servletConfig = servletConfig;
}
}
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.demo.tweetstore.config;
import static com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.demo.tweetstore.controller.AddTweetsController;
import org.jclouds.demo.tweetstore.controller.StoreTweetsController;
import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses;
import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.ServletConfigAware;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.SimpleServletHandlerAdapter;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import com.google.appengine.api.labs.taskqueue.Queue;
import com.google.appengine.api.labs.taskqueue.QueueFactory;
import com.google.appengine.api.labs.taskqueue.TaskOptions.Method;
import com.google.appengine.repackaged.com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.io.Closeables;
import com.google.inject.Module;
/**
* Creates servlets (using resources from the {@link SpringAppConfig}) and mappings.
*
* @author Andrew Phillips
* @see SpringAppConfig
*/
@Configuration
public class SpringServletConfig extends LoggingConfig implements ServletConfigAware {
public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts";
private ServletConfig servletConfig;
private Map<String, BlobStoreContext> providerTypeToBlobStoreMap;
private Twitter twitterClient;
private String container;
@PostConstruct
public void initialize() throws IOException {
BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory();
Properties props = loadJCloudsProperties();
logger.trace("About to initialize members.");
Module googleModule = new GoogleAppEngineConfigurationModule();
Set<Module> modules = ImmutableSet.<Module> of(googleModule);
// shared across all blobstores and used to retrieve tweets
try {
twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
.getProperty("credential"));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
}
// common namespace for storing tweets
container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER);
// instantiate and store references to all blobstores by provider name
providerTypeToBlobStoreMap = Maps.newHashMap();
for (String hint : Splitter.on(',').split(
checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) {
providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props));
}
// get a queue for submitting store tweet requests
Queue queue = QueueFactory.getQueue("twitter");
// submit a job to store tweets for each configured blobstore
for (String name : providerTypeToBlobStoreMap.keySet()) {
queue.add(url("/store/do").header("context", name).method(Method.GET));
}
logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient,
container, providerTypeToBlobStoreMap.keySet());
}
private Properties loadJCloudsProperties() {
logger.trace("About to read properties from '%s'", "/WEB-INF/jclouds.properties");
Properties props = new Properties();
InputStream input = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/jclouds.properties");
try {
props.load(input);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
Closeables.closeQuietly(input);
}
logger.trace("Properties successfully read.");
return props;
}
@Bean
public StoreTweetsController storeTweetsController() {
StoreTweetsController controller = new StoreTweetsController(providerTypeToBlobStoreMap, container, twitterClient);
injectServletConfig(controller);
return controller;
}
@Bean
public AddTweetsController addTweetsController() {
AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap,
serviceToStoredTweetStatuses());
injectServletConfig(controller);
return controller;
}
private void injectServletConfig(Servlet servlet) {
logger.trace("About to inject servlet config '%s'", servletConfig);
try {
servlet.init(checkNotNull(servletConfig));
} catch (ServletException exception) {
throw new BeanCreationException("Unable to instantiate " + servlet, exception);
}
logger.trace("Successfully injected servlet config.");
}
@Bean
ServiceToStoredTweetStatuses serviceToStoredTweetStatuses() {
return new ServiceToStoredTweetStatuses(providerTypeToBlobStoreMap, container);
}
@Bean
public HandlerMapping handlerMapping() {
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
Map<String, Object> urlMap = Maps.newHashMapWithExpectedSize(2);
urlMap.put("/store/*", storeTweetsController());
urlMap.put("/tweets/*", addTweetsController());
mapping.setUrlMap(urlMap);
/*
* "/store" and "/tweets" are part of the servlet mapping and thus stripped by the mapping if
* using default settings.
*/
mapping.setAlwaysUseFullPath(true);
return mapping;
}
@Bean
public HandlerAdapter servletHandlerAdapter() {
return new SimpleServletHandlerAdapter();
}
@PreDestroy
public void destroy() throws Exception {
logger.trace("About to close contexts.");
for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) {
context.close();
}
logger.trace("Contexts closed.");
}
/*
* (non-Javadoc)
*
* @see
* org.springframework.web.context.ServletConfigAware#setServletConfig(javax.servlet.ServletConfig
* )
*/
@Override
public void setServletConfig(ServletConfig servletConfig) {
this.servletConfig = servletConfig;
}
}

View File

@ -1,129 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed 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.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../project/pom.xml</relativePath>
</parent>
<artifactId>jclouds-rimuhosting</artifactId>
<name>jclouds RimuHosting core</name>
<description>jclouds components to access RimuHosting</description>
<scm>
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/rimuhosting</connection>
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/rimuhosting</developerConnection>
<url>http://jclouds.googlecode.com/svn/trunk/rimuhosting</url>
</scm>
<properties>
<!-- when instances are hung, open a ticket and add here -->
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes>
<test.rimuhosting.endpoint>https://rimuhosting.com/r</test.rimuhosting.endpoint>
<test.rimuhosting.apiversion>1.0</test.rimuhosting.apiversion>
<test.rimuhosting.identity>FIXME</test.rimuhosting.identity>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-jsch</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>test.rimuhosting.endpoint</name>
<value>${test.rimuhosting.endpoint}</value>
</property>
<property>
<name>test.rimuhosting.apiversion</name>
<value>${test.rimuhosting.apiversion}</value>
</property>
<property>
<name>test.rimuhosting.identity</name>
<value>${test.rimuhosting.identity}</value>
</property>
<property>
<name>jclouds.compute.blacklist.nodes</name>
<value>${jclouds.compute.blacklist.nodes}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed 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.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../project/pom.xml</relativePath>
</parent>
<artifactId>jclouds-rimuhosting</artifactId>
<name>jclouds RimuHosting core</name>
<description>jclouds components to access RimuHosting</description>
<scm>
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/rimuhosting</connection>
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/rimuhosting</developerConnection>
<url>http://jclouds.googlecode.com/svn/trunk/rimuhosting</url>
</scm>
<properties>
<!-- when instances are hung, open a ticket and add here -->
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes>
<test.rimuhosting.endpoint>https://rimuhosting.com/r</test.rimuhosting.endpoint>
<test.rimuhosting.apiversion>1.0</test.rimuhosting.apiversion>
<test.rimuhosting.identity>FIXME</test.rimuhosting.identity>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-jsch</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>test.rimuhosting.endpoint</name>
<value>${test.rimuhosting.endpoint}</value>
</property>
<property>
<name>test.rimuhosting.apiversion</name>
<value>${test.rimuhosting.apiversion}</value>
</property>
<property>
<name>test.rimuhosting.identity</name>
<value>${test.rimuhosting.identity}</value>
</property>
<property>
<name>jclouds.compute.blacklist.nodes</name>
<value>${jclouds.compute.blacklist.nodes}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,39 +1,39 @@
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed 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 name="test-copy" default="copy" basedir=".">
<!-- Note you need to have a copy of jclouds-vfs-1.0-beta-3-jar-with-dependencies.jar in an ant lib directory
Due to weird classloading issues, vfs will not work dynamically loaded -->
<taskdef resource="org/apache/commons/vfs/tasks/tasks.properties" />
<property name="jclouds.blobstore.url" value="blobstore://${jclouds.blobstore.account}:${jclouds.blobstore.key}@${jclouds.blobstore.provider}" />
<property name="jclouds.blobstore.container" value="jclouds-demo" />
<target name="copy">
<v-copy
destdir="${jclouds.blobstore.url}/${jclouds.blobstore.container}"
src="http://mirror.cc.columbia.edu/pub/software/apache/maven/binaries/apache-maven-2.2.1-bin.zip"
overwrite="true"
preservelastmodified="false"/>
</target>
</project>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed 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 name="test-copy" default="copy" basedir=".">
<!-- Note you need to have a copy of jclouds-vfs-1.0-beta-3-jar-with-dependencies.jar in an ant lib directory
Due to weird classloading issues, vfs will not work dynamically loaded -->
<taskdef resource="org/apache/commons/vfs/tasks/tasks.properties" />
<property name="jclouds.blobstore.url" value="blobstore://${jclouds.blobstore.account}:${jclouds.blobstore.key}@${jclouds.blobstore.provider}" />
<property name="jclouds.blobstore.container" value="jclouds-demo" />
<target name="copy">
<v-copy
destdir="${jclouds.blobstore.url}/${jclouds.blobstore.container}"
src="http://mirror.cc.columbia.edu/pub/software/apache/maven/binaries/apache-maven-2.2.1-bin.zip"
overwrite="true"
preservelastmodified="false"/>
</target>
</project>

View File

@ -1,4 +1,4 @@
del c:\etc\chef\client.rb 2>NUL
echo log_level :info>>c:\etc\chef\client.rb
echo log_location STDOUT>>c:\etc\chef\client.rb
echo chef_server_url "http://localhost:4000">>c:\etc\chef\client.rb
del c:\etc\chef\client.rb 2>NUL
echo log_level :info>>c:\etc\chef\client.rb
echo log_location STDOUT>>c:\etc\chef\client.rb
echo chef_server_url "http://localhost:4000">>c:\etc\chef\client.rb

View File

@ -1,134 +1,134 @@
@echo off
set PATH=
set JAVA_HOME=
set PATH=
GOTO FUNCTION_END
:abort
echo aborting: %EXCEPTION%
exit /b 1
:default
set INSTANCE_NAME=mkebsboot
set INSTANCE_HOME=/mnt/tmp
set LOG_DIR=/mnt/tmp
exit /b 0
:mkebsboot
set TMP_DIR=/mnt/tmp
exit /b 0
:findPid
set FOUND_PID=
set _expression=%1
shift
set FIND_PROCESS=TASKLIST /FI "WINDOWTITLE eq %_expression%" /NH
FOR /F "usebackq tokens=2 delims= " %%A IN (`cmd /c "%FIND_PROCESS% 2>NUL"`) DO (
SET FOUND_PID=%%A
)
if defined FOUND_PID (
exit /b 0
) else (
set EXCEPTION=%_expression% not found
exit /b 1
)
:forget
SETLOCAL
set FOUND_PID=
set NEXT_MINUTE=
set INSTANCE_NAME=%1
shift
set SCRIPT=%1
shift
set LOG_DIR=%1
shift
CALL :findProcess %INSTANCE_NAME%
if defined FOUND_PID (
echo %INSTANCE_NAME% already running pid [%FOUND_PID%]
) else (
CALL :nextMinute
set _DATE=%DATE:~4%
set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE%
echo %INSTANCE_NAME% will start at %NEXT_MINUTE%
set SECONDS=%TIME:~6,2%
set /a SECOND=60-SECONDS
%CMD% >NUL
ping -n %SECONDS% 127.0.0.1 > NUL 2>&1
CALL :findProcess %INSTANCE_NAME%
if not defined FOUND_PID (
set EXCEPTION=%INSTANCE_NAME% did not start
abort
)
)
exit /b 0
:FUNCTION_END
set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem
if not "%1" == "init" if not "%1" == "status" if not "%1" == "stop" if not "%1" == "start" if not "%1" == "tail" if not "%1" == "tailerr" if not "%1" == "run" (
set EXCEPTION=bad argument: %1 not in init status stop start tail tailerr run
goto abort
)
goto CASE_%1
:CASE_init
call :default
if errorlevel 1 goto abort
call :mkebsboot
if errorlevel 1 goto abort
md %INSTANCE_HOME%
del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL
echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd
echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd
md %INSTANCE_HOME%
del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL
echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd
echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd
echo exit /b 0 >>%INSTANCE_HOME%\mkebsboot.cmd
GOTO END_SWITCH
:CASE_status
call :default
if errorlevel 1 goto abort
call :findPid %INSTANCE_NAME%
if errorlevel 1 goto abort
echo [%FOUND_PID%]
GOTO END_SWITCH
:CASE_stop
call :default
if errorlevel 1 goto abort
call :findPid %INSTANCE_NAME%
if errorlevel 1 goto abort
if defined FOUND_PID (
TASKKILL /F /T /PID %FOUND_PID% >NUL
)
GOTO END_SWITCH
:CASE_start
call :default
if errorlevel 1 goto abort
call :forget %INSTANCE_NAME% %INSTANCE_HOME%\%INSTANCE_NAME%.cmd %LOG_DIR%
if errorlevel 1 goto abort
GOTO END_SWITCH
:CASE_tail
call :default
if errorlevel 1 goto abort
tail %LOG_DIR%\stdout.log
GOTO END_SWITCH
:CASE_tailerr
call :default
if errorlevel 1 goto abort
tail %LOG_DIR%\stderr.log
GOTO END_SWITCH
:CASE_run
call :default
if errorlevel 1 goto abort
%INSTANCE_HOME%\%INSTANCE_NAME%.cmd
GOTO END_SWITCH
:END_SWITCH
exit /b 0
@echo off
set PATH=
set JAVA_HOME=
set PATH=
GOTO FUNCTION_END
:abort
echo aborting: %EXCEPTION%
exit /b 1
:default
set INSTANCE_NAME=mkebsboot
set INSTANCE_HOME=/mnt/tmp
set LOG_DIR=/mnt/tmp
exit /b 0
:mkebsboot
set TMP_DIR=/mnt/tmp
exit /b 0
:findPid
set FOUND_PID=
set _expression=%1
shift
set FIND_PROCESS=TASKLIST /FI "WINDOWTITLE eq %_expression%" /NH
FOR /F "usebackq tokens=2 delims= " %%A IN (`cmd /c "%FIND_PROCESS% 2>NUL"`) DO (
SET FOUND_PID=%%A
)
if defined FOUND_PID (
exit /b 0
) else (
set EXCEPTION=%_expression% not found
exit /b 1
)
:forget
SETLOCAL
set FOUND_PID=
set NEXT_MINUTE=
set INSTANCE_NAME=%1
shift
set SCRIPT=%1
shift
set LOG_DIR=%1
shift
CALL :findProcess %INSTANCE_NAME%
if defined FOUND_PID (
echo %INSTANCE_NAME% already running pid [%FOUND_PID%]
) else (
CALL :nextMinute
set _DATE=%DATE:~4%
set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE%
echo %INSTANCE_NAME% will start at %NEXT_MINUTE%
set SECONDS=%TIME:~6,2%
set /a SECOND=60-SECONDS
%CMD% >NUL
ping -n %SECONDS% 127.0.0.1 > NUL 2>&1
CALL :findProcess %INSTANCE_NAME%
if not defined FOUND_PID (
set EXCEPTION=%INSTANCE_NAME% did not start
abort
)
)
exit /b 0
:FUNCTION_END
set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem
if not "%1" == "init" if not "%1" == "status" if not "%1" == "stop" if not "%1" == "start" if not "%1" == "tail" if not "%1" == "tailerr" if not "%1" == "run" (
set EXCEPTION=bad argument: %1 not in init status stop start tail tailerr run
goto abort
)
goto CASE_%1
:CASE_init
call :default
if errorlevel 1 goto abort
call :mkebsboot
if errorlevel 1 goto abort
md %INSTANCE_HOME%
del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL
echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd
echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd
md %INSTANCE_HOME%
del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL
echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd
echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd
echo exit /b 0 >>%INSTANCE_HOME%\mkebsboot.cmd
GOTO END_SWITCH
:CASE_status
call :default
if errorlevel 1 goto abort
call :findPid %INSTANCE_NAME%
if errorlevel 1 goto abort
echo [%FOUND_PID%]
GOTO END_SWITCH
:CASE_stop
call :default
if errorlevel 1 goto abort
call :findPid %INSTANCE_NAME%
if errorlevel 1 goto abort
if defined FOUND_PID (
TASKKILL /F /T /PID %FOUND_PID% >NUL
)
GOTO END_SWITCH
:CASE_start
call :default
if errorlevel 1 goto abort
call :forget %INSTANCE_NAME% %INSTANCE_HOME%\%INSTANCE_NAME%.cmd %LOG_DIR%
if errorlevel 1 goto abort
GOTO END_SWITCH
:CASE_tail
call :default
if errorlevel 1 goto abort
tail %LOG_DIR%\stdout.log
GOTO END_SWITCH
:CASE_tailerr
call :default
if errorlevel 1 goto abort
tail %LOG_DIR%\stderr.log
GOTO END_SWITCH
:CASE_run
call :default
if errorlevel 1 goto abort
%INSTANCE_HOME%\%INSTANCE_NAME%.cmd
GOTO END_SWITCH
:END_SWITCH
exit /b 0

View File

@ -1,17 +1,17 @@
md %TEMP%\%USERNAME%\scripttest
del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL
echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
md %TEMP%\%USERNAME%\scripttest
del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL
echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo exit /b 0 >>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
md %TEMP%\%USERNAME%\scripttest
del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL
echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
md %TEMP%\%USERNAME%\scripttest
del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL
echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo exit /b 0 >>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd

View File

@ -1,36 +1,36 @@
@echo off
set PATH=
set JAVA_HOME=
set PATH=
set RUNTIME=
GOTO FUNCTION_END
:abort
echo aborting: %EXCEPTION%
exit /b 1
:default
set RUNTIME=Moo
exit /b 0
:FUNCTION_END
set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem
if not "%1" == "start" if not "%1" == "stop" if not "%1" == "status" (
set EXCEPTION=bad argument: %1 not in start stop status
goto abort
)
goto CASE_%1
:CASE_start
call :default
if errorlevel 1 goto abort
echo start %RUNTIME%
GOTO END_SWITCH
:CASE_stop
call :default
if errorlevel 1 goto abort
echo stop %RUNTIME%
GOTO END_SWITCH
:CASE_status
del %TEMP%\%USERNAME%\scripttest\temp.txt 2>NUL
echo hello world>>%TEMP%\%USERNAME%\scripttest\temp.txt
echo the following should be []: [%RUNTIME%]
GOTO END_SWITCH
:END_SWITCH
exit /b 0
@echo off
set PATH=
set JAVA_HOME=
set PATH=
set RUNTIME=
GOTO FUNCTION_END
:abort
echo aborting: %EXCEPTION%
exit /b 1
:default
set RUNTIME=Moo
exit /b 0
:FUNCTION_END
set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem
if not "%1" == "start" if not "%1" == "stop" if not "%1" == "status" (
set EXCEPTION=bad argument: %1 not in start stop status
goto abort
)
goto CASE_%1
:CASE_start
call :default
if errorlevel 1 goto abort
echo start %RUNTIME%
GOTO END_SWITCH
:CASE_stop
call :default
if errorlevel 1 goto abort
echo stop %RUNTIME%
GOTO END_SWITCH
:CASE_status
del %TEMP%\%USERNAME%\scripttest\temp.txt 2>NUL
echo hello world>>%TEMP%\%USERNAME%\scripttest\temp.txt
echo the following should be []: [%RUNTIME%]
GOTO END_SWITCH
:END_SWITCH
exit /b 0

View File

@ -1,192 +1,192 @@
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed 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 name="compute" default="dump" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property file="build.properties" />
<property name="jclouds.version" value="1.0-SNAPSHOT" />
<property name="privatekeyfile" value="${user.home}/.ssh/id_rsa" />
<property name="publickeyfile" value="${user.home}/.ssh/id_rsa.pub" />
<mkdir dir="build" />
<get src="http://opensource.become.com/apache//maven/binaries/maven-ant-tasks-2.1.1.jar" dest="build/maven-ant-tasks.jar"/>
<input
message="Which provider would you like to use (ec2, cloudservers, vcloud, terremark, rimuhosting)?"
validargs="ec2,cloudservers,vcloud,trmk-ecloud,trmk-vcloudexpress,eucalyptus,bluelock-vcdirector,gogrid,rimuhosting"
addproperty="provider"
/>
<input
message="Which driver does ${provider} use?"
validargs="aws,rackspace,vcloud,bluelock,gogrid,terremark,ibmdev,rimuhosting"
addproperty="driver"
/>
<path id="maven-ant-tasks.classpath" path="build/maven-ant-tasks.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath" />
<artifact:localRepository id="local.repository" path="${user.home}/.m2/repository" />
<artifact:remoteRepository id="jclouds.repository" url="http://jclouds.googlecode.com/svn/repo" />
<artifact:remoteRepository id="jclouds-snapshot.repository" url="https://oss.sonatype.org/content/repositories/snapshots" />
<artifact:dependencies pathId="jclouds.classpath">
<dependency groupId="org.jclouds" artifactId="jclouds-antcontrib" version="${jclouds.version}" />
<dependency groupId="org.jclouds" artifactId="jclouds-${driver}" version="${jclouds.version}" />
<localRepository refid="local.repository" />
<remoteRepository refid="jclouds.repository" />
<remoteRepository refid="jclouds-snapshot.repository" />
</artifact:dependencies>
<typedef name="compute" classname="org.jclouds.tools.ant.taskdefs.compute.ComputeTask" classpathref="jclouds.classpath" />
<input
message="What is your identity on ${provider}?"
addproperty="identity"
/>
<input
message="What is the credential for ${identity}?"
addproperty="credential"
/>
<property name="jclouds.compute.url" value="compute://${identity}:${credential}@${provider}" />
<target name="list" description="list the identity of all nodes">
<compute actions="list" provider="${jclouds.compute.url}" />
</target>
<target name="list-details" description="list the details of all nodes">
<compute actions="list-details" provider="${jclouds.compute.url}" />
</target>
<target name="list-images" description="list the images supported">
<compute actions="list-images" provider="${jclouds.compute.url}" />
</target>
<target name="list-hardwares" description="list the hardwares supported">
<compute actions="list-hardwares" provider="${jclouds.compute.url}" />
</target>
<target name="list-locations" description="list the locations supported">
<compute actions="list-locations" provider="${jclouds.compute.url}" />
</target>
<target name="dump" description="list all information we can obtain about the cloud">
<compute actions="list-locations,list-hardwares,list-images,list-details" provider="${jclouds.compute.url}" />
</target>
<target name="reboot" depends="reboot-id,reboot-tag" />
<target name="reboot-id" description="reboot the node ${id}" unless="tag">
<input
message="Which node do you wish to reboot"
addproperty="id"
/>
<compute actions="reboot" provider="${jclouds.compute.url}">
<nodes id="${id}" />
</compute>
</target>
<target name="reboot-tag" description="reboot the nodes with tag ${tag}" unless="id" >
<input
message="Which tag do you wish to reboot"
addproperty="tag"
/>
<compute actions="reboot" provider="${jclouds.compute.url}">
<nodes tag="${tag}" />
</compute>
</target>
<target name="destroy" depends="destroy-id,destroy-tag" />
<target name="destroy-id" description="destroy the node ${id}" unless="tag">
<input
message="Which node do you wish to destroy"
addproperty="id"
/>
<compute actions="destroy" provider="${jclouds.compute.url}">
<nodes id="${id}" />
</compute>
</target>
<target name="destroy-tag" description="destroy the nodes with tag ${tag}" unless="id" >
<input
message="Which tag do you wish to destroy"
addproperty="tag"
/>
<compute actions="destroy" provider="${jclouds.compute.url}">
<nodes tag="${tag}" />
</compute>
</target>
<target name="get" depends="get-tag,get-id" />
<target name="get-id" description="get the node ${id}" unless="tag">
<input
message="Which node do you wish to get"
addproperty="id"
/>
<compute actions="get" provider="${jclouds.compute.url}">
<nodes id="${id}" />
</compute>
</target>
<target name="get-tag" description="get the nodes with tag ${tag}" unless="id" >
<input
message="Which tag do you wish to get"
addproperty="tag"
/>
<compute actions="get" provider="${jclouds.compute.url}">
<nodes tag="${tag}" />
</compute>
</target>
<property name="location" value="" />
<target name="create" description="create the node ${tag}">
<property name="privatekeyfile" value="${user.home}/.ssh/id_rsa" />
<property name="publickeyfile" value="${user.home}/.ssh/id_rsa.pub" />
<property name="os" value="UBUNTU" />
<property name="count" value="1" />
<input
message="What do you want to tag your nodes with?"
addproperty="tag"
/>
<compute actions="create" provider="${jclouds.compute.url}">
<nodes privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}" tag="${tag}" count="${count}" os="${os}" hardware="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
</compute>
</target>
</project>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed 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 name="compute" default="dump" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property file="build.properties" />
<property name="jclouds.version" value="1.0-SNAPSHOT" />
<property name="privatekeyfile" value="${user.home}/.ssh/id_rsa" />
<property name="publickeyfile" value="${user.home}/.ssh/id_rsa.pub" />
<mkdir dir="build" />
<get src="http://opensource.become.com/apache//maven/binaries/maven-ant-tasks-2.1.1.jar" dest="build/maven-ant-tasks.jar"/>
<input
message="Which provider would you like to use (ec2, cloudservers, vcloud, terremark, rimuhosting)?"
validargs="ec2,cloudservers,vcloud,trmk-ecloud,trmk-vcloudexpress,eucalyptus,bluelock-vcdirector,gogrid,rimuhosting"
addproperty="provider"
/>
<input
message="Which driver does ${provider} use?"
validargs="aws,rackspace,vcloud,bluelock,gogrid,terremark,ibmdev,rimuhosting"
addproperty="driver"
/>
<path id="maven-ant-tasks.classpath" path="build/maven-ant-tasks.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath" />
<artifact:localRepository id="local.repository" path="${user.home}/.m2/repository" />
<artifact:remoteRepository id="jclouds.repository" url="http://jclouds.googlecode.com/svn/repo" />
<artifact:remoteRepository id="jclouds-snapshot.repository" url="https://oss.sonatype.org/content/repositories/snapshots" />
<artifact:dependencies pathId="jclouds.classpath">
<dependency groupId="org.jclouds" artifactId="jclouds-antcontrib" version="${jclouds.version}" />
<dependency groupId="org.jclouds" artifactId="jclouds-${driver}" version="${jclouds.version}" />
<localRepository refid="local.repository" />
<remoteRepository refid="jclouds.repository" />
<remoteRepository refid="jclouds-snapshot.repository" />
</artifact:dependencies>
<typedef name="compute" classname="org.jclouds.tools.ant.taskdefs.compute.ComputeTask" classpathref="jclouds.classpath" />
<input
message="What is your identity on ${provider}?"
addproperty="identity"
/>
<input
message="What is the credential for ${identity}?"
addproperty="credential"
/>
<property name="jclouds.compute.url" value="compute://${identity}:${credential}@${provider}" />
<target name="list" description="list the identity of all nodes">
<compute actions="list" provider="${jclouds.compute.url}" />
</target>
<target name="list-details" description="list the details of all nodes">
<compute actions="list-details" provider="${jclouds.compute.url}" />
</target>
<target name="list-images" description="list the images supported">
<compute actions="list-images" provider="${jclouds.compute.url}" />
</target>
<target name="list-hardwares" description="list the hardwares supported">
<compute actions="list-hardwares" provider="${jclouds.compute.url}" />
</target>
<target name="list-locations" description="list the locations supported">
<compute actions="list-locations" provider="${jclouds.compute.url}" />
</target>
<target name="dump" description="list all information we can obtain about the cloud">
<compute actions="list-locations,list-hardwares,list-images,list-details" provider="${jclouds.compute.url}" />
</target>
<target name="reboot" depends="reboot-id,reboot-tag" />
<target name="reboot-id" description="reboot the node ${id}" unless="tag">
<input
message="Which node do you wish to reboot"
addproperty="id"
/>
<compute actions="reboot" provider="${jclouds.compute.url}">
<nodes id="${id}" />
</compute>
</target>
<target name="reboot-tag" description="reboot the nodes with tag ${tag}" unless="id" >
<input
message="Which tag do you wish to reboot"
addproperty="tag"
/>
<compute actions="reboot" provider="${jclouds.compute.url}">
<nodes tag="${tag}" />
</compute>
</target>
<target name="destroy" depends="destroy-id,destroy-tag" />
<target name="destroy-id" description="destroy the node ${id}" unless="tag">
<input
message="Which node do you wish to destroy"
addproperty="id"
/>
<compute actions="destroy" provider="${jclouds.compute.url}">
<nodes id="${id}" />
</compute>
</target>
<target name="destroy-tag" description="destroy the nodes with tag ${tag}" unless="id" >
<input
message="Which tag do you wish to destroy"
addproperty="tag"
/>
<compute actions="destroy" provider="${jclouds.compute.url}">
<nodes tag="${tag}" />
</compute>
</target>
<target name="get" depends="get-tag,get-id" />
<target name="get-id" description="get the node ${id}" unless="tag">
<input
message="Which node do you wish to get"
addproperty="id"
/>
<compute actions="get" provider="${jclouds.compute.url}">
<nodes id="${id}" />
</compute>
</target>
<target name="get-tag" description="get the nodes with tag ${tag}" unless="id" >
<input
message="Which tag do you wish to get"
addproperty="tag"
/>
<compute actions="get" provider="${jclouds.compute.url}">
<nodes tag="${tag}" />
</compute>
</target>
<property name="location" value="" />
<target name="create" description="create the node ${tag}">
<property name="privatekeyfile" value="${user.home}/.ssh/id_rsa" />
<property name="publickeyfile" value="${user.home}/.ssh/id_rsa.pub" />
<property name="os" value="UBUNTU" />
<property name="count" value="1" />
<input
message="What do you want to tag your nodes with?"
addproperty="tag"
/>
<compute actions="create" provider="${jclouds.compute.url}">
<nodes privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}" tag="${tag}" count="${count}" os="${os}" hardware="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
</compute>
</target>
</project>