blob: b404bae3679a5c9d24fef10e4ec89ba20d4f7063 [file] [log] [blame]
Madan Jampani64689552015-02-17 10:00:27 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.store.service;
18
19/**
20 * Provides a context for transactional operations.
21 * <p>
22 * A transaction context provides a boundary within which transactions
23 * are run. It also is a place where all modifications made within a transaction
24 * are cached until the point when the transaction commits or aborts. It thus ensures
25 * isolation of work happening with in the transaction boundary.
26 * <p>
27 * A transaction context is a vehicle for grouping operations into a unit with the
28 * properties of atomicity, isolation, and durability. Transactions also provide the
29 * ability to maintain an application's invariants or integrity constraints,
30 * supporting the property of consistency. Together these properties are known as ACID.
31 */
32public interface TransactionContext {
33
34 /**
35 * Returns if this transaction context is open.
36 * @return true if open, false otherwise.
37 */
38 boolean isOpen();
39
40 /**
41 * Starts a new transaction.
42 */
43 void begin();
44
45 /**
46 * Commits a transaction that was previously started thereby making its changes permanent
47 * and externally visible.
48 * @throws TransactionException if transaction fails to commit.
49 */
50 void commit();
51
52 /**
53 * Rolls back the current transaction, discarding all its changes.
54 */
55 void rollback();
56
57 /**
58 * Creates a new transactional map.
Ray Milkey144eec52015-02-20 11:22:32 -080059 * @param <K> key type
60 * @param <V> value type
Madan Jampani64689552015-02-17 10:00:27 -080061 * @param mapName name of the transactional map.
62 * @param serializer serializer to use for encoding/decoding keys and vaulues.
63 * @return new Transactional Map.
64 */
65 <K, V> TransactionalMap<K, V> createTransactionalMap(String mapName, Serializer serializer);
Ray Milkey144eec52015-02-20 11:22:32 -080066}