001/* 002 * Copyright 2014-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2014-2020 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2015-2020 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.controls; 037 038 039 040import com.unboundid.util.StaticUtils; 041import com.unboundid.util.ThreadSafety; 042import com.unboundid.util.ThreadSafetyLevel; 043 044 045 046/** 047 * This enum defines the options that may be specified for the transaction 048 * commit durability when using the transaction settings request control. 049 * <BR> 050 * <BLOCKQUOTE> 051 * <B>NOTE:</B> This class, and other classes within the 052 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 053 * supported for use against Ping Identity, UnboundID, and 054 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 055 * for proprietary functionality or for external specifications that are not 056 * considered stable or mature enough to be guaranteed to work in an 057 * interoperable way with other types of LDAP servers. 058 * </BLOCKQUOTE> 059 * 060 * @see TransactionSettingsRequestControl 061 */ 062@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 063public enum TransactionSettingsCommitDurability 064{ 065 /** 066 * Indicates that the commit should be non-synchronous. Atomicity, 067 * consistency, and isolation will be maintained for the transaction, but 068 * there is no guarantee that the record of the transaction will be written 069 * to disk by the time operation processing is complete and the response has 070 * been returned to the client. In the event of a JVM, operating system, or 071 * hardware failure before the transaction record is actually flushed to disk, 072 * then changes that are part of that transaction could be rolled back when 073 * the server is started back up. 074 */ 075 NON_SYNCHRONOUS(0), 076 077 078 079 /** 080 * Indicates that the commit should be partially synchronous. Atomicity, 081 * consistency, and isolation will be maintained for the transaction, and a 082 * record of the transaction will be written to disk during the commit, but 083 * that transaction record will not be synchronously flushed. In the event of 084 * an operating system or hardware failure before the transaction record is 085 * actually flushed to disk, then changes that are part of that transaction 086 * could be rolled back when the server is started back up. 087 */ 088 PARTIALLY_SYNCHRONOUS(1), 089 090 091 092 /** 093 * Indicates that the commit should be fully synchronous. Atomicity, 094 * consistency, isolation, and durability will be maintained for the 095 * transaction, and a record of the transaction will be flushed to disk before 096 * the commit is completed. In the event of a JVM, operating system, or 097 * hardware failure, then any changes that are part of that transaction will 098 * still be reflected in the database when the server is started back up (as 099 * long as the database files are still intact). 100 */ 101 FULLY_SYNCHRONOUS(2); 102 103 104 105 // The integer value for this commit durability. 106 private final int intValue; 107 108 109 110 /** 111 * Creates a new transaction settings commit durability with the provided 112 * integer value. 113 * 114 * @param intValue The integer value for this commit durability. 115 */ 116 TransactionSettingsCommitDurability(final int intValue) 117 { 118 this.intValue = intValue; 119 } 120 121 122 123 /** 124 * Retrieves the integer value for this transaction settings commit durability 125 * value. 126 * 127 * @return The integer value for this transaction settings commit durability 128 * value. 129 */ 130 public int intValue() 131 { 132 return intValue; 133 } 134 135 136 137 /** 138 * Retrieves the commit durability value with the specified integer value. 139 * 140 * @param intValue The integer value for the commit durability to retrieve. 141 * 142 * @return The commit durability value with the specified integer value, or 143 * {@code null} if there is no such commit durability value. 144 */ 145 public static TransactionSettingsCommitDurability valueOf(final int intValue) 146 { 147 for (final TransactionSettingsCommitDurability v : values()) 148 { 149 if (v.intValue == intValue) 150 { 151 return v; 152 } 153 } 154 155 return null; 156 } 157 158 159 160 /** 161 * Retrieves the transaction settings commit durability with the specified 162 * name. 163 * 164 * @param name The name of the transaction settings commit durability to 165 * retrieve. It must not be {@code null}. 166 * 167 * @return The requested transaction settings commit durability, or 168 * {@code null} if no such durability is defined. 169 */ 170 public static TransactionSettingsCommitDurability forName(final String name) 171 { 172 switch (StaticUtils.toLowerCase(name)) 173 { 174 case "nonsynchronous": 175 case "non-synchronous": 176 case "non_synchronous": 177 return NON_SYNCHRONOUS; 178 case "partiallysynchronous": 179 case "partially-synchronous": 180 case "partially_synchronous": 181 return PARTIALLY_SYNCHRONOUS; 182 case "fullysynchronous": 183 case "fully-synchronous": 184 case "fully_synchronous": 185 return FULLY_SYNCHRONOUS; 186 default: 187 return null; 188 } 189 } 190}