Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 1 | package org.onlab.onos.store.service; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 5 | /** |
| 6 | * Service interface for a strongly consistent and durable |
| 7 | * key value data store. |
| 8 | */ |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 9 | public interface DatabaseService { |
| 10 | |
| 11 | /** |
| 12 | * Performs a read on the database. |
| 13 | * @param request read request. |
| 14 | * @return ReadResult |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 15 | * @throws DatabaseException if there is a failure in executing read. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 16 | */ |
| 17 | ReadResult read(ReadRequest request); |
| 18 | |
| 19 | /** |
| 20 | * Performs a batch read operation on the database. |
| 21 | * The main advantage of batch read operation is parallelization. |
| 22 | * @param batch batch of read requests to execute. |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 23 | * @return batch read result. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 24 | */ |
| 25 | List<OptionalResult<ReadResult, DatabaseException>> batchRead(List<ReadRequest> batch); |
| 26 | |
Yuta HIGUCHI | 361664e | 2014-11-06 17:28:47 -0800 | [diff] [blame^] | 27 | // FIXME Give me a better name |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 28 | /** |
| 29 | * Performs a write operation on the database. |
Madan Jampani | 9b19a82 | 2014-11-04 21:37:13 -0800 | [diff] [blame] | 30 | * @param request write request |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 31 | * @return write result. |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 32 | * @throws DatabaseException if there is failure in execution write. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 33 | */ |
Yuta HIGUCHI | 361664e | 2014-11-06 17:28:47 -0800 | [diff] [blame^] | 34 | OptionalResult<WriteResult, DatabaseException> writeNothrow(WriteRequest request); |
| 35 | |
| 36 | /** |
| 37 | * Performs a write operation on the database. |
| 38 | * @param request write request |
| 39 | * @return write result. |
| 40 | * @throws OptimisticLockException FIXME define conditional failure |
| 41 | * @throws PreconditionFailedException FIXME define conditional failure |
| 42 | * @throws DatabaseException if there is failure in execution write. |
| 43 | */ |
| 44 | WriteResult write(WriteRequest request)/* throws OptimisticLockException, PreconditionFailedException*/; |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Performs a batch write operation on the database. |
| 48 | * Batch write provides transactional semantics. Either all operations |
| 49 | * succeed or none of them do. |
| 50 | * @param batch batch of write requests to execute as a transaction. |
| 51 | * @return result of executing the batch write operation. |
| 52 | */ |
| 53 | List<OptionalResult<WriteResult, DatabaseException>> batchWrite(List<WriteRequest> batch); |
| 54 | } |