Showing
10 changed files
with
227 additions
and
201 deletions
| ... | @@ -8,63 +8,63 @@ import com.google.common.collect.Lists; | ... | @@ -8,63 +8,63 @@ import com.google.common.collect.Lists; |
| 8 | /** | 8 | /** |
| 9 | * Collection of read requests to be submitted as one batch. | 9 | * Collection of read requests to be submitted as one batch. |
| 10 | */ | 10 | */ |
| 11 | -public class BatchReadRequest { | 11 | +public final class BatchReadRequest { |
| 12 | 12 | ||
| 13 | - private final List<ReadRequest> readRequests; | 13 | + private final List<ReadRequest> readRequests; |
| 14 | 14 | ||
| 15 | - /** | 15 | + /** |
| 16 | - * Creates a new BatchReadRequest object from the specified list of read requests. | 16 | + * Creates a new BatchReadRequest object from the specified list of read requests. |
| 17 | - * @param readRequests read requests. | 17 | + * @param readRequests read requests. |
| 18 | - * @return BatchReadRequest object. | 18 | + * @return BatchReadRequest object. |
| 19 | - */ | 19 | + */ |
| 20 | - public static BatchReadRequest create(List<ReadRequest> readRequests) { | 20 | + public static BatchReadRequest create(List<ReadRequest> readRequests) { |
| 21 | - return new BatchReadRequest(readRequests); | 21 | + return new BatchReadRequest(readRequests); |
| 22 | - } | 22 | + } |
| 23 | 23 | ||
| 24 | - private BatchReadRequest(List<ReadRequest> readRequests) { | 24 | + private BatchReadRequest(List<ReadRequest> readRequests) { |
| 25 | - this.readRequests = Collections.unmodifiableList(readRequests); | 25 | + this.readRequests = Collections.unmodifiableList(readRequests); |
| 26 | - } | 26 | + } |
| 27 | 27 | ||
| 28 | - /** | 28 | + /** |
| 29 | - * Returns the number of requests in this batch. | 29 | + * Returns the number of requests in this batch. |
| 30 | - * @return size of request batch. | 30 | + * @return size of request batch. |
| 31 | - */ | 31 | + */ |
| 32 | - public int batchSize() { | 32 | + public int batchSize() { |
| 33 | - return readRequests.size(); | 33 | + return readRequests.size(); |
| 34 | - } | 34 | + } |
| 35 | 35 | ||
| 36 | - /** | 36 | + /** |
| 37 | - * Returns the requests in this batch as a list. | 37 | + * Returns the requests in this batch as a list. |
| 38 | - * @return list of read requests | 38 | + * @return list of read requests |
| 39 | - */ | 39 | + */ |
| 40 | - public List<ReadRequest> getAsList() { | 40 | + public List<ReadRequest> getAsList() { |
| 41 | - return readRequests; | 41 | + return readRequests; |
| 42 | - } | 42 | + } |
| 43 | 43 | ||
| 44 | - /** | 44 | + /** |
| 45 | - * Builder for BatchReadRequest. | 45 | + * Builder for BatchReadRequest. |
| 46 | - */ | 46 | + */ |
| 47 | - public static class Builder { | 47 | + public static class Builder { |
| 48 | 48 | ||
| 49 | - private final List<ReadRequest> readRequests = Lists.newLinkedList(); | 49 | + private final List<ReadRequest> readRequests = Lists.newLinkedList(); |
| 50 | 50 | ||
| 51 | - /** | 51 | + /** |
| 52 | - * Append a get request. | 52 | + * Append a get request. |
| 53 | - * @param tableName table name | 53 | + * @param tableName table name |
| 54 | - * @param key key to fetch. | 54 | + * @param key key to fetch. |
| 55 | - * @return this Builder | 55 | + * @return this Builder |
| 56 | - */ | 56 | + */ |
| 57 | - public Builder get(String tableName, String key) { | 57 | + public Builder get(String tableName, String key) { |
| 58 | - readRequests.add(new ReadRequest(tableName, key)); | 58 | + readRequests.add(new ReadRequest(tableName, key)); |
| 59 | - return this; | 59 | + return this; |
| 60 | - } | 60 | + } |
| 61 | 61 | ||
| 62 | - /** | ||
| 63 | - * Builds a BatchReadRequest | ||
| 64 | - * @return BatchReadRequest | ||
| 65 | - */ | ||
| 66 | - public BatchReadRequest build() { | ||
| 67 | - return new BatchReadRequest(readRequests); | ||
| 68 | - } | ||
| 69 | - } | ||
| 70 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 62 | + /** | ||
| 63 | + * Builds a BatchReadRequest. | ||
| 64 | + * @return BatchReadRequest | ||
| 65 | + */ | ||
| 66 | + public BatchReadRequest build() { | ||
| 67 | + return new BatchReadRequest(readRequests); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | +} | ... | ... |
| ... | @@ -3,19 +3,30 @@ package org.onlab.onos.store.service; | ... | @@ -3,19 +3,30 @@ package org.onlab.onos.store.service; |
| 3 | import java.util.Collections; | 3 | import java.util.Collections; |
| 4 | import java.util.List; | 4 | import java.util.List; |
| 5 | 5 | ||
| 6 | +/** | ||
| 7 | + * Result of a batch read operation. | ||
| 8 | + */ | ||
| 6 | public class BatchReadResult { | 9 | public class BatchReadResult { |
| 7 | - | ||
| 8 | - private final List<ReadResult> readResults; | ||
| 9 | - | ||
| 10 | - public BatchReadResult(List<ReadResult> readResults) { | ||
| 11 | - this.readResults = Collections.unmodifiableList(readResults); | ||
| 12 | - } | ||
| 13 | - | ||
| 14 | - public List<ReadResult> getAsList() { | ||
| 15 | - return readResults; | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - public int batchSize() { | ||
| 19 | - return readResults.size(); | ||
| 20 | - } | ||
| 21 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 10 | + | ||
| 11 | + private final List<ReadResult> readResults; | ||
| 12 | + | ||
| 13 | + public BatchReadResult(List<ReadResult> readResults) { | ||
| 14 | + this.readResults = Collections.unmodifiableList(readResults); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * Returns the results as a list. | ||
| 19 | + * @return list of results | ||
| 20 | + */ | ||
| 21 | + public List<ReadResult> getAsList() { | ||
| 22 | + return readResults; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * Returns the batch size. | ||
| 27 | + * @return batch size | ||
| 28 | + */ | ||
| 29 | + public int batchSize() { | ||
| 30 | + return readResults.size(); | ||
| 31 | + } | ||
| 32 | +} | ... | ... |
| ... | @@ -8,83 +8,83 @@ import com.google.common.collect.Lists; | ... | @@ -8,83 +8,83 @@ import com.google.common.collect.Lists; |
| 8 | /** | 8 | /** |
| 9 | * Collection of write requests to be submitted as one batch. | 9 | * Collection of write requests to be submitted as one batch. |
| 10 | */ | 10 | */ |
| 11 | -public class BatchWriteRequest { | ||
| 12 | - | ||
| 13 | - private final List<WriteRequest> writeRequests; | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * Creates a new BatchWriteRequest object from the specified list of write requests. | ||
| 17 | - * @param writeRequests write requests. | ||
| 18 | - * @return BatchWriteRequest object. | ||
| 19 | - */ | ||
| 20 | - public static BatchWriteRequest create(List<WriteRequest> writeRequests) { | ||
| 21 | - return new BatchWriteRequest(writeRequests); | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - private BatchWriteRequest(List<WriteRequest> writeRequests) { | ||
| 25 | - this.writeRequests = Collections.unmodifiableList(writeRequests); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - /** | ||
| 29 | - * Returns the requests in this batch as a list. | ||
| 30 | - * @return list of write requests | ||
| 31 | - */ | ||
| 32 | - public List<WriteRequest> getAsList() { | ||
| 33 | - return writeRequests; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * Returns the number of requests in this batch. | ||
| 38 | - * @return size of request batch. | ||
| 39 | - */ | ||
| 40 | - public int batchSize() { | ||
| 41 | - return writeRequests.size(); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | - * Builder for BatchWriteRequest. | ||
| 46 | - */ | ||
| 47 | - public static class Builder { | ||
| 48 | - | ||
| 49 | - private final List<WriteRequest> writeRequests = Lists.newLinkedList(); | ||
| 50 | - | ||
| 51 | - public Builder put(String tableName, String key, byte[] value) { | ||
| 52 | - writeRequests.add(WriteRequest.put(tableName, key, value)); | ||
| 53 | - return this; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - public Builder putIfAbsent(String tableName, String key, byte[] value) { | ||
| 57 | - writeRequests.add(WriteRequest.putIfAbsent(tableName, key, value)); | ||
| 58 | - return this; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - public Builder putIfValueMatches(String tableName, String key, byte[] oldValue, byte[] newValue) { | ||
| 62 | - writeRequests.add(WriteRequest.putIfValueMatches(tableName, key, oldValue, newValue)); | ||
| 63 | - return this; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - public Builder putIfVersionMatches(String tableName, String key, byte[] value, long version) { | ||
| 67 | - writeRequests.add(WriteRequest.putIfVersionMatches(tableName, key, value, version)); | ||
| 68 | - return this; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - public Builder remove(String tableName, String key) { | ||
| 72 | - writeRequests.add(WriteRequest.remove(tableName, key)); | ||
| 73 | - return this; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - public Builder removeIfVersionMatches(String tableName, String key, long version) { | ||
| 77 | - writeRequests.add(WriteRequest.removeIfVersionMatches(tableName, key, version)); | ||
| 78 | - return this; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - public Builder removeIfValueMatches(String tableName, String key, byte[] value) { | ||
| 82 | - writeRequests.add(WriteRequest.removeIfValueMatches(tableName, key, value)); | ||
| 83 | - return this; | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - public BatchWriteRequest build() { | ||
| 87 | - return new BatchWriteRequest(writeRequests); | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 11 | +public final class BatchWriteRequest { | ||
| 12 | + | ||
| 13 | + private final List<WriteRequest> writeRequests; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * Creates a new BatchWriteRequest object from the specified list of write requests. | ||
| 17 | + * @param writeRequests write requests. | ||
| 18 | + * @return BatchWriteRequest object. | ||
| 19 | + */ | ||
| 20 | + public static BatchWriteRequest create(List<WriteRequest> writeRequests) { | ||
| 21 | + return new BatchWriteRequest(writeRequests); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + private BatchWriteRequest(List<WriteRequest> writeRequests) { | ||
| 25 | + this.writeRequests = Collections.unmodifiableList(writeRequests); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Returns the requests in this batch as a list. | ||
| 30 | + * @return list of write requests | ||
| 31 | + */ | ||
| 32 | + public List<WriteRequest> getAsList() { | ||
| 33 | + return writeRequests; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Returns the number of requests in this batch. | ||
| 38 | + * @return size of request batch. | ||
| 39 | + */ | ||
| 40 | + public int batchSize() { | ||
| 41 | + return writeRequests.size(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Builder for BatchWriteRequest. | ||
| 46 | + */ | ||
| 47 | + public static class Builder { | ||
| 48 | + | ||
| 49 | + private final List<WriteRequest> writeRequests = Lists.newLinkedList(); | ||
| 50 | + | ||
| 51 | + public Builder put(String tableName, String key, byte[] value) { | ||
| 52 | + writeRequests.add(WriteRequest.put(tableName, key, value)); | ||
| 53 | + return this; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public Builder putIfAbsent(String tableName, String key, byte[] value) { | ||
| 57 | + writeRequests.add(WriteRequest.putIfAbsent(tableName, key, value)); | ||
| 58 | + return this; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public Builder putIfValueMatches(String tableName, String key, byte[] oldValue, byte[] newValue) { | ||
| 62 | + writeRequests.add(WriteRequest.putIfValueMatches(tableName, key, oldValue, newValue)); | ||
| 63 | + return this; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public Builder putIfVersionMatches(String tableName, String key, byte[] value, long version) { | ||
| 67 | + writeRequests.add(WriteRequest.putIfVersionMatches(tableName, key, value, version)); | ||
| 68 | + return this; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public Builder remove(String tableName, String key) { | ||
| 72 | + writeRequests.add(WriteRequest.remove(tableName, key)); | ||
| 73 | + return this; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public Builder removeIfVersionMatches(String tableName, String key, long version) { | ||
| 77 | + writeRequests.add(WriteRequest.removeIfVersionMatches(tableName, key, version)); | ||
| 78 | + return this; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public Builder removeIfValueMatches(String tableName, String key, byte[] value) { | ||
| 82 | + writeRequests.add(WriteRequest.removeIfValueMatches(tableName, key, value)); | ||
| 83 | + return this; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public BatchWriteRequest build() { | ||
| 87 | + return new BatchWriteRequest(writeRequests); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | +} | ... | ... |
| ... | @@ -3,28 +3,43 @@ package org.onlab.onos.store.service; | ... | @@ -3,28 +3,43 @@ package org.onlab.onos.store.service; |
| 3 | import java.util.Collections; | 3 | import java.util.Collections; |
| 4 | import java.util.List; | 4 | import java.util.List; |
| 5 | 5 | ||
| 6 | +/** | ||
| 7 | + * Result of a batch write operation. | ||
| 8 | + */ | ||
| 6 | public class BatchWriteResult { | 9 | public class BatchWriteResult { |
| 7 | - | ||
| 8 | - private final List<WriteResult> writeResults; | ||
| 9 | - | ||
| 10 | - public BatchWriteResult(List<WriteResult> writeResults) { | ||
| 11 | - this.writeResults = Collections.unmodifiableList(writeResults); | ||
| 12 | - } | ||
| 13 | - | ||
| 14 | - public boolean isSuccessful() { | ||
| 15 | - for (WriteResult result : writeResults) { | ||
| 16 | - if (result.status() != WriteStatus.OK) { | ||
| 17 | - return false; | ||
| 18 | - } | ||
| 19 | - } | ||
| 20 | - return true; | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - public List<WriteResult> getAsList() { | ||
| 24 | - return this.writeResults; | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - public int batchSize() { | ||
| 28 | - return writeResults.size(); | ||
| 29 | - } | ||
| 30 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 10 | + | ||
| 11 | + private final List<WriteResult> writeResults; | ||
| 12 | + | ||
| 13 | + public BatchWriteResult(List<WriteResult> writeResults) { | ||
| 14 | + this.writeResults = Collections.unmodifiableList(writeResults); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * Returns true if this batch write operation was successful. | ||
| 19 | + * @return true if successful, false otherwise. | ||
| 20 | + */ | ||
| 21 | + public boolean isSuccessful() { | ||
| 22 | + for (WriteResult result : writeResults) { | ||
| 23 | + if (result.status() != WriteStatus.OK) { | ||
| 24 | + return false; | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + return true; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Returns the results as a List. | ||
| 32 | + * @return list of batch results. | ||
| 33 | + */ | ||
| 34 | + public List<WriteResult> getAsList() { | ||
| 35 | + return this.writeResults; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Returns the size of this batch. | ||
| 40 | + * @return batch size. | ||
| 41 | + */ | ||
| 42 | + public int batchSize() { | ||
| 43 | + return writeResults.size(); | ||
| 44 | + } | ||
| 45 | +} | ... | ... |
| ... | @@ -13,7 +13,7 @@ public interface DatabaseService { | ... | @@ -13,7 +13,7 @@ public interface DatabaseService { |
| 13 | * @returns value (and version) associated with this key. This calls returns null if the key does not exist. | 13 | * @returns value (and version) associated with this key. This calls returns null if the key does not exist. |
| 14 | */ | 14 | */ |
| 15 | VersionedValue get(String tableName, String key); | 15 | VersionedValue get(String tableName, String key); |
| 16 | - | 16 | + |
| 17 | /** | 17 | /** |
| 18 | * Associate the key with a value. | 18 | * Associate the key with a value. |
| 19 | * @param tableName table name in which this key/value resides. | 19 | * @param tableName table name in which this key/value resides. |
| ... | @@ -22,7 +22,7 @@ public interface DatabaseService { | ... | @@ -22,7 +22,7 @@ public interface DatabaseService { |
| 22 | * @return the previous value associated with the specified key, or null if there was no mapping for the key. | 22 | * @return the previous value associated with the specified key, or null if there was no mapping for the key. |
| 23 | */ | 23 | */ |
| 24 | VersionedValue put(String tableName, String key, byte[] value); | 24 | VersionedValue put(String tableName, String key, byte[] value); |
| 25 | - | 25 | + |
| 26 | /** | 26 | /** |
| 27 | * If the specified key is not already associated with a value, associate it with the given value. | 27 | * If the specified key is not already associated with a value, associate it with the given value. |
| 28 | * @param tableName table name in which this key/value resides. | 28 | * @param tableName table name in which this key/value resides. |
| ... | @@ -31,7 +31,7 @@ public interface DatabaseService { | ... | @@ -31,7 +31,7 @@ public interface DatabaseService { |
| 31 | * @return true if put was successful, false if there is already a value associated with this key | 31 | * @return true if put was successful, false if there is already a value associated with this key |
| 32 | */ | 32 | */ |
| 33 | boolean putIfAbsent(String tableName, String key, byte[] value); | 33 | boolean putIfAbsent(String tableName, String key, byte[] value); |
| 34 | - | 34 | + |
| 35 | /** | 35 | /** |
| 36 | * Sets the key to the specified value if the version in the database (for that key) | 36 | * Sets the key to the specified value if the version in the database (for that key) |
| 37 | * matches the specified version. | 37 | * matches the specified version. |
| ... | @@ -42,7 +42,7 @@ public interface DatabaseService { | ... | @@ -42,7 +42,7 @@ public interface DatabaseService { |
| 42 | * @return true if put was successful, false if there version in database is different from what is specified. | 42 | * @return true if put was successful, false if there version in database is different from what is specified. |
| 43 | */ | 43 | */ |
| 44 | boolean putIfVersionMatches(String tableName, String key, byte[] value, long version); | 44 | boolean putIfVersionMatches(String tableName, String key, byte[] value, long version); |
| 45 | - | 45 | + |
| 46 | /** | 46 | /** |
| 47 | * Replaces the entry for a key only if currently mapped to a given value. | 47 | * Replaces the entry for a key only if currently mapped to a given value. |
| 48 | * @param tableName name of table associated with this operation. | 48 | * @param tableName name of table associated with this operation. |
| ... | @@ -52,7 +52,7 @@ public interface DatabaseService { | ... | @@ -52,7 +52,7 @@ public interface DatabaseService { |
| 52 | * @return true if put was successful, false if there version in database is different from what is specified. | 52 | * @return true if put was successful, false if there version in database is different from what is specified. |
| 53 | */ | 53 | */ |
| 54 | boolean putIfValueMatches(String tableName, String key, byte[] oldValue, byte[] newValue); | 54 | boolean putIfValueMatches(String tableName, String key, byte[] oldValue, byte[] newValue); |
| 55 | - | 55 | + |
| 56 | /** | 56 | /** |
| 57 | * Removes the key (and associated value). | 57 | * Removes the key (and associated value). |
| 58 | * @param tableName name of table associated with this operation. | 58 | * @param tableName name of table associated with this operation. |
| ... | @@ -60,7 +60,7 @@ public interface DatabaseService { | ... | @@ -60,7 +60,7 @@ public interface DatabaseService { |
| 60 | * @return value previously associated with the key. This call returns null if the key does not exist. | 60 | * @return value previously associated with the key. This call returns null if the key does not exist. |
| 61 | */ | 61 | */ |
| 62 | VersionedValue remove(String tableName, String key); | 62 | VersionedValue remove(String tableName, String key); |
| 63 | - | 63 | + |
| 64 | /** | 64 | /** |
| 65 | * Removes the key (and associated value) if the version in the database matches specified version. | 65 | * Removes the key (and associated value) if the version in the database matches specified version. |
| 66 | * @param tableName name of table associated with this operation. | 66 | * @param tableName name of table associated with this operation. |
| ... | @@ -69,7 +69,7 @@ public interface DatabaseService { | ... | @@ -69,7 +69,7 @@ public interface DatabaseService { |
| 69 | * @return true if remove was successful, false if there version in database is different from what is specified. | 69 | * @return true if remove was successful, false if there version in database is different from what is specified. |
| 70 | */ | 70 | */ |
| 71 | boolean removeIfVersionMatches(String tableName, String key, long version); | 71 | boolean removeIfVersionMatches(String tableName, String key, long version); |
| 72 | - | 72 | + |
| 73 | /** | 73 | /** |
| 74 | * Removes the key (and associated value) if the value in the database matches specified value. | 74 | * Removes the key (and associated value) if the value in the database matches specified value. |
| 75 | * @param tableName name of table associated with this operation. | 75 | * @param tableName name of table associated with this operation. |
| ... | @@ -78,14 +78,14 @@ public interface DatabaseService { | ... | @@ -78,14 +78,14 @@ public interface DatabaseService { |
| 78 | * @return true if remove was successful, false if there value in database is different from what is specified. | 78 | * @return true if remove was successful, false if there value in database is different from what is specified. |
| 79 | */ | 79 | */ |
| 80 | boolean removeIfValueMatches(String tableName, String key, byte[] value); | 80 | boolean removeIfValueMatches(String tableName, String key, byte[] value); |
| 81 | - | 81 | + |
| 82 | /** | 82 | /** |
| 83 | * Performs a batch read operation and returns the results. | 83 | * Performs a batch read operation and returns the results. |
| 84 | * @param batchRequest batch request. | 84 | * @param batchRequest batch request. |
| 85 | * @return result of the batch operation. | 85 | * @return result of the batch operation. |
| 86 | */ | 86 | */ |
| 87 | BatchReadResult batchRead(BatchReadRequest batchRequest); | 87 | BatchReadResult batchRead(BatchReadRequest batchRequest); |
| 88 | - | 88 | + |
| 89 | /** | 89 | /** |
| 90 | * Performs a batch write operation and returns the results. | 90 | * Performs a batch write operation and returns the results. |
| 91 | * This method provides transactional semantics. Either all writes succeed or none do. | 91 | * This method provides transactional semantics. Either all writes succeed or none do. |
| ... | @@ -96,4 +96,4 @@ public interface DatabaseService { | ... | @@ -96,4 +96,4 @@ public interface DatabaseService { |
| 96 | * @return result of the batch operation. | 96 | * @return result of the batch operation. |
| 97 | */ | 97 | */ |
| 98 | BatchWriteResult batchWrite(BatchWriteRequest batchRequest); | 98 | BatchWriteResult batchWrite(BatchWriteRequest batchRequest); |
| 99 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 99 | +} | ... | ... |
| ... | @@ -9,11 +9,11 @@ package org.onlab.onos.store.service; | ... | @@ -9,11 +9,11 @@ package org.onlab.onos.store.service; |
| 9 | */ | 9 | */ |
| 10 | public interface Lock { | 10 | public interface Lock { |
| 11 | 11 | ||
| 12 | - /** | 12 | + /** |
| 13 | - * Returns the path this lock will be used to guard from concurrent access. | 13 | + * Returns the path this lock will be used to guard from concurrent access. |
| 14 | - * @return path. | 14 | + * @return path. |
| 15 | - */ | 15 | + */ |
| 16 | - String path(); | 16 | + String path(); |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * Acquires the lock. | 19 | * Acquires the lock. |
| ... | @@ -79,4 +79,4 @@ public interface Lock { | ... | @@ -79,4 +79,4 @@ public interface Lock { |
| 79 | * extend expiration fails or if the path is currently not locked by this instance. | 79 | * extend expiration fails or if the path is currently not locked by this instance. |
| 80 | */ | 80 | */ |
| 81 | boolean extendExpiration(int leaseDurationMillis); | 81 | boolean extendExpiration(int leaseDurationMillis); |
| 82 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 82 | +} | ... | ... |
| ... | @@ -14,17 +14,17 @@ public class ReadResult { | ... | @@ -14,17 +14,17 @@ public class ReadResult { |
| 14 | private final ReadStatus status; | 14 | private final ReadStatus status; |
| 15 | 15 | ||
| 16 | public ReadResult(ReadStatus status, String tableName, String key, VersionedValue value) { | 16 | public ReadResult(ReadStatus status, String tableName, String key, VersionedValue value) { |
| 17 | - this.status = status; | 17 | + this.status = status; |
| 18 | this.tableName = tableName; | 18 | this.tableName = tableName; |
| 19 | this.key = key; | 19 | this.key = key; |
| 20 | this.value = value; | 20 | this.value = value; |
| 21 | } | 21 | } |
| 22 | - | 22 | + |
| 23 | /** | 23 | /** |
| 24 | * Returns the status of the read operation. | 24 | * Returns the status of the read operation. |
| 25 | */ | 25 | */ |
| 26 | public ReadStatus status() { | 26 | public ReadStatus status() { |
| 27 | - return status; | 27 | + return status; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /** | 30 | /** | ... | ... |
| ... | @@ -7,27 +7,27 @@ import com.google.common.base.MoreObjects; | ... | @@ -7,27 +7,27 @@ import com.google.common.base.MoreObjects; |
| 7 | * Database write result. | 7 | * Database write result. |
| 8 | */ | 8 | */ |
| 9 | public class WriteResult { | 9 | public class WriteResult { |
| 10 | - | 10 | + |
| 11 | private final WriteStatus status; | 11 | private final WriteStatus status; |
| 12 | private final VersionedValue previousValue; | 12 | private final VersionedValue previousValue; |
| 13 | - | 13 | + |
| 14 | public WriteResult(WriteStatus status, VersionedValue previousValue) { | 14 | public WriteResult(WriteStatus status, VersionedValue previousValue) { |
| 15 | - this.status = status; | 15 | + this.status = status; |
| 16 | this.previousValue = previousValue; | 16 | this.previousValue = previousValue; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | public VersionedValue previousValue() { | 19 | public VersionedValue previousValue() { |
| 20 | return previousValue; | 20 | return previousValue; |
| 21 | } | 21 | } |
| 22 | - | 22 | + |
| 23 | public WriteStatus status() { | 23 | public WriteStatus status() { |
| 24 | - return status; | 24 | + return status; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | @Override | 27 | @Override |
| 28 | public String toString() { | 28 | public String toString() { |
| 29 | return MoreObjects.toStringHelper(getClass()) | 29 | return MoreObjects.toStringHelper(getClass()) |
| 30 | - .add("status", status) | 30 | + .add("status", status) |
| 31 | .add("previousValue", previousValue) | 31 | .add("previousValue", previousValue) |
| 32 | .toString(); | 32 | .toString(); |
| 33 | } | 33 | } | ... | ... |
-
Please register or login to post a comment