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 for the transaction
032 * commit durability when using the transaction settings request control.
033 * <BR>
034 * <BLOCKQUOTE>
035 *   <B>NOTE:</B>  This class, and other classes within the
036 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
037 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
038 *   server products.  These classes provide support for proprietary
039 *   functionality or for external specifications that are not considered stable
040 *   or mature enough to be guaranteed to work in an interoperable way with
041 *   other types of LDAP servers.
042 * </BLOCKQUOTE>
043 *
044 * @see TransactionSettingsRequestControl
045 */
046@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
047public enum TransactionSettingsCommitDurability
048{
049  /**
050   * Indicates that the commit should be non-synchronous.  Atomicity,
051   * consistency, and isolation will be maintained for the transaction, but
052   * there is no guarantee that the record of the transaction will be written
053   * to disk by the time operation processing is complete and the response has
054   * been returned to the client.  In the event of a JVM, operating system, or
055   * hardware failure before the transaction record is actually flushed to disk,
056   * then changes that are part of that transaction could be rolled back when
057   * the server is started back up.
058   */
059  NON_SYNCHRONOUS(0),
060
061
062
063  /**
064   * Indicates that the commit should be partially synchronous.  Atomicity,
065   * consistency, and isolation will be maintained for the transaction, and a
066   * record of the transaction will be written to disk during the commit, but
067   * that transaction record will not be synchronously flushed.  In the event of
068   * an operating system or hardware failure before the transaction record is
069   * actually flushed to disk, then changes that are part of that transaction
070   * could be rolled back when the server is started back up.
071   */
072  PARTIALLY_SYNCHRONOUS(1),
073
074
075
076  /**
077   * Indicates that the commit should be fully synchronous.  Atomicity,
078   * consistency, isolation, and durability will be maintained for the
079   * transaction, and a record of the transaction will be flushed to disk before
080   * the commit is completed.  In the event of a JVM, operating system, or
081   * hardware failure, then any changes that are part of that transaction will
082   * still be reflected in the database when the server is started back up (as
083   * long as the database files are still intact).
084   */
085  FULLY_SYNCHRONOUS(2);
086
087
088
089  // The integer value for this commit durability.
090  private final int intValue;
091
092
093
094  /**
095   * Creates a new transaction settings commit durability with the provided
096   * integer value.
097   *
098   * @param  intValue  The integer value for this commit durability.
099   */
100  TransactionSettingsCommitDurability(final int intValue)
101  {
102    this.intValue = intValue;
103  }
104
105
106
107  /**
108   * Retrieves the integer value for this transaction settings commit durability
109   * value.
110   *
111   * @return  The integer value for this transaction settings commit durability
112   *          value.
113   */
114  public int intValue()
115  {
116    return intValue;
117  }
118
119
120
121  /**
122   * Retrieves the commit durability value with the specified integer value.
123   *
124   * @param  intValue  The integer value for the commit durability to retrieve.
125   *
126   * @return  The commit durability value with the specified integer value, or
127   *          {@code null} if there is no such commit durability value.
128   */
129  public static TransactionSettingsCommitDurability valueOf(final int intValue)
130  {
131    for (final TransactionSettingsCommitDurability v : values())
132    {
133      if (v.intValue == intValue)
134      {
135        return v;
136      }
137    }
138
139    return null;
140  }
141}