Skip to content
Snippets Groups Projects
Commit 8631b459 authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

Merge commit '249f7a18'

parents 642846b6 249f7a18
No related branches found
No related tags found
No related merge requests found
Showing
with 113 additions and 374 deletions
......@@ -19,6 +19,13 @@
limitations under the License.
-->
<!--
The build uses pregenerated Thrift code by default to reduce build
dependencies. To generate it locally run the gen-thrift target.
If you change the Thrift files be sure to also commit the updated
generated code.
-->
<project default="dist" name="Floodlight">
<property name="target" location="target"/>
<property name="build" location="${target}/bin"/>
......@@ -32,13 +39,14 @@
<property name="python-src" location="src/main/python"/>
<property name="docs" location="${target}/docs"/>
<property name="main-class" value="net.floodlightcontroller.core.Main"/>
<property name="packetstreamer-gen" location="lib/gen-java" />
<property name="packetstreamer-gen-build" location="lib/gen-java-bin"/>
<property name="packetstreamer-thrift-jar" value="packetstreamer-thrift.jar"/>
<property name="floodlight-nodeps-jar" location="${target}/floodlight-nodeps.jar"/>
<property name="floodlight-debian-jar" location="${target}/floodlight-debian.jar"/>
<property name="floodlight-jar" location="${target}/floodlight.jar"/>
<property name="floodlight-test-jar" location="${target}/floodlight-test.jar"/>
<property name="thrift.dir" value="${basedir}/src/main/thrift"/>
<property name="thrift.out.dir" value="lib/gen-java"/>
<property name="thrift.package" value="net/floodlightcontroller/packetstreamer/thrift"/>
<property name="ant.build.javac.source" value="1.6"/>
<property name="ant.build.javac.target" value="1.6"/>
<property name="lib" location="lib"/>
<patternset id="lib">
<include name="logback-classic-1.0.0.jar"/>
......@@ -58,26 +66,11 @@
<include name="jython-2.5.2.jar"/>
<include name="libthrift-0.7.0.jar"/>
</patternset>
<!-- Dependencies we can't get from Debian/Ubuntu. -->
<patternset id="debian-lib">
<include name="org.restlet-2.1-RC1.jar"/>
<include name="org.restlet.ext.jackson-2.1-RC1.jar"/>
<include name="org.restlet.ext.simple-2.1-RC1.jar"/>
<include name="org.restlet.ext.slf4j-2.1-RC1.jar"/>
<include name="libthrift-0.7.0.jar"/>
<include name="simple-4.1.21.jar"/>
</patternset>
<patternset id="genlib">
<include name="${packetstreamer-thrift-jar}"/>
</patternset>
<path id="classpath">
<fileset dir="lib">
<fileset dir="${lib}">
<patternset refid="lib"/>
</fileset>
<fileset dir="${target}/lib">
<patternset refid="genlib"/>
</fileset>
</path>
<patternset id="lib-cobertura">
......@@ -88,7 +81,7 @@
<include name="log4j-1.2.9.jar"/>
</patternset>
<path id="classpath-cobertura">
<fileset dir="lib">
<fileset dir="${lib}">
<patternset refid="lib-cobertura"/>
</fileset>
</path>
......@@ -98,29 +91,26 @@
<include name="org.easymock_2.5.2.jar"/>
</patternset>
<path id="classpath-test">
<fileset dir="lib">
<fileset dir="${lib}">
<patternset refid="lib-test"/>
<patternset refid="lib-cobertura"/>
<patternset refid="lib"/>
</fileset>
<fileset dir="${target}/lib">
<patternset refid="genlib"/>
</fileset>
</path>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${build-test}"/>
<mkdir dir="${target}/lib"/>
<mkdir dir="${packetstreamer-gen-build}"/>
<mkdir dir="${thrift.out.dir}"/>
<mkdir dir="${test-output}"/>
</target>
<target name="compile" depends="init,packetstreamer-thrift">
<target name="compile" depends="init">
<javac includeAntRuntime="false"
classpathref="classpath"
debug="true"
srcdir="${source}:${packetstreamer-gen}"
srcdir="${source}:${thrift.out.dir}"
destdir="${build}">
</javac>
</target>
......@@ -135,22 +125,23 @@
destdir="${build-test}"/>
</target>
<target name="compile-thrift" depends="init">
<javac srcdir="${packetstreamer-gen}"
includeantruntime="false"
destdir="${packetstreamer-gen-build}"
debug="true" debuglevel="lines,vars,source"
classpathref="classpath" />
</target>
<target name="packetstreamer-thrift" depends="compile-thrift">
<jar jarfile="${target}/lib/${packetstreamer-thrift-jar}"
basedir="${packetstreamer-gen-build}"/>
<!-- Thrift build based on http://www.flester.com/blog/2009/04/26/using-thrift-from-ant -->
<fileset id="thrift.files" dir="${thrift.dir}">
<include name="**/*.thrift"/>
</fileset>
<target name="gen-thrift" depends="init">
<pathconvert property="thrift.file.list" refid="thrift.files"
pathsep=" " dirsep="/">
</pathconvert>
<echo message="Running thrift generator on ${thrift.file.list}"/>
<exec executable="thrift" dir="${basedir}" failonerror="true">
<arg line="--strict -v --gen java -o ${thrift.out.dir}/.. ${thrift.file.list}"/>
</exec>
</target>
<target name="clean">
<delete dir="${target}"/>
<delete dir="${packetstreamer-gen-build}"/>
<delete file="${target}/lib/${packetstreamer-thrift-jar}"/>
</target>
<target name="run" depends="dist">
......@@ -212,7 +203,7 @@
<target name="coverage" depends="instrument,test,coverage-report"/>
<target name="dist" depends="compile,compile-test">
<jar destfile="${floodlight-nodeps-jar}" filesetmanifest="mergewithoutmain">
<jar destfile="${floodlight-jar}" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<attribute name="Class-Path" value="."/>
......@@ -222,30 +213,9 @@
<fileset dir="${python-src}">
<include name="**/*.py"/>
</fileset>
<zipgroupfileset dir="${target}/lib">
<patternset refid="genlib"/>
</zipgroupfileset>
</jar>
<jar destfile="${floodlight-jar}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<attribute name="Class-Path" value="."/>
</manifest>
<zipgroupfileset dir="lib">
<zipgroupfileset dir="${lib}">
<patternset refid="lib"/>
</zipgroupfileset>
<zipfileset src="${floodlight-nodeps-jar}"/>
</jar>
<jar destfile="${floodlight-debian-jar}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<!-- JARs under /usr/share/java on Debian/Ubuntu -->
<attribute name="Class-Path" value="args4j.jar slf4j-api.jar logback-core.jar logback-classic.jar jackson-core-asl.jar jackson-mapper-asl.jar easymock.jar netty.jar concurrentlinkedhashmap-lru.jar jython.jar antlr3-runtime.jar asm3.jar asm3-tree.jar ."/>
</manifest>
<zipgroupfileset dir="lib">
<patternset refid="debian-lib"/>
</zipgroupfileset>
<zipfileset src="${floodlight-nodeps-jar}"/>
</jar>
<jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
<manifest>
......@@ -253,13 +223,10 @@
</manifest>
<fileset dir="${build-test}"/>
<fileset dir="${resources}"/>
<zipgroupfileset dir="lib">
<zipgroupfileset dir="${lib}">
<patternset refid="lib-test"/>
<patternset refid="lib-cobertura"/>
</zipgroupfileset>
<zipgroupfileset dir="${target}/lib">
<patternset refid="genlib"/>
</zipgroupfileset>
</jar>
</target>
......@@ -281,20 +248,17 @@
version="true"/>
</target>
<target name="eclipse" depends="init,packetstreamer-thrift">
<pathconvert property="lib">
<target name="eclipse" depends="init">
<pathconvert property="eclipse-lib">
<map from="${basedir}/" to=""/>
<fileset dir="lib">
<fileset dir="${lib}">
<patternset refid="lib"/>
<patternset refid="lib-test"/>
</fileset>
<fileset dir="${target}/lib">
<patternset refid="genlib"/>
</fileset>
</pathconvert>
<exec executable="${basedir}/setup-eclipse.sh">
<arg value="${main-class}"/>
<arg value="${lib}"/>
<arg value="${eclipse-lib}"/>
</exec>
</target>
......
/files
/floodlight.debhelper.log
/floodlight.substvars
/floodlight
The Debian Package floodlight
----------------------------
Comments regarding the Package
-- Rich Lane <rlane@bigswitch.com> Thu, 10 May 2012 23:02:25 -0700
floodlight (0.82) unstable; urgency=low
* Initial Release.
-- Rich Lane <rlane@bigswitch.com> Thu, 10 May 2012 23:02:25 -0700
8
Source: floodlight
Section: net
Priority: extra
Maintainer: Rich Lane <rlane@bigswitch.com>
Build-Depends: debhelper (>= 8.0.0), javahelper (>= 0.40ubuntu1), liblogback-java (>= 1.0.0-1), libjackson-json-java (>= 1.9.2-1), libeasymock-java (>= 2.4+ds1-6), libslf4j-java (>= 1.6.4-1), libnetty-java (>= 1:3.2.6.Final-2), libargs4j-java (>= 2.0.16-2), libconcurrentlinkedhashmap-java (>= 1.1~jdk5-1), jython (>= 2.5.1-2ubuntu2)
Standards-Version: 3.9.2
Homepage: http://floodlight.openflowhub.org/
Vcs-Git: git://github.com/floodlight/floodlight.git
Vcs-Browser: https://github.com/floodlight/floodlight
Package: floodlight
Architecture: all
Depends: ${java:Depends}, ${misc:Depends}
Description: Java based OpenFlow controller
Floodlight is a Java based OpenFlow controller originally written by David
Erickson at Stanford University.
Format: http://dep.debian.net/deps/dep5
Upstream-Name: floodlight
Source: https://github.com/floodlight/floodlight
Files: *
Copyright: 2011 Big Switch Networks <rlane@bigswitch.com>
License: Apache-2.0
Files: debian/*
Copyright: 2012 Big Switch Networks <rlane@bigswitch.com>
License: Apache-2.0
License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian systems, the complete text of the Apache version 2.0 license
can be found in "/usr/share/common-licenses/Apache-2.0".
NOTICE.txt
README.txt
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH FLOODLIGHT 1 "May 14, 2012"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
floodlight \- An Apache licensed, Java based OpenFlow controller
.SH SYNOPSIS
.B floodlight
.RI [ options ]
.SH DESCRIPTION
This manual page documents briefly the
.B floodlight
command.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBfloodlight\fP is an Apache licensed, Java based OpenFlow controller.
.SH OPTIONS
.TP
.B \-cf, \-\-configFile FILE
Floodlight configuration file.
.SH AUTHOR
floodlight was written by David Erickson and Big Switch Networks.
.PP
This manual page was written by Rich Lane <rlane@bigswitch.com>,
for the Debian project (and may be used by others).
target/floodlight-debian.jar usr/share/java
debian/misc/floodlight usr/bin
debian/floodlight.1
#!/bin/sh
### BEGIN INIT INFO
# Provides: floodlight
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: An Apache licensed, Java based OpenFlow controller
# Description: An Apache licensed, Java based OpenFlow controller
### END INIT INFO
# Author: Rich Lane <rlane@bigswitch.com>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=floodlight # Introduce a short description here
NAME=floodlight # Introduce the short server's name here
DAEMON=/usr/bin/floodlight # Introduce the server's location here
DAEMON_ARGS="" # Arguments to run the daemon with
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON -b -m -- \
$DAEMON_ARGS \
|| return 2
# Wait for the server to start.
while ! nc -z localhost 6633; do sleep 1; done
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
#!/bin/sh
exec java -jar /usr/share/java/floodlight-debian.jar "$@"
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export JAVA_HOME=/usr/lib/jvm/default-java
%:
dh $@ --with javahelper
3.0 (native)
......@@ -166,6 +166,8 @@ public class Controller implements IFloodlightProviderService,
// Configuration options
protected int openFlowPort = 6633;
protected int workerThreads = 0;
// The id for this controller node. Should be unique for each controller
// node in a controller cluster.
protected String controllerId = "localhost";
// The current role of the controller.
......@@ -418,15 +420,42 @@ public class Controller implements IFloodlightProviderService,
* @throws IOException
*/
protected void sendRoleRequest(IOFSwitch sw, Role role) throws IOException {
// There are three cases to consider:
//
// 1) If the controller role at the point the switch connected was
// null/disabled, then we never sent the role request probe to the
// switch and therefore never set the SWITCH_SUPPORTS_NX_ROLE
// attribute for the switch, so supportsNxRole is null. In that
// case since we're now enabling role support for the controller
// we should send out the role request probe/update to the switch.
//
// 2) If supportsNxRole == Boolean.TRUE then that means we've already
// sent the role request probe to the switch and it replied with
// a role reply message, so we know it supports role request
// messages. Now we're changing the role and we want to send
// it another role request message to inform it of the new role
// for the controller.
//
// 3) If supportsNxRole == Boolean.FALSE, then that means we sent the
// role request probe to the switch but it responded with an error
// indicating that it didn't understand the role request message.
// In that case we don't want to send it another role request that
// it (still) doesn't understand. But if the new role of the
// controller is SLAVE, then we don't want the switch to remain
// connected to this controller. It might support the older serial
// failover model for HA support, so we want to terminate the
// connection and get it to initiate a connection with another
// controller in its list of controllers. Eventually (hopefully, if
// things are configured correctly) it will walk down its list of
// controllers and connect to the current master controller.
Boolean supportsNxRole = (Boolean)
sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE);
if ((supportsNxRole != null) && supportsNxRole) {
if ((supportsNxRole == null) || supportsNxRole) {
// Handle cases #1 and #2
sendNxRoleRequest(sw, role);
} else if (supportsNxRole != null && !supportsNxRole) {
// We know switch does not support role-request (and so sw.role is null)
// but we may have just switched roles from MASTER to SLAVE in which
// case we should disconnect switch
if (getRole() == Role.SLAVE && sw.getRole() == null) {
} else {
// Handle case #3
if (getRole() == Role.SLAVE) {
log.error("Disconnecting switch {} that doesn't support " +
"role request messages from a controller that went to SLAVE mode");
// Closing the channel should result in a call to
......@@ -1704,7 +1733,11 @@ public class Controller implements IFloodlightProviderService,
roleString = properties.getProperty("floodlight.role");
}
catch (IOException exc) {
log.error("Error reading current role value from file: {}", rolePath);
// Don't treat it as an error if the file specified by the
// rolepath property doesn't exist. This lets us enable the
// HA mechanism by just creating/setting the floodlight.role
// property in that file without having to modify the
// floodlight properties.
}
}
}
......
......@@ -39,6 +39,7 @@ import net.floodlightcontroller.core.types.MacVlanPair;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.floodlightcontroller.util.TimedCache;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.jboss.netty.channel.Channel;
import org.openflow.protocol.OFFeaturesReply;
import org.openflow.protocol.OFFlowMod;
......@@ -139,6 +140,7 @@ public class OFSwitchImpl implements IOFSwitch {
return this.attributes.containsKey(name);
}
@JsonIgnore
public Channel getChannel() {
return this.channel;
}
......@@ -451,6 +453,7 @@ public class OFSwitchImpl implements IOFSwitch {
* switch list from being modified out from under the listeners.
* @return
*/
@JsonIgnore
public Lock getListenerReadLock() {
return listenerLock.readLock();
}
......@@ -462,6 +465,7 @@ public class OFSwitchImpl implements IOFSwitch {
* message from the switch.
* @return
*/
@JsonIgnore
public Lock getListenerWriteLock() {
return listenerLock.writeLock();
}
......
......@@ -11,33 +11,10 @@ import org.restlet.resource.Post;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RoleResource extends ServerResource {
public class ControllerRoleResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(RoleResource.class);
protected static Logger log = LoggerFactory.getLogger(ControllerRoleResource.class);
public static class RoleInfo {
protected String role;
public RoleInfo() {
}
public RoleInfo(String role) {
setRole(role);
}
public RoleInfo(Role role) {
this.role = (role != null) ? role.name() : "DISABLED";
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
}
@Get("json")
public RoleInfo getRole() {
IFloodlightProviderService floodlightProvider =
......
......@@ -39,6 +39,7 @@ public class CoreWebRoutable implements RestletRoutable {
Router router = new Router(context);
router.attach("/module/all/json", ModuleLoaderResource.class);
router.attach("/module/loaded/json", LoadedModuleLoaderResource.class);
router.attach("/switch/{switchId}/role/json", SwitchRoleResource.class);
router.attach("/switch/all/{statType}/json", AllSwitchStatisticsResource.class);
router.attach("/switch/{switchId}/{statType}/json", SwitchStatisticsResource.class);
router.attach("/controller/switches/json", ControllerSwitchesResource.class);
......@@ -56,7 +57,7 @@ public class CoreWebRoutable implements RestletRoutable {
EventHistoryTopologyClusterResource.class);
router.attach("/storage/tables/json", StorageSourceTablesResource.class);
router.attach("/controller/summary/json", ControllerSummaryResource.class);
router.attach("/role/json", RoleResource.class);
router.attach("/role/json", ControllerRoleResource.class);
router.attach("/health/json", HealthCheckResource.class);
return router;
}
......
package net.floodlightcontroller.core.web;
import net.floodlightcontroller.core.IFloodlightProviderService.Role;
public class RoleInfo {
protected String role;
public RoleInfo() {
}
public RoleInfo(String role) {
setRole(role);
}
public RoleInfo(Role role) {
this.role = (role != null) ? role.name() : "DISABLED";
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment