001 /* 002 * Copyright 2014-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021 package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025 import com.unboundid.util.ThreadSafety; 026 import com.unboundid.util.ThreadSafetyLevel; 027 028 029 030 /** 031 * <BLOCKQUOTE> 032 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 033 * LDAP SDK for Java. It is not available for use in applications that 034 * include only the Standard Edition of the LDAP SDK, and is not supported for 035 * use in conjunction with non-UnboundID products. 036 * </BLOCKQUOTE> 037 * This enum defines the options that may be specified for the transaction 038 * commit durability when using the transaction settings request control. 039 * 040 * @see TransactionSettingsRequestControl 041 */ 042 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 043 public enum TransactionSettingsCommitDurability 044 { 045 /** 046 * Indicates that the commit should be non-synchronous. Atomicity, 047 * consistency, and isolation will be maintained for the transaction, but 048 * there is no guarantee that the record of the transaction will be written 049 * to disk by the time operation processing is complete and the response has 050 * been returned to the client. In the event of a JVM, operating system, or 051 * hardware failure before the transaction record is actually flushed to disk, 052 * then changes that are part of that transaction could be rolled back when 053 * the server is started back up. 054 */ 055 NON_SYNCHRONOUS(0), 056 057 058 059 /** 060 * Indicates that the commit should be partially synchronous. Atomicity, 061 * consistency, and isolation will be maintained for the transaction, and a 062 * record of the transaction will be written to disk during the commit, but 063 * that transaction record will not be synchronously flushed. In the event of 064 * an operating system or hardware failure before the transaction record is 065 * actually flushed to disk, then changes that are part of that transaction 066 * could be rolled back when the server is started back up. 067 */ 068 PARTIALLY_SYNCHRONOUS(1), 069 070 071 072 /** 073 * Indicates that the commit should be fully synchronous. Atomicity, 074 * consistency, isolation, and durability will be maintained for the 075 * transaction, and a record of the transaction will be flushed to disk before 076 * the commit is completed. In the event of a JVM, operating system, or 077 * hardware failure, then any changes that are part of that transaction will 078 * still be reflected in the database when the server is started back up (as 079 * long as the database files are still intact). 080 */ 081 FULLY_SYNCHRONOUS(2); 082 083 084 085 // The integer value for this commit durability. 086 private final int intValue; 087 088 089 090 /** 091 * Creates a new transaction settings commit durability with the provided 092 * integer value. 093 * 094 * @param intValue The integer value for this commit durability. 095 */ 096 private TransactionSettingsCommitDurability(final int intValue) 097 { 098 this.intValue = intValue; 099 } 100 101 102 103 /** 104 * Retrieves the integer value for this transaction settings commit durability 105 * value. 106 * 107 * @return The integer value for this transaction settings commit durability 108 * value. 109 */ 110 public int intValue() 111 { 112 return intValue; 113 } 114 115 116 117 /** 118 * Retrieves the commit durability value with the specified integer value. 119 * 120 * @param intValue The integer value for the commit durability to retrieve. 121 * 122 * @return The commit durability value with the specified integer value, or 123 * {@code null} if there is no such commit durability value. 124 */ 125 public static TransactionSettingsCommitDurability valueOf(final int intValue) 126 { 127 for (final TransactionSettingsCommitDurability v : values()) 128 { 129 if (v.intValue == intValue) 130 { 131 return v; 132 } 133 } 134 135 return null; 136 } 137 }