com.hazelcast.config

## Class SemaphoreConfig

- java.lang.Object
- - com.hazelcast.config.SemaphoreConfig

- All Implemented Interfaces:
    NamedConfig, DataSerializable, IdentifiedDataSerializable, com.hazelcast.nio.serialization.impl.Versioned
  Direct Known Subclasses:
    SemaphoreConfigReadOnly

      public class SemaphoreConfig
      extends Object
      implements IdentifiedDataSerializable, com.hazelcast.nio.serialization.impl.Versioned, NamedConfig

  Contains the configuration for an `ISemaphore`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_ASYNC_BACKUP_COUNT` Default asynchronous backup count.
    `static int` | `DEFAULT_SYNC_BACKUP_COUNT` Default synchronous backup count.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SemaphoreConfig()` Creates a default configured `SemaphoreConfig`.
    `SemaphoreConfig(SemaphoreConfig config)` Creates a SemaphoreConfig by cloning another one.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `SemaphoreConfigReadOnly` | `getAsReadOnly()` Deprecated. this method will be removed in 4.0; it is meant for internal usage only
    `int` | `getAsyncBackupCount()` Returns the number of asynchronous backups.
    `int` | `getBackupCount()` Returns the number of synchronous backups.
    `int` | `getFactoryId()` Returns DataSerializableFactory factory ID for this class.
    `int` | `getId()` Returns type identifier for this class.
    `int` | `getInitialPermits()` Gets the initial number of permits.
    `String` | `getName()` Gets the name of the semaphore.
    `String` | `getQuorumName()`
    `int` | `getTotalBackupCount()` Returns the total number of backups (synchronous plus asynchronous); the returned value will always equal or bigger than 0.
    `int` | `hashCode()`
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `SemaphoreConfig` | `setAsyncBackupCount(int asyncBackupCount)` Sets the number of asynchronous backups.
    `SemaphoreConfig` | `setBackupCount(int backupCount)` Sets the number of synchronous backups.
    `SemaphoreConfig` | `setInitialPermits(int initialPermits)` Sets the initial number of permits.
    `SemaphoreConfig` | `setName(String name)` Sets the name of the semaphore.
    `SemaphoreConfig` | `setQuorumName(String quorumName)`
    `String` | `toString()`
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_SYNC_BACKUP_COUNT

          public static final int DEFAULT_SYNC_BACKUP_COUNT

      Default synchronous backup count.
      See Also:
        Constant Field Values

    - #### DEFAULT_ASYNC_BACKUP_COUNT

          public static final int DEFAULT_ASYNC_BACKUP_COUNT

      Default asynchronous backup count.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SemaphoreConfig

          public SemaphoreConfig()

      Creates a default configured `SemaphoreConfig`.

    - #### SemaphoreConfig

          public SemaphoreConfig(SemaphoreConfig config)

      Creates a SemaphoreConfig by cloning another one.
      Parameters:
        `config` - the SemaphoreConfig to copy
      Throws:
        `IllegalArgumentException` - if config is `null`

  - ### Method Detail

    - #### getAsReadOnly

          public SemaphoreConfigReadOnly getAsReadOnly()

      Deprecated. this method will be removed in 4.0; it is meant for internal usage only
      Gets immutable version of this configuration.
      Returns:
        immutable version of this configuration

    - #### getName

          public String getName()

      Gets the name of the semaphore. If no name has been configured, `null` is returned.
      Specified by:
        `getName` in interface `NamedConfig`
      Returns:
        the name of the semaphore

    - #### setName

          public SemaphoreConfig setName(String name)

      Sets the name of the semaphore.
      Specified by:
        `setName` in interface `NamedConfig`
      Parameters:
        `name` - the name of the semaphore
      Returns:
        the updated SemaphoreConfig
      Throws:
        `IllegalArgumentException` - if name is `null` or empty

    - #### getInitialPermits

          public int getInitialPermits()

      Gets the initial number of permits.
      Returns:
        the initial number of permits

    - #### setInitialPermits

          public SemaphoreConfig setInitialPermits(int initialPermits)

      Sets the initial number of permits. The initial number of permits can be 0; meaning that there is no permit. It can also be a negative number, meaning that there is a shortage of permits.
      Parameters:
        `initialPermits` - the initial number of permits
      Returns:
        the updated SemaphoreConfig

    - #### getBackupCount

          public int getBackupCount()

      Returns the number of synchronous backups.
      Returns:
        the number of synchronous backups
      See Also:
        `setBackupCount(int)`

    - #### setBackupCount

          public SemaphoreConfig setBackupCount(int backupCount)

      Sets the number of synchronous backups.
      Parameters:
        `backupCount` - the number of synchronous backups to set
      Returns:
        the updated SemaphoreConfig
      Throws:
        `IllegalArgumentException` - if backupCount smaller than 0, or larger than the maximum number of backup or the sum of the backups and async backups is larger than the maximum number of backups
      See Also:
        `setAsyncBackupCount(int)`, `getBackupCount()`

    - #### getAsyncBackupCount

          public int getAsyncBackupCount()

      Returns the number of asynchronous backups.
      Returns:
        the number of asynchronous backups
      See Also:
        `setAsyncBackupCount(int)`

    - #### setAsyncBackupCount

          public SemaphoreConfig setAsyncBackupCount(int asyncBackupCount)

      Sets the number of asynchronous backups. 0 means no backups.
      Parameters:
        `asyncBackupCount` - the number of asynchronous synchronous backups to set
      Returns:
        the updated SemaphoreConfig
      Throws:
        `IllegalArgumentException` - if asyncBackupCount smaller than 0, or larger than the maximum number of backup or the sum of the backups and async backups is larger than the maximum number of backups
      See Also:
        `setBackupCount(int)`, `getAsyncBackupCount()`

    - #### getTotalBackupCount

          public int getTotalBackupCount()

      Returns the total number of backups (synchronous plus asynchronous); the returned value will always equal or bigger than 0.
      Returns:
        the total number of backups (synchronous plus asynchronous)

    - #### getQuorumName

          public String getQuorumName()

    - #### setQuorumName

          public SemaphoreConfig setQuorumName(String quorumName)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getFactoryId

          public int getFactoryId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
        `getFactoryId` in interface `IdentifiedDataSerializable`
      Returns:
        factory ID

    - #### getId

          public int getId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
        `getId` in interface `IdentifiedDataSerializable`
      Returns:
        type ID

    - #### writeData

          public void writeData(ObjectDataOutput out)
                         throws IOException

      Description copied from interface: `DataSerializable`
      Writes object fields to output stream
      Specified by:
        `writeData` in interface `DataSerializable`
      Parameters:
        `out` - output
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the output stream has been closed.

    - #### readData

          public void readData(ObjectDataInput in)
                        throws IOException

      Description copied from interface: `DataSerializable`
      Reads fields from the input stream
      Specified by:
        `readData` in interface `DataSerializable`
      Parameters:
        `in` - input
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the input stream has been closed.

    - #### equals

          public final boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2020. All rights reserved.