Madan Jampani

Javadoc fixess

......@@ -3,7 +3,7 @@ package org.onlab.onos.store.service;
import java.util.List;
/**
* Service for running administrative tasks on a Database.
* Service interface for running administrative tasks on a Database.
*/
public interface DatabaseAdminService {
......
......@@ -2,13 +2,17 @@ package org.onlab.onos.store.service;
import java.util.List;
/**
* Service interface for a strongly consistent and durable
* key value data store.
*/
public interface DatabaseService {
/**
* Performs a read on the database.
* @param request read request.
* @return ReadResult
* @throws DatabaseException
* @throws DatabaseException if there is a failure in executing read.
*/
ReadResult read(ReadRequest request);
......@@ -16,7 +20,7 @@ public interface DatabaseService {
* Performs a batch read operation on the database.
* The main advantage of batch read operation is parallelization.
* @param batch batch of read requests to execute.
* @return
* @return batch read result.
*/
List<OptionalResult<ReadResult, DatabaseException>> batchRead(List<ReadRequest> batch);
......@@ -24,7 +28,7 @@ public interface DatabaseService {
* Performs a write operation on the database.
* @param request
* @return write result.
* @throws DatabaseException
* @throws DatabaseException if there is failure in execution write.
*/
WriteResult write(WriteRequest request);
......
......@@ -5,16 +5,16 @@ package org.onlab.onos.store.service;
* <p>
* If a result is present, get() will return it otherwise get() will throw
* the exception that was encountered in the process of generating the result.
*
* </p>
* @param <R> type of result.
* @param <E> exception encountered in generating the result.
*/
public interface OptionalResult<R, E extends Throwable> {
/**
* Returns the result.
* Returns the result or throws an exception if there is no
* valid result.
* @return result
* @throws E if there is no valid result.
*/
public R get();
......
......@@ -2,7 +2,8 @@ package org.onlab.onos.store.service;
/**
* Exception that indicates a precondition failure.
* <ul>Scenarios that can cause this exception:
* 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
......@@ -11,4 +12,4 @@ package org.onlab.onos.store.service;
*/
@SuppressWarnings("serial")
public class PreconditionFailedException extends DatabaseException {
}
}
\ No newline at end of file
......
package org.onlab.onos.store.service;
import org.onlab.onos.store.service.impl.VersionedValue;
/**
* Database read result.
......
package org.onlab.onos.store.service;
import org.onlab.onos.store.service.impl.VersionedValue;
/**
* Database write result.
......
......@@ -12,6 +12,7 @@ import net.kuujo.copycat.StateMachine;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.onos.store.service.ReadRequest;
import org.onlab.onos.store.service.ReadResult;
import org.onlab.onos.store.service.VersionedValue;
import org.onlab.onos.store.service.WriteRequest;
import org.onlab.onos.store.service.WriteResult;
import org.onlab.util.KryoNamespace;
......
......@@ -33,6 +33,7 @@ import org.onlab.onos.store.serializers.ImmutableSetSerializer;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.onos.store.service.ReadRequest;
import org.onlab.onos.store.service.ReadResult;
import org.onlab.onos.store.service.VersionedValue;
import org.onlab.onos.store.service.WriteRequest;
import org.onlab.onos.store.service.WriteResult;
import org.onlab.util.KryoNamespace;
......
package org.onlab.onos.store.service.impl;
import java.util.Arrays;
/**
* Wrapper object that holds the object (as byte array) and its version.
*/
public class VersionedValue {
private final byte[] value;
private final long version;
/**
* Creates a new instance with the specified value and version.
* @param value
* @param version
*/
public VersionedValue(byte[] value, long version) {
this.value = value;
this.version = version;
}
/**
* Returns the value.
* @return value.
*/
public byte[] value() {
return value;
}
/**
* Returns the version.
* @return version.
*/
public long version() {
return version;
}
@Override
public String toString() {
return "VersionedValue [value=" + Arrays.toString(value) + ", version="
+ version + "]";
}
}