How to add CouchDB docker cartridge to Apache Stratos

As I start all of my Stratos related articles I would like to pitch some insight about this open source platform. Let's start off from it.

This cartridges is developed for use in Apache Stratos. Which is design and developed by WSO2 Inc. This is a PAAS environment lately donated to Apache foundation by WSO2. In order to develop a cartridge I need an up and running Stratos instance on top of Openstack. Openstack is an IAAS provider that I’m using, you can use Amazon EC2 as well.

In this article I will not do much coding stuff but some configuration stuff using terminal, Openstack and Stratos. Therefore I believe you have a basic idea about these environments. In my previous article we made the dockerfile and the related scripts for configuring Startos agent. Now it's time to deploy CouchDB cartridge to cloud.

First of all clone my github project of developed CouchDB docker cartridge.

$ git clone https://github.com/thushara35/startos-docker-couchdb-cartridge.git
Cut stratos-couchdb-config-files folder to some other directory, it is not a part of the dockerfile. Since we are going to use it later for configure CouchDB with Stratos keep it safe.

Now you should have a separate folder to keep your folder which contains cartridge dockerfile in your machine. Navigate to that directory, in my case i created a folder call couchdb-cartridge in /media/sf_docker_vm/ directory then copy all the stuff that was on my cloned startos-docker-couchdb-cartridge except stratos-couchdb-config-files folder.

stratos@Dev-PC:~$ cd /media/sf_docker_vm/couchdb-cartridge
stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$

If you copy all the stuff correctly you should see something like this.

stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$ ls
couchapps  Dockerfile  packs  scripts

Now we need to build the docker image. If your running this for 1st time this task will take sometime to complete. Don't miss the dot(.) at the end of the command, it's a part of it. 

stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$ docker build -t couchdb-cartridge .

Above bold couchdb-cartridge can name any way you prefer and it will be the docker image name that's going to create. After above process ends you can see newly build image using docker images command.

stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE couchdb-cartridge latest 47e77fff208b 6 days ago 861.8 MB docker-registry latest a158e64ae76a 6 weeks ago 596.2 MB 10.0.2.15:5042/docker-busybox latest 2eb418e07fd5 6 weeks ago 4.964 MB docker-busybox latest 2eb418e07fd5 6 weeks ago 4.964 MB ubuntu 12.04 822a01ae9a15 8 weeks ago 108.1 MB
47e77fff208b will be the image ID for newly created docker image.

Now we need to tag this docker image which simply means that create a copy of it for use of Openstack. 

stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$ docker tag couchdb-cartridge 192.168.57.30:5042/couchdb-cartridge

http://192.168.57.30:5042/ will be the IP of the "docker-registry server (openstack)" followed by it 192.168.57.30:5042/couchdb-cartridge will be the name of that tag. This will take seconds since it will only creates a reference of previously build couchdb-cartridge
stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE couchdb-cartridge latest 47e77fff208b 6 days ago 861.8 MB 192.168.57.30:5042/couchdb-cartridge latest 47e77fff208b 6 days ago 861.8 MB php-cartridge latest 809d2a1ebaf0 4 weeks ago 668.3 MB docker-registry latest a158e64ae76a 6 weeks ago 596.2 MB docker-busybox latest 2eb418e07fd5 6 weeks ago 4.964 MB 10.0.2.15:5042/docker-busybox latest 2eb418e07fd5 6 weeks ago 4.964 MB ubuntu 12.04 822a01ae9a15 8 weeks ago 108.1 MB
47e77fff208b will be the image ID for tagged docker image as well.

Now we need push the image docker image to Openstack glance(openrc). 
stratos@Dev-PC:/media/sf_docker_vm/couchdb-cartridge$ docker push 192.168.57.30:5042/couchdb-cartridge The push refers to a repository [192.168.57.30:5042/couchdb-cartridge] (len: 1) Sending image list Pushing repository 192.168.57.30:5042/couchdb-cartridge (1 tags) 511136ea3c5a: Image already pushed, skipping ...(omitted) 822a01ae9a15: Image already pushed, skipping 722149ca1d75: Image successfully pushed ...(omitted) 47e77fff208b: Image successfully pushed Pushing tags for rev [47e77fff208b] on {http://192.168.57.30:5042/v1/repositories/couchdb-cartridge/tags/latest}
*some text are omitted 

After you done with the docker push your done with the docker related configuration stuff. now if you login to Openstack you can find couchdb-cartridg in the image list.


Click on the couchdb-cartridge:latest and you can see ID of that image, Your going to need that ID later for cartridge configuration.
CouchDB image ID
Before moving on please downloaded sample configuration files here or else kindly navigate to the folder(stratos-couchdb-config-files) which I have asked keep earlier. 

We are done with the terminal stuff, now we should login to Stratos to continue with cartridge configuration. Just after you login to Stratos open Configure Stratos tab. Now you are 6 simple steps behind to subscribe to your first CouchDB cartridge. Below image will depict the steps.



Step 1 : 
Now you need to allocate a partition for CouchDB. You can use previously used partitions if you want or else just copy and paste the content of partition.json. Then click deploy.

Step 2 :
This is also same as above just paste the content of autho_scale_policies.json

Step 3 :
Just copy and paste the content of deployements_policies.json. Make sure you have included the correct partition details in the json file before it deployed. If your using the same partition.json that i used keep the deployements_policies.json as it is. 

Step 4 :
For this example Im not going to deploy any LB. But below I include a sample json script of a LB

{
  "type": "lb",
  "provider": "apache",
  "displayName": "Lb",
  "description": "Lb Cartridge",
  "version": "1.0",
  "host": "stratos.apache.org",
  "defaultAutoscalingPolicy": "economyPolicy",
  "defaultDeploymentPolicy": "depexp",
  "multiTenant": "false",
  "portMapping": [
    {
      "protocol": "http",
      "port": "22",
      "proxyPort": "8280"
    }
  ],
  "deployment": {},
  "iaasProvider": [
    {
      "type": "openstack",
      "imageId": "RegionOne/9865ed3f-724b-44e1-874f-f759aeceb9ef",
      "property": [
        {
          "name": "instanceType",
          "value": "RegionOne/2"
        }
      ]
    }
  ],
  "property": [
    {
      "name": "load.balancer",
      "value": "true"
    }
  ]
}

letters in blue colour should be replace by the LB image ID and Flavors(will describe more about this in step 5)

Now your 2 steps away from subscribing the cartridge.

Step 5 :
This step is the most important step because after this you can successfully subscribe to cartridge and will view in the cartridge list. Kindly open the cartridge _configuration.json located in the stratos-couchdb-config-files folder.

{
    "type":"couchdb",
    "provider":"data",
    "host":"dev.stratos.org",
    "displayName":"Couchdb",
    "description":"Couchdb Cartridge",
    "version":"1.6.1",
    "defaultAutoscalingPolicy":"economyPolicy",
    "defaultDeploymentPolicy": "couchdb-openstack",
    "multiTenant":"false",
    "portMapping":[
         {
            "protocol":"http",
            "port":"80",
            "proxyPort":"8280"
         }
    ],
    "deployment": {},
    "iaasProvider":[
         {
            "type":"openstack",
            "imageId":"RegionOne/ef5a3a0e-1911-41aa-b3d2-0acc78efe8b6",
            "maxInstanceLimit":"4",
            "property":[
          {
            "name": "instanceType",
            "value": "RegionOne/2"
        },
       {
                "name": "keyPair",
                "value": "demo"
       },
{
            "name": "securityGroups",
            "value": "open-all"
            }
            ]
         }
    ],
    "property":[
        {
            "name":"payload_parameter.MB_IP",
            "value":"192.168.57.30"
        },
        {
            "name":"payload_parameter.MB_PORT",
            "value":"61616"
        },
        {
            "name":"payload_parameter.CEP_IP",
            "value":"192.168.57.30"
        },
        {
            "name":"payload_parameter.CEP_PORT",
            "value":"7613"
        }
    ]
}

Before deploy you need to change or consider about some values inputting in this json. first one is the display name this is a user defined property and it will be the display name of your CouchDB cartridge. 
Second one is the defaultAutoscalingPolicy and defaultDeploymentPolicy should be the same id value that you input in the autho_scale_policies.json and deployements_policies.json respectively. If your using the same files that I'm using leave it as it is.

3rd one is the image ID of the openstack image, we have already went through it above. Please scroll up and find CouchDB image ID caption. For me that value should be 1ba11b91-970a-49ec-948c-c8ebe824ca53. For you it must be a different ID and replace that value in above json script. 

4th is the maxInstanceLimit which I have set to 1. This is also up to you. I personally prefer maximum of 4 instances for demonstration purposes. 

5th is about Flavors! sounds yummy!
User can chose how many CPU's and RAM wanted to his cartridge. According to that can chose a Flavors. As per authors research he prefer m1.small for CouchDB cartridge which is number 2.

6th is to set MB_IP and CEP_IP, this should be the localhost IP which is Openstack IP in this case it is 192.168.57.30

Step 6 :
We are going to skip this section.

Now you can find CouchDB cartridge in the Subscribe to cartridge section.

Simply click on it and open it. Then you will get a simple form like below.
Just input a public URL you prefer and others will be automatically get selected according to the values you gave in step 5.
Now you all have to do is just click on the Subscribe to Cartridge button and in minutes you will be subscribe to CouchDB cartridge. 
Let's see how will be the Stratos log present it.

TID: [0] [STRATOS] [2014-09-30 19:37:15,271] INFO {org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils} - Generated key : gQMYm3RzH131LLIU {org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils} TID: [0] [STRATOS] [2014-09-30 19:37:15,277] INFO {org.apache.stratos.manager.manager.CartridgeSubscriptionManager} - Tenant [-1234] with username [admin subscribed to ] Cartridge with Alias mycouchdb, Cartridge Type: couchdb, Repo URL: , Autoscale Policy: economyPolicy, Deployment Policy: couchdb-openstack {org.apache.stratos.manager.manager.CartridgeSubscriptionManager} TID: [0] [STRATOS] [2014-09-30 19:37:15,278] INFO {org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour} - Payload: SERVICE_NAME=couchdb,HOST_NAME=mycouchdb.dev.stratos.org,MULTITENANT=false,TENANT_ID=-1234,TENANT_RANGE=-1234,CARTRIDGE_ALIAS=mycouchdb,CLUSTER_ID=mycouchdb.couchdb.domain,CARTRIDGE_KEY=gQMYm3RzH131LLIU,DEPLOYMENT=default,REPO_URL=null,PORTS=80,PUPPET_IP=192.168.57.30,PUPPET_HOSTNAME=puppet.dev.stratos.org,PUPPET_ENV=puppet_environment,MB_IP=192.168.57.30,MB_PORT=61616,CEP_PORT=7613,CEP_IP=192.168.57.30,MYSQL_PASSWORD=mmucrtxb,DB_USER=root,DB_HOST=localhost,COMMIT_ENABLED=false {org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour} TID: [0] [STRATOS] [2014-09-30 19:37:15,278] INFO {org.apache.stratos.manager.utils.ApplicationManagementUtil} - Register service.. {org.apache.stratos.manager.utils.ApplicationManagementUtil} TID: [0] [STRATOS] [2014-09-30 19:37:15,318] INFO {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} - Publishing cluster created event: Cluster [serviceName=couchdb, clusterId=mycouchdb.couchdb.domain, autoscalePolicyName=economyPolicy, deploymentPolicyName=couchdb-openstack, hostNames=[mycouchdb.dev.stratos.org], tenantRange=null, isLbCluster=false, properties={}] {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} TID: [0] [STRATOS] [2014-09-30 19:37:15,329] INFO {org.apache.stratos.messaging.message.processor.topology.ClusterCreatedMessageProcessor} - Cluster created: Cluster [serviceName=couchdb, clusterId=mycouchdb.couchdb.domain, autoscalePolicyName=economyPolicy, deploymentPolicyName=couchdb-openstack, hostNames=[mycouchdb.dev.stratos.org], tenantRange=null, isLbCluster=false, properties={}] {org.apache.stratos.messaging.message.processor.topology.ClusterCreatedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:37:15,332] INFO {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} - [ClusterCreatedEventListener] Received: class org.apache.stratos.messaging.event.topology.ClusterCreatedEvent {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} TID: [0] [STRATOS] [2014-09-30 19:37:15,336] WARN {org.apache.stratos.messaging.message.processor.topology.ClusterCreatedMessageProcessor} - Cluster already exists in service: [service] couchdb [cluster] mycouchdb.couchdb.domain {org.apache.stratos.messaging.message.processor.topology.ClusterCreatedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:37:15,338] INFO {org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver} - Event received: ClusterCreatedEvent [serviceName=couchdb, cluster=Cluster [serviceName=couchdb, clusterId=mycouchdb.couchdb.domain, autoscalePolicyName=economyPolicy, deploymentPolicyName=couchdb-openstack, hostNames=[mycouchdb.dev.stratos.org], tenantRange=null, isLbCluster=false, properties={}]] {org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver} TID: [0] [STRATOS] [2014-09-30 19:37:15,361] INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} - Successfully registered: Registrant [clusterId=mycouchdb.couchdb.domain, tenantRange=-1234, hostName=mycouchdb.dev.stratos.org, cartridgeType=couchdb, properties=Properties [properties=null], autoScalerPolicyName=economyPolicy, deploymentPolicyName=couchdb-openstack] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} TID: [0] [STRATOS] [2014-09-30 19:37:15,475] INFO {org.apache.stratos.manager.manager.CartridgeSubscriptionManager} - Successful Subscription: CartridgeSubscription [subscriptionId=0, type=couchdb, alias=mycouchdb, autoscalingPolicyName=economyPolicy, deploymentPolicyName=couchdb-openstack, subscriber=Subscriber [adminUserName=admin, tenantId=-1234, tenantDomain=carbon.super], repository=null, cartridgeInfo=org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo@18ef5044, payload=SERVICE_NAME=couchdb,HOST_NAME=mycouchdb.dev.stratos.org,MULTITENANT=false,TENANT_ID=-1234,TENANT_RANGE=-1234,CARTRIDGE_ALIAS=mycouchdb,CLUSTER_ID=mycouchdb.couchdb.domain,CARTRIDGE_KEY=gQMYm3RzH131LLIU,DEPLOYMENT=default,REPO_URL=null,PORTS=80,PUPPET_IP=192.168.57.30,PUPPET_HOSTNAME=puppet.dev.stratos.org,PUPPET_ENV=puppet_environment,MB_IP=192.168.57.30,MB_PORT=61616,CEP_PORT=7613,CEP_IP=192.168.57.30,MYSQL_PASSWORD=mmucrtxb,DB_USER=root,DB_HOST=localhost,COMMIT_ENABLED=false, cluster=mycouchdb.couchdb.domain] {org.apache.stratos.manager.manager.CartridgeSubscriptionManager} TID: [0] [STRATOS] [2014-09-30 19:37:15,478] INFO {org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils} - Publishing tenant subscribed event: [tenant-id] -1234 [service] couchdb {org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils} TID: [0] [STRATOS] [2014-09-30 19:37:20,350] INFO {org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient} - Validating partitions of policy via cloud controller: [id] couchdb-openstack {org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient} TID: [0] [STRATOS] [2014-09-30 19:37:22,219] INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} - All partitions [P1] were validated successfully, against the Cartridge: couchdb {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} TID: [0] [STRATOS] [2014-09-30 19:37:23,357] INFO {org.apache.stratos.autoscaler.util.AutoscalerUtil} - Partition context has been added: [partition] P1 {org.apache.stratos.autoscaler.util.AutoscalerUtil} TID: [0] [STRATOS] [2014-09-30 19:37:23,357] INFO {org.apache.stratos.autoscaler.util.AutoscalerUtil} - Network partition context has been added: [network partition] openstack {org.apache.stratos.autoscaler.util.AutoscalerUtil} TID: [0] [STRATOS] [2014-09-30 19:37:23,358] INFO {org.apache.stratos.autoscaler.util.AutoscalerUtil} - Cluster monitor created: ClusterMonitor [clusterId=mycouchdb.couchdb.domain, serviceId=couchdb, deploymentPolicy=Deployment Policy [id]couchdb-openstack [partitions] [org.apache.stratos.cloud.controller.stub.deployment.partition.Partition@3a3ccc72], autoscalePolicy=ASPolicy [id=economyPolicy, displayName=null, description=null], lbReferenceType=null] {org.apache.stratos.autoscaler.util.AutoscalerUtil} TID: [0] [STRATOS] [2014-09-30 19:37:23,358] INFO {org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver} - Cluster monitor has been added successfully: [cluster] mycouchdb.couchdb.domain {org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver} TID: [0] [STRATOS] [2014-09-30 19:38:23,384] INFO {org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient} - Trying to spawn an instance via cloud controller: [cluster] mycouchdb.couchdb.domain [partition] P1 [lb-cluster] null [network-partition-id] openstack {org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient} TID: [0] [STRATOS] [2014-09-30 19:38:44,398] INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} - Instance is successfully starting up. MemberContext [memberId=mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323, nodeId=RegionOne/c5135972-f300-4e20-a603-f0257f7a3804, clusterId=mycouchdb.couchdb.domain, cartridgeType=couchdb, privateIpAddress=null, publicIpAddress=null, allocatedIpAddress=null, initTime=1412086103385, lbClusterId=null, networkPartitionId=openstack] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} TID: [0] [STRATOS] [2014-09-30 19:38:44,911] INFO {org.apache.stratos.cloud.controller.iaases.OpenstackNovaIaas} - Successfully associated an IP address 192.168.92.1 for node with id: RegionOne/c5135972-f300-4e20-a603-f0257f7a3804 {org.apache.stratos.cloud.controller.iaases.OpenstackNovaIaas} TID: [0] [STRATOS] [2014-09-30 19:38:44,911] INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} - Allocated an ip address: MemberContext [memberId=mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323, nodeId=RegionOne/c5135972-f300-4e20-a603-f0257f7a3804, clusterId=mycouchdb.couchdb.domain, cartridgeType=couchdb, privateIpAddress=null, publicIpAddress=null, allocatedIpAddress=192.168.92.1, initTime=1412086103385, lbClusterId=null, networkPartitionId=openstack] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} TID: [0] [STRATOS] [2014-09-30 19:38:44,911] INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} - Retrieving Public IP Address : MemberContext [memberId=mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323, nodeId=RegionOne/c5135972-f300-4e20-a603-f0257f7a3804, clusterId=mycouchdb.couchdb.domain, cartridgeType=couchdb, privateIpAddress=null, publicIpAddress=192.168.92.1, allocatedIpAddress=192.168.92.1, initTime=1412086103385, lbClusterId=null, networkPartitionId=openstack] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} TID: [0] [STRATOS] [2014-09-30 19:38:44,911] INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} - Retrieving Private IP Address. MemberContext [memberId=mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323, nodeId=RegionOne/c5135972-f300-4e20-a603-f0257f7a3804, clusterId=mycouchdb.couchdb.domain, cartridgeType=couchdb, privateIpAddress=10.11.12.2, publicIpAddress=192.168.92.1, allocatedIpAddress=192.168.92.1, initTime=1412086103385, lbClusterId=null, networkPartitionId=openstack] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} TID: [0] [STRATOS] [2014-09-30 19:38:44,972] INFO {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} - Publishing instance spawned event: [service] couchdb [cluster] mycouchdb.couchdb.domain [network-partition] openstack [partition] P1 [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 [lb-cluster-id] null {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} TID: [0] [STRATOS] [2014-09-30 19:38:44,985] INFO {org.apache.stratos.messaging.message.processor.topology.InstanceSpawnedMessageProcessor} - Member created: [service] couchdb [cluster] mycouchdb.couchdb.domain [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.messaging.message.processor.topology.InstanceSpawnedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:38:44,990] INFO {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} - [InstanceSpawnedEventListener] Received: class org.apache.stratos.messaging.event.topology.InstanceSpawnedEvent {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} TID: [0] [STRATOS] [2014-09-30 19:38:44,991] WARN {org.apache.stratos.messaging.message.processor.topology.InstanceSpawnedMessageProcessor} - Member already exists: [service] couchdb [cluster] mycouchdb.couchdb.domain [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.messaging.message.processor.topology.InstanceSpawnedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:38:58,320] INFO {org.apache.stratos.manager.listener.InstanceStatusListener} - Instance status message received {org.apache.stratos.manager.listener.InstanceStatusListener} TID: [0] [STRATOS] [2014-09-30 19:38:58,324] INFO {org.apache.stratos.manager.listener.InstanceStatusListener} - Event class name: org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent {org.apache.stratos.manager.listener.InstanceStatusListener} TID: [0] [STRATOS] [2014-09-30 19:38:58,328] INFO {org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageDelegator} - Instance status event message received from queue: org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent {org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageDelegator} TID: [0] [STRATOS] [2014-09-30 19:38:58,330] INFO {org.apache.stratos.manager.listener.InstanceStatusListener} - Cluster id: mycouchdb.couchdb.domain {org.apache.stratos.manager.listener.InstanceStatusListener} TID: [0] [STRATOS] [2014-09-30 19:38:58,330] INFO {org.apache.stratos.cloud.controller.topology.TopologyBuilder} - member started event adding status started {org.apache.stratos.cloud.controller.topology.TopologyBuilder} TID: [0] [STRATOS] [2014-09-30 19:38:58,368] INFO {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} - Publishing member started event: [service] couchdb [cluster] mycouchdb.couchdb.domain [network-partition] openstack [partition] P1 [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} TID: [0] [STRATOS] [2014-09-30 19:38:58,373] INFO {org.apache.stratos.messaging.message.processor.topology.MemberStartedMessageProcessor} - Member started: [service] couchdb [cluster] mycouchdb.couchdb.domain [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.messaging.message.processor.topology.MemberStartedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:38:58,375] INFO {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} - [MemberStartedEventListener] Received: class org.apache.stratos.messaging.event.topology.MemberStartedEvent {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} TID: [0] [STRATOS] [2014-09-30 19:38:58,376] WARN {org.apache.stratos.messaging.message.processor.topology.MemberStartedMessageProcessor} - Member already started: [service] couchdb [cluster] mycouchdb.couchdb.domain [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.messaging.message.processor.topology.MemberStartedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:39:03,634] INFO {org.apache.stratos.manager.listener.InstanceStatusListener} - Instance status message received {org.apache.stratos.manager.listener.InstanceStatusListener} TID: [0] [STRATOS] [2014-09-30 19:39:03,634] INFO {org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageDelegator} - Instance status event message received from queue: org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent {org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageDelegator} TID: [0] [STRATOS] [2014-09-30 19:39:03,634] INFO {org.apache.stratos.manager.listener.InstanceStatusListener} - Event class name: org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent {org.apache.stratos.manager.listener.InstanceStatusListener} TID: [0] [STRATOS] [2014-09-30 19:39:03,636] INFO {org.apache.stratos.cloud.controller.topology.TopologyBuilder} - member started event adding status activated {org.apache.stratos.cloud.controller.topology.TopologyBuilder} TID: [0] [STRATOS] [2014-09-30 19:39:03,666] INFO {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} - Publishing member activated event: [service] couchdb [cluster] mycouchdb.couchdb.domain [network-partition] openstack [partition] P1 [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} TID: [0] [STRATOS] [2014-09-30 19:39:03,671] INFO {org.apache.stratos.messaging.message.processor.topology.MemberActivatedMessageProcessor} - Member activated: [service] couchdb [cluster] mycouchdb.couchdb.domain [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.messaging.message.processor.topology.MemberActivatedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:39:03,675] INFO {org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver} - Member stat context has been added successfully: [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver} TID: [0] [STRATOS] [2014-09-30 19:39:03,676] WARN {org.apache.stratos.messaging.message.processor.topology.MemberActivatedMessageProcessor} - Member already activated: [service] couchdb [cluster] mycouchdb.couchdb.domain [member] mycouchdb.couchdb.domaind44b99ce-7621-40d1-a098-40a0f8389323 {org.apache.stratos.messaging.message.processor.topology.MemberActivatedMessageProcessor} TID: [0] [STRATOS] [2014-09-30 19:39:03,678] INFO {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver} - [MemberActivatedEventListener] Received: class org.apache.stratos.messaging.event.topology.MemberActivatedEvent {org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver}
*this is the full log that generated in the /stratos/apache-stratos-default/repository/logs/wso2carbon.log. Lines that are coloured using      is logs that generated while configuring the stratos cartridge.      coloured line is the place that stratos tries to spawn an instance. If Stratos successfully spawn an instance then it throw a message saying Member created and now you can access the secure shell using ssh to your CouchDB docker container. 

stratos@Dev-PC:~$ ssh root@10.11.12.2
The authenticity of host '10.11.12.2 (10.11.12.2)' can't be established.
ECDSA key fingerprint is 74:95:b3:5f:22:5a:dc:70:8c:ab:50:c8:45:65:77:9d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.11.12.2' (ECDSA) to the list of known hosts.

root@10.11.12.2's password: <password gave in line 24 at Dockerfile>

Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.11.0-26-generic x86_64)
the exact distribution terms for each program are described in the
* Documentation: https://help.ubuntu.com
the exact distribution terms for each program are described in the
The programs included with the Ubuntu system are free software;
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law. 
root@instance-00000001:~#

Within few seconds your log will update saying Member started,this is a good sign because your one step closer to generate a fully activated member instance. 
If everything goes fine Stratos log will be updated by Member activated message means that member is successfully activated and your good to go. 

Troubleshot 

This section is reserved for those who can't reach the Member activated state.

There were 5 milestones in above sections those are :
  1. Cartridge configuration
  2. Trying to spawn an instance
  3. Member created
  4. Member started
  5. Member activated
If you didn't pass the 1st milestone and the issue is somewhere in your json configuration files please double check all of them and make sure you get above log. 

If you get a big exception just after the 2nd milestone there can be several reason for cause that. please check below stuff throughly 


  • Please check whether you have added the MB_IP and CEP_IP stuff correctly in the cartridge configuration json.
  • Then check apache-stratos-cartridge-agent-4.0.0.tgz(/couchdb-cartridge/packs) is correctly mounted and try extracting it and check whether it's tally with /apache-stratos-cartridge-agent-4.0.0/bin/stratos.sh and couchdb-cartridge/scripts/init.sh(we discussed about this in my previous post, please go through it)

If you successfully created the member(3rd milestone) now you can log in to docker container using secure shell(ssh- which we have discussed earlier). Then check for these files and make sure sure they all executed correctly.
  • /tmp/payload/launch-params
  • /mnt/apache-stratos-cartridge-agent-4.0.0/payload/launch-params
  • /mnt/apache-stratos-cartridge-agent-4.0.0/bin/stratos.sh
  • /tmp/run-script.log
  • /tmp/init.log
  • /tmp/init-script.log
  • /tmp/agent.log
  • /var/log/metadata_svc_bugfix.log

Each and every above file should be generated properly. Please double check if you got an error or stuck in this section.

If you successfully reached the 4th milestone your done with the hard stuff if you stuck from here that means there should be a issue in your memory allocation(Flavors). 

  • Higher the Flavors value by 1 and try again. 
  • Check Openstack dashboard if your fully utilising the allocated memory you can't create anymore instances.


Happy day scenario 

If you reach the 5th milestone which is the happy day scenario you can check below stuff and move forward with the CouchDB development.

Check for active instances and make sure it is 1.


Login to Openstack and check for active instances and make sure Status is Active.

If these things are working fine type the private URL which generated by Openstack for Stratos CouchDB instance. Here it should be http://10.11.12.2. If you enter this value in a browser you should get something like this.

Then enter http://10.11.12.2:5984 and you'll direct to this page(5984 is the default port that we exposed in the docker file for use of CouchDB).

Now you can view dashboard(Futon) for CouchDB by simply going to http://10.11.12.2:5984/_utils/index.html URL. Will show you something like this(You will not see this much databases in the first run). 

Last You need to check whether CouchDB is working properly. To check that navigate to this http://10.11.12.2:5984/_utils/verify_install.html. Then click on verify your installation icon. If everything went fine you will get something like this.
If you get this message your CouchDB is working fine and it's Time to Relax!
Note : Please left any questions in the comment section or just ask it in stackoverflow and paste  the link in the comment section. 

In the next article author will explain how to deploy you first couchApp.

Thank you and have a nice day!

Comments