blob: cf0ef0aee7a1748a443e72612080cbb87c79f486 [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
Yuta HIGUCHI361664e2014-11-06 17:28:47 -080027 // FIXME Give me a better name
Madan Jampani08822c42014-11-04 17:17:46 -080028 /**
29 * Performs a write operation on the database.
Madan Jampani9b19a822014-11-04 21:37:13 -080030 * @param request write request
Madan Jampani08822c42014-11-04 17:17:46 -080031 * @return write result.
Madan Jampani37c2e702014-11-04 18:11:10 -080032 * @throws DatabaseException if there is failure in execution write.
Madan Jampani08822c42014-11-04 17:17:46 -080033 */
Yuta HIGUCHI361664e2014-11-06 17:28:47 -080034 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 Jampani08822c42014-11-04 17:17:46 -080045
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}