Eliminate tab character from datastore package
Change-Id: I6eea92ce72268c4ca90f1bd24bdccf7edf4cbb7f
diff --git a/src/main/java/net/onrc/onos/datastore/topology/KVDevice.java b/src/main/java/net/onrc/onos/datastore/topology/KVDevice.java
index 105f6f7..e076c14 100644
--- a/src/main/java/net/onrc/onos/datastore/topology/KVDevice.java
+++ b/src/main/java/net/onrc/onos/datastore/topology/KVDevice.java
@@ -32,18 +32,18 @@
private static final Logger log = LoggerFactory.getLogger(KVDevice.class);
private static final ThreadLocal<Kryo> deviceKryo = new ThreadLocal<Kryo>() {
- @Override
- protected Kryo initialValue() {
- Kryo kryo = new Kryo();
- kryo.setRegistrationRequired(true);
- kryo.setReferences(false);
- kryo.register(byte[].class);
- kryo.register(byte[][].class);
- kryo.register(HashMap.class);
- // TODO check if we should explicitly specify EnumSerializer
- kryo.register(STATUS.class);
- return kryo;
- }
+ @Override
+ protected Kryo initialValue() {
+ Kryo kryo = new Kryo();
+ kryo.setRegistrationRequired(true);
+ kryo.setReferences(false);
+ kryo.register(byte[].class);
+ kryo.register(byte[][].class);
+ kryo.register(HashMap.class);
+ // TODO check if we should explicitly specify EnumSerializer
+ kryo.register(STATUS.class);
+ return kryo;
+ }
};
public static final String GLOBAL_DEVICE_TABLE_NAME = "G:Device";
@@ -58,25 +58,25 @@
// Assuming mac is unique cluster-wide
public static byte[] getDeviceID(final byte[] mac) {
- return DeviceEvent.getDeviceID(mac).array();
+ return DeviceEvent.getDeviceID(mac).array();
}
public static byte[] getMacFromKey(final byte[] key) {
- ByteBuffer keyBuf = ByteBuffer.wrap(key);
- if (keyBuf.getChar() != 'D') {
- throw new IllegalArgumentException("Invalid Device key");
- }
- byte[] mac = new byte[keyBuf.remaining()];
- keyBuf.get(mac);
- return mac;
+ ByteBuffer keyBuf = ByteBuffer.wrap(key);
+ if (keyBuf.getChar() != 'D') {
+ throw new IllegalArgumentException("Invalid Device key");
+ }
+ byte[] mac = new byte[keyBuf.remaining()];
+ keyBuf.get(mac);
+ return mac;
}
public KVDevice(final byte[] mac) {
- super(DataStoreClient.getClient().getTable(GLOBAL_DEVICE_TABLE_NAME), getDeviceID(mac));
+ super(DataStoreClient.getClient().getTable(GLOBAL_DEVICE_TABLE_NAME), getDeviceID(mac));
- this.mac = mac;
- this.portIds = new TreeSet<>(ByteArrayComparator.BYTEARRAY_COMPARATOR);
- this.isPortIdsModified = true;
+ this.mac = mac;
+ this.portIds = new TreeSet<>(ByteArrayComparator.BYTEARRAY_COMPARATOR);
+ this.isPortIdsModified = true;
}
/**
@@ -87,62 +87,62 @@
* @return
*/
public static KVDevice createFromKey(final byte[] key) {
- return new KVDevice(getMacFromKey(key));
+ return new KVDevice(getMacFromKey(key));
}
public static Iterable<KVDevice> getAllDevices() {
- return new DeviceEnumerator();
+ return new DeviceEnumerator();
}
public static class DeviceEnumerator implements Iterable<KVDevice> {
- @Override
- public Iterator<KVDevice> iterator() {
- return new DeviceIterator();
- }
+ @Override
+ public Iterator<KVDevice> iterator() {
+ return new DeviceIterator();
+ }
}
public static class DeviceIterator extends AbstractObjectIterator<KVDevice> {
- public DeviceIterator() {
- super(DataStoreClient.getClient().getTable(GLOBAL_DEVICE_TABLE_NAME));
- }
+ public DeviceIterator() {
+ super(DataStoreClient.getClient().getTable(GLOBAL_DEVICE_TABLE_NAME));
+ }
- @Override
- public KVDevice next() {
- IKVEntry o = enumerator.next();
- KVDevice e = KVDevice.createFromKey(o.getKey());
- e.deserialize(o.getValue(), o.getVersion());
- return e;
- }
+ @Override
+ public KVDevice next() {
+ IKVEntry o = enumerator.next();
+ KVDevice e = KVDevice.createFromKey(o.getKey());
+ e.deserialize(o.getValue(), o.getVersion());
+ return e;
+ }
}
public byte[] getMac() {
- // TODO may need to clone() to be sure this object will be immutable.
- return mac;
+ // TODO may need to clone() to be sure this object will be immutable.
+ return mac;
}
public byte[] getId() {
- return getKey();
+ return getKey();
}
public void addPortId(final byte[] portId) {
- // TODO: Should we copy portId, or reference is OK.
- isPortIdsModified |= portIds.add(portId);
+ // TODO: Should we copy portId, or reference is OK.
+ isPortIdsModified |= portIds.add(portId);
}
public void removePortId(final byte[] portId) {
- isPortIdsModified |= portIds.remove(portId);
+ isPortIdsModified |= portIds.remove(portId);
}
public void emptyPortIds() {
- portIds.clear();
- this.isPortIdsModified = true;
+ portIds.clear();
+ this.isPortIdsModified = true;
}
public void addAllToPortIds(final Collection<byte[]> portIds) {
- // TODO: Should we copy portId, or reference is OK.
- isPortIdsModified |= this.portIds.addAll(portIds);
+ // TODO: Should we copy portId, or reference is OK.
+ isPortIdsModified |= this.portIds.addAll(portIds);
}
/**
@@ -150,53 +150,53 @@
* @return Unmodifiable Set view of all the PortIds;
*/
public Set<byte[]> getAllPortIds() {
- return Collections.unmodifiableSet(portIds);
+ return Collections.unmodifiableSet(portIds);
}
@Override
public byte[] serialize() {
- Map<Object, Object> map = getPropertyMap();
+ Map<Object, Object> map = getPropertyMap();
- map.put(PROP_MAC, mac);
- if (isPortIdsModified) {
- byte[][] portIdArray = new byte[portIds.size()][];
- map.put(PROP_PORT_IDS, portIds.toArray(portIdArray));
- isPortIdsModified = false;
- }
+ map.put(PROP_MAC, mac);
+ if (isPortIdsModified) {
+ byte[][] portIdArray = new byte[portIds.size()][];
+ map.put(PROP_PORT_IDS, portIds.toArray(portIdArray));
+ isPortIdsModified = false;
+ }
- return serializePropertyMap(deviceKryo.get(), map);
+ return serializePropertyMap(deviceKryo.get(), map);
}
@Override
protected boolean deserialize(final byte[] bytes) {
- boolean success = deserializePropertyMap(deviceKryo.get(), bytes);
- if (!success) {
- log.error("Deserializing Link: " + this + " failed.");
- return false;
- }
- Map<Object, Object> map = this.getPropertyMap();
+ boolean success = deserializePropertyMap(deviceKryo.get(), bytes);
+ if (!success) {
+ log.error("Deserializing Link: " + this + " failed.");
+ return false;
+ }
+ Map<Object, Object> map = this.getPropertyMap();
- if (this.portIds == null) {
- this.portIds = new TreeSet<>(
- ByteArrayComparator.BYTEARRAY_COMPARATOR);
- }
- byte[][] portIdArray = (byte[][]) map.get(PROP_PORT_IDS);
- if (portIdArray != null) {
- this.portIds.clear();
- this.portIds.addAll(Arrays.asList(portIdArray));
- isPortIdsModified = false;
- } else {
- // trigger write on next serialize
- isPortIdsModified = true;
- }
+ if (this.portIds == null) {
+ this.portIds = new TreeSet<>(
+ ByteArrayComparator.BYTEARRAY_COMPARATOR);
+ }
+ byte[][] portIdArray = (byte[][]) map.get(PROP_PORT_IDS);
+ if (portIdArray != null) {
+ this.portIds.clear();
+ this.portIds.addAll(Arrays.asList(portIdArray));
+ isPortIdsModified = false;
+ } else {
+ // trigger write on next serialize
+ isPortIdsModified = true;
+ }
- return success;
+ return success;
}
@Override
public String toString() {
- // TODO output all properties?
- return "[" + this.getClass().getSimpleName()
- + " " + ByteArrayUtil.toHexStringBuffer(mac, ":") + "]";
+ // TODO output all properties?
+ return "[" + this.getClass().getSimpleName()
+ + " " + ByteArrayUtil.toHexStringBuffer(mac, ":") + "]";
}
}