Eliminate tab character from datastore package
Change-Id: I6eea92ce72268c4ca90f1bd24bdccf7edf4cbb7f
diff --git a/src/main/java/net/onrc/onos/datastore/topology/KVPort.java b/src/main/java/net/onrc/onos/datastore/topology/KVPort.java
index 3b66864..452bf94 100644
--- a/src/main/java/net/onrc/onos/datastore/topology/KVPort.java
+++ b/src/main/java/net/onrc/onos/datastore/topology/KVPort.java
@@ -30,25 +30,25 @@
private static final Logger log = LoggerFactory.getLogger(KVPort.class);
private static final ThreadLocal<Kryo> portKryo = 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_PORT_TABLE_NAME = "G:Port";
// must not re-order enum members, ordinal will be sent over wire
public enum STATUS {
- INACTIVE, ACTIVE;
+ INACTIVE, ACTIVE;
}
private final Long dpid;
@@ -57,49 +57,49 @@
private STATUS status;
public static byte[] getPortID(final Long dpid, final Long number) {
- return PortEvent.getPortID(dpid, number).array();
+ return PortEvent.getPortID(dpid, number).array();
}
public static long[] getPortPairFromKey(final byte[] key) {
- return getPortPairFromKey(ByteBuffer.wrap(key));
+ return getPortPairFromKey(ByteBuffer.wrap(key));
}
public static long[] getPortPairFromKey(final ByteBuffer keyBuf) {
- long[] pair = new long[2];
- if (keyBuf.getChar() != 'S') {
- throw new IllegalArgumentException("Invalid Port key:" + keyBuf
- + " "
- + ByteArrayUtil.toHexStringBuffer(keyBuf.array(), ":"));
- }
- pair[0] = keyBuf.getLong();
- if (keyBuf.getChar() != 'P') {
- throw new IllegalArgumentException("Invalid Port key:" + keyBuf
- + " "
- + ByteArrayUtil.toHexStringBuffer(keyBuf.array(), ":"));
- }
- pair[1] = keyBuf.getLong();
- return pair;
+ long[] pair = new long[2];
+ if (keyBuf.getChar() != 'S') {
+ throw new IllegalArgumentException("Invalid Port key:" + keyBuf
+ + " "
+ + ByteArrayUtil.toHexStringBuffer(keyBuf.array(), ":"));
+ }
+ pair[0] = keyBuf.getLong();
+ if (keyBuf.getChar() != 'P') {
+ throw new IllegalArgumentException("Invalid Port key:" + keyBuf
+ + " "
+ + ByteArrayUtil.toHexStringBuffer(keyBuf.array(), ":"));
+ }
+ pair[1] = keyBuf.getLong();
+ return pair;
}
public static long getDpidFromKey(final byte[] key) {
- return getPortPairFromKey(key)[0];
+ return getPortPairFromKey(key)[0];
}
public static long getNumberFromKey(final byte[] key) {
- return getPortPairFromKey(key)[1];
+ return getPortPairFromKey(key)[1];
}
// FIXME specify DPID,number here, or Should caller specify the key it self?
// In other words, should layer above have the control of the ID?
public KVPort(final Long dpid, final Long number) {
- super(DataStoreClient.getClient().getTable(GLOBAL_PORT_TABLE_NAME), getPortID(dpid, number));
+ super(DataStoreClient.getClient().getTable(GLOBAL_PORT_TABLE_NAME), getPortID(dpid, number));
- // TODO Auto-generated constructor stub
+ // TODO Auto-generated constructor stub
- this.dpid = dpid;
- this.number = number;
- this.status = STATUS.INACTIVE;
+ this.dpid = dpid;
+ this.number = number;
+ this.status = STATUS.INACTIVE;
}
/**
@@ -110,96 +110,96 @@
* @return KVPort instance
*/
public static KVPort createFromKey(final byte[] key) {
- long[] pair = getPortPairFromKey(key);
- return new KVPort(pair[0], pair[1]);
+ long[] pair = getPortPairFromKey(key);
+ return new KVPort(pair[0], pair[1]);
}
public static Iterable<KVPort> getAllPorts() {
- return new PortEnumerator();
+ return new PortEnumerator();
}
public static class PortEnumerator implements Iterable<KVPort> {
- @Override
- public Iterator<KVPort> iterator() {
- return new PortIterator();
- }
+ @Override
+ public Iterator<KVPort> iterator() {
+ return new PortIterator();
+ }
}
public static class PortIterator extends AbstractObjectIterator<KVPort> {
- public PortIterator() {
- super(DataStoreClient.getClient().getTable(GLOBAL_PORT_TABLE_NAME));
- }
+ public PortIterator() {
+ super(DataStoreClient.getClient().getTable(GLOBAL_PORT_TABLE_NAME));
+ }
- @Override
- public KVPort next() {
- IKVEntry o = enumerator.next();
- KVPort e = KVPort.createFromKey(o.getKey());
- e.deserialize(o.getValue(), o.getVersion());
- return e;
- }
+ @Override
+ public KVPort next() {
+ IKVEntry o = enumerator.next();
+ KVPort e = KVPort.createFromKey(o.getKey());
+ e.deserialize(o.getValue(), o.getVersion());
+ return e;
+ }
}
public STATUS getStatus() {
- return status;
+ return status;
}
public void setStatus(final STATUS status) {
- this.status = status;
+ this.status = status;
}
public Long getDpid() {
- return dpid;
+ return dpid;
}
public Long getNumber() {
- return number;
+ return number;
}
public byte[] getId() {
- return getKey();
+ return getKey();
}
@Override
public byte[] serialize() {
- Map<Object, Object> map = getPropertyMap();
+ Map<Object, Object> map = getPropertyMap();
- PortProperty.Builder port = PortProperty.newBuilder();
- port.setDpid(dpid);
- port.setNumber(number);
- port.setStatus(status.ordinal());
+ PortProperty.Builder port = PortProperty.newBuilder();
+ port.setDpid(dpid);
+ port.setNumber(number);
+ port.setStatus(status.ordinal());
- if (!map.isEmpty()) {
- byte[] propMaps = serializePropertyMap(portKryo.get(), map);
- port.setValue(ByteString.copyFrom(propMaps));
- }
+ if (!map.isEmpty()) {
+ byte[] propMaps = serializePropertyMap(portKryo.get(), map);
+ port.setValue(ByteString.copyFrom(propMaps));
+ }
- return port.build().toByteArray();
+ return port.build().toByteArray();
}
@Override
protected boolean deserialize(final byte[] bytes) {
- try {
- boolean success = true;
+ try {
+ boolean success = true;
- PortProperty port = PortProperty.parseFrom(bytes);
- byte[] props = port.getValue().toByteArray();
- success &= deserializePropertyMap(portKryo.get(), props);
- this.status = STATUS.values()[port.getStatus()];
+ PortProperty port = PortProperty.parseFrom(bytes);
+ byte[] props = port.getValue().toByteArray();
+ success &= deserializePropertyMap(portKryo.get(), props);
+ this.status = STATUS.values()[port.getStatus()];
- return success;
- } catch (InvalidProtocolBufferException e) {
- log.error("Deserializing Port: " + this + " failed.", e);
- return false;
- }
+ return success;
+ } catch (InvalidProtocolBufferException e) {
+ log.error("Deserializing Port: " + this + " failed.", e);
+ return false;
+ }
}
@Override
public String toString() {
- // TODO output all properties?
- return "[" + this.getClass().getSimpleName()
- + " 0x" + Long.toHexString(dpid) + "@" + number
- + " STATUS:" + status + "]";
+ // TODO output all properties?
+ return "[" + this.getClass().getSimpleName()
+ + " 0x" + Long.toHexString(dpid) + "@" + number
+ + " STATUS:" + status + "]";
}
}