Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

25
Apache Stratos (Incubating) Hangout IV Stratos Controller and CLI Internals 13 August 2013 M. Isuru Tharanga Chrishantha Perera. Committer & PPMC Member of Apache Stratos (Incubating), Senior Software Engineer at WSO2, Inc.

description

Slides used for Apache Stratos (incubating) Fourth Hangout. Hangout video can be found at http://youtu.be/VtF9DVGKbTQ Website: http://stratos.incubator.apache.org Mailing List: Subscribe: [email protected] Post (after subscription): [email protected] Social Media: Google+: https://plus.google.com/103515557134069849802 Twitter: https://twitter.com/ApacheStratos Facebook: https://www.facebook.com/apache.stratos LinkedIn: http://www.linkedin.com/groups?home=&gid=5131436

Transcript of Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Page 1: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Apache Stratos(Incubating)Hangout IVStratos Controller and CLI Internals13 August 2013

M. Isuru Tharanga Chrishantha Perera.Committer & PPMC Member of Apache Stratos (Incubating),

Senior Software Engineer at WSO2, Inc.

Page 2: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Agenda● What is Stratos Controller?● How does Stratos Controller communicate

with Cloud Controller?● Auto-scaling policies configuration● How does the Artifact Distribution

Coordinator work?● How CLI works?

2

Page 3: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

High Level Architecture

3

Page 4: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Stratos Controller Workflow

4

Page 5: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

So, What is Stratos Controller (SC)?● Basically, it’s Carbon + Set of Features

5

Page 6: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

What is SC? (Cont.)● Mainly consists of User Interface

○ Tenant Management○ Cartridge Subscription

● Artifact Distribution Coordinator○ Responsible for distribution of artifacts

● Configuring Auto-Scaling Policies○ Configuring policies.xml in

<SC_HOME>/repository/conf

6

Page 7: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

SC Components├── components

│ ├── org.apache.stratos.adc.mgt│ ├── org.apache.stratos.cartridge.mgt.ui│ ├── ...│ └── org.apache.stratos.tenant.mgt.ui

├── features

│ ├── adc

│ ├── ...│ └── manager

├── products

│ └── stratos-controller

└── service-stubs

├── org.apache.stratos.adc.mgt.stub └── org.apache.stratos.lb.cartridge.autoscaler.service.stub

7

Page 8: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

SC Features● Register a Tenant.● View list of available Cartridges.● View list of subscribed Cartridges.● Subscribe to a Cartridge.● Unsubscribe from a Cartridge.● Connect to a data Cartridge while

subscribing to a Cartridge.● View subscribed Cartridge detailed

information.8

Page 9: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

SC Features (Cont.)● Add domain mapping.● Remove domain mapping.● Synchronize repository.● Monitor logs of Cartridge instances.

9

Page 10: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Application Management Service methodsArtifact Id: org.apache.stratos.adc.mgtClass: org.apache.stratos.adc.mgt.service.ApplicationManagementService

/** * Get Available Cartridges * * @return Available Cartridges */public Cartridge[] getAvailableCartridges(boolean multiTenant)

throws ADCException;

/** * Get Subscribed Cartridges * * @return Subscribed Cartridges */public Cartridge[] getSubscribedCartridges() throws ADCException;

public Cartridge getCartridgeInfo(String alias)throws ADCException, NotSubscribedException;

public PolicyDefinition[] getPolicyDefinitions();

public void synchronizeRepository(String cartridgeAlias)throws ADCException, NotSubscribedException;

10

Page 11: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Application Management Service methods (Cont.)

/** * Subscribe to a cartridge */public SubscriptionInfo subscribe(String cartridgeType,

String alias, String policy, String repoURL, boolean privateRepo,String repoUsername, String repoPassword, String dataCartridgeType,String dataCartridgeAlias) throws ADCException, PolicyException,UnregisteredCartridgeException, InvalidCartridgeAliasException,DuplicateCartridgeAliasException, RepositoryRequiredException,AlreadySubscribedException, RepositoryCredentialsRequiredException,InvalidRepositoryException, RepositoryTransportException;

/** * Unsubscribing the cartridge * * @param alias name of the cartridge to be unsubscribed */public void unsubscribe(String alias) throws ADCException,

NotSubscribedException;

public String addDomainMapping(String mappedDomain,String cartridgeAlias) throws ADCException,DomainMappingExistsException, NotSubscribedException;

public void removeDomainMapping(String cartridgeAlias)throws ADCException, NotSubscribedException;

11

Page 12: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

SC Cartridge Subscription

12

Page 13: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

What happens when you subscribe?

13

Page 14: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Current Database Schema

14

Page 15: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Auto-scaling policies● Defined in <SC_HOME>/repository/conf/policies.xml<policies>

<policy name="single" isDefault="true"><description>Single - Instances: Min 1, Max 1</description><min_app_instances>1</min_app_instances><max_app_instances>1</max_app_instances><max_requests_per_second>5</max_requests_per_second><alarming_upper_rate>0.7</alarming_upper_rate><alarming_lower_rate>0.2</alarming_lower_rate><scale_down_factor>0.25</scale_down_factor><rounds_to_average>2</rounds_to_average>

</policy><policy name="elastic" isDefault="false">

<description>Elastic - Instances: Min 1, Max 4</description><min_app_instances>1</min_app_instances><max_app_instances>4</max_app_instances><max_requests_per_second>5</max_requests_per_second><alarming_upper_rate>0.7</alarming_upper_rate><alarming_lower_rate>0.2</alarming_lower_rate><scale_down_factor>0.25</scale_down_factor><rounds_to_average>2</rounds_to_average>

</policy></policies>

15

Page 16: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Artifact Distribution Coordinator● Responsible for distribution of artifacts● Uses Git as the Code Repository

16

Page 17: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

How ADC works

17

Page 18: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

How does Git Repo notify the ADC?● Add a service hook to the Git Repository● For example: GitHub

18

Page 19: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Interactive CLI Tool● Used by tenants to manage subscriptions.● Same functions as the UI, except:

○ Tenant registering○ Monitoring logs of Cartridge instances.

19

Page 20: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

CLI Modes● Interactive mode$export STRATOS_URL= https://demo.stratos.incubator.apache.org:9445

$./stratos.sh -u <username> -p <password>

stratos>

● Single command line mode○ User can execute commands in one line.○ It will not show the stratos> prompt○ The user can export the username and password to

the environment and execute commands.$export STRATOS_USERNAME=<username>

$export STRATOS_PASSWORD=<password>

$ stratos.sh -u [username] -p [password] [action commands]

20

Page 21: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

CLI Tool Technology● Supports following features via jline 2

○ Command history○ Auto-completion of commands○ Character masking (for passwords)

● Apache Commons CLI● Connects to SC● Artifact Id: org.apache.stratos.cli

21

Page 22: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

CLI Design

22

Page 23: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

CLI Commands

23

Page 24: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Questions?

24

Page 25: Apache Stratos (incubating) Hangout IV - Stratos Controller and CLI Internals

Join us!Website: http://stratos.incubator.apache.org

Mailing List:Subscribe: [email protected] (after subscription): [email protected]

Social Media:Google+: https://plus.google.com/103515557134069849802Twitter: https://twitter.com/ApacheStratosFacebook: https://www.facebook.com/apache.stratosLinkedIn: http://www.linkedin.com/groups?home=&gid=5131436

25