blob: 449fd71dd032449f78826f706f39fecdd160a855 [file] [log] [blame]
Madan Jampani08822c42014-11-04 17:17:46 -08001package org.onlab.onos.store.service;
2
3import java.util.List;
4
Madan Jampani37c2e702014-11-04 18:11:10 -08005/**
6 * Service interface for a strongly consistent and durable
7 * key value data store.
8 */
Madan Jampani08822c42014-11-04 17:17:46 -08009public interface DatabaseService {
10
11 /**
12 * Performs a read on the database.
13 * @param request read request.
14 * @return ReadResult
Madan Jampani37c2e702014-11-04 18:11:10 -080015 * @throws DatabaseException if there is a failure in executing read.
Madan Jampani08822c42014-11-04 17:17:46 -080016 */
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 Jampani37c2e702014-11-04 18:11:10 -080023 * @return batch read result.
Madan Jampani08822c42014-11-04 17:17:46 -080024 */
25 List<OptionalResult<ReadResult, DatabaseException>> batchRead(List<ReadRequest> batch);
26
27 /**
28 * Performs a write operation on the database.
29 * @param request
30 * @return write result.
Madan Jampani37c2e702014-11-04 18:11:10 -080031 * @throws DatabaseException if there is failure in execution write.
Madan Jampani08822c42014-11-04 17:17:46 -080032 */
33 WriteResult write(WriteRequest request);
34
35 /**
36 * Performs a batch write operation on the database.
37 * Batch write provides transactional semantics. Either all operations
38 * succeed or none of them do.
39 * @param batch batch of write requests to execute as a transaction.
40 * @return result of executing the batch write operation.
41 */
42 List<OptionalResult<WriteResult, DatabaseException>> batchWrite(List<WriteRequest> batch);
43}