Removed dead code
diff --git a/core/api/src/main/java/org/onlab/onos/store/service/OptimisticLockException.java b/core/api/src/main/java/org/onlab/onos/store/service/OptimisticLockException.java
deleted file mode 100644
index 090eb63..0000000
--- a/core/api/src/main/java/org/onlab/onos/store/service/OptimisticLockException.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.onlab.onos.store.service;
-
-/**
- * Exception that indicates a optimistic lock failure.
- */
-@SuppressWarnings("serial")
-public class OptimisticLockException extends PreconditionFailedException {
-}
diff --git a/core/api/src/main/java/org/onlab/onos/store/service/PreconditionFailedException.java b/core/api/src/main/java/org/onlab/onos/store/service/PreconditionFailedException.java
deleted file mode 100644
index 8a631a0..0000000
--- a/core/api/src/main/java/org/onlab/onos/store/service/PreconditionFailedException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.onlab.onos.store.service;
-
-/**
- * Exception that indicates a precondition failure.
- * Scenarios that can cause this exception:
- * <ul>
- * <li>An operation that attempts to write a new value iff the current value is equal
- * to some specified value.</li>
- * <li>An operation that attempts to write a new value iff the current version
- * matches a specified value</li>
- * </ul>
- */
-@SuppressWarnings("serial")
-public class PreconditionFailedException extends DatabaseException {
-}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onlab/onos/store/service/ReadStatus.java b/core/api/src/main/java/org/onlab/onos/store/service/ReadStatus.java
index 72ed356..8d8c6a3 100644
--- a/core/api/src/main/java/org/onlab/onos/store/service/ReadStatus.java
+++ b/core/api/src/main/java/org/onlab/onos/store/service/ReadStatus.java
@@ -1,6 +1,17 @@
package org.onlab.onos.store.service;
+/**
+ * Status of completed read request.
+ */
public enum ReadStatus {
- OK,
+
+ /**
+ * Read completed successfully.
+ */
+ OK,
+
+ /**
+ * Read failed due to an invalid table name being specified.
+ */
NO_SUCH_TABLE
}
diff --git a/core/api/src/main/java/org/onlab/onos/store/service/WriteAborted.java b/core/api/src/main/java/org/onlab/onos/store/service/WriteAborted.java
deleted file mode 100644
index a2ebd2a..0000000
--- a/core/api/src/main/java/org/onlab/onos/store/service/WriteAborted.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.onlab.onos.store.service;
-
-
-/**
- * Exception that indicates a write operation is aborted.
- * Aborted operations do not mutate database state is any form.
- */
-@SuppressWarnings("serial")
-public class WriteAborted extends DatabaseException {
-}
diff --git a/core/api/src/main/java/org/onlab/onos/store/service/WriteStatus.java b/core/api/src/main/java/org/onlab/onos/store/service/WriteStatus.java
index 8c9990a..2267838 100644
--- a/core/api/src/main/java/org/onlab/onos/store/service/WriteStatus.java
+++ b/core/api/src/main/java/org/onlab/onos/store/service/WriteStatus.java
@@ -1,8 +1,27 @@
package org.onlab.onos.store.service;
+/**
+ * Status of completed write request.
+ */
public enum WriteStatus {
+
+ /**
+ * Write completed successfully.
+ */
OK,
+
+ /**
+ * Write was aborted (ex: if one or more write operations in a batch fail, others are aborted)
+ */
ABORTED,
+
+ /**
+ * Write failed due to pre-condition failure. (ex: version or value mis-match)
+ */
PRECONDITION_VIOLATION,
+
+ /**
+ * Write failed due to an invalid table name being specified.
+ */
NO_SUCH_TABLE,
}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/ClusterMessagingProtocol.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/ClusterMessagingProtocol.java
index e16838d..0ba67cf 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/ClusterMessagingProtocol.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/ClusterMessagingProtocol.java
@@ -111,16 +111,12 @@
.register(ReadRequest.class)
.register(WriteRequest.class)
.register(WriteRequest.Type.class)
- .register(InternalReadResult.class)
- .register(InternalWriteResult.class)
- .register(InternalReadResult.Status.class)
.register(WriteResult.class)
.register(ReadResult.class)
.register(BatchReadRequest.class)
.register(BatchWriteRequest.class)
.register(ReadStatus.class)
.register(WriteStatus.class)
- .register(InternalWriteResult.Status.class)
.register(VersionedValue.class)
.build();
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 4a7367d..c466941 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
@@ -11,7 +11,6 @@
import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.store.service.DatabaseService;
import org.onlab.onos.store.service.Lock;
-import org.onlab.onos.store.service.OptimisticLockException;
/**
* A distributed lock implementation.
@@ -57,12 +56,10 @@
@Override
public boolean tryLock(int leaseDurationMillis) {
- try {
- databaseService.putIfAbsent(DistributedLockManager.ONOS_LOCK_TABLE_NAME, path, lockId);
- return true;
- } catch (OptimisticLockException e) {
- return false;
- }
+ return databaseService.putIfAbsent(
+ DistributedLockManager.ONOS_LOCK_TABLE_NAME,
+ path,
+ lockId);
}
@Override
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalReadResult.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalReadResult.java
deleted file mode 100644
index d016ba1..0000000
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalReadResult.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.onlab.onos.store.service.impl;
-
-import java.io.Serializable;
-
-import org.onlab.onos.store.service.ReadResult;
-
-/**
- * Result of a read operation executed on the DatabaseStateMachine.
- */
-@SuppressWarnings("serial")
-public class InternalReadResult implements Serializable {
-
- public enum Status {
- OK,
- NO_SUCH_TABLE
- }
-
- private final Status status;
- private final ReadResult result;
-
- public InternalReadResult(Status status, ReadResult result) {
- this.status = status;
- this.result = result;
- }
-
- public Status status() {
- return status;
- }
-
- public ReadResult result() {
- return result;
- }
-
- @Override
- public String toString() {
- return "InternalReadResult [status=" + status + ", result=" + result
- + "]";
- }
-}
\ No newline at end of file
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java
deleted file mode 100644
index e936f48..0000000
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.onlab.onos.store.service.impl;
-
-import org.onlab.onos.store.service.WriteResult;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Result of a write operation executed on the DatabaseStateMachine.
- */
-public class InternalWriteResult {
-
- public enum Status {
- OK,
- ABORTED,
- NO_SUCH_TABLE,
- PREVIOUS_VERSION_MISMATCH,
- PREVIOUS_VALUE_MISMATCH
- }
-
- private final Status status;
- private final WriteResult result;
-
- public static InternalWriteResult ok(WriteResult result) {
- return new InternalWriteResult(Status.OK, result);
- }
-
- public InternalWriteResult(Status status, WriteResult result) {
- this.status = status;
- this.result = result;
- }
-
- public Status status() {
- return status;
- }
-
- public WriteResult result() {
- return result;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("status", status)
- .add("result", result)
- .toString();
- }
-}