001/* 002 * Copyright 2014-2017 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2017 Ping Identity Corporation 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 */ 021package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025import com.unboundid.util.ThreadSafety; 026import com.unboundid.util.ThreadSafetyLevel; 027 028 029 030/** 031 * This enum defines the options that may be specified to indicate whether and 032 * when to acquire an exclusive lock in the target backend when processing a 033 * transaction. 034 * <BR> 035 * <BLOCKQUOTE> 036 * <B>NOTE:</B> This class, and other classes within the 037 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 038 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 039 * server products. These classes provide support for proprietary 040 * functionality or for external specifications that are not considered stable 041 * or mature enough to be guaranteed to work in an interoperable way with 042 * other types of LDAP servers. 043 * </BLOCKQUOTE> 044 * 045 * @see TransactionSettingsRequestControl 046 */ 047@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 048public enum TransactionSettingsBackendLockBehavior 049{ 050 /** 051 * Indicates that the server should not make any attempt to acquire an 052 * exclusive lock in the target backend, whether during the initial attempt or 053 * a subsequent retry. This will allow the highest level of concurrency for 054 * operations within the backend, but may increase the risk of lock conflicts 055 * between transactions in a server processing many operations concurrently. 056 * This risk may be mitigated by indicating that the transaction should be 057 * retried one or more times. 058 */ 059 DO_NOT_ACQUIRE(0), 060 061 062 063 /** 064 * Indicates that if the server is unable to successfully commit the 065 * associated transaction after one or more attempts without holding an 066 * exclusive lock in the target backend, then it should make one more attempt 067 * after acquiring the lock. This will avoid the need to acquire the lock 068 * unless the maximum number of attempts have been unsuccessful without it. 069 */ 070 ACQUIRE_AFTER_RETRIES(1), 071 072 073 074 /** 075 * Indicates that if the server is unable to successfully commit the 076 * associated transaction after the first attempt without holding an exclusive 077 * lock in the target backend, then it should make one or more 078 * additional attempts (as specified by the requested number of retries) after 079 * acquiring the lock. This will avoid the need to acquire the lock for 080 * operations that can be completed on the first attempt without it. 081 */ 082 ACQUIRE_BEFORE_RETRIES(2), 083 084 085 086 /** 087 * Indicates that the server should acquire an exclusive lock in the target 088 * backend before performing any backend processing for the operation. This 089 * will limit concurrency, as the backend will not be able to process any 090 * other operation while the associated operation is in progress, but this 091 * will also minimize the chance of a thread deadlock or lock timeout as a 092 * result of a conflict between database interactions from multiple 093 * simultaneous operations. 094 */ 095 ACQUIRE_BEFORE_INITIAL_ATTEMPT(3); 096 097 098 099 // The integer value for this backend lock behavior. 100 private final int intValue; 101 102 103 104 /** 105 * Creates a new transaction settings backend lock behavior with the provided 106 * integer value. 107 * 108 * @param intValue The integer value for this backend lock behavior. 109 */ 110 TransactionSettingsBackendLockBehavior(final int intValue) 111 { 112 this.intValue = intValue; 113 } 114 115 116 117 /** 118 * Retrieves the integer value for this transaction settings backend lock 119 * behavior value. 120 * 121 * @return The integer value for this transaction settings backend lock 122 * behavior value. 123 */ 124 public int intValue() 125 { 126 return intValue; 127 } 128 129 130 131 /** 132 * Retrieves the backend lock behavior value with the specified integer value. 133 * 134 * @param intValue The integer value for the backend lock behavior to 135 * retrieve. 136 * 137 * @return The backend lock behavior value with the specified integer value, 138 * or {@code null} if there is no such backend lock behavior value. 139 */ 140 public static TransactionSettingsBackendLockBehavior 141 valueOf(final int intValue) 142 { 143 for (final TransactionSettingsBackendLockBehavior v : values()) 144 { 145 if (v.intValue == intValue) 146 { 147 return v; 148 } 149 } 150 151 return null; 152 } 153}