View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.omid.committable;
19  
20  import org.apache.phoenix.thirdparty.com.google.common.base.Optional;
21  import org.apache.phoenix.thirdparty.com.google.common.util.concurrent.ListenableFuture;
22  import org.apache.phoenix.thirdparty.com.google.common.util.concurrent.SettableFuture;
23  
24  import java.io.IOException;
25  
26  public class NullCommitTable implements CommitTable {
27      @Override
28      public CommitTable.Writer getWriter() {
29          return new Writer();
30      }
31  
32      @Override
33      public CommitTable.Client getClient() {
34          return new Client();
35      }
36  
37      public static class Writer implements CommitTable.Writer {
38          @Override
39          public void addCommittedTransaction(long startTimestamp, long commitTimestamp) {
40              // noop
41          }
42  
43          @Override
44          public void updateLowWatermark(long lowWatermark) throws IOException {
45              // noop
46          }
47  
48          @Override
49          public void clearWriteBuffer() {
50              // noop
51          }
52  
53          @Override
54          public boolean atomicAddCommittedTransaction(long startTimestamp, long commitTimestamp) throws IOException {
55              return true;
56          }
57  
58          @Override
59          public void flush() throws IOException {
60              // noop
61          }
62      }
63  
64      public static class Client implements CommitTable.Client {
65          @Override
66          public ListenableFuture<Optional<CommitTimestamp>> getCommitTimestamp(long startTimestamp) {
67              throw new UnsupportedOperationException();
68          }
69  
70          @Override
71          public ListenableFuture<Long> readLowWatermark() {
72              throw new UnsupportedOperationException();
73          }
74  
75          @Override
76          public ListenableFuture<Void> deleteCommitEntry(long startTimestamp) {
77              SettableFuture<Void> f = SettableFuture.create();
78              f.set(null);
79              return f;
80          }
81  
82          @Override
83          public ListenableFuture<Boolean> tryInvalidateTransaction(long startTimestamp) {
84              throw new UnsupportedOperationException();
85          }
86  
87      }
88  }