blob: 58957a299a2e8ed01dfffbfd1cfbd143f0366bd2 [file] [log] [blame]
Madan Jampanicadd70b2016-02-08 13:45:43 -08001/*
2 * Copyright 2016 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 */
16package org.onosproject.store.primitives.impl;
17
18import java.util.concurrent.CompletableFuture;
19
20import org.onosproject.store.primitives.TransactionId;
21import org.onosproject.store.primitives.resources.impl.CommitResult;
22import org.onosproject.store.primitives.resources.impl.PrepareResult;
23import org.onosproject.store.primitives.resources.impl.RollbackResult;
24
25/**
26 * Participant in a two-phase commit protocol.
27 */
28public interface TransactionParticipant {
29
30 /**
31 * Attempts to execute the prepare phase for the specified {@link Transaction transaction}.
32 * @param transaction transaction
33 * @return future for prepare result
34 */
35 CompletableFuture<PrepareResult> prepare(Transaction transaction);
36
37 /**
38 * Attempts to execute the commit phase for previously prepared transaction.
39 * @param transactionId transaction identifier
40 * @return future for commit result
41 */
42 CompletableFuture<CommitResult> commit(TransactionId transactionId);
43
44 /**
45 * Attempts to execute the rollback phase for previously prepared transaction.
46 * @param transactionId transaction identifier
47 * @return future for rollback result
48 */
49 CompletableFuture<RollbackResult> rollback(TransactionId transactionId);
50}