Skip to content
Snippets Groups Projects
Commit 85318360 authored by Sandeep Hebbani's avatar Sandeep Hebbani
Browse files

Merge branch 'master' of github.com:bigswitch/bigswitchcontroller

parents d186123c 345b3b86
No related branches found
No related tags found
No related merge requests found
Showing
with 180 additions and 121 deletions
...@@ -211,6 +211,17 @@ public interface IFloodlightProviderService extends ...@@ -211,6 +211,17 @@ public interface IFloodlightProviderService extends
*/ */
public void setAlwaysClearFlowsOnSwAdd(boolean value); public void setAlwaysClearFlowsOnSwAdd(boolean value);
/**
* Get controller memory information
*/
public Map<String, Long> getMemory();
/**
* returns the uptime of this controller.
* @return
*/
public Long getUptime();
/** /**
* Adds an OFSwitch driver * Adds an OFSwitch driver
* @param desc The starting portion of switch's manufacturer string * @param desc The starting portion of switch's manufacturer string
......
...@@ -19,6 +19,8 @@ package net.floodlightcontroller.core.internal; ...@@ -19,6 +19,8 @@ package net.floodlightcontroller.core.internal;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -199,9 +201,6 @@ public class Controller implements IFloodlightProviderService, ...@@ -199,9 +201,6 @@ public class Controller implements IFloodlightProviderService,
protected RoleChanger roleChanger; protected RoleChanger roleChanger;
protected SingletonTask roleChangeDamper; protected SingletonTask roleChangeDamper;
// Start time of the controller
protected long systemStartTime;
// Flag to always flush flow table on switch reconnect (HA or otherwise) // Flag to always flush flow table on switch reconnect (HA or otherwise)
protected boolean alwaysClearFlowsOnSwAdd = false; protected boolean alwaysClearFlowsOnSwAdd = false;
...@@ -1791,7 +1790,6 @@ public class Controller implements IFloodlightProviderService, ...@@ -1791,7 +1790,6 @@ public class Controller implements IFloodlightProviderService,
this.notifiedRole = this.role; this.notifiedRole = this.role;
this.roleChanger = new RoleChanger(this); this.roleChanger = new RoleChanger(this);
initVendorMessages(); initVendorMessages();
this.systemStartTime = System.currentTimeMillis();
String option = configParams.get("flushSwitchesOnReconnect"); String option = configParams.get("flushSwitchesOnReconnect");
...@@ -1972,7 +1970,8 @@ public class Controller implements IFloodlightProviderService, ...@@ -1972,7 +1970,8 @@ public class Controller implements IFloodlightProviderService,
@Override @Override
public long getSystemStartTime() { public long getSystemStartTime() {
return (this.systemStartTime); RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getStartTime();
} }
@Override @Override
...@@ -1984,6 +1983,21 @@ public class Controller implements IFloodlightProviderService, ...@@ -1984,6 +1983,21 @@ public class Controller implements IFloodlightProviderService,
return this.alwaysClearFlowsOnSwAdd; return this.alwaysClearFlowsOnSwAdd;
} }
@Override
public Map<String, Long> getMemory() {
Map<String, Long> m = new HashMap<String, Long>();
Runtime runtime = Runtime.getRuntime();
m.put("total", runtime.totalMemory());
m.put("free", runtime.freeMemory());
return m;
}
@Override
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
@Override @Override
public void addOFSwitchDriver(String description, IOFSwitchDriver driver) { public void addOFSwitchDriver(String description, IOFSwitchDriver driver) {
IOFSwitchDriver existingDriver = switchBindingMap.get(description); IOFSwitchDriver existingDriver = switchBindingMap.get(description);
......
...@@ -23,25 +23,24 @@ import org.restlet.resource.ServerResource; ...@@ -23,25 +23,24 @@ import org.restlet.resource.ServerResource;
public class SystemUptimeResource extends ServerResource { public class SystemUptimeResource extends ServerResource {
public class UptimeRest { public class UptimeRest {
long systemUptimeMsec; long systemUptimeMsec;
public long getSystemUptimeMsec() { public long getSystemUptimeMsec() {
return systemUptimeMsec; return systemUptimeMsec;
} }
} }
@Get("json") @Get("json")
public UptimeRest retrieve() { public UptimeRest retrieve() {
IFloodlightProviderService floodlightProvider = IFloodlightProviderService floodlightProvider =
(IFloodlightProviderService)getContext().getAttributes(). (IFloodlightProviderService)getContext().getAttributes().
get(IFloodlightProviderService.class.getCanonicalName()); get(IFloodlightProviderService.class.getCanonicalName());
UptimeRest uptime = new UptimeRest(); UptimeRest uptime = new UptimeRest();
uptime.systemUptimeMsec = uptime.systemUptimeMsec = floodlightProvider.getUptime();
System.currentTimeMillis() - floodlightProvider.getSystemStartTime();
return (uptime);
return (uptime); }
}
} }
...@@ -418,7 +418,9 @@ public class Device implements IDevice { ...@@ -418,7 +418,9 @@ public class Device implements IDevice {
if (apMap == null || apMap.isEmpty()) { if (apMap == null || apMap.isEmpty()) {
apList.add(newAP); apList.add(newAP);
attachmentPoints = apList; attachmentPoints = apList;
return true; // there are no old attachment points - we should not treat this
// as a device moved.
return false;
} }
long id = topology.getL2DomainId(sw); long id = topology.getL2DomainId(sw);
......
...@@ -794,7 +794,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -794,7 +794,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
if (srcEntity == null) if (srcEntity == null)
return Command.STOP; return Command.STOP;
// Learn from ARP packet. // Learn from ARP packet for special VRRP settings.
// In VRRP settings, the source MAC address and sender MAC // In VRRP settings, the source MAC address and sender MAC
// addresses can be different. In such cases, we need to learn // addresses can be different. In such cases, we need to learn
// the IP to MAC mapping of the VRRP IP address. The source // the IP to MAC mapping of the VRRP IP address. The source
...@@ -1036,6 +1036,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1036,6 +1036,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
(learnap ? (int)inPort : null), (learnap ? (int)inPort : null),
new Date()); new Date());
} }
/** /**
* Look up a {@link Device} based on the provided {@link Entity}. We first * Look up a {@link Device} based on the provided {@link Entity}. We first
* check the primary index. If we do not find an entry there we classify * check the primary index. If we do not find an entry there we classify
...@@ -1076,9 +1077,10 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1076,9 +1077,10 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
* the given source device. The source device is important since * the given source device. The source device is important since
* there could be ambiguity in the destination device without the * there could be ambiguity in the destination device without the
* attachment point information. * attachment point information.
* @param source the source device. The returned destination will be * @param reference the source device's entity class.
* in the same entity class as the source. * The returned destination will be
* @param dstEntity the entity to look up * in the same entity class as the source.
* @param dstEntity the entity to look up
* @return an {@link Device} or null if no device is found. * @return an {@link Device} or null if no device is found.
*/ */
protected Device findDestByEntity(IEntityClass reference, protected Device findDestByEntity(IEntityClass reference,
...@@ -1107,7 +1109,6 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1107,7 +1109,6 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
return deviceMap.get(deviceKey); return deviceMap.get(deviceKey);
} }
/** /**
* Look up a {@link Device} within a particular entity class based on * Look up a {@link Device} within a particular entity class based on
* the provided {@link Entity}. * the provided {@link Entity}.
...@@ -1707,6 +1708,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1707,6 +1708,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
return new Device(device, entity, insertionpoint); return new Device(device, entity, insertionpoint);
} }
//not used
protected Device allocateDevice(Device device, Set <Entity> entities) { protected Device allocateDevice(Device device, Set <Entity> entities) {
List <AttachmentPoint> newPossibleAPs = List <AttachmentPoint> newPossibleAPs =
new ArrayList<AttachmentPoint>(); new ArrayList<AttachmentPoint>();
...@@ -1737,7 +1739,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1737,7 +1739,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
} }
// ********************* // *********************
// IEntityClassListener // ITopologyListener
// ********************* // *********************
/** /**
......
/** /**
* Copyright 2012 Big Switch Networks, Inc. * Copyright 2012 Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University * Originally created by David Erickson, Stanford University
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may * 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 * not use this file except in compliance with the License. You may obtain
* a copy of the License at * a copy of the License at
...@@ -31,7 +31,7 @@ public class DeviceUniqueIndex extends DeviceIndex { ...@@ -31,7 +31,7 @@ public class DeviceUniqueIndex extends DeviceIndex {
/** /**
* The index * The index
*/ */
private ConcurrentHashMap<IndexedEntity, Long> index; private final ConcurrentHashMap<IndexedEntity, Long> index;
/** /**
* Construct a new device index using the provided key fields * Construct a new device index using the provided key fields
...@@ -51,10 +51,10 @@ public class DeviceUniqueIndex extends DeviceIndex { ...@@ -51,10 +51,10 @@ public class DeviceUniqueIndex extends DeviceIndex {
final Long deviceKey = findByEntity(entity); final Long deviceKey = findByEntity(entity);
if (deviceKey != null) if (deviceKey != null)
return Collections.<Long>singleton(deviceKey).iterator(); return Collections.<Long>singleton(deviceKey).iterator();
return Collections.<Long>emptySet().iterator(); return Collections.<Long>emptySet().iterator();
} }
@Override @Override
public Iterator<Long> getAll() { public Iterator<Long> getAll() {
return index.values().iterator(); return index.values().iterator();
...@@ -68,15 +68,15 @@ public class DeviceUniqueIndex extends DeviceIndex { ...@@ -68,15 +68,15 @@ public class DeviceUniqueIndex extends DeviceIndex {
Long ret = index.putIfAbsent(ie, deviceKey); Long ret = index.putIfAbsent(ie, deviceKey);
if (ret != null && !ret.equals(deviceKey)) { if (ret != null && !ret.equals(deviceKey)) {
// If the return value is non-null, then fail the insert // If the return value is non-null, then fail the insert
// (this implies that a device using this entity has // (this implies that a device using this entity has
// already been created in another thread). // already been created in another thread).
return false; return false;
} }
} }
return true; return true;
} }
@Override @Override
public void updateIndex(Entity entity, Long deviceKey) { public void updateIndex(Entity entity, Long deviceKey) {
IndexedEntity ie = new IndexedEntity(keyFields, entity); IndexedEntity ie = new IndexedEntity(keyFields, entity);
......
...@@ -54,4 +54,6 @@ public interface IRoutingDecision { ...@@ -54,4 +54,6 @@ public interface IRoutingDecision {
public void setMulticastInterfaces(List<SwitchPort> lspt); public void setMulticastInterfaces(List<SwitchPort> lspt);
public Integer getWildcards(); public Integer getWildcards();
public void setWildcards(Integer wildcards); public void setWildcards(Integer wildcards);
public short getHardTimeout();
public void setHardTimeout(short hardTimeout);
} }
...@@ -29,6 +29,7 @@ public class RoutingDecision implements IRoutingDecision { ...@@ -29,6 +29,7 @@ public class RoutingDecision implements IRoutingDecision {
protected RoutingAction action; protected RoutingAction action;
protected Integer wildcards; protected Integer wildcards;
protected short hardTimeout;
protected SwitchPort srcPort; protected SwitchPort srcPort;
protected IDevice srcDevice; protected IDevice srcDevice;
protected List<IDevice> destDevices; protected List<IDevice> destDevices;
...@@ -46,6 +47,7 @@ public class RoutingDecision implements IRoutingDecision { ...@@ -46,6 +47,7 @@ public class RoutingDecision implements IRoutingDecision {
Collections.synchronizedList(new ArrayList<SwitchPort>()); Collections.synchronizedList(new ArrayList<SwitchPort>());
this.action = action; this.action = action;
this.wildcards = null; this.wildcards = null;
this.hardTimeout = ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT;
} }
@Override @Override
...@@ -100,6 +102,16 @@ public class RoutingDecision implements IRoutingDecision { ...@@ -100,6 +102,16 @@ public class RoutingDecision implements IRoutingDecision {
this.wildcards = wildcards; this.wildcards = wildcards;
} }
@Override
public short getHardTimeout() {
return hardTimeout;
}
@Override
public void setHardTimeout(short hardTimeout) {
this.hardTimeout = hardTimeout;
}
@Override @Override
public void addToContext(FloodlightContext cntx) { public void addToContext(FloodlightContext cntx) {
rtStore.put(cntx, IRoutingDecision.CONTEXT_DECISION, this); rtStore.put(cntx, IRoutingDecision.CONTEXT_DECISION, this);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
package net.floodlightcontroller.core.test; package net.floodlightcontroller.core.test;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
...@@ -361,4 +363,18 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro ...@@ -361,4 +363,18 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
return null; return null;
} }
@Override
public Map<String, Long> getMemory() {
Map<String, Long> m = new HashMap<String, Long>();
Runtime runtime = Runtime.getRuntime();
m.put("total", runtime.totalMemory());
m.put("free", runtime.freeMemory());
return m;
}
@Override
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
} }
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