The Rackspace Cloud platform includes everything you need to build websites and applications that scale servers, storage, networking, APIs, and more. The Rackspace Cloud is based on OpenStack, which is a global collaboration of developers and cloud computing technologists producing the ubiquitous open source cloud computing platform for public and private clouds.
This guide assumes you‘re familiar with Java and its technologies. To get started you’ll need access to the Rackspace cloud and jclouds.
javac -version
mvn -version
mkdir jclouds
cd jclouds
mvn dependency:copy-dependencies "-DoutputDirectory=./lib"
jclouds/
pom.xml
lib/
*.jar
There are some differences in terminology between jclouds and Rackspace/OpenStack that should be made clear.
Cloud Files is an easy to use online storage for files and media which can be delivered globally over Akamai's content delivery network (CDN).
Cloud Files works with a portable layer in jclouds that is used to access features common to all cloud object storage systems. Cloud Files also works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Swift object storage systems. Finally, Cloud Files works with the Rackspace layer in jclouds that is used to access features specific to the Rackspace object storage system.
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/cloudfiles/
CloudFilesPublish.java
Constants.java
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudfiles/CloudFilesPublish.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudfiles.CloudFilesPublish myUsername myApiKey Create Container jclouds-example-publish Create Object From File createObjectFromFile.html Enable CDN Container Go to http://blah.rackcdn.com/createObjectFromFile.html
Cloud Servers is an easy to use service that provides on-demand servers that you can use to to build dynamic websites, deliver mobile apps, or crunch big data.
Cloud Servers works with a portable layer in jclouds that is used to access features common to all cloud compute systems. Cloud Servers also works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Nova compute systems.
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/cloudservers/
CloudServersPublish.java
Constants.java
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudservers/CloudServersPublish.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudservers.CloudServersPublish myUsername myApiKey Create Server {id=IAD/4d560...} Configure And Start Webserver (a lot of ssh output) Login: ssh root@123.123.123.123 Password: a1b2c3d4 Go to http://123.123.123.123
Cloud Block Storage allows you to create volumes on which to persistently store your data from your servers, even when those servers have been deleted. It delivers consistent performance for your I/O-intensive applications.
Cloud Block Storage works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Cinder block storage systems.
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/cloudblockstorage/
CreateVolumeAndAttach.java
Constants.java
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudblockstorage/CreateVolumeAndAttach.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudblockstorage.CreateVolumeAndAttach myUsername myApiKey Create Server {id=DFW/8814...} Login: ssh root@123.123.123.123 Password: a1b2c3d4 Create Volume Volume{id=53d9...} Create Volume Attachment VolumeAttachment{id=53d9...} Mount Volume and Create Filesystem Exit Status: 0 List Volumes ...
Cloud Load Balancers distributes workloads across two or more servers, network links, and other resources to maximize throughput, minimize response time, and avoid overload. Rackspace Cloud Load Balancers allow you to quickly load balance multiple Cloud Servers for optimal resource utilization.
Cloud Load Balancers works with the Rackspace layer in jclouds that is used to access features specific to the Rackspace load balancer system.
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/cloudloadbalancers/
CreateLoadBalancerWithExistingServers.java
Constants.java
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudloadbalancers/CreateLoadBalancerWithExistingServers.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudloadbalancers.CreateLoadBalancerWithExistingServers myUsername myApiKey Create Cloud Load Balancer LoadBalancer{id=85901...} Go to http://166.78.34.87
Cloud Databases provides easily managed cloud MySQL instances with built-in data replication for speed and reliability.
You can access Cloud Databases with the jclouds openstack-trove API by specifying the rackspace clouddatabases providers “rackspace-clouddatabases-us” and “rackspace-clouddatabases-uk”. The -us one can be used to access the United States regions, and the -uk one is for the United Kingdom regions. The examples use the -us provider, but the providers are interchangeable (but regions will differ).
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/clouddatabases/
CreateInstance.java
Constants.java
Note: When providing a java classpath in Windows, the path separator is ‘;’ instead of ‘:’
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/clouddatabases/CreateInstance.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.clouddatabases.CreateInstance myUsername myApiKey
In addition to the create database instance example, by going through the clouddatabases example code, you will learn to create instances, databases, and database users as well as delete and modify them. You will also learn how to set up and access a database from the public internet over JDBC. You can find the examples documentation in the Rackspace examples.
Cloud Auto Scale takes the work out of capacity planning, allowing Rackspace Cloud Monitoring alerts or scheduled events to create and delete servers. Through the use of webhooks, Auto Scale can be integrated into countless deployment scenarios. Read the dev blog here.
You can access Cloud Auto Scale with the jclouds rackspace-autoscale API by specifying the Auto Scale provider “rackspace-autoscale-us”. There is no -uk provider at this time.
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/autoscale/
CreatePolicy.java
Constants.java
Note: When providing a java classpath in Windows, the path separator is ‘;’ instead of ‘:’ Note: This uses the API key, not the password.
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/autoscale/CreatePolicy.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.autoscale.CreatePolicy myUsername myApiKey
In addition to the CreatePolicy example, by going through the Auto Scale example code, you will learn to create and execute webhooks, and delete and modify groups, policies, and webhooks. You can find the examples documentation in the Rackspace examples.
Cloud Queues easily connect distributed applications without installing complex software. Create unlimited queues quickly and send unlimited messages.
Cloud Queues works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Marconi queuing systems.
jclouds/
pom.xml
lib/
*.jar
org/jclouds/examples/rackspace/cloudqueues/
ProducerConsumer.java
Constants.java
javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudqueues/ProducerConsumer.java java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudqueues.ProducerConsumer myUsername myApiKey Producer Consumer Producer 1 Message 1:0 Producer 1 Message 1:1 Consumer 1 Message 1:0 (Queue This Way) Consumer 2 Message 1:1 (Queue This Way) Producer 1 Message 1:2 Consumer 1 Message 1:2 (Queue This Way) Producer 1 Message 1:3 Consumer 1 Message 1:3 (Queue This Way) Producer 1 Message 1:4 Producer 1 Message 1:5 Consumer 2 Message 1:4 (Queue This Way) ...
Setting up jclouds to work in a managed container is easy. You simply need to ensure that jclouds won't spawn any of its own threads. You can do this by using the ExecutorServiceModule when building your Context.
An example code snippet:
{% highlight java %} import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.concurrent.config.ExecutorServiceModule;
public class MyJEEClass { ...
private void init() { Iterable modules = ImmutableSet. of( new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
ComputeServiceContext context = ContextBuilder.newBuilder("rackspace-cloudservers-us") .credentials("myUsername", "myApiKey") .modules(modules) .buildView(ComputeServiceContext.class); ComputeService compute = context.getComputeService();
}
... } {% endhighlight %}
This is a list of providers that work with the Rackspace Cloud that you can use to build your Context.
"cloudfiles-us"
"cloudfiles-uk"
"rackspace-cloudservers-us"
"rackspace-cloudservers-uk"
"rackspace-autoscale-us"
"rackspace-cloudblockstorage-us"
"rackspace-cloudblockstorage-uk"
"rackspace-cloudloadbalancers-us"
"rackspace-cloudloadbalancers-uk"
"rackspace-clouddatabases-us"
"rackspace-clouddatabases-uk"
"rackspace-cloudqueues-us"
"rackspace-cloudqueues-uk"
Your feedback is appreciated! If you have specific issues with Rackspace support in jclouds, we'd prefer that you file an issue via JIRA.
For general feedback and support requests, please join the jclouds community.