ONOS-1871: Send Topology MastershipEvent info to Topology listeners.

The MastershipEvent info is needed by applications such as the GUI
(via the Websocket client).

NOTE: Previously, the Mastership Events were sent only when there
was any change, but no Mastership Events were sent when a listener
has just subscribed.

The solution is to add a mechanism for creating and sending Topology
Snapshot event to new listeners, and that event also includes
the Mastership Events.

The modifications are:

 * Renamed and updated the ITopologyService API for adding/removing
   Topology listeners:
   OLD: registerTopologyListener() and deregisterTopologyListener()
   NEW: addListener() and removeListener()

   Also, addListener() has a second argument:
       "boolean startFromSnapshot"
   If that argument is true, and if the topology is not empty, the first
   (expected) event to that listener should be a snapshot of the current
   topology.

 * Added TopologyEvents() constructor for ADDED events only. Such event
   can be used to represent a snapshot of the topology.

 * Added new APIs to TopologyInternal:
   getAllSwitchEvents(), getAllPortEvents(), get AllLinkEvents(),
   getAllHostEvents()
   Those APIs are needed for creating a snapshot of the topology.

 * Added a mechanism for creating empty (NO-OP) TopologyEvent instance,
   and use that mechanism to "wake-up" the EventHandler processing thread
   when it needs to send Topology Snapshot to a new listener.
   This solution is (kind-of) a hack.

Change-Id: Ie1eb52242f58682aac61f54af29c3b5d291ac0bd
15 files changed
tree: 034f3c2be25534aa36af135a77fb1210554c9fa3
  1. .checkstyle
  2. .gitignore
  3. .gitreview
  4. Authors
  5. CollaboratorAgreement.txt
  6. LICENSE.txt
  7. NOTICE.txt
  8. PARTNERS.txt
  9. README.md
  10. build-ramcloud-java-bindings.sh
  11. cluster-mgmt/
  12. conf/
  13. gui/
  14. install-oracle-java.sh
  15. lib/
  16. old-scripts/
  17. onos.sh
  18. onoscli
  19. pom.xml
  20. prep-for-offline.sh
  21. ramcloud-build-scripts/
  22. sample/
  23. scripts/
  24. setup-ramcloud.sh
  25. src/
  26. start-ons2014demo.sh
  27. start-rest.sh
  28. vm-utils/
  29. web/
README.md

ONOS

ONOS (Open Networking Operating System) is an experimental distributed SDN OS. Currently, it is under active development. ONOS was announced and demonstrated at ONS'13, '14.

Getting Started with ONOS

Following URL has the instructions how to get started with ONOS, starting from downloading the development VM:

https://wiki.onlab.us/display/onosdocs/Getting+Started+with+ONOS

Building ONOS

  1. Cleanly build ONOS

     $ cd ${ONOS_HOME}/
     $ mvn clean compile
    

External Dependencies

  1. Required packages

     $ sudo apt-get install maven python-flask python-cmd2 python-pyparsing
    
  2. ZooKeeper

    Download and install apache-zookeeper-3.4.6: http://zookeeper.apache.org/releases.html

    By default ONOS expect ZooKeeper to be installed in ~/zookeeper-3.4.6.
    This can be changed by specifing the path using ZK_HOME environment variable.

    Data directory ZooKeeper uses by default is /var/lib/zookeeper. You will need to give current user permission to write to this directory.

    This directory can be changed using specifying ZK_LIB_DIR environment variable and running ./onos.sh setup to generate ${ONOS_HOME}/conf/zoo.cfg.

    See Configuration for details about ./onos.sh setup.

  3. RAMCloud

    Run setup-ramcloud.sh to download and install RAMCloud to ~/ramcloud.
    Installation path can be changed by specifing RAMCLOUD_HOME environment variable.

     $ cd ${ONOS_HOME}/
     $ ./setup-ramcloud.sh
    

Configuration

./onos.sh setup script is used to generate ONOS related configuration files. This script read configuration from "${ONOS_CONF_DIR}/onos_node.`hostname`.conf".

Copy the file "${ONOS_HOME}/conf/onos_node.conf" to match the hostname and configure the content appropriately.
e.g., To use RAMCloud as data store change host.backend to ramcloud

Once you're done with required configuration run following to generate configuration files.

    $ cd ${ONOS_HOME}/
    $ ./onos.sh setup

Running ONOS and required components

To start ZooKeeper, RAMCloud (if enabled in configuration) and ONOS core.

    $ cd ${ONOS_HOME}/
    $ ./onos.sh start single-node

To stop all the above

    $ cd ${ONOS_HOME}/
    $ ./onos.sh stop

If you need to use the REST APIs, follow the instruction for "Start ONOS REST API server" in next section.

Running ONOS components one by one

You can manually start/stop individual ONOS components as follows:

  1. Start Zookeeper

     $ cd ${ONOS_HOME}/
     $ ./onos.sh zk start
    
     ## Confirm Zookeeper is running:
     $ ./onos.sh zk status
    
  2. Start RAMCloud Coordinator (only on one of the node in cluster)

     $ cd ${ONOS_HOME}/
     $ ./onos.sh rc-coord start
    
     ## Confirm RAMCloud Coordinator is running:
     $ ./onos.sh rc-coord status
    
  3. Start RAMCloud Server

     $ cd ${ONOS_HOME}/
     $ ./onos.sh rc-server start
    
     ## Confirm RAMCloud Server is running:
     $ ./onos.sh rc-server status
    
  4. Start ONOS

     $ cd ${ONOS_HOME}/
     $ ./onos.sh core start
    
     ## Confirm ONOS is running:
     $ ./onos.sh core status
    
  5. Start ONOS REST API server

     $ cd ${ONOS_HOME}/
     $ ./start-rest.sh start
    
     ## Confirm the REST API server is running:
     $ ./start-rest.sh status
    

Running unit tests

Unit tests bundled with ONOS source code, can be executed by using the following:

    $ cd ${ONOS_HOME}/
    $ mvn test

Some of the unit tests, which take longer time to execute are excluded from the above goal. To force running all the unit tests, use the following commands:

    $ cd ${ONOS_HOME}/
    $ mvn test -P all-tests

To run only a subset of the unit tests, use the following commands:

    $ cd ${ONOS_HOME}/
    $ mvn test -Dtest=PortNumberTest

Comma and wildcards can be used to specify multiple test cases. See maven-surefire-plugin website for details.

Running static analysis

ONOS utilizes several static analysis tools to detect programmatic and formatting errors. To run some of the analysis against the code, use the following commands:

    $ cd ${ONOS_HOME}
    $ mvn clean verify -P error-prone

Downloading dependencies (Optional)

Maven need the Internet connection to download required dependencies and plugins, when they're used for the first time.

If you need to develop ONOS in an Internet unreachable environment you may want to run the following helper script before you go offline, so that required dependencies and plugins for frequently used maven target will be downloaded to your local environment.

    $ ./prep-for-offline.sh

License

Apache 2.0