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
19 package org.apache.hadoop.hbase.client;
20
21 /**
22 * Enum describing the durability guarantees for {@link Mutation}
23 * Note that the items must be sorted in order of increasing durability
24 */
25 public enum Durability {
26 /**
27 * Use the column family's default setting to determine durability.
28 * This must remain the first option.
29 */
30 USE_DEFAULT,
31 /**
32 * Do not write the Mutation to the WAL
33 */
34 SKIP_WAL,
35 /**
36 * Write the Mutation to the WAL asynchronously
37 */
38 ASYNC_WAL,
39 /**
40 * Write the Mutation to the WAL synchronously.
41 * The data is flushed to the filesystem implementation, but not necessarily to disk.
42 * For HDFS this will flush the data to the designated number of DataNodes.
43 * See <a href="https://issues.apache.org/jira/browse/HADOOP-6313">HADOOP-6313<a/>
44 */
45 SYNC_WAL,
46 /**
47 * Write the Mutation to the WAL synchronously and force the entries to disk.
48 * (Note: this is currently not supported and will behave identical to {@link #SYNC_WAL})
49 * See <a href="https://issues.apache.org/jira/browse/HADOOP-6313">HADOOP-6313<a/>
50 */
51 FSYNC_WAL;
52
53 // efficiently translate ordinal back to items of this Enum
54 // (Enum.values()[ordinal] generates too much garbage)
55 public static Durability valueOf(int ordinal) {
56 switch (ordinal) {
57 case 0: return USE_DEFAULT;
58 case 1: return SKIP_WAL;
59 case 2: return ASYNC_WAL;
60 case 3: return SYNC_WAL;
61 case 4: return FSYNC_WAL;
62 default: throw new IllegalArgumentException("Unknown Durability Ordinal:"+ordinal);
63 }
64 }
65 }