blob: 0bd9d6cd4eca102b32010c3b4da41826aeea0439 [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
= Atomic Types
:javaFile: {javaCodeDir}/DataStructures.java
Ignite supports distributed atomic long and atomic reference, similar to `java.util.concurrent.atomic.AtomicLong` and `java.util.concurrent.atomic.AtomicReference` respectively.
Atomics in Ignite are distributed across the cluster, essentially enabling performing atomic operations (such as increment-and-get or compare-and-set) with the same globally-visible value. For example, you could update the value of an atomic long on one node and read it from another node.
Features:
* Retrieve current value.
* Atomically modify current value.
* Atomically increment or decrement current value.
* Atomically compare-and-set the current value to new value.
Distributed atomic long and atomic reference can be obtained via `IgniteAtomicLong` and `IgniteAtomicReference` interfaces respectively, as shown below:
.AtomicLong:
[source, java]
----
include::{javaFile}[tags=atomic-long, indent=0]
----
.AtomicReference:
[source, java]
----
include::{javaFile}[tags=atomic-reference, indent=0]
----
All atomic operations provided by `IgniteAtomicLong` and `IgniteAtomicReference` are synchronous. The time an atomic operation will take depends on the number of nodes performing concurrent operations with the same instance of atomic long, the intensity of these operations, and network latency.
== Atomic Configuration
Atomics in Ignite can be configured via the `atomicConfiguration` property of `IgniteConfiguration`.
The following table lists available configuration parameters:
[cols="1,1,1",opts="header"]
|===
| Setter | Description | Default
| `setBackups(int)` | The number of backups. | 0
| `setCacheMode(CacheMode)` | Cache mode for all atomic types. | `PARTITIONED`
| `setAtomicSequenceReserveSize(int)` | Sets the number of sequence values reserved for `IgniteAtomicSequence` instances. | 1000
|===