Madan Jampani

Removed dead code

package org.onlab.onos.store.service;
/**
* Exception that indicates a optimistic lock failure.
*/
@SuppressWarnings("serial")
public class OptimisticLockException extends PreconditionFailedException {
}
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
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
}
......
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 {
}
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,
}
......
......@@ -111,16 +111,12 @@ public class ClusterMessagingProtocol
.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();
......
......@@ -11,7 +11,6 @@ import org.joda.time.DateTime;
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 @@ public class DistributedLock implements Lock {
@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
......
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
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();
}
}