
Subscribe-Publish Frame Work:
1.Command to Install Flask Webserver frame work.
  sudo pip install Flask

  Along with flask we need the following packages:
   msgpack
   fnmatch
   operator
   logging
   oslo_utils
   ConfigParser
 
2.Files: i.sub_main.py
         ii.pubrecords.py
         iii.pub_sub.conf

3.Command to start the server:
    #python sun_main.py
4.Command for subscription:
      i.app_id:Application ID,should be unique.
      ii.target:
           Presently only udp is supported.
           a.udp:<ip:portno>
           b.kafka:<kafkaip:kafkaport>
      iii.sub_info:Sunscription notifications.ex:cpu_util,cpu_*
           It can be given as single input or list.
      iv.query:
         Below information need to provide as part of query.
         a.field:fileds like user id ,porject id etc.,
         b.op:"eq","gt","lt" etc.,
         c.value:value of the fileds.
     Example:
  		 curl -i -H "Content-Type: application/json" -X POST -d '{"app_id":"10","target":"udp://10.11.10.1:5006","sub_info":"cpu_util","query":[{"field":"user_id","op":"eq","value":"e1271a86bd4e413c87248baf2e5f01e0"},{"field":"project_id","op":"eq","value":"b1a3bf16d2014b47be9aefea88087318"},{"field":"resource_id","op":"eq","value":"658cd03f-d0f0-4f55-9f48-39e7222a8646"}]}' -L http://10.11.10.1:4455/subscribe
           curl -i -H "Content-Type: application/json" -X POST -d '{"app_id":"10","target":"udp://10.11.10.1:5006", "sub_info":["cpu_util", "memory"],"query":[{"field":"user_id","op":"eq","value":"e1271a86bd4e413c87248baf2e5f01e0"},{"field":"project_id","op":"eq","value":"b1a3bf16d2014b47be9aefea88087318"},{"field":"resource_id","op":"eq","value":"658cd03f-d0f0-4f55-9f48-39e7222a8646"}]}' -L http://10.11.10.1:4455/subscribe

5.Command for unsunscription:
    For unsubcription only appid will be needed.
    curl -i -H "Content-Type: application/json" -X POST -d '{"app_id":"10"}' http://10.11.10.1:4455/unsubscribe

6.Running Kafka on the server server where pub-sub module is running:
  i.Download the kafka from:
     #https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz
     http://apache.arvixe.com/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz
  ii.install java
     sudo apt-get update
     sudo apt-get install default-jre
  iii. install kafka package
     sudo easy_install pip
     sudo pip install kafka-python
  iv.tar -xzf kafka_2.11-0.9.0.0.tgz
  v. Start the zookeeper server:
      bin/zookeeper-server-start.sh config/zookeeper.properties
  vi.Start Kafka Server :
      bin/kafka-server-start.sh config/server.properties
  vii.To read messages from kafka on a topic test :
     bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
  viii.Before configuring kafka:// publisher in ceilometer:
     install kafka on both controller node and compute nodes
     Restart the ceilometer-agent-notification, ceilometer-agent-compute, ceilometer-agent-central daemons

7.[Optional]Install Kafka-web-console (GUI)
  i.wget https://github.com/adamfokken/kafka-web-console/archive/topic-add-remove.zip
  ii.unzip it
  iii.wget http://downloads.typesafe.com/typesafe-activator/1.3.2/typesafe-activator-1.3.2-minimal.zip
  iv.unzip it and add it to the system path so you can execute the activator command that it provides.
  v.Install javac if required: sudo apt-get install openjdk-7-jdk
  vi.cd kafka-web-console-topic-add-remove
  vii.activator start -DapplyEvolutions.default=true
  viii.Point your browser to the kafka we-console port (9000) and register the zookeeper
