Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/main/java/net/floodlightcontroller/util/BundleAction.java b/src/main/java/net/floodlightcontroller/util/BundleAction.java
index 0d82275..ea797a8 100644
--- a/src/main/java/net/floodlightcontroller/util/BundleAction.java
+++ b/src/main/java/net/floodlightcontroller/util/BundleAction.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -22,7 +22,6 @@
import java.util.List;
/**
- *
* @author David Erickson (daviderickson@cs.stanford.edu)
*/
public enum BundleAction {
@@ -33,16 +32,16 @@
public static List<BundleAction> getAvailableActions(BundleState state) {
List<BundleAction> actions = new ArrayList<BundleAction>();
- if (Arrays.binarySearch(new BundleState[] {
+ if (Arrays.binarySearch(new BundleState[]{
BundleState.ACTIVE, BundleState.STARTING,
- BundleState.UNINSTALLED }, state) < 0) {
+ BundleState.UNINSTALLED}, state) < 0) {
actions.add(START);
}
- if (Arrays.binarySearch(new BundleState[] {
+ if (Arrays.binarySearch(new BundleState[]{
BundleState.ACTIVE}, state) >= 0) {
actions.add(STOP);
}
- if (Arrays.binarySearch(new BundleState[] {
+ if (Arrays.binarySearch(new BundleState[]{
BundleState.UNINSTALLED}, state) < 0) {
actions.add(UNINSTALL);
}
diff --git a/src/main/java/net/floodlightcontroller/util/BundleState.java b/src/main/java/net/floodlightcontroller/util/BundleState.java
index f89bc0b..ef32958 100644
--- a/src/main/java/net/floodlightcontroller/util/BundleState.java
+++ b/src/main/java/net/floodlightcontroller/util/BundleState.java
@@ -1,33 +1,32 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
/**
- *
* @author David Erickson (daviderickson@cs.stanford.edu)
*/
public enum BundleState {
- ACTIVE (32),
- INSTALLED (2),
- RESOLVED (4),
- STARTING (8),
- STOPPING (16),
- UNINSTALLED (1);
+ ACTIVE(32),
+ INSTALLED(2),
+ RESOLVED(4),
+ STARTING(8),
+ STOPPING(16),
+ UNINSTALLED(1);
protected int value;
diff --git a/src/main/java/net/floodlightcontroller/util/EventHistory.java b/src/main/java/net/floodlightcontroller/util/EventHistory.java
index 69031ba..40c9a36 100644
--- a/src/main/java/net/floodlightcontroller/util/EventHistory.java
+++ b/src/main/java/net/floodlightcontroller/util/EventHistory.java
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package net.floodlightcontroller.util;
@@ -7,30 +7,33 @@
/**
* @author subrata
- *
*/
public class EventHistory<T> {
public static final int EV_HISTORY_DEFAULT_SIZE = 1024;
- public String description;
- public int event_history_size;
- public int current_index;
+ public String description;
+ public int event_history_size;
+ public int current_index;
public boolean full; // true if all are in use
public ArrayList<Event> events;
public String getDescription() {
return description;
}
+
public int getEvent_history_size() {
return event_history_size;
}
+
public int getCurrent_index() {
return current_index;
}
+
public boolean isFull() {
return full;
}
+
public ArrayList<Event> getEvents() {
return events;
}
@@ -69,18 +72,18 @@
events = new ArrayList<Event>(maxEvents);
for (int idx = 0; idx < maxEvents; idx++) {
- Event evH = new Event();
+ Event evH = new Event();
evH.base_info = new EventHistoryBaseInfo();
- evH.info = null;
+ evH.info = null;
evH.base_info.state = EvState.FREE;
- evH.base_info.idx = idx;
+ evH.base_info.idx = idx;
events.add(idx, evH);
}
description = "Event-History:" + desc;
- event_history_size = maxEvents;
- current_index = 0;
- full = false;
+ event_history_size = maxEvents;
+ current_index = 0;
+ full = false;
}
// Constructor for default size
@@ -95,11 +98,11 @@
description = "No event found";
return;
}
- int curSize = (eventHist.full)?eventHist.event_history_size:
- eventHist.current_index;
- int size = (latestK < curSize)?latestK:curSize;
+ int curSize = (eventHist.full) ? eventHist.event_history_size :
+ eventHist.current_index;
+ int size = (latestK < curSize) ? latestK : curSize;
int evIdx = eventHist.current_index;
- int topSz = (evIdx >= size)?size:evIdx;
+ int topSz = (evIdx >= size) ? size : evIdx;
// Need to create a new one since size is different
events = new ArrayList<Event>(size);
@@ -107,7 +110,7 @@
// Get the top part
int origIdx = evIdx;
for (int idx = 0; idx < topSz; idx++) {
- Event evH = eventHist.events.get(--origIdx);
+ Event evH = eventHist.events.get(--origIdx);
evH.base_info.idx = idx;
events.add(idx, evH);
}
@@ -121,9 +124,9 @@
}
description = eventHist.description;
- event_history_size = size;
- current_index = 0; // since it is full
- full = true;
+ event_history_size = size;
+ current_index = 0; // since it is full
+ full = true;
}
// Get an index for writing a new event. This method is synchronized for
@@ -131,13 +134,13 @@
// by the caller event at the index is updated without any lock
public synchronized int NextIdx() {
// curIdx should be in the 0 to evArraySz-1
- if (current_index == (event_history_size-1)) {
+ if (current_index == (event_history_size - 1)) {
current_index = 0;
full = true;
- return (event_history_size-1);
+ return (event_history_size - 1);
} else {
current_index++;
- return (current_index-1);
+ return (current_index - 1);
}
}
@@ -148,6 +151,7 @@
* and the current object at that array location is returned to the
* calling process so that the calling process can use that object
* for the next event of the same type
+ *
* @param t
* @param op
* @return
@@ -165,7 +169,7 @@
return temp;
}
- /***
+ /**
* Clear the event history, needs to be done under lock
*/
public void clear() {
diff --git a/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfo.java b/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfo.java
index 74fc973..52b623d 100644
--- a/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfo.java
+++ b/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfo.java
@@ -3,23 +3,26 @@
import org.codehaus.jackson.map.annotate.JsonSerialize;
-@JsonSerialize(using=EventHistoryBaseInfoJSONSerializer.class)
+@JsonSerialize(using = EventHistoryBaseInfoJSONSerializer.class)
public class EventHistoryBaseInfo {
- public int idx;
- public long time_ms; // timestamp in milliseconds
- public EventHistory.EvState state;
- public EventHistory.EvAction action;
+ public int idx;
+ public long time_ms; // timestamp in milliseconds
+ public EventHistory.EvState state;
+ public EventHistory.EvAction action;
// Getters
public int getIdx() {
return idx;
}
+
public long getTime_ms() {
return time_ms;
}
+
public EventHistory.EvState getState() {
return state;
}
+
public EventHistory.EvAction getAction() {
return action;
}
diff --git a/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfoJSONSerializer.java b/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfoJSONSerializer.java
index 3916282..0fe4b17 100644
--- a/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfoJSONSerializer.java
+++ b/src/main/java/net/floodlightcontroller/util/EventHistoryBaseInfoJSONSerializer.java
@@ -1,18 +1,18 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-*
-* 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.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -27,32 +27,31 @@
/**
* @author subrata
- *
*/
-public class EventHistoryBaseInfoJSONSerializer extends
- JsonSerializer<EventHistoryBaseInfo> {
+public class EventHistoryBaseInfoJSONSerializer extends
+ JsonSerializer<EventHistoryBaseInfo> {
-
+
/**
* Performs the serialization of a EventHistory.BaseInfo object
*/
@Override
public void serialize(EventHistoryBaseInfo base_info, JsonGenerator jGen,
- SerializerProvider serializer)
- throws IOException, JsonProcessingException {
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
jGen.writeStartObject();
- jGen.writeNumberField("Idx", base_info.getIdx());
+ jGen.writeNumberField("Idx", base_info.getIdx());
Timestamp ts = new Timestamp(base_info.getTime_ms());
String tsStr = ts.toString();
while (tsStr.length() < 23) {
tsStr = tsStr.concat("0");
}
jGen.writeStringField("Time", tsStr);
- jGen.writeStringField("State", base_info.getState().name());
+ jGen.writeStringField("State", base_info.getState().name());
String acStr = base_info.getAction().name().toLowerCase();
// Capitalize the first letter
- acStr = acStr.substring(0,1).toUpperCase().concat(acStr.substring(1));
+ acStr = acStr.substring(0, 1).toUpperCase().concat(acStr.substring(1));
jGen.writeStringField("Action", acStr);
jGen.writeEndObject();
}
diff --git a/src/main/java/net/floodlightcontroller/util/FilterIterator.java b/src/main/java/net/floodlightcontroller/util/FilterIterator.java
index 47cd5c9..fac4e7a 100644
--- a/src/main/java/net/floodlightcontroller/util/FilterIterator.java
+++ b/src/main/java/net/floodlightcontroller/util/FilterIterator.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2012, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2012, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -30,6 +30,7 @@
/**
* Construct a filter iterator from the given sub iterator
+ *
* @param subIterator the sub iterator over which we'll filter
*/
public FilterIterator(Iterator<T> subIterator) {
@@ -40,11 +41,12 @@
/**
* Check whether the given value should be returned by the
* filter
+ *
* @param value the value to check
* @return true if the value should be included
*/
protected abstract boolean matches(T value);
-
+
// ***********
// Iterator<T>
// ***********
@@ -52,7 +54,7 @@
@Override
public boolean hasNext() {
if (next != null) return true;
-
+
while (subIterator.hasNext()) {
next = subIterator.next();
if (matches(next))
diff --git a/src/main/java/net/floodlightcontroller/util/IterableIterator.java b/src/main/java/net/floodlightcontroller/util/IterableIterator.java
index 584de08..b71404a 100644
--- a/src/main/java/net/floodlightcontroller/util/IterableIterator.java
+++ b/src/main/java/net/floodlightcontroller/util/IterableIterator.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2012 Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2012 Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -28,7 +28,7 @@
public class IterableIterator<T> implements Iterator<T> {
Iterator<? extends Iterable<T>> subIterator;
Iterator<T> current = null;
-
+
public IterableIterator(Iterator<? extends Iterable<T>> subIterator) {
super();
this.subIterator = subIterator;
@@ -46,7 +46,7 @@
while (!current.hasNext() && subIterator.hasNext()) {
current = subIterator.next().iterator();
}
-
+
return current.hasNext();
}
diff --git a/src/main/java/net/floodlightcontroller/util/LRUHashMap.java b/src/main/java/net/floodlightcontroller/util/LRUHashMap.java
index 477e886..7b8d536 100644
--- a/src/main/java/net/floodlightcontroller/util/LRUHashMap.java
+++ b/src/main/java/net/floodlightcontroller/util/LRUHashMap.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -21,18 +21,18 @@
import java.util.Map;
public class LRUHashMap<K, V> extends LinkedHashMap<K, V> {
-
+
private static final long serialVersionUID = 1L;
-
+
private final int capacity;
- public LRUHashMap(int capacity)
- {
- super(capacity+1, 0.75f, true);
+
+ public LRUHashMap(int capacity) {
+ super(capacity + 1, 0.75f, true);
this.capacity = capacity;
}
-
- protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
- return size() > capacity;
+
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
+ return size() > capacity;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/MACAddress.java b/src/main/java/net/floodlightcontroller/util/MACAddress.java
index 13d83d1..f3ac52b 100644
--- a/src/main/java/net/floodlightcontroller/util/MACAddress.java
+++ b/src/main/java/net/floodlightcontroller/util/MACAddress.java
@@ -15,9 +15,9 @@
*
* @author Sho Shimizu (sho.shimizu@gmail.com)
*/
-@JsonDeserialize(using=MACAddressDeserializer.class)
-@JsonSerialize(using=MACAddressSerializer.class)
-public class MACAddress implements Serializable{
+@JsonDeserialize(using = MACAddressDeserializer.class)
+@JsonSerialize(using = MACAddressSerializer.class)
+public class MACAddress implements Serializable {
private static final long serialVersionUID = 10000L;
public static final int MAC_ADDRESS_LENGTH = 6;
private byte[] address = new byte[MAC_ADDRESS_LENGTH];
@@ -26,7 +26,7 @@
* Default constructor.
*/
public MACAddress() {
- this.address = new byte[] { 0, 0, 0, 0, 0, 0};
+ this.address = new byte[]{0, 0, 0, 0, 0, 0};
}
/**
@@ -40,6 +40,7 @@
/**
* Returns a MAC address instance representing the value of the specified {@code String}.
+ *
* @param address the String representation of the MAC Address to be parsed.
* @return a MAC Address instance representing the value of the specified {@code String}.
* @throws IllegalArgumentException if the string cannot be parsed as a MAC address.
@@ -49,13 +50,13 @@
if (elements.length != MAC_ADDRESS_LENGTH) {
throw new IllegalArgumentException(
"Specified MAC Address must contain 12 hex digits" +
- " separated pairwise by :'s.");
+ " separated pairwise by :'s.");
}
byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH];
for (int i = 0; i < MAC_ADDRESS_LENGTH; i++) {
String element = elements[i];
- addressInBytes[i] = (byte)Integer.parseInt(element, 16);
+ addressInBytes[i] = (byte) Integer.parseInt(element, 16);
}
return new MACAddress(addressInBytes);
@@ -63,6 +64,7 @@
/**
* Returns a MAC address instance representing the specified {@code byte} array.
+ *
* @param address the byte array to be parsed.
* @return a MAC address instance representing the specified {@code byte} array.
* @throws IllegalArgumentException if the byte array cannot be parsed as a MAC address.
@@ -78,18 +80,19 @@
/**
* Returns a MAC address instance representing the specified {@code long} value.
* The lower 48 bits of the long value are used to parse as a MAC address.
+ *
* @param address the long value to be parsed. The lower 48 bits are used for a MAC address.
* @return a MAC address instance representing the specified {@code long} value.
* @throws IllegalArgumentException if the long value cannot be parsed as a MAC address.
*/
public static MACAddress valueOf(long address) {
- byte[] addressInBytes = new byte[] {
- (byte)((address >> 40) & 0xff),
- (byte)((address >> 32) & 0xff),
- (byte)((address >> 24) & 0xff),
- (byte)((address >> 16) & 0xff),
- (byte)((address >> 8 ) & 0xff),
- (byte)((address >> 0) & 0xff)
+ byte[] addressInBytes = new byte[]{
+ (byte) ((address >> 40) & 0xff),
+ (byte) ((address >> 32) & 0xff),
+ (byte) ((address >> 24) & 0xff),
+ (byte) ((address >> 16) & 0xff),
+ (byte) ((address >> 8) & 0xff),
+ (byte) ((address >> 0) & 0xff)
};
return new MACAddress(addressInBytes);
@@ -97,6 +100,7 @@
/**
* Returns the length of the {@code MACAddress}.
+ *
* @return the length of the {@code MACAddress}.
*/
public int length() {
@@ -105,6 +109,7 @@
/**
* Returns the value of the {@code MACAddress} as a {@code byte} array.
+ *
* @return the numeric value represented by this object after conversion to type {@code byte} array.
*/
public byte[] toBytes() {
@@ -113,6 +118,7 @@
/**
* Returns the value of the {@code MACAddress} as a {@code long}.
+ *
* @return the numeric value represented by this object after conversion to type {@code long}.
*/
public long toLong() {
@@ -126,6 +132,7 @@
/**
* Returns {@code true} if the MAC address is the broadcast address.
+ *
* @return {@code true} if the MAC address is the broadcast address.
*/
public boolean isBroadcast() {
@@ -138,6 +145,7 @@
/**
* Returns {@code true} if the MAC address is the multicast address.
+ *
* @return {@code true} if the MAC address is the multicast address.
*/
public boolean isMulticast() {
@@ -157,7 +165,7 @@
return false;
}
- MACAddress other = (MACAddress)o;
+ MACAddress other = (MACAddress) o;
return Arrays.equals(this.address, other.address);
}
@@ -168,6 +176,6 @@
@Override
public String toString() {
- return HexString.toHexString(address);
+ return HexString.toHexString(address);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/MultiIterator.java b/src/main/java/net/floodlightcontroller/util/MultiIterator.java
index bcbc916..347ff10 100644
--- a/src/main/java/net/floodlightcontroller/util/MultiIterator.java
+++ b/src/main/java/net/floodlightcontroller/util/MultiIterator.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2012 Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2012 Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -28,7 +28,7 @@
public class MultiIterator<T> implements Iterator<T> {
Iterator<Iterator<T>> subIterator;
Iterator<T> current = null;
-
+
public MultiIterator(Iterator<Iterator<T>> subIterator) {
super();
this.subIterator = subIterator;
@@ -46,7 +46,7 @@
while (!current.hasNext() && subIterator.hasNext()) {
current = subIterator.next();
}
-
+
return current.hasNext();
}
diff --git a/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java b/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java
index 4dfb60b..47a92a9 100644
--- a/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java
+++ b/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java
@@ -15,35 +15,37 @@
import org.openflow.protocol.OFType;
/**
- * Dampens OFMessages sent to an OF switch. A message is only written to
+ * Dampens OFMessages sent to an OF switch. A message is only written to
* a switch if the same message (as defined by .equals()) has not been written
* in the last n milliseconds. Timer granularity is based on TimedCache
- * @author gregor
*
+ * @author gregor
*/
public class OFMessageDamper {
/**
* An entry in the TimedCache. A cache entry consists of the sent message
- * as well as the switch to which the message was sent.
- *
- * NOTE: We currently use the full OFMessage object. To save space, we
- * could use a cryptographic hash (e.g., SHA-1). However, this would
- * obviously be more time-consuming....
- *
+ * as well as the switch to which the message was sent.
+ * <p/>
+ * NOTE: We currently use the full OFMessage object. To save space, we
+ * could use a cryptographic hash (e.g., SHA-1). However, this would
+ * obviously be more time-consuming....
+ * <p/>
* We also store a reference to the actual IOFSwitch object and /not/
* the switch DPID. This way we are guarnteed to not dampen messages if
* a switch disconnects and then reconnects.
- *
+ *
* @author gregor
*/
protected static class DamperEntry {
OFMessage msg;
IOFSwitch sw;
+
public DamperEntry(OFMessage msg, IOFSwitch sw) {
super();
this.msg = msg;
this.sw = sw;
}
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@@ -55,6 +57,7 @@
result = prime * result + ((sw == null) ? 0 : sw.hashCode());
return result;
}
+
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@@ -72,67 +75,70 @@
} else if (!sw.equals(other.sw)) return false;
return true;
}
-
-
+
+
}
+
TimedCache<DamperEntry> cache;
EnumSet<OFType> msgTypesToCache;
+
/**
- *
- * @param capacity the maximum number of messages that should be
- * kept
- * @param typesToDampen The set of OFMessageTypes that should be
- * dampened by this instance. Other types will be passed through
- * @param timeout The dampening timeout. A message will only be
- * written if the last write for the an equal message more than
- * timeout ms ago.
+ * @param capacity the maximum number of messages that should be
+ * kept
+ * @param typesToDampen The set of OFMessageTypes that should be
+ * dampened by this instance. Other types will be passed through
+ * @param timeout The dampening timeout. A message will only be
+ * written if the last write for the an equal message more than
+ * timeout ms ago.
*/
- public OFMessageDamper(int capacity,
- Set<OFType> typesToDampen,
+ public OFMessageDamper(int capacity,
+ Set<OFType> typesToDampen,
int timeout) {
cache = new TimedCache<DamperEntry>(capacity, timeout);
msgTypesToCache = EnumSet.copyOf(typesToDampen);
- }
-
+ }
+
/**
* write the messag to the switch according to our dampening settings
+ *
* @param sw
* @param msg
* @param cntx
* @return true if the message was written to the switch, false if
- * the message was dampened.
+ * the message was dampened.
* @throws IOException
*/
public boolean write(IOFSwitch sw, OFMessage msg, FloodlightContext cntx)
- throws IOException {
+ throws IOException {
return write(sw, msg, cntx, false);
}
-
+
/**
* write the messag to the switch according to our dampening settings
+ *
* @param sw
* @param msg
* @param cntx
* @param flush true to flush the packet immidiately
* @return true if the message was written to the switch, false if
- * the message was dampened.
+ * the message was dampened.
* @throws IOException
*/
public boolean write(IOFSwitch sw, OFMessage msg,
- FloodlightContext cntx, boolean flush)
+ FloodlightContext cntx, boolean flush)
throws IOException {
- if (! msgTypesToCache.contains(msg.getType())) {
+ if (!msgTypesToCache.contains(msg.getType())) {
sw.write(msg, cntx);
if (flush) {
sw.flush();
}
return true;
}
-
+
DamperEntry entry = new DamperEntry(msg, sw);
if (cache.update(entry)) {
// entry exists in cache. Dampening.
- return false;
+ return false;
} else {
sw.write(msg, cntx);
if (flush) {
diff --git a/src/main/java/net/floodlightcontroller/util/TimedCache.java b/src/main/java/net/floodlightcontroller/util/TimedCache.java
index 3a44556..2a90f0b 100644
--- a/src/main/java/net/floodlightcontroller/util/TimedCache.java
+++ b/src/main/java/net/floodlightcontroller/util/TimedCache.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* 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.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * 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.
+ **/
package net.floodlightcontroller.util;
@@ -26,55 +26,53 @@
* The value is time-stamp in milliseconds
* The time interval denotes the interval for which the entry should remain in the hashmap.
* If an entry is present in the Linkedhashmap, it does not mean that it's valid (recently seen)
- *
+ *
* @param <K> Type of the values in this cache
*/
-public class TimedCache<K> {
+public class TimedCache<K> {
private final long timeoutInterval; //specified in milliseconds.
- private ConcurrentMap<K, Long> cache;
-
+ private ConcurrentMap<K, Long> cache;
+
/**
- *
- * @param capacity the maximum number of entries in the cache before the
- * oldest entry is evicted.
+ * @param capacity the maximum number of entries in the cache before the
+ * oldest entry is evicted.
* @param timeToLive specified in milliseconds
*/
- public TimedCache(int capacity, int timeToLive) {
+ public TimedCache(int capacity, int timeToLive) {
cache = new ConcurrentLinkedHashMap.Builder<K, Long>()
- .maximumWeightedCapacity(capacity)
- .build();
+ .maximumWeightedCapacity(capacity)
+ .build();
this.timeoutInterval = timeToLive;
}
-
+
public long getTimeoutInterval() {
return this.timeoutInterval;
}
-
+
/**
* Always try to update the cache and set the last-seen value for this key.
- *
+ * <p/>
* Return true, if a valid existing field was updated, else return false.
* (note: if multiple threads update simultaneously, one of them will succeed,
- * other wills return false)
- *
+ * other wills return false)
+ *
* @param key
* @return boolean
*/
- public boolean update(K key)
- {
+ public boolean update(K key) {
Long curr = new Long(System.currentTimeMillis());
Long prev = cache.putIfAbsent(key, curr);
-
+
if (prev == null) {
- return false;
+ return false;
}
if (curr - prev > this.timeoutInterval) {
if (cache.replace(key, prev, curr)) {
- return false;
+ return false;
}
}
-
+
return true;
}
}