001/* 002 * Copyright 2014-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2014-2024 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) 2014-2024 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.NotNull; 041import com.unboundid.util.Nullable; 042import com.unboundid.util.StaticUtils; 043import com.unboundid.util.ThreadSafety; 044import com.unboundid.util.ThreadSafetyLevel; 045 046 047 048/** 049 * This enum defines the options that may be specified for the transaction 050 * commit durability when using the transaction settings request control. 051 * <BR> 052 * <BLOCKQUOTE> 053 * <B>NOTE:</B> This class, and other classes within the 054 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 055 * supported for use against Ping Identity, UnboundID, and 056 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 057 * for proprietary functionality or for external specifications that are not 058 * considered stable or mature enough to be guaranteed to work in an 059 * interoperable way with other types of LDAP servers. 060 * </BLOCKQUOTE> 061 * 062 * @see TransactionSettingsRequestControl 063 */ 064@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 065public enum TransactionSettingsCommitDurability 066{ 067 /** 068 * Indicates that the commit should be non-synchronous. Atomicity, 069 * consistency, and isolation will be maintained for the transaction, but 070 * there is no guarantee that the record of the transaction will be written 071 * to disk by the time operation processing is complete and the response has 072 * been returned to the client. In the event of a JVM, operating system, or 073 * hardware failure before the transaction record is actually flushed to disk, 074 * then changes that are part of that transaction could be rolled back when 075 * the server is started back up. 076 */ 077 NON_SYNCHRONOUS(0), 078 079 080 081 /** 082 * Indicates that the commit should be partially synchronous. Atomicity, 083 * consistency, and isolation will be maintained for the transaction, and a 084 * record of the transaction will be written to disk during the commit, but 085 * that transaction record will not be synchronously flushed. In the event of 086 * an operating system or hardware failure before the transaction record is 087 * actually flushed to disk, then changes that are part of that transaction 088 * could be rolled back when the server is started back up. 089 */ 090 PARTIALLY_SYNCHRONOUS(1), 091 092 093 094 /** 095 * Indicates that the commit should be fully synchronous. Atomicity, 096 * consistency, isolation, and durability will be maintained for the 097 * transaction, and a record of the transaction will be flushed to disk before 098 * the commit is completed. In the event of a JVM, operating system, or 099 * hardware failure, then any changes that are part of that transaction will 100 * still be reflected in the database when the server is started back up (as 101 * long as the database files are still intact). 102 */ 103 FULLY_SYNCHRONOUS(2); 104 105 106 107 // The integer value for this commit durability. 108 private final int intValue; 109 110 111 112 /** 113 * Creates a new transaction settings commit durability with the provided 114 * integer value. 115 * 116 * @param intValue The integer value for this commit durability. 117 */ 118 TransactionSettingsCommitDurability(final int intValue) 119 { 120 this.intValue = intValue; 121 } 122 123 124 125 /** 126 * Retrieves the integer value for this transaction settings commit durability 127 * value. 128 * 129 * @return The integer value for this transaction settings commit durability 130 * value. 131 */ 132 public int intValue() 133 { 134 return intValue; 135 } 136 137 138 139 /** 140 * Retrieves the commit durability value with the specified integer value. 141 * 142 * @param intValue The integer value for the commit durability to retrieve. 143 * 144 * @return The commit durability value with the specified integer value, or 145 * {@code null} if there is no such commit durability value. 146 */ 147 @Nullable() 148 public static TransactionSettingsCommitDurability valueOf(final int intValue) 149 { 150 for (final TransactionSettingsCommitDurability v : values()) 151 { 152 if (v.intValue == intValue) 153 { 154 return v; 155 } 156 } 157 158 return null; 159 } 160 161 162 163 /** 164 * Retrieves the transaction settings commit durability with the specified 165 * name. 166 * 167 * @param name The name of the transaction settings commit durability to 168 * retrieve. It must not be {@code null}. 169 * 170 * @return The requested transaction settings commit durability, or 171 * {@code null} if no such durability is defined. 172 */ 173 @Nullable() 174 public static TransactionSettingsCommitDurability forName( 175 @NotNull final String name) 176 { 177 switch (StaticUtils.toLowerCase(name)) 178 { 179 case "nonsynchronous": 180 case "non-synchronous": 181 case "non_synchronous": 182 return NON_SYNCHRONOUS; 183 case "partiallysynchronous": 184 case "partially-synchronous": 185 case "partially_synchronous": 186 return PARTIALLY_SYNCHRONOUS; 187 case "fullysynchronous": 188 case "fully-synchronous": 189 case "fully_synchronous": 190 return FULLY_SYNCHRONOUS; 191 default: 192 return null; 193 } 194 } 195}