More checkstyle fixes.
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
index e3de134..fc73374 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
@@ -228,76 +228,89 @@
@Override
public boolean putIfAbsent(String tableName, String key, byte[] value) {
- BatchWriteRequest batchRequest = new BatchWriteRequest.Builder().putIfAbsent(tableName, key, value).build();
+ BatchWriteRequest batchRequest = new BatchWriteRequest.Builder()
+ .putIfAbsent(tableName, key, value).build();
WriteResult writeResult = batchWrite(batchRequest).getAsList().get(0);
if (writeResult.status().equals(WriteStatus.OK)) {
return true;
} else if (writeResult.status().equals(WriteStatus.PRECONDITION_VIOLATION)) {
return false;
}
- throw new DatabaseException("putIfAbsent failed due to status: " + writeResult.status());
+ throw new DatabaseException("putIfAbsent failed due to status: "
+ + writeResult.status());
}
@Override
public boolean putIfVersionMatches(String tableName, String key,
byte[] value, long version) {
- BatchWriteRequest batchRequest = new BatchWriteRequest.Builder().putIfVersionMatches(tableName, key, value, version).build();
+ BatchWriteRequest batchRequest =
+ new BatchWriteRequest.Builder()
+ .putIfVersionMatches(tableName, key, value, version).build();
WriteResult writeResult = batchWrite(batchRequest).getAsList().get(0);
if (writeResult.status().equals(WriteStatus.OK)) {
return true;
} else if (writeResult.status().equals(WriteStatus.PRECONDITION_VIOLATION)) {
return false;
}
- throw new DatabaseException("putIfVersionMatches failed due to status: " + writeResult.status());
+ throw new DatabaseException("putIfVersionMatches failed due to status: "
+ + writeResult.status());
}
@Override
public boolean putIfValueMatches(String tableName, String key,
byte[] oldValue, byte[] newValue) {
- BatchWriteRequest batchRequest = new BatchWriteRequest.Builder().putIfValueMatches(tableName, key, oldValue, newValue).build();
+ BatchWriteRequest batchRequest = new BatchWriteRequest.Builder()
+ .putIfValueMatches(tableName, key, oldValue, newValue).build();
WriteResult writeResult = batchWrite(batchRequest).getAsList().get(0);
if (writeResult.status().equals(WriteStatus.OK)) {
return true;
} else if (writeResult.status().equals(WriteStatus.PRECONDITION_VIOLATION)) {
return false;
}
- throw new DatabaseException("putIfValueMatches failed due to status: " + writeResult.status());
+ throw new DatabaseException("putIfValueMatches failed due to status: "
+ + writeResult.status());
}
@Override
public VersionedValue remove(String tableName, String key) {
- BatchWriteRequest batchRequest = new BatchWriteRequest.Builder().remove(tableName, key).build();
+ BatchWriteRequest batchRequest = new BatchWriteRequest.Builder()
+ .remove(tableName, key).build();
WriteResult writeResult = batchWrite(batchRequest).getAsList().get(0);
if (writeResult.status().equals(WriteStatus.OK)) {
return writeResult.previousValue();
}
- throw new DatabaseException("remove failed due to status: " + writeResult.status());
+ throw new DatabaseException("remove failed due to status: "
+ + writeResult.status());
}
@Override
public boolean removeIfVersionMatches(String tableName, String key,
long version) {
- BatchWriteRequest batchRequest = new BatchWriteRequest.Builder().removeIfVersionMatches(tableName, key, version).build();
+ BatchWriteRequest batchRequest = new BatchWriteRequest.Builder()
+ .removeIfVersionMatches(tableName, key, version).build();
WriteResult writeResult = batchWrite(batchRequest).getAsList().get(0);
if (writeResult.status().equals(WriteStatus.OK)) {
return true;
} else if (writeResult.status().equals(WriteStatus.PRECONDITION_VIOLATION)) {
return false;
}
- throw new DatabaseException("removeIfVersionMatches failed due to status: " + writeResult.status());
+ throw new DatabaseException("removeIfVersionMatches failed due to status: "
+ + writeResult.status());
}
@Override
public boolean removeIfValueMatches(String tableName, String key,
byte[] value) {
- BatchWriteRequest batchRequest = new BatchWriteRequest.Builder().removeIfValueMatches(tableName, key, value).build();
+ BatchWriteRequest batchRequest = new BatchWriteRequest.Builder()
+ .removeIfValueMatches(tableName, key, value).build();
WriteResult writeResult = batchWrite(batchRequest).getAsList().get(0);
if (writeResult.status().equals(WriteStatus.OK)) {
return true;
} else if (writeResult.status().equals(WriteStatus.PRECONDITION_VIOLATION)) {
return false;
}
- throw new DatabaseException("removeIfValueMatches failed due to status: " + writeResult.status());
+ throw new DatabaseException("removeIfValueMatches failed due to status: "
+ + writeResult.status());
}
@Override
@@ -404,4 +417,4 @@
}
return null;
}
-}
+}
\ No newline at end of file
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
index 17b174c..7fc0ac0 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
@@ -47,7 +47,7 @@
private final Logger log = getLogger(getClass());
// message subject for database update notifications.
- public static MessageSubject DATABASE_UPDATE_EVENTS =
+ public static final MessageSubject DATABASE_UPDATE_EVENTS =
new MessageSubject("database-update-events");
// serializer used for snapshot
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventHandler.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventHandler.java
index 58d5446..5eca21f 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventHandler.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventHandler.java
@@ -38,11 +38,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DatabaseUpdateEventHandler implements DatabaseUpdateEventListener, EventHandler<LeaderElectEvent> {
+/**
+ * Database update event handler.
+ */
+public class DatabaseUpdateEventHandler implements
+ DatabaseUpdateEventListener, EventHandler<LeaderElectEvent> {
private final Logger log = LoggerFactory.getLogger(getClass());
- public final static MessageSubject DATABASE_UPDATES = new MessageSubject("database-update-event");
+ public static final MessageSubject DATABASE_UPDATES =
+ new MessageSubject("database-update-event");
private DatabaseService databaseService;
private ClusterService cluster;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventListener.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventListener.java
index f7b147f..d97191c 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventListener.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseUpdateEventListener.java
@@ -16,23 +16,26 @@
package org.onlab.onos.store.service.impl;
+/**
+ * Interface of database update event listeners.
+ */
public interface DatabaseUpdateEventListener {
-
+
/**
- *
- * @param event
+ * Notifies listeners of a table modified event.
+ * @param event table modification event.
*/
public void tableModified(TableModificationEvent event);
-
+
/**
- *
+ * Notifies listeners of a table created event.
* @param tableName
* @param expirationTimeMillis
*/
public void tableCreated(String tableName, int expirationTimeMillis);
-
+
/**
- *
+ * Notifies listeners of a table deleted event.
* @param tableName
*/
public void tableDeleted(String tableName);
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java
index eaae063..4a7367d 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java
@@ -69,7 +69,7 @@
public boolean tryLock(
long waitTimeMillis,
int leaseDurationMillis) {
- if (tryLock(leaseDurationMillis) == false) {
+ if (!tryLock(leaseDurationMillis)) {
CompletableFuture<Void> future =
lockManager.lockIfAvailable(this, waitTimeMillis, leaseDurationMillis);
try {
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java
index c87ab37..f83b042 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java
@@ -80,7 +80,10 @@
throw new UnsupportedOperationException();
}
- protected CompletableFuture<Void> lockIfAvailable(Lock lock, long waitTimeMillis, int leaseDurationMillis) {
+ protected CompletableFuture<Void> lockIfAvailable(
+ Lock lock,
+ long waitTimeMillis,
+ int leaseDurationMillis) {
CompletableFuture<Void> future = new CompletableFuture<>();
locksToAcquire.put(
lock.path(),
@@ -103,7 +106,9 @@
if (event.type() == TableModificationEvent.Type.ROW_DELETED) {
List<LockRequest> existingRequests = locksToAcquire.get(path);
- if (existingRequests == null) return;
+ if (existingRequests == null) {
+ return;
+ }
Iterator<LockRequest> existingRequestIterator = existingRequests.iterator();
while (existingRequestIterator.hasNext()) {
@@ -111,7 +116,7 @@
if (request.expirationTime().isAfter(DateTime.now())) {
existingRequestIterator.remove();
} else {
- if (request.lock().tryLock(request.leaseDurationMillis()) == true) {
+ if (request.lock().tryLock(request.leaseDurationMillis())) {
request.future().complete(null);
existingRequests.remove(0);
}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/TableModificationEvent.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/TableModificationEvent.java
index 25956de..885c9fa 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/TableModificationEvent.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/TableModificationEvent.java
@@ -1,25 +1,50 @@
package org.onlab.onos.store.service.impl;
-public class TableModificationEvent {
+/**
+ * A table modification event.
+ */
+public final class TableModificationEvent {
+ /**
+ * Type of table modification event.
+ *
+ */
public enum Type {
ROW_ADDED,
ROW_DELETED,
ROW_UPDATED
}
-
+
private final String tableName;
private final String key;
private final Type type;
+ /**
+ * Creates a new row deleted table modification event.
+ * @param tableName table name.
+ * @param key row key
+ * @return table modification event.
+ */
public static TableModificationEvent rowDeleted(String tableName, String key) {
return new TableModificationEvent(tableName, key, Type.ROW_DELETED);
}
-
+
+ /**
+ * Creates a new row added table modification event.
+ * @param tableName table name.
+ * @param key row key
+ * @return table modification event.
+ */
public static TableModificationEvent rowAdded(String tableName, String key) {
return new TableModificationEvent(tableName, key, Type.ROW_ADDED);
}
-
+
+ /**
+ * Creates a new row updated table modification event.
+ * @param tableName table name.
+ * @param key row key
+ * @return table modification event.
+ */
public static TableModificationEvent rowUpdated(String tableName, String key) {
return new TableModificationEvent(tableName, key, Type.ROW_UPDATED);
}
@@ -30,14 +55,26 @@
this.type = type;
}
+ /**
+ * Returns name of table this event is for.
+ * @return table name
+ */
public String tableName() {
return tableName;
}
+ /**
+ * Returns the row key this event is for.
+ * @return row key
+ */
public String key() {
return key;
}
+ /**
+ * Returns the type of table modification event.
+ * @return event type.
+ */
public Type type() {
return type;
}