SlideShare una empresa de Scribd logo
1 de 56
Descargar para leer sin conexión
1
Taming the Cloud Database
with
Apache jclouds
http://j.mp/acjdb14
Introductions
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
2
➢ Zack Shoylev
➢ irc: zacksh twitter: @zackshoylev
freenode #jclouds
Also email!
Introductions
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
3
Developer Relations Group
https://developer.rackspace.com/support/
Goals
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
4
➢ jclouds
➢ Create a database in the cloud
➢ Abstractions and how to contribute
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
5
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
6
➢ Buzzword
➢ Networked and distributed computing
➢ Variety of services
➢ Compute (servers)
➢ Storage (files)
➢ Databases
➢ Email
➢ …
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
7
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
8
➢ Public cloud (external provider)
➢ Private cloud (internal deployment)
➢ Hybrid cloud
➢ Public + Private
Rackspace
example
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
9
Your
System
S
D
K
Cloud
AP
I
VM
VM
VM
➢ This can be an application server
➢ Or your home machine
➢ Or belong to one of your end users
➢ Or a cloud VM
➢ Or a smartphone
jclouds
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
10
➢ Advantages
➢ Metered pricing (pay as you go)
➢ Project scalability (unlimited)
➢ Safer (offsite/redundant)
➢ Economies of scale
➢ Expertise
➢ Support
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
11
➢ Disadvantages
➢ Less hardware control
➢ Provider-controlled downtime
➢ Virtualization (efficiency)
➢ Provider lock-in
➢ Provider-specific apis/sdks/features
➢ Expensive to switch clouds or deploy locally
➢ jclouds minimizes this disadvantage
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
12
➢ Can’t someone else do it?
The Cloud
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
13
➢ Database specific advantages
➢ Optimized by provider
➢ Settings
➢ Container virtualization
➢ Automated software updates
➢ Redundant data storage
➢ Backup
➢ Migration
➢ Support
OpenStack
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
14
➢ Cloud OS
➢ Open-sourced by Rackspace and NASA
(2010)
➢ Free
➢ Supported
➢ AT&T, HP, IBM, Red Hat, Rackspace, Dell, Cisco,
Intel, VMware, …
jclouds
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
15
➢ Cloud SDK
➢ Apache project
➢ Java (and Clojure)
➢ Easy
➢ Portable
➢ Cloud-agnostic
➢ Community
➢ Open source
jclouds
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
16
➢ HTTP requests, responses, retries
➢ Authentication and re-authentication
➢ Pagination
➢ Polling
➢ Rate limits
➢ Retries
➢ Abstractions
➢ Logging
➢ Less code
jclouds
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
17
jclouds
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
18
➢ Services
➢ Storage
➢ Compute
➢ VM Images
➢ Load Balancers
➢ DNS
➢ Databases
➢ …
➢ Providers
➢ Openstack
➢ Rackspace
➢ HP
➢ Amazon
➢ Azure
➢ …
jclouds
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
19
AWS aws-ec2 US-VA,US-CA,IE,SG
Bluelock bluelock-vcloud-zone01 US-IN
CloudSigma US cloudsigma-lvs US-NV
CloudSigma CH cloudsigma-zrh CH-ZH
CloudSigma DC cloudsigma-wdc US-DC
DigitalOcean digitalocean
ElasticHosts GB elastichosts-lon-b GB-LND
ElasticHosts GB elastichosts-lon-p GB-LND
ElasticHosts US elastichosts-sat-p US-TX
Go2Cloud go2cloud-jhb1 ZA-GP
GoGrid gogrid US-CA,US-VA
Green House Data greenhousedata-element-
vcloud
US-WY
HP hpcloud-compute US-NV
Ninefold ninefold-compute AU-NSW
OpenHosting openhosting-east1 US-VA
Rackspace UK (First Gen) cloudservers-uk GB-SLG
Rackspace US (First Gen) cloudservers-us US-IL,US-TX
Rackspace UK (Next Gen) rackspace-cloudservers-uk GB-SLG
Rackspace US (Next Gen) rackspace-cloudservers-us US-IL,US-TX
SeverLove serverlove-z1-man GB-MAN
SkaliCloud skalicloud-sdg-my MY-10
SoftLayer softlayer
Compute
Providers
jclouds
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
20
➢ Showcase database code
➢ Best practices
➢ Compare with compute code
➢ Gotchas and workarounds
➢ Abstractions
Requirements
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
21
➢ Maven 3
➢ Java 6+
➢ jclouds
➢ Windows or Linux [etc..] (thanks Java!)
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
22
Skeleton
Project
Create User
Create Instance
Initialize API
Create Database
Test Connection
Cleanup
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
23
➢ Maven Dependencies
➢ Selective subset
➢ Versioning
➢ jclouds-labs
POM
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
24
https://github.com/jclouds/jclouds-examples/blob/master/rackspace/pom.xml
<dependency>
<groupId>org.apache.jclouds.provider</groupId>
<artifactId>rackspace-clouddatabases-us</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
Logging
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
25
// This module is responsible for enabling logging
Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule());
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(username, apiKey)
.modules(modules) // don't forget to add the modules to your context!
.buildView(ComputeServiceContext.class);
logback.xml
<configuration scan="false">
…
<appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds-wire.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
26
Skeleton
Project
Create User
Create Instance
Initialize API
Create Database
Test Connection
Cleanup
Initialize
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
27
private final TroveApi troveApi;
troveApi = ContextBuilder
.newBuilder("rackspace-clouddatabases-
us")
.credentials(username, apiKey)
.buildApi(TroveApi.class);
Architecture
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
28
Cloud Databases
Trove
jclouds-database
Increasing level of
abstraction
Provider
settings:
Endpoint, etc.
Implementation
code
Abstraction
s
Architecture
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
29
Cloud Databases
Trove
jclouds-database
Increasing level of
abstraction
Provider
settings:
Endpoint, etc.
Implementation
code
Abstraction
s
Not implemented
Initialize
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
30
private final FlavorApi flavorApi;
flavorApi = troveApi.getFlavorApiForZone(ZONE);
APIs
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
31
➢ TroveApi
➢ FlavorApi
➢ InstanceApi
➢ DatabaseApi
➢ UserApi
➢ Utils
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
32
Skeleton
Project
Create User
Create Instance
Initialize API
Create Database
Test Connection
Cleanup
Create Instance
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
33
Flavor flavor = Iterables.getFirst(flavorApi.list(), null);
…
Instance instance = instanceApi.create(flavorId, size, name);
flavor.getId()
Volume size in
GB
Create Instance
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
34
Instance updatedInstance = awaitAvailable(instance, instanceApi);
Create Instance
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
35
Instance updatedInstance = awaitAvailable(instance, instanceApi);
Polls status, waits until ready. Will not retry by
itself!
Actual Code
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
36
InstanceApi instanceApi = api.getInstanceApiForZone(zone);
for (int retries = 0; retries < 10; retries++) {
Instance instance = null;
try {
instance = instanceApi.create(flavorId, size, name);
} catch (Exception e) {
Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS);
logger.error(Arrays.toString(e.getStackTrace()));
continue;
}
Instance updatedInstance = awaitAvailable(instance, instanceApi);
if (updatedInstance != null) {
return updatedInstance;
}
instanceApi.delete(instance.getId());
InstancePredicates.awaitDeleted(instanceApi).apply(instance);
}
return null;
Actual Code
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
37
Utils.
getWorkingInstance(
String zone,
String name,
String flavorId,
int size)
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
38
Skeleton
Project
Create User
Create Instance
Initialize API
Create Database
Test Connection
Cleanup
Create Database
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
39
troveApi = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.buildApi(TroveApi.class);
instanceApi = troveApi.getInstanceApiForZone(ZONE);
databaseApi = troveApi
.getDatabaseApiForZoneAndInstance(ZONE,getInstance().getId());
getSomeApiForXandYandZ – fairly common in jclouds
Create Database
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
40
boolean result = databaseApi.create(NAME);
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
41
Skeleton
Project
Create User
Create Instance
Initialize API
Create Database
Test Connection
Cleanup
Create User
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
42
userApi = troveApi
.getUserApiForZoneAndInstance(ZONE, instance.getId());
boolean result = userApi.create(UNAME, PASSWORD, DBNAME);
User name
User password
Database
name
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
43
Skeleton
Project
Create User
Create Instance
Initialize API
Create Database
Test Connection
Cleanup
Test Connection
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
44
Load balancer needed!
CreateLoadBalancer createLB = CreateLoadBalancer.
builder()
.name(NAME)
.protocol("MYSQL")
.port(3306)
.algorithm(LoadBalancer.Algorithm.RANDOM)
.nodes(addNodes)
.virtualIPType(VirtualIP.Type.PUBLIC)
.build();
Test Connection
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
45
loadBalancer = lbApi.create(createLB);
Test Connection
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
46
StringBuilder connString = new StringBuilder();
connString.append("jdbc:mysql://");
connString
.append(getVirtualIPv4(getLb().getVirtualIPs()));
connString.append("/");
connString.append(DBNAME); connString.append("?
user=");
connString.append(UNAME);
connString.append("&password=");
connString.append(PASSWORD);
Test Connection
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
47
Connection conn =
DriverManager.getConnection(connString.toString());
Test Connection
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
48
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 3+5");
rs.first();
System.out.format(" 3+5 is %s%n", rs.getInt(1));
Going forward
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
49
➢ jclouds examples
➢ https://github.com/jclouds/jclouds-examples
➢ More docs
➢ http://jclouds.incubator.apache.org/documentation/
➢ http://javadocs.jclouds.cloudbees.net/
➢ Maven alternatives?
➢ http://jclouds.incubator.apache.
org/documentation/userguide/installation-guide/
➢ Contribute!
➢ https://wiki.apache.org/jclouds/How%20to%
20Contribute
Java Project
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
50
➢ Compile
➢ javac -classpath "lib/*:src/main/java/:src/main/resources/"
src/main/java/org/jclouds/examples/rackspace/*.java
➢ Run
➢ java -classpath "lib/*:src/main/java/:src/main/resources/" org.jclouds.examples.
rackspace.clouddatabases.CreateInstance username apikey
Going forward
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
51
➢ TroveApi
➢ Backup Extension
➢ Settings Extension
➢ Abstraction layer
Going forward
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
52
➢ TroveApi
➢ Backup Extension
➢ Settings Extension
➢ Abstraction layer
Rackspac
e
Microsof
t
Amazo
n
CouchDB
Salesforc
e
Going forward
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
53
➢ TroveApi
➢ Backup Extension
➢ Settings Extension
➢ Abstraction layer
Rackspac
e
Microsof
t
Amazo
n
CouchDB
Salesforc
e
Going forward
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
54
Going forward
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
55
Collaborate!
http://jclouds.apache.org/
http://jclouds.apache.org/community/
Taming the Cloud Database with Apache jclouds http://j.
mp/acjdb14
56
Thank you!
http://developer.rackspace.com
sdk-support@rackspace.com
Zack Shoylev
Software Developer
zacksh #jclouds
@zackshoylev

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSD
 
The Best and Worst of Cassandra-stress Tool (Christopher Batey, The Last Pick...
The Best and Worst of Cassandra-stress Tool (Christopher Batey, The Last Pick...The Best and Worst of Cassandra-stress Tool (Christopher Batey, The Last Pick...
The Best and Worst of Cassandra-stress Tool (Christopher Batey, The Last Pick...
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMX
 
Spark / Mesos Cluster Optimization
Spark / Mesos Cluster OptimizationSpark / Mesos Cluster Optimization
Spark / Mesos Cluster Optimization
 
Configuring Your First Hadoop Cluster On EC2
Configuring Your First Hadoop Cluster On EC2Configuring Your First Hadoop Cluster On EC2
Configuring Your First Hadoop Cluster On EC2
 
Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013
Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013
Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013
 
Caching the Uncacheable: Leveraging Your CDN to Cache Dynamic Content
Caching the Uncacheable: Leveraging Your CDN to Cache Dynamic ContentCaching the Uncacheable: Leveraging Your CDN to Cache Dynamic Content
Caching the Uncacheable: Leveraging Your CDN to Cache Dynamic Content
 
Stampede con 2014 cassandra in the real world
Stampede con 2014   cassandra in the real worldStampede con 2014   cassandra in the real world
Stampede con 2014 cassandra in the real world
 
Building an Impenetrable ZooKeeper - Kathleen Ting
Building an Impenetrable ZooKeeper - Kathleen TingBuilding an Impenetrable ZooKeeper - Kathleen Ting
Building an Impenetrable ZooKeeper - Kathleen Ting
 
Production Readiness Strategies in an Automated World
Production Readiness Strategies in an Automated WorldProduction Readiness Strategies in an Automated World
Production Readiness Strategies in an Automated World
 
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
Stupid Boot Tricks: using ipxe and chef to get to boot management blissStupid Boot Tricks: using ipxe and chef to get to boot management bliss
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
 
MySQL in your laptop
MySQL in your laptopMySQL in your laptop
MySQL in your laptop
 
Unity Makes Strength
Unity Makes StrengthUnity Makes Strength
Unity Makes Strength
 
Tips for going fast in a slow world: Michael May at OSCON 2015
Tips for going fast in a slow world: Michael May at OSCON 2015Tips for going fast in a slow world: Michael May at OSCON 2015
Tips for going fast in a slow world: Michael May at OSCON 2015
 
Script it
Script itScript it
Script it
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at Scale
 
JahiaOne - Performance Tuning
JahiaOne - Performance TuningJahiaOne - Performance Tuning
JahiaOne - Performance Tuning
 
How To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesHow To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - Slides
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)
 

Destacado

Các mã sản phẩm
Các mã sản phẩmCác mã sản phẩm
Các mã sản phẩm
July Rain
 
Sandra sanchezintegradora1
Sandra sanchezintegradora1Sandra sanchezintegradora1
Sandra sanchezintegradora1
Sandra Sánchez
 
Structure of taxation and classification of taxes
Structure of taxation and classification of taxesStructure of taxation and classification of taxes
Structure of taxation and classification of taxes
shaik moin
 

Destacado (15)

Các mã sản phẩm
Các mã sản phẩmCác mã sản phẩm
Các mã sản phẩm
 
Sandra sanchezintegradora1
Sandra sanchezintegradora1Sandra sanchezintegradora1
Sandra sanchezintegradora1
 
LAN's by Group 1
LAN's by Group 1LAN's by Group 1
LAN's by Group 1
 
Planet
PlanetPlanet
Planet
 
Structure of taxation and classification of taxes
Structure of taxation and classification of taxesStructure of taxation and classification of taxes
Structure of taxation and classification of taxes
 
The niche in the market: The case of Belgian Wines
The niche in the market: The case of Belgian WinesThe niche in the market: The case of Belgian Wines
The niche in the market: The case of Belgian Wines
 
Glossary english ma. gpe. mata
Glossary english ma. gpe. mataGlossary english ma. gpe. mata
Glossary english ma. gpe. mata
 
Itqon
ItqonItqon
Itqon
 
KERJA
KERJAKERJA
KERJA
 
Skill Accelerator Presentation
Skill Accelerator PresentationSkill Accelerator Presentation
Skill Accelerator Presentation
 
La Coruña 2013
La Coruña 2013La Coruña 2013
La Coruña 2013
 
Digestive system
Digestive systemDigestive system
Digestive system
 
8th class-result-2013-faisalabad
8th class-result-2013-faisalabad8th class-result-2013-faisalabad
8th class-result-2013-faisalabad
 
Reflexes
ReflexesReflexes
Reflexes
 
A Theoretical Analysis of the Tenets of Multinational Enterprise (MNE)
A Theoretical Analysis of the Tenets of Multinational Enterprise (MNE)A Theoretical Analysis of the Tenets of Multinational Enterprise (MNE)
A Theoretical Analysis of the Tenets of Multinational Enterprise (MNE)
 

Similar a Taming the Cloud Database with Apache jclouds

Federated Storage Resources GCC2018 https://vimeo.com/291738189
Federated Storage Resources GCC2018 https://vimeo.com/291738189Federated Storage Resources GCC2018 https://vimeo.com/291738189
Federated Storage Resources GCC2018 https://vimeo.com/291738189
Vahid Jalili
 
Scale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabricScale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabric
Wim Van den Broeck
 

Similar a Taming the Cloud Database with Apache jclouds (20)

Federated Storage Resources GCC2018 https://vimeo.com/291738189
Federated Storage Resources GCC2018 https://vimeo.com/291738189Federated Storage Resources GCC2018 https://vimeo.com/291738189
Federated Storage Resources GCC2018 https://vimeo.com/291738189
 
Running your Java EE 6 applications in the Cloud (FISL 12)
Running your Java EE 6 applications in the Cloud (FISL 12)Running your Java EE 6 applications in the Cloud (FISL 12)
Running your Java EE 6 applications in the Cloud (FISL 12)
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
 
Scale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabricScale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabric
 
JFokus 2011 - Running your Java EE 6 apps in the Cloud
JFokus 2011 - Running your Java EE 6 apps in the CloudJFokus 2011 - Running your Java EE 6 apps in the Cloud
JFokus 2011 - Running your Java EE 6 apps in the Cloud
 
Running your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the CloudRunning your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the Cloud
 
Moving to Containers: Building with Docker and Amazon ECS - CON310 - re:Inven...
Moving to Containers: Building with Docker and Amazon ECS - CON310 - re:Inven...Moving to Containers: Building with Docker and Amazon ECS - CON310 - re:Inven...
Moving to Containers: Building with Docker and Amazon ECS - CON310 - re:Inven...
 
Gaming across multiple devices
Gaming across multiple devicesGaming across multiple devices
Gaming across multiple devices
 
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
 
Quarkus Denmark 2019
Quarkus Denmark 2019Quarkus Denmark 2019
Quarkus Denmark 2019
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing
 
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
 
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support Engineer
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Monitoring Docker at Scale - Docker San Francisco Meetup - August 11, 2015
Monitoring Docker at Scale - Docker San Francisco Meetup - August 11, 2015Monitoring Docker at Scale - Docker San Francisco Meetup - August 11, 2015
Monitoring Docker at Scale - Docker San Francisco Meetup - August 11, 2015
 
Introduction to Docker and deployment and Azure
Introduction to Docker and deployment and AzureIntroduction to Docker and deployment and Azure
Introduction to Docker and deployment and Azure
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the Cloud
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Taming the Cloud Database with Apache jclouds

  • 1. 1 Taming the Cloud Database with Apache jclouds http://j.mp/acjdb14
  • 2. Introductions Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 2 ➢ Zack Shoylev ➢ irc: zacksh twitter: @zackshoylev freenode #jclouds Also email!
  • 3. Introductions Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 3 Developer Relations Group https://developer.rackspace.com/support/
  • 4. Goals Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 4 ➢ jclouds ➢ Create a database in the cloud ➢ Abstractions and how to contribute
  • 5. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 5
  • 6. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 6 ➢ Buzzword ➢ Networked and distributed computing ➢ Variety of services ➢ Compute (servers) ➢ Storage (files) ➢ Databases ➢ Email ➢ …
  • 7. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 7
  • 8. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 8 ➢ Public cloud (external provider) ➢ Private cloud (internal deployment) ➢ Hybrid cloud ➢ Public + Private Rackspace example
  • 9. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 9 Your System S D K Cloud AP I VM VM VM ➢ This can be an application server ➢ Or your home machine ➢ Or belong to one of your end users ➢ Or a cloud VM ➢ Or a smartphone jclouds
  • 10. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 10 ➢ Advantages ➢ Metered pricing (pay as you go) ➢ Project scalability (unlimited) ➢ Safer (offsite/redundant) ➢ Economies of scale ➢ Expertise ➢ Support
  • 11. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 11 ➢ Disadvantages ➢ Less hardware control ➢ Provider-controlled downtime ➢ Virtualization (efficiency) ➢ Provider lock-in ➢ Provider-specific apis/sdks/features ➢ Expensive to switch clouds or deploy locally ➢ jclouds minimizes this disadvantage
  • 12. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 12 ➢ Can’t someone else do it?
  • 13. The Cloud Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 13 ➢ Database specific advantages ➢ Optimized by provider ➢ Settings ➢ Container virtualization ➢ Automated software updates ➢ Redundant data storage ➢ Backup ➢ Migration ➢ Support
  • 14. OpenStack Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 14 ➢ Cloud OS ➢ Open-sourced by Rackspace and NASA (2010) ➢ Free ➢ Supported ➢ AT&T, HP, IBM, Red Hat, Rackspace, Dell, Cisco, Intel, VMware, …
  • 15. jclouds Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 15 ➢ Cloud SDK ➢ Apache project ➢ Java (and Clojure) ➢ Easy ➢ Portable ➢ Cloud-agnostic ➢ Community ➢ Open source
  • 16. jclouds Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 16 ➢ HTTP requests, responses, retries ➢ Authentication and re-authentication ➢ Pagination ➢ Polling ➢ Rate limits ➢ Retries ➢ Abstractions ➢ Logging ➢ Less code
  • 17. jclouds Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 17
  • 18. jclouds Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 18 ➢ Services ➢ Storage ➢ Compute ➢ VM Images ➢ Load Balancers ➢ DNS ➢ Databases ➢ … ➢ Providers ➢ Openstack ➢ Rackspace ➢ HP ➢ Amazon ➢ Azure ➢ …
  • 19. jclouds Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 19 AWS aws-ec2 US-VA,US-CA,IE,SG Bluelock bluelock-vcloud-zone01 US-IN CloudSigma US cloudsigma-lvs US-NV CloudSigma CH cloudsigma-zrh CH-ZH CloudSigma DC cloudsigma-wdc US-DC DigitalOcean digitalocean ElasticHosts GB elastichosts-lon-b GB-LND ElasticHosts GB elastichosts-lon-p GB-LND ElasticHosts US elastichosts-sat-p US-TX Go2Cloud go2cloud-jhb1 ZA-GP GoGrid gogrid US-CA,US-VA Green House Data greenhousedata-element- vcloud US-WY HP hpcloud-compute US-NV Ninefold ninefold-compute AU-NSW OpenHosting openhosting-east1 US-VA Rackspace UK (First Gen) cloudservers-uk GB-SLG Rackspace US (First Gen) cloudservers-us US-IL,US-TX Rackspace UK (Next Gen) rackspace-cloudservers-uk GB-SLG Rackspace US (Next Gen) rackspace-cloudservers-us US-IL,US-TX SeverLove serverlove-z1-man GB-MAN SkaliCloud skalicloud-sdg-my MY-10 SoftLayer softlayer Compute Providers
  • 20. jclouds Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 20 ➢ Showcase database code ➢ Best practices ➢ Compare with compute code ➢ Gotchas and workarounds ➢ Abstractions
  • 21. Requirements Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 21 ➢ Maven 3 ➢ Java 6+ ➢ jclouds ➢ Windows or Linux [etc..] (thanks Java!)
  • 22. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 22 Skeleton Project Create User Create Instance Initialize API Create Database Test Connection Cleanup
  • 23. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 23 ➢ Maven Dependencies ➢ Selective subset ➢ Versioning ➢ jclouds-labs
  • 24. POM Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 24 https://github.com/jclouds/jclouds-examples/blob/master/rackspace/pom.xml <dependency> <groupId>org.apache.jclouds.provider</groupId> <artifactId>rackspace-clouddatabases-us</artifactId> <version>${jclouds.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.25</version> </dependency>
  • 25. Logging Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 25 // This module is responsible for enabling logging Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule()); ComputeServiceContext context = ContextBuilder.newBuilder(provider) .credentials(username, apiKey) .modules(modules) // don't forget to add the modules to your context! .buildView(ComputeServiceContext.class); logback.xml <configuration scan="false"> … <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender"> <file>target/test-data/jclouds-wire.log</file> <encoder> <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> </encoder> </appender>
  • 26. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 26 Skeleton Project Create User Create Instance Initialize API Create Database Test Connection Cleanup
  • 27. Initialize Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 27 private final TroveApi troveApi; troveApi = ContextBuilder .newBuilder("rackspace-clouddatabases- us") .credentials(username, apiKey) .buildApi(TroveApi.class);
  • 28. Architecture Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 28 Cloud Databases Trove jclouds-database Increasing level of abstraction Provider settings: Endpoint, etc. Implementation code Abstraction s
  • 29. Architecture Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 29 Cloud Databases Trove jclouds-database Increasing level of abstraction Provider settings: Endpoint, etc. Implementation code Abstraction s Not implemented
  • 30. Initialize Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 30 private final FlavorApi flavorApi; flavorApi = troveApi.getFlavorApiForZone(ZONE);
  • 31. APIs Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 31 ➢ TroveApi ➢ FlavorApi ➢ InstanceApi ➢ DatabaseApi ➢ UserApi ➢ Utils
  • 32. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 32 Skeleton Project Create User Create Instance Initialize API Create Database Test Connection Cleanup
  • 33. Create Instance Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 33 Flavor flavor = Iterables.getFirst(flavorApi.list(), null); … Instance instance = instanceApi.create(flavorId, size, name); flavor.getId() Volume size in GB
  • 34. Create Instance Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 34 Instance updatedInstance = awaitAvailable(instance, instanceApi);
  • 35. Create Instance Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 35 Instance updatedInstance = awaitAvailable(instance, instanceApi); Polls status, waits until ready. Will not retry by itself!
  • 36. Actual Code Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 36 InstanceApi instanceApi = api.getInstanceApiForZone(zone); for (int retries = 0; retries < 10; retries++) { Instance instance = null; try { instance = instanceApi.create(flavorId, size, name); } catch (Exception e) { Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS); logger.error(Arrays.toString(e.getStackTrace())); continue; } Instance updatedInstance = awaitAvailable(instance, instanceApi); if (updatedInstance != null) { return updatedInstance; } instanceApi.delete(instance.getId()); InstancePredicates.awaitDeleted(instanceApi).apply(instance); } return null;
  • 37. Actual Code Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 37 Utils. getWorkingInstance( String zone, String name, String flavorId, int size)
  • 38. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 38 Skeleton Project Create User Create Instance Initialize API Create Database Test Connection Cleanup
  • 39. Create Database Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 39 troveApi = ContextBuilder.newBuilder(PROVIDER) .credentials(username, apiKey) .buildApi(TroveApi.class); instanceApi = troveApi.getInstanceApiForZone(ZONE); databaseApi = troveApi .getDatabaseApiForZoneAndInstance(ZONE,getInstance().getId()); getSomeApiForXandYandZ – fairly common in jclouds
  • 40. Create Database Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 40 boolean result = databaseApi.create(NAME);
  • 41. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 41 Skeleton Project Create User Create Instance Initialize API Create Database Test Connection Cleanup
  • 42. Create User Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 42 userApi = troveApi .getUserApiForZoneAndInstance(ZONE, instance.getId()); boolean result = userApi.create(UNAME, PASSWORD, DBNAME); User name User password Database name
  • 43. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 43 Skeleton Project Create User Create Instance Initialize API Create Database Test Connection Cleanup
  • 44. Test Connection Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 44 Load balancer needed! CreateLoadBalancer createLB = CreateLoadBalancer. builder() .name(NAME) .protocol("MYSQL") .port(3306) .algorithm(LoadBalancer.Algorithm.RANDOM) .nodes(addNodes) .virtualIPType(VirtualIP.Type.PUBLIC) .build();
  • 45. Test Connection Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 45 loadBalancer = lbApi.create(createLB);
  • 46. Test Connection Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 46 StringBuilder connString = new StringBuilder(); connString.append("jdbc:mysql://"); connString .append(getVirtualIPv4(getLb().getVirtualIPs())); connString.append("/"); connString.append(DBNAME); connString.append("? user="); connString.append(UNAME); connString.append("&password="); connString.append(PASSWORD);
  • 47. Test Connection Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 47 Connection conn = DriverManager.getConnection(connString.toString());
  • 48. Test Connection Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 48 Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT 3+5"); rs.first(); System.out.format(" 3+5 is %s%n", rs.getInt(1));
  • 49. Going forward Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 49 ➢ jclouds examples ➢ https://github.com/jclouds/jclouds-examples ➢ More docs ➢ http://jclouds.incubator.apache.org/documentation/ ➢ http://javadocs.jclouds.cloudbees.net/ ➢ Maven alternatives? ➢ http://jclouds.incubator.apache. org/documentation/userguide/installation-guide/ ➢ Contribute! ➢ https://wiki.apache.org/jclouds/How%20to% 20Contribute
  • 50. Java Project Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 50 ➢ Compile ➢ javac -classpath "lib/*:src/main/java/:src/main/resources/" src/main/java/org/jclouds/examples/rackspace/*.java ➢ Run ➢ java -classpath "lib/*:src/main/java/:src/main/resources/" org.jclouds.examples. rackspace.clouddatabases.CreateInstance username apikey
  • 51. Going forward Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 51 ➢ TroveApi ➢ Backup Extension ➢ Settings Extension ➢ Abstraction layer
  • 52. Going forward Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 52 ➢ TroveApi ➢ Backup Extension ➢ Settings Extension ➢ Abstraction layer Rackspac e Microsof t Amazo n CouchDB Salesforc e
  • 53. Going forward Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 53 ➢ TroveApi ➢ Backup Extension ➢ Settings Extension ➢ Abstraction layer Rackspac e Microsof t Amazo n CouchDB Salesforc e
  • 54. Going forward Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 54
  • 55. Going forward Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 55 Collaborate! http://jclouds.apache.org/ http://jclouds.apache.org/community/
  • 56. Taming the Cloud Database with Apache jclouds http://j. mp/acjdb14 56 Thank you! http://developer.rackspace.com sdk-support@rackspace.com Zack Shoylev Software Developer zacksh #jclouds @zackshoylev