Ignite-454 java8 support
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1adfd615 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1adfd615 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1adfd615 Branch: refs/heads/ignite-454 Commit: 1adfd615716412706ea67cc6ad13cdfc2b7341ab Parents: 5ab695b Author: avinogradov <[email protected]> Authored: Mon Mar 16 18:06:38 2015 +0300 Committer: avinogradov <[email protected]> Committed: Mon Mar 16 18:06:38 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheAdapter.java | 4 +- .../processors/igfs/IgfsLocalMetrics.java | 28 +- .../processors/rest/GridRestProcessor.java | 2 +- .../streamer/StreamerMetricsHolder.java | 22 +- .../streamer/StreamerStageMetricsHolder.java | 10 +- .../processors/task/GridTaskProcessor.java | 2 +- .../util/offheap/unsafe/GridUnsafeMap.java | 6 +- .../unsafe/GridUnsafePartitionedMap.java | 2 +- .../index/StreamerIndexProviderAdapter.java | 2 +- .../org/jdk8/backport/ConcurrentHashMap8.java | 14 +- .../jdk8/backport/ConcurrentLinkedDeque8.java | 2 +- .../jdk8/backport/ConcurrentLinkedHashMap.java | 4 +- .../main/java/org/jdk8/backport/LongAdder.java | 235 ------------ .../main/java/org/jdk8/backport/LongAdder8.java | 235 ++++++++++++ .../main/java/org/jdk8/backport/Striped64.java | 370 ------------------- .../java/org/jdk8/backport/Striped64_8.java | 370 +++++++++++++++++++ ...CacheJdbcBlobStoreMultithreadedSelfTest.java | 4 +- .../IgniteDataStreamerPerformanceTest.java | 2 +- .../future/GridFutureListenPerformanceTest.java | 2 +- .../ignite/jvmtest/BlockingQueueTest.java | 2 +- .../lang/GridFutureListenPerformanceTest.java | 2 +- .../colocation/GridTestCacheStore.java | 3 +- .../communication/GridIoManagerBenchmark.java | 2 +- .../job/GridJobExecutionLoadTestClient.java | 2 +- ...GridJobExecutionLoadTestClientSemaphore.java | 2 +- ...JobExecutionSingleNodeSemaphoreLoadTest.java | 4 +- .../tests/p2p/GridExternalAffinityFunction.java | 2 +- .../query/h2/opt/GridLuceneIndex.java | 7 +- .../query/h2/sql/GridSqlQueryParser.java | 4 +- modules/schema-import/pom.xml | 18 +- pom.xml | 2 +- 31 files changed, 682 insertions(+), 684 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 02501c2..0a49215 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -193,7 +193,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, private boolean mongoMetaCache; /** Current IGFS data cache size. */ - private LongAdder igfsDataCacheSize; + private LongAdder8 igfsDataCacheSize; /** Max space for IGFS. */ private long igfsDataSpaceMax; @@ -257,7 +257,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (F.eq(ctx.name(), igfsCfg.getDataCacheName())) { if (!ctx.isNear()) { igfsDataCache = true; - igfsDataCacheSize = new LongAdder(); + igfsDataCacheSize = new LongAdder8(); igfsDataSpaceMax = igfsCfg.getMaxSpaceSize(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLocalMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLocalMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLocalMetrics.java index fda1ef9..1247f5f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLocalMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsLocalMetrics.java @@ -26,22 +26,22 @@ import org.jdk8.backport.*; */ public class IgfsLocalMetrics { /** Block reads. First value - total reads, second value - reads delegated to the secondary file system. */ - private volatile IgniteBiTuple<LongAdder, LongAdder> blocksRead; + private volatile IgniteBiTuple<LongAdder8, LongAdder8> blocksRead; /** Block writes. First value - total writes, second value - writes delegated to the secondary file system. */ - private volatile IgniteBiTuple<LongAdder, LongAdder> blocksWritten; + private volatile IgniteBiTuple<LongAdder8, LongAdder8> blocksWritten; /** Byte reads. First value - total bytes read, second value - consumed time. */ - private volatile IgniteBiTuple<LongAdder, LongAdder> bytesRead; + private volatile IgniteBiTuple<LongAdder8, LongAdder8> bytesRead; /** Byte writes. First value - total bytes written, second value - consumed time. */ - private volatile IgniteBiTuple<LongAdder, LongAdder> bytesWritten; + private volatile IgniteBiTuple<LongAdder8, LongAdder8> bytesWritten; /** Number of files opened for read. */ - private final LongAdder filesOpenedForRead = new LongAdder(); + private final LongAdder8 filesOpenedForRead = new LongAdder8(); /** Number of files opened for write. */ - private final LongAdder filesOpenedForWrite = new LongAdder(); + private final LongAdder8 filesOpenedForWrite = new LongAdder8(); /** * Constructor. @@ -71,7 +71,7 @@ public class IgfsLocalMetrics { * @param readTime Read time. */ void addReadBytesTime(long readBytes, long readTime) { - IgniteBiTuple<LongAdder, LongAdder> bytesRead0 = bytesRead; + IgniteBiTuple<LongAdder8, LongAdder8> bytesRead0 = bytesRead; bytesRead0.get1().add(readBytes); bytesRead0.get2().add(readTime); @@ -98,7 +98,7 @@ public class IgfsLocalMetrics { * @param writeTime Write time. */ void addWrittenBytesTime(long writtenBytes, long writeTime) { - IgniteBiTuple<LongAdder, LongAdder> bytesWritten0 = bytesWritten; + IgniteBiTuple<LongAdder8, LongAdder8> bytesWritten0 = bytesWritten; bytesWritten0.get1().add(writtenBytes); bytesWritten0.get2().add(writeTime); @@ -125,7 +125,7 @@ public class IgfsLocalMetrics { * @param secondary Number of blocks read form secondary FS. */ void addReadBlocks(int total, int secondary) { - IgniteBiTuple<LongAdder, LongAdder> blocksRead0 = blocksRead; + IgniteBiTuple<LongAdder8, LongAdder8> blocksRead0 = blocksRead; blocksRead0.get1().add(total); blocksRead0.get2().add(secondary); @@ -152,7 +152,7 @@ public class IgfsLocalMetrics { * @param secondary Number of blocks written to secondary FS. */ void addWriteBlocks(int total, int secondary) { - IgniteBiTuple<LongAdder, LongAdder> blocksWritten0 = blocksWritten; + IgniteBiTuple<LongAdder8, LongAdder8> blocksWritten0 = blocksWritten; blocksWritten0.get1().add(total); blocksWritten0.get2().add(secondary); @@ -204,9 +204,9 @@ public class IgfsLocalMetrics { * Reset summary counters. */ void reset() { - blocksRead = F.t(new LongAdder(), new LongAdder()); - blocksWritten = F.t(new LongAdder(), new LongAdder()); - bytesRead = F.t(new LongAdder(), new LongAdder()); - bytesWritten = F.t(new LongAdder(), new LongAdder()); + blocksRead = F.t(new LongAdder8(), new LongAdder8()); + blocksWritten = F.t(new LongAdder8(), new LongAdder8()); + bytesRead = F.t(new LongAdder8(), new LongAdder8()); + bytesWritten = F.t(new LongAdder8(), new LongAdder8()); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java index fe47a1f..c132a72 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java @@ -71,7 +71,7 @@ public class GridRestProcessor extends GridProcessorAdapter { private final GridSpinReadWriteLock busyLock = new GridSpinReadWriteLock(); /** Workers count. */ - private final LongAdder workersCnt = new LongAdder(); + private final LongAdder8 workersCnt = new LongAdder8(); /** SecurityContext map. */ private ConcurrentMap<UUID, SecurityContext> sesMap = new ConcurrentHashMap<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerMetricsHolder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerMetricsHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerMetricsHolder.java index c130510..cfbd172 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerMetricsHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerMetricsHolder.java @@ -37,13 +37,13 @@ public class StreamerMetricsHolder implements StreamerMetrics { private volatile long lastStageSampleTs; /** Number of running stages. */ - private LongAdder stageActiveCnt = new LongAdder(); + private LongAdder8 stageActiveCnt = new LongAdder8(); /** Number of waiting stages. */ - private LongAdder stageWaitingCnt = new LongAdder(); + private LongAdder8 stageWaitingCnt = new LongAdder8(); /** Total number of stages executed. */ - private LongAdder stageTotalCnt = new LongAdder(); + private LongAdder8 stageTotalCnt = new LongAdder8(); /** Max exec time. */ private GridAtomicLong pipelineMaxExecTime = new GridAtomicLong(); @@ -52,7 +52,7 @@ public class StreamerMetricsHolder implements StreamerMetrics { private GridAtomicLong pipelineMinExecTime = new GridAtomicLong(Long.MAX_VALUE); /** Pipeline average exec time sampler. */ - private LongAdder pipelineSumExecTime = new LongAdder(); + private LongAdder8 pipelineSumExecTime = new LongAdder8(); /** Max exec nodes. */ private GridAtomicInteger pipelineMaxExecNodes = new GridAtomicInteger(); @@ -61,10 +61,10 @@ public class StreamerMetricsHolder implements StreamerMetrics { private GridAtomicInteger pipelineMinExecNodes = new GridAtomicInteger(Integer.MAX_VALUE); /** Avg exec nodes. */ - private LongAdder pipelineSumExecNodes = new LongAdder(); + private LongAdder8 pipelineSumExecNodes = new LongAdder8(); /** Total number of pipelines finished on this node. */ - private LongAdder pipelineTotalCnt = new LongAdder(); + private LongAdder8 pipelineTotalCnt = new LongAdder8(); /** Query max exec time. */ private GridAtomicLong qryMaxExecTime = new GridAtomicLong(); @@ -73,7 +73,7 @@ public class StreamerMetricsHolder implements StreamerMetrics { private GridAtomicLong qryMinExecTime = new GridAtomicLong(Long.MAX_VALUE); /** Query average exec time sampler. */ - private LongAdder qrySumExecTime = new LongAdder(); + private LongAdder8 qrySumExecTime = new LongAdder8(); /** Query max exec nodes. */ private GridAtomicInteger qryMaxExecNodes = new GridAtomicInteger(); @@ -82,19 +82,19 @@ public class StreamerMetricsHolder implements StreamerMetrics { private GridAtomicInteger qryMinExecNodes = new GridAtomicInteger(Integer.MAX_VALUE); /** Query avg exec nodes. */ - private LongAdder qrySumExecNodes = new LongAdder(); + private LongAdder8 qrySumExecNodes = new LongAdder8(); /** Total number of queries finished on this node. */ - private LongAdder qryTotalCnt = new LongAdder(); + private LongAdder8 qryTotalCnt = new LongAdder8(); /** Current active sessions. */ - private LongAdder curActiveSessions = new LongAdder(); + private LongAdder8 curActiveSessions = new LongAdder8(); /** Max active sessions. */ private GridAtomicInteger maxActiveSessions = new GridAtomicInteger(); /** Failures count. */ - private LongAdder failuresCnt = new LongAdder(); + private LongAdder8 failuresCnt = new LongAdder8(); /** Stages metrics. */ private final StreamerStageMetricsHolder[] stageMetrics; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerStageMetricsHolder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerStageMetricsHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerStageMetricsHolder.java index ed95628..91c3dfa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerStageMetricsHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/StreamerStageMetricsHolder.java @@ -35,7 +35,7 @@ public class StreamerStageMetricsHolder implements StreamerStageMetrics { private GridAtomicLong maxExecTime = new GridAtomicLong(); /** Stage execution time sum. */ - private LongAdder sumExecTime = new LongAdder(); + private LongAdder8 sumExecTime = new LongAdder8(); /** Stage minimum waiting time. */ private GridAtomicLong minWaitTime = new GridAtomicLong(Long.MAX_VALUE); @@ -44,16 +44,16 @@ public class StreamerStageMetricsHolder implements StreamerStageMetrics { private GridAtomicLong maxWaitTime = new GridAtomicLong(); /** Stage average waiting time sum. */ - private LongAdder sumWaitTime = new LongAdder(); + private LongAdder8 sumWaitTime = new LongAdder8(); /** Total number of times this stage was executed. */ - private LongAdder totalExecCnt = new LongAdder(); + private LongAdder8 totalExecCnt = new LongAdder8(); /** Failures count. */ - private LongAdder failuresCnt = new LongAdder(); + private LongAdder8 failuresCnt = new LongAdder8(); /** Number of threads executing this stage. */ - private LongAdder curActive = new LongAdder(); + private LongAdder8 curActive = new LongAdder8(); /** * @param name Stage name. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java index a686d37..7ba5d67 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java @@ -73,7 +73,7 @@ public class GridTaskProcessor extends GridProcessorAdapter { private final GridLocalEventListener discoLsnr; /** Total executed tasks. */ - private final LongAdder execTasks = new LongAdder(); + private final LongAdder8 execTasks = new LongAdder8(); /** */ private final ThreadLocal<Map<GridTaskThreadContextKey, Object>> thCtx = http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java index dc742c7..3028f38 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java @@ -92,7 +92,7 @@ public class GridUnsafeMap<K> implements GridOffHeapMap<K> { private final GridUnsafeLru lru; /** Total entry count. */ - private final LongAdder totalCnt; + private final LongAdder8 totalCnt; /** Event listener. */ private GridOffHeapEventListener evtLsnr; @@ -128,7 +128,7 @@ public class GridUnsafeMap<K> implements GridOffHeapMap<K> { if (lru != null) this.evictLsnr = evictLsnr; - totalCnt = new LongAdder(); + totalCnt = new LongAdder8(); // Find power-of-two sizes best matching arguments int shift = 0; @@ -186,7 +186,7 @@ public class GridUnsafeMap<K> implements GridOffHeapMap<K> { * @param lruPoller LRU poller. */ @SuppressWarnings("unchecked") - GridUnsafeMap(int part, int concurrency, float load, long initCap, LongAdder totalCnt, GridUnsafeMemory mem, + GridUnsafeMap(int part, int concurrency, float load, long initCap, LongAdder8 totalCnt, GridUnsafeMemory mem, GridUnsafeLru lru, @Nullable GridOffHeapEvictListener evictLsnr, GridUnsafeLruPoller lruPoller) { this.part = part; this.concurrency = concurrency > MAX_CONCURRENCY ? MAX_CONCURRENCY : concurrency; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java index 4d4ba61..af6f9bd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java @@ -60,7 +60,7 @@ public class GridUnsafePartitionedMap implements GridOffHeapPartitionedMap { private final int parts; /** */ - private final LongAdder totalCnt = new LongAdder(); + private final LongAdder8 totalCnt = new LongAdder8(); /** * @param parts Partitions. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/apache/ignite/streamer/index/StreamerIndexProviderAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/streamer/index/StreamerIndexProviderAdapter.java b/modules/core/src/main/java/org/apache/ignite/streamer/index/StreamerIndexProviderAdapter.java index 51f34ee..6a672a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/streamer/index/StreamerIndexProviderAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/streamer/index/StreamerIndexProviderAdapter.java @@ -66,7 +66,7 @@ public abstract class StreamerIndexProviderAdapter<E, K, V> implements StreamerI private StreamerIndexUpdater<E, K, V> updater; /** */ - private final LongAdder evtsCnt = new LongAdder(); + private final LongAdder8 evtsCnt = new LongAdder8(); /** Read write lock. */ private final GridSpinReadWriteLock rwLock = new GridSpinReadWriteLock(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/ConcurrentHashMap8.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/ConcurrentHashMap8.java b/modules/core/src/main/java/org/jdk8/backport/ConcurrentHashMap8.java index 91181d5..3110d5c 100644 --- a/modules/core/src/main/java/org/jdk8/backport/ConcurrentHashMap8.java +++ b/modules/core/src/main/java/org/jdk8/backport/ConcurrentHashMap8.java @@ -106,7 +106,7 @@ import java.util.concurrent.locks.*; * same mapping value. * * <p>A ConcurrentHashMapV8 can be used as scalable frequency map (a - * form of histogram or multiset) by using {@link LongAdder} values + * form of histogram or multiset) by using {@link LongAdder8} values * and initializing via {@link #computeIfAbsent}. For example, to add * a count to a {@code ConcurrentHashMapV8<String,LongAdder> freqs}, you * can use {@code freqs.computeIfAbsent(k -> new @@ -554,7 +554,7 @@ public class ConcurrentHashMap8<K, V> /** * The counter maintaining number of elements. */ - private transient final LongAdder counter; + private transient final LongAdder8 counter; /** * Table initialization and resizing control. When negative, the @@ -2477,7 +2477,7 @@ public class ConcurrentHashMap8<K, V> * Creates a new, empty map with the default initial table size (16). */ public ConcurrentHashMap8() { - this.counter = new LongAdder(); + this.counter = new LongAdder8(); } /** @@ -2496,7 +2496,7 @@ public class ConcurrentHashMap8<K, V> int cap = ((initialCapacity >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY : tableSizeFor(initialCapacity + (initialCapacity >>> 1) + 1)); - this.counter = new LongAdder(); + this.counter = new LongAdder8(); this.sizeCtl = cap; } @@ -2506,7 +2506,7 @@ public class ConcurrentHashMap8<K, V> * @param m the map */ public ConcurrentHashMap8(Map<? extends K, ? extends V> m) { - this.counter = new LongAdder(); + this.counter = new LongAdder8(); this.sizeCtl = DEFAULT_CAPACITY; internalPutAll(m); } @@ -2557,7 +2557,7 @@ public class ConcurrentHashMap8<K, V> long size = (long)(1.0 + (long)initialCapacity / loadFactor); int cap = (size >= (long)MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : tableSizeFor((int)size); - this.counter = new LongAdder(); + this.counter = new LongAdder8(); this.sizeCtl = cap; } @@ -3335,7 +3335,7 @@ public class ConcurrentHashMap8<K, V> s.defaultReadObject(); this.segments = null; // unneeded // initialize transient final field - UNSAFE.putObjectVolatile(this, counterOffset, new LongAdder()); + UNSAFE.putObjectVolatile(this, counterOffset, new LongAdder8()); // Create all nodes, then place in table once size is known long size = 0L; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedDeque8.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedDeque8.java b/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedDeque8.java index 3f149ab..fd4f43d 100644 --- a/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedDeque8.java +++ b/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedDeque8.java @@ -272,7 +272,7 @@ public class ConcurrentLinkedDeque8<E> extends AbstractCollection<E> implements private volatile Node<E> tail; /** */ - private final LongAdder size = new LongAdder(); + private final LongAdder8 size = new LongAdder8(); /** Previous and next terminators. */ private static final Node<Object> PREV_TERMINATOR, NEXT_TERMINATOR; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedHashMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedHashMap.java b/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedHashMap.java index 8992e77..9f13f37 100644 --- a/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedHashMap.java +++ b/modules/core/src/main/java/org/jdk8/backport/ConcurrentLinkedHashMap.java @@ -206,10 +206,10 @@ public class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K, V> implements private final ConcurrentLinkedDeque8<HashEntry<K, V>> entryQ; /** Atomic variable containing map size. */ - private final LongAdder size = new LongAdder(); + private final LongAdder8 size = new LongAdder8(); /** */ - private final LongAdder modCnt = new LongAdder(); + private final LongAdder8 modCnt = new LongAdder8(); /** */ private final int maxCap; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/LongAdder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/LongAdder.java b/modules/core/src/main/java/org/jdk8/backport/LongAdder.java deleted file mode 100644 index 1460b4c..0000000 --- a/modules/core/src/main/java/org/jdk8/backport/LongAdder.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -/* - * Copyright © 1993, 2013, Oracle and/or its affiliates. - * All rights reserved. - */ - -package org.jdk8.backport; - -import java.io.*; -import java.util.concurrent.atomic.*; - -/** - * One or more variables that together maintain an initially zero - * {@code long} sum. When updates (method {@link #add}) are contended - * across threads, the set of variables may grow dynamically to reduce - * contention. Method {@link #sum} (or, equivalently, {@link - * #longValue}) returns the current total combined across the - * variables maintaining the sum. - * - * <p> This class is usually preferable to {@link AtomicLong} when - * multiple threads update a common sum that is used for purposes such - * as collecting statistics, not for fine-grained synchronization - * control. Under low update contention, the two classes have similar - * characteristics. But under high contention, expected throughput of - * this class is significantly higher, at the expense of higher space - * consumption. - * - * <p>This class extends {@link Number}, but does <em>not</em> define - * methods such as {@code hashCode} and {@code compareTo} because - * instances are expected to be mutated, and so are not useful as - * collection keys. - * - * <p><em>jsr166e note: This class is targeted to be placed in - * java.util.concurrent.atomic<em> - * - * @since 1.8 - * @author Doug Lea - */ -@SuppressWarnings("ALL") -public class LongAdder extends Striped64 implements Serializable { - private static final long serialVersionUID = 7249069246863182397L; - - /** - * Version of plus for use in retryUpdate - */ - final long fn(long v, long x) { return v + x; } - - /** - * Creates a new adder with initial sum of zero. - */ - public LongAdder() { - } - - /** - * Adds the given value. - * - * @param x the value to add - */ - public void add(long x) { - Cell[] as; long b, v; HashCode hc; Cell a; int n; - if ((as = cells) != null || !casBase(b = base, b + x)) { - boolean uncontended = true; - int h = (hc = threadHashCode.get()).code; - if (as == null || (n = as.length) < 1 || - (a = as[(n - 1) & h]) == null || - !(uncontended = a.cas(v = a.value, v + x))) - retryUpdate(x, hc, uncontended); - } - } - - /** - * Equivalent to {@code add(1)}. - */ - public void increment() { - add(1L); - } - - /** - * Equivalent to {@code add(-1)}. - */ - public void decrement() { - add(-1L); - } - - /** - * Returns the current sum. The returned value is <em>NOT</em> an - * atomic snapshot: Invocation in the absence of concurrent - * updates returns an accurate result, but concurrent updates that - * occur while the sum is being calculated might not be - * incorporated. - * - * @return the sum - */ - public long sum() { - long sum = base; - Cell[] as = cells; - if (as != null) { - int n = as.length; - for (int i = 0; i < n; ++i) { - Cell a = as[i]; - if (a != null) - sum += a.value; - } - } - return sum; - } - - /** - * Resets variables maintaining the sum to zero. This method may - * be a useful alternative to creating a new adder, but is only - * effective if there are no concurrent updates. Because this - * method is intrinsically racy, it should only be used when it is - * known that no threads are concurrently updating. - */ - public void reset() { - internalReset(0L); - } - - /** - * Equivalent in effect to {@link #sum} followed by {@link - * #reset}. This method may apply for example during quiescent - * points between multithreaded computations. If there are - * updates concurrent with this method, the returned value is - * <em>not</em> guaranteed to be the final value occurring before - * the reset. - * - * @return the sum - */ - public long sumThenReset() { - long sum = base; - Cell[] as = cells; - base = 0L; - if (as != null) { - int n = as.length; - for (int i = 0; i < n; ++i) { - Cell a = as[i]; - if (a != null) { - sum += a.value; - a.value = 0L; - } - } - } - return sum; - } - - /** - * Equivalent to {@link #sum}. - * - * @return the sum - */ - public long longValue() { - return sum(); - } - - /** - * Returns the {@link #sum} as an {@code int} after a narrowing - * primitive conversion. - */ - public int intValue() { - return (int)sum(); - } - - /** - * Returns the {@link #sum} as a {@code float} - * after a widening primitive conversion. - */ - public float floatValue() { - return (float)sum(); - } - - /** - * Returns the {@link #sum} as a {@code double} after a widening - * primitive conversion. - */ - public double doubleValue() { - return (double)sum(); - } - - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - s.defaultWriteObject(); - s.writeLong(sum()); - } - - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException { - s.defaultReadObject(); - busy = 0; - cells = null; - base = s.readLong(); - } - - /** - * Returns the String representation of the {@link #sum}. - * - * @return String representation of the {@link #sum} - */ - public String toString() { - return Long.toString(sum()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/LongAdder8.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/LongAdder8.java b/modules/core/src/main/java/org/jdk8/backport/LongAdder8.java new file mode 100644 index 0000000..de741a1 --- /dev/null +++ b/modules/core/src/main/java/org/jdk8/backport/LongAdder8.java @@ -0,0 +1,235 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* + * Copyright © 1993, 2013, Oracle and/or its affiliates. + * All rights reserved. + */ + +package org.jdk8.backport; + +import java.io.*; +import java.util.concurrent.atomic.*; + +/** + * One or more variables that together maintain an initially zero + * {@code long} sum. When updates (method {@link #add}) are contended + * across threads, the set of variables may grow dynamically to reduce + * contention. Method {@link #sum} (or, equivalently, {@link + * #longValue}) returns the current total combined across the + * variables maintaining the sum. + * + * <p> This class is usually preferable to {@link AtomicLong} when + * multiple threads update a common sum that is used for purposes such + * as collecting statistics, not for fine-grained synchronization + * control. Under low update contention, the two classes have similar + * characteristics. But under high contention, expected throughput of + * this class is significantly higher, at the expense of higher space + * consumption. + * + * <p>This class extends {@link Number}, but does <em>not</em> define + * methods such as {@code hashCode} and {@code compareTo} because + * instances are expected to be mutated, and so are not useful as + * collection keys. + * + * <p><em>jsr166e note: This class is targeted to be placed in + * java.util.concurrent.atomic<em> + * + * @since 1.8 + * @author Doug Lea + */ +@SuppressWarnings("ALL") +public class LongAdder8 extends Striped64_8 implements Serializable { + private static final long serialVersionUID = 7249069246863182397L; + + /** + * Version of plus for use in retryUpdate + */ + final long fn(long v, long x) { return v + x; } + + /** + * Creates a new adder with initial sum of zero. + */ + public LongAdder8() { + } + + /** + * Adds the given value. + * + * @param x the value to add + */ + public void add(long x) { + Cell[] as; long b, v; HashCode hc; Cell a; int n; + if ((as = cells) != null || !casBase(b = base, b + x)) { + boolean uncontended = true; + int h = (hc = threadHashCode.get()).code; + if (as == null || (n = as.length) < 1 || + (a = as[(n - 1) & h]) == null || + !(uncontended = a.cas(v = a.value, v + x))) + retryUpdate(x, hc, uncontended); + } + } + + /** + * Equivalent to {@code add(1)}. + */ + public void increment() { + add(1L); + } + + /** + * Equivalent to {@code add(-1)}. + */ + public void decrement() { + add(-1L); + } + + /** + * Returns the current sum. The returned value is <em>NOT</em> an + * atomic snapshot: Invocation in the absence of concurrent + * updates returns an accurate result, but concurrent updates that + * occur while the sum is being calculated might not be + * incorporated. + * + * @return the sum + */ + public long sum() { + long sum = base; + Cell[] as = cells; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) + sum += a.value; + } + } + return sum; + } + + /** + * Resets variables maintaining the sum to zero. This method may + * be a useful alternative to creating a new adder, but is only + * effective if there are no concurrent updates. Because this + * method is intrinsically racy, it should only be used when it is + * known that no threads are concurrently updating. + */ + public void reset() { + internalReset(0L); + } + + /** + * Equivalent in effect to {@link #sum} followed by {@link + * #reset}. This method may apply for example during quiescent + * points between multithreaded computations. If there are + * updates concurrent with this method, the returned value is + * <em>not</em> guaranteed to be the final value occurring before + * the reset. + * + * @return the sum + */ + public long sumThenReset() { + long sum = base; + Cell[] as = cells; + base = 0L; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) { + sum += a.value; + a.value = 0L; + } + } + } + return sum; + } + + /** + * Equivalent to {@link #sum}. + * + * @return the sum + */ + public long longValue() { + return sum(); + } + + /** + * Returns the {@link #sum} as an {@code int} after a narrowing + * primitive conversion. + */ + public int intValue() { + return (int)sum(); + } + + /** + * Returns the {@link #sum} as a {@code float} + * after a widening primitive conversion. + */ + public float floatValue() { + return (float)sum(); + } + + /** + * Returns the {@link #sum} as a {@code double} after a widening + * primitive conversion. + */ + public double doubleValue() { + return (double)sum(); + } + + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + s.defaultWriteObject(); + s.writeLong(sum()); + } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + busy = 0; + cells = null; + base = s.readLong(); + } + + /** + * Returns the String representation of the {@link #sum}. + * + * @return String representation of the {@link #sum} + */ + public String toString() { + return Long.toString(sum()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/Striped64.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/Striped64.java b/modules/core/src/main/java/org/jdk8/backport/Striped64.java deleted file mode 100644 index e0e724d..0000000 --- a/modules/core/src/main/java/org/jdk8/backport/Striped64.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -/* - * Copyright © 1993, 2013, Oracle and/or its affiliates. - * All rights reserved. - */ - -package org.jdk8.backport; - -import java.util.*; - -/** - * A package-local class holding common representation and mechanics - * for classes supporting dynamic striping on 64bit values. The class - * extends Number so that concrete subclasses must publicly do so. - */ -@SuppressWarnings("ALL") -abstract class Striped64 extends Number { - /* - * This class maintains a lazily-initialized table of atomically - * updated variables, plus an extra "base" field. The table size - * is a power of two. Indexing uses masked per-thread hash codes. - * Nearly all declarations in this class are package-private, - * accessed directly by subclasses. - * - * Table entries are of class Cell; a variant of AtomicLong padded - * to reduce cache contention on most processors. Padding is - * overkill for most Atomics because they are usually irregularly - * scattered in memory and thus don't interfere much with each - * other. But Atomic objects residing in arrays will tend to be - * placed adjacent to each other, and so will most often share - * cache lines (with a huge negative performance impact) without - * this precaution. - * - * In part because Cells are relatively large, we avoid creating - * them until they are needed. When there is no contention, all - * updates are made to the base field. Upon first contention (a - * failed CAS on base update), the table is initialized to size 2. - * The table size is doubled upon further contention until - * reaching the nearest power of two greater than or equal to the - * number of CPUS. Table slots remain empty (null) until they are - * needed. - * - * A single spinlock ("busy") is used for initializing and - * resizing the table, as well as populating slots with new Cells. - * There is no need for a blocking lock: When the lock is not - * available, threads try other slots (or the base). During these - * retries, there is increased contention and reduced locality, - * which is still better than alternatives. - * - * Per-thread hash codes are initialized to random values. - * Contention and/or table collisions are indicated by failed - * CASes when performing an update operation (see method - * retryUpdate). Upon a collision, if the table size is less than - * the capacity, it is doubled in size unless some other thread - * holds the lock. If a hashed slot is empty, and lock is - * available, a new Cell is created. Otherwise, if the slot - * exists, a CAS is tried. Retries proceed by "double hashing", - * using a secondary hash (Marsaglia XorShift) to try to find a - * free slot. - * - * The table size is capped because, when there are more threads - * than CPUs, supposing that each thread were bound to a CPU, - * there would exist a perfect hash function mapping threads to - * slots that eliminates collisions. When we reach capacity, we - * search for this mapping by randomly varying the hash codes of - * colliding threads. Because search is random, and collisions - * only become known via CAS failures, convergence can be slow, - * and because threads are typically not bound to CPUS forever, - * may not occur at all. However, despite these limitations, - * observed contention rates are typically low in these cases. - * - * It is possible for a Cell to become unused when threads that - * once hashed to it terminate, as well as in the case where - * doubling the table causes no thread to hash to it under - * expanded mask. We do not try to detect or remove such cells, - * under the assumption that for long-running instances, observed - * contention levels will recur, so the cells will eventually be - * needed again; and for short-lived ones, it does not matter. - */ - - /** - * Padded variant of AtomicLong supporting only raw accesses plus CAS. - * The value field is placed between pads, hoping that the JVM doesn't - * reorder them. - * - * JVM intrinsics note: It would be possible to use a release-only - * form of CAS here, if it were provided. - */ - static final class Cell { - volatile long p0, p1, p2, p3, p4, p5, p6; - volatile long value; - volatile long q0, q1, q2, q3, q4, q5, q6; - Cell(long x) { value = x; } - - final boolean cas(long cmp, long val) { - return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val); - } - - // Unsafe mechanics - private static final sun.misc.Unsafe UNSAFE; - private static final long valueOffset; - static { - try { - UNSAFE = getUnsafe(); - Class<?> ak = Cell.class; - valueOffset = UNSAFE.objectFieldOffset - (ak.getDeclaredField("value")); - } catch (Exception e) { - throw new Error(e); - } - } - - } - - /** - * Holder for the thread-local hash code. The code is initially - * random, but may be set to a different value upon collisions. - */ - static final class HashCode { - static final Random rng = new Random(); - int code; - HashCode() { - int h = rng.nextInt(); // Avoid zero to allow xorShift rehash - code = (h == 0) ? 1 : h; - } - } - - /** - * The corresponding ThreadLocal class - */ - static final class ThreadHashCode extends ThreadLocal<HashCode> { - public HashCode initialValue() { return new HashCode(); } - } - - /** - * Static per-thread hash codes. Shared across all instances to - * reduce ThreadLocal pollution and because adjustments due to - * collisions in one table are likely to be appropriate for - * others. - */ - static final ThreadHashCode threadHashCode = new ThreadHashCode(); - - /** Number of CPUS, to place bound on table size */ - static final int NCPU = Runtime.getRuntime().availableProcessors(); - - /** - * Table of cells. When non-null, size is a power of 2. - */ - transient volatile Cell[] cells; - - /** - * Base value, used mainly when there is no contention, but also as - * a fallback during table initialization races. Updated via CAS. - */ - transient volatile long base; - - /** - * Spinlock (locked via CAS) used when resizing and/or creating Cells. - */ - transient volatile int busy; - - /** - * Package-private default constructor - */ - Striped64() { - } - - /** - * CASes the base field. - */ - final boolean casBase(long cmp, long val) { - return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val); - } - - /** - * CASes the busy field from 0 to 1 to acquire lock. - */ - final boolean casBusy() { - return UNSAFE.compareAndSwapInt(this, busyOffset, 0, 1); - } - - /** - * Computes the function of current and new value. Subclasses - * should open-code this update function for most uses, but the - * virtualized form is needed within retryUpdate. - * - * @param currentValue the current value (of either base or a cell) - * @param newValue the argument from a user update call - * @return result of the update function - */ - abstract long fn(long currentValue, long newValue); - - /** - * Handles cases of updates involving initialization, resizing, - * creating new Cells, and/or contention. See above for - * explanation. This method suffers the usual non-modularity - * problems of optimistic retry code, relying on rechecked sets of - * reads. - * - * @param x the value - * @param hc the hash code holder - * @param wasUncontended false if CAS failed before call - */ - final void retryUpdate(long x, HashCode hc, boolean wasUncontended) { - int h = hc.code; - boolean collide = false; // True if last slot nonempty - for (;;) { - Cell[] as; Cell a; int n; long v; - if ((as = cells) != null && (n = as.length) > 0) { - if ((a = as[(n - 1) & h]) == null) { - if (busy == 0) { // Try to attach new Cell - Cell r = new Cell(x); // Optimistically create - if (busy == 0 && casBusy()) { - boolean created = false; - try { // Recheck under lock - Cell[] rs; int m, j; - if ((rs = cells) != null && - (m = rs.length) > 0 && - rs[j = (m - 1) & h] == null) { - rs[j] = r; - created = true; - } - } finally { - busy = 0; - } - if (created) - break; - continue; // Slot is now non-empty - } - } - collide = false; - } - else if (!wasUncontended) // CAS already known to fail - wasUncontended = true; // Continue after rehash - else if (a.cas(v = a.value, fn(v, x))) - break; - else if (n >= NCPU || cells != as) - collide = false; // At max size or stale - else if (!collide) - collide = true; - else if (busy == 0 && casBusy()) { - try { - if (cells == as) { // Expand table unless stale - Cell[] rs = new Cell[n << 1]; - for (int i = 0; i < n; ++i) - rs[i] = as[i]; - cells = rs; - } - } finally { - busy = 0; - } - collide = false; - continue; // Retry with expanded table - } - h ^= h << 13; // Rehash - h ^= h >>> 17; - h ^= h << 5; - } - else if (busy == 0 && cells == as && casBusy()) { - boolean init = false; - try { // Initialize table - if (cells == as) { - Cell[] rs = new Cell[2]; - rs[h & 1] = new Cell(x); - cells = rs; - init = true; - } - } finally { - busy = 0; - } - if (init) - break; - } - else if (casBase(v = base, fn(v, x))) - break; // Fall back on using base - } - hc.code = h; // Record index for next time - } - - - /** - * Sets base and all cells to the given value. - */ - final void internalReset(long initialValue) { - Cell[] as = cells; - base = initialValue; - if (as != null) { - int n = as.length; - for (int i = 0; i < n; ++i) { - Cell a = as[i]; - if (a != null) - a.value = initialValue; - } - } - } - - // Unsafe mechanics - private static final sun.misc.Unsafe UNSAFE; - private static final long baseOffset; - private static final long busyOffset; - static { - try { - UNSAFE = getUnsafe(); - Class<?> sk = Striped64.class; - baseOffset = UNSAFE.objectFieldOffset - (sk.getDeclaredField("base")); - busyOffset = UNSAFE.objectFieldOffset - (sk.getDeclaredField("busy")); - } catch (Exception e) { - throw new Error(e); - } - } - - /** - * Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. - * Replace with a simple call to Unsafe.getUnsafe when integrating - * into a jdk. - * - * @return a sun.misc.Unsafe - */ - private static sun.misc.Unsafe getUnsafe() { - try { - return sun.misc.Unsafe.getUnsafe(); - } catch (SecurityException se) { - try { - return java.security.AccessController.doPrivileged - (new java.security - .PrivilegedExceptionAction<sun.misc.Unsafe>() { - public sun.misc.Unsafe run() throws Exception { - java.lang.reflect.Field f = sun.misc - .Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - return (sun.misc.Unsafe) f.get(null); - }}); - } catch (java.security.PrivilegedActionException e) { - throw new RuntimeException("Could not initialize intrinsics", - e.getCause()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/main/java/org/jdk8/backport/Striped64_8.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jdk8/backport/Striped64_8.java b/modules/core/src/main/java/org/jdk8/backport/Striped64_8.java new file mode 100644 index 0000000..f83b774 --- /dev/null +++ b/modules/core/src/main/java/org/jdk8/backport/Striped64_8.java @@ -0,0 +1,370 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* + * Copyright © 1993, 2013, Oracle and/or its affiliates. + * All rights reserved. + */ + +package org.jdk8.backport; + +import java.util.*; + +/** + * A package-local class holding common representation and mechanics + * for classes supporting dynamic striping on 64bit values. The class + * extends Number so that concrete subclasses must publicly do so. + */ +@SuppressWarnings("ALL") +abstract class Striped64_8 extends Number { + /* + * This class maintains a lazily-initialized table of atomically + * updated variables, plus an extra "base" field. The table size + * is a power of two. Indexing uses masked per-thread hash codes. + * Nearly all declarations in this class are package-private, + * accessed directly by subclasses. + * + * Table entries are of class Cell; a variant of AtomicLong padded + * to reduce cache contention on most processors. Padding is + * overkill for most Atomics because they are usually irregularly + * scattered in memory and thus don't interfere much with each + * other. But Atomic objects residing in arrays will tend to be + * placed adjacent to each other, and so will most often share + * cache lines (with a huge negative performance impact) without + * this precaution. + * + * In part because Cells are relatively large, we avoid creating + * them until they are needed. When there is no contention, all + * updates are made to the base field. Upon first contention (a + * failed CAS on base update), the table is initialized to size 2. + * The table size is doubled upon further contention until + * reaching the nearest power of two greater than or equal to the + * number of CPUS. Table slots remain empty (null) until they are + * needed. + * + * A single spinlock ("busy") is used for initializing and + * resizing the table, as well as populating slots with new Cells. + * There is no need for a blocking lock: When the lock is not + * available, threads try other slots (or the base). During these + * retries, there is increased contention and reduced locality, + * which is still better than alternatives. + * + * Per-thread hash codes are initialized to random values. + * Contention and/or table collisions are indicated by failed + * CASes when performing an update operation (see method + * retryUpdate). Upon a collision, if the table size is less than + * the capacity, it is doubled in size unless some other thread + * holds the lock. If a hashed slot is empty, and lock is + * available, a new Cell is created. Otherwise, if the slot + * exists, a CAS is tried. Retries proceed by "double hashing", + * using a secondary hash (Marsaglia XorShift) to try to find a + * free slot. + * + * The table size is capped because, when there are more threads + * than CPUs, supposing that each thread were bound to a CPU, + * there would exist a perfect hash function mapping threads to + * slots that eliminates collisions. When we reach capacity, we + * search for this mapping by randomly varying the hash codes of + * colliding threads. Because search is random, and collisions + * only become known via CAS failures, convergence can be slow, + * and because threads are typically not bound to CPUS forever, + * may not occur at all. However, despite these limitations, + * observed contention rates are typically low in these cases. + * + * It is possible for a Cell to become unused when threads that + * once hashed to it terminate, as well as in the case where + * doubling the table causes no thread to hash to it under + * expanded mask. We do not try to detect or remove such cells, + * under the assumption that for long-running instances, observed + * contention levels will recur, so the cells will eventually be + * needed again; and for short-lived ones, it does not matter. + */ + + /** + * Padded variant of AtomicLong supporting only raw accesses plus CAS. + * The value field is placed between pads, hoping that the JVM doesn't + * reorder them. + * + * JVM intrinsics note: It would be possible to use a release-only + * form of CAS here, if it were provided. + */ + static final class Cell { + volatile long p0, p1, p2, p3, p4, p5, p6; + volatile long value; + volatile long q0, q1, q2, q3, q4, q5, q6; + Cell(long x) { value = x; } + + final boolean cas(long cmp, long val) { + return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val); + } + + // Unsafe mechanics + private static final sun.misc.Unsafe UNSAFE; + private static final long valueOffset; + static { + try { + UNSAFE = getUnsafe(); + Class<?> ak = Cell.class; + valueOffset = UNSAFE.objectFieldOffset + (ak.getDeclaredField("value")); + } catch (Exception e) { + throw new Error(e); + } + } + + } + + /** + * Holder for the thread-local hash code. The code is initially + * random, but may be set to a different value upon collisions. + */ + static final class HashCode { + static final Random rng = new Random(); + int code; + HashCode() { + int h = rng.nextInt(); // Avoid zero to allow xorShift rehash + code = (h == 0) ? 1 : h; + } + } + + /** + * The corresponding ThreadLocal class + */ + static final class ThreadHashCode extends ThreadLocal<HashCode> { + public HashCode initialValue() { return new HashCode(); } + } + + /** + * Static per-thread hash codes. Shared across all instances to + * reduce ThreadLocal pollution and because adjustments due to + * collisions in one table are likely to be appropriate for + * others. + */ + static final ThreadHashCode threadHashCode = new ThreadHashCode(); + + /** Number of CPUS, to place bound on table size */ + static final int NCPU = Runtime.getRuntime().availableProcessors(); + + /** + * Table of cells. When non-null, size is a power of 2. + */ + transient volatile Cell[] cells; + + /** + * Base value, used mainly when there is no contention, but also as + * a fallback during table initialization races. Updated via CAS. + */ + transient volatile long base; + + /** + * Spinlock (locked via CAS) used when resizing and/or creating Cells. + */ + transient volatile int busy; + + /** + * Package-private default constructor + */ + Striped64_8() { + } + + /** + * CASes the base field. + */ + final boolean casBase(long cmp, long val) { + return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val); + } + + /** + * CASes the busy field from 0 to 1 to acquire lock. + */ + final boolean casBusy() { + return UNSAFE.compareAndSwapInt(this, busyOffset, 0, 1); + } + + /** + * Computes the function of current and new value. Subclasses + * should open-code this update function for most uses, but the + * virtualized form is needed within retryUpdate. + * + * @param currentValue the current value (of either base or a cell) + * @param newValue the argument from a user update call + * @return result of the update function + */ + abstract long fn(long currentValue, long newValue); + + /** + * Handles cases of updates involving initialization, resizing, + * creating new Cells, and/or contention. See above for + * explanation. This method suffers the usual non-modularity + * problems of optimistic retry code, relying on rechecked sets of + * reads. + * + * @param x the value + * @param hc the hash code holder + * @param wasUncontended false if CAS failed before call + */ + final void retryUpdate(long x, HashCode hc, boolean wasUncontended) { + int h = hc.code; + boolean collide = false; // True if last slot nonempty + for (;;) { + Cell[] as; Cell a; int n; long v; + if ((as = cells) != null && (n = as.length) > 0) { + if ((a = as[(n - 1) & h]) == null) { + if (busy == 0) { // Try to attach new Cell + Cell r = new Cell(x); // Optimistically create + if (busy == 0 && casBusy()) { + boolean created = false; + try { // Recheck under lock + Cell[] rs; int m, j; + if ((rs = cells) != null && + (m = rs.length) > 0 && + rs[j = (m - 1) & h] == null) { + rs[j] = r; + created = true; + } + } finally { + busy = 0; + } + if (created) + break; + continue; // Slot is now non-empty + } + } + collide = false; + } + else if (!wasUncontended) // CAS already known to fail + wasUncontended = true; // Continue after rehash + else if (a.cas(v = a.value, fn(v, x))) + break; + else if (n >= NCPU || cells != as) + collide = false; // At max size or stale + else if (!collide) + collide = true; + else if (busy == 0 && casBusy()) { + try { + if (cells == as) { // Expand table unless stale + Cell[] rs = new Cell[n << 1]; + for (int i = 0; i < n; ++i) + rs[i] = as[i]; + cells = rs; + } + } finally { + busy = 0; + } + collide = false; + continue; // Retry with expanded table + } + h ^= h << 13; // Rehash + h ^= h >>> 17; + h ^= h << 5; + } + else if (busy == 0 && cells == as && casBusy()) { + boolean init = false; + try { // Initialize table + if (cells == as) { + Cell[] rs = new Cell[2]; + rs[h & 1] = new Cell(x); + cells = rs; + init = true; + } + } finally { + busy = 0; + } + if (init) + break; + } + else if (casBase(v = base, fn(v, x))) + break; // Fall back on using base + } + hc.code = h; // Record index for next time + } + + + /** + * Sets base and all cells to the given value. + */ + final void internalReset(long initialValue) { + Cell[] as = cells; + base = initialValue; + if (as != null) { + int n = as.length; + for (int i = 0; i < n; ++i) { + Cell a = as[i]; + if (a != null) + a.value = initialValue; + } + } + } + + // Unsafe mechanics + private static final sun.misc.Unsafe UNSAFE; + private static final long baseOffset; + private static final long busyOffset; + static { + try { + UNSAFE = getUnsafe(); + Class<?> sk = Striped64_8.class; + baseOffset = UNSAFE.objectFieldOffset + (sk.getDeclaredField("base")); + busyOffset = UNSAFE.objectFieldOffset + (sk.getDeclaredField("busy")); + } catch (Exception e) { + throw new Error(e); + } + } + + /** + * Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. + * Replace with a simple call to Unsafe.getUnsafe when integrating + * into a jdk. + * + * @return a sun.misc.Unsafe + */ + private static sun.misc.Unsafe getUnsafe() { + try { + return sun.misc.Unsafe.getUnsafe(); + } catch (SecurityException se) { + try { + return java.security.AccessController.doPrivileged + (new java.security + .PrivilegedExceptionAction<sun.misc.Unsafe>() { + public sun.misc.Unsafe run() throws Exception { + java.lang.reflect.Field f = sun.misc + .Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + return (sun.misc.Unsafe) f.get(null); + }}); + } catch (java.security.PrivilegedActionException e) { + throw new RuntimeException("Could not initialize intrinsics", + e.getCause()); + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java index 0504d55..b94728d 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java @@ -238,8 +238,8 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr CacheStore store = cctx.store().configuredStore(); - long opened = ((LongAdder)U.field(store, "opened")).sum(); - long closed = ((LongAdder)U.field(store, "closed")).sum(); + long opened = ((LongAdder8)U.field(store, "opened")).sum(); + long closed = ((LongAdder8)U.field(store, "closed")).sum(); assert opened > 0; assert closed > 0; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java index 3d100e1..9590b87 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java @@ -141,7 +141,7 @@ public class IgniteDataStreamerPerformanceTest extends GridCommonAbstractTest { ldr.updater(DataStreamerCacheUpdaters.<Integer, String>batchedSorted()); ldr.autoFlushFrequency(0); - final LongAdder cnt = new LongAdder(); + final LongAdder8 cnt = new LongAdder8(); long start = U.currentTimeMillis(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureListenPerformanceTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureListenPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureListenPerformanceTest.java index b550845..c090bd3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureListenPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureListenPerformanceTest.java @@ -37,7 +37,7 @@ public class GridFutureListenPerformanceTest { * @throws InterruptedException If failed. */ public static void main(String[] args) throws InterruptedException { - final LongAdder cnt = new LongAdder(); + final LongAdder8 cnt = new LongAdder8(); final ConcurrentLinkedDeque8<GridFutureAdapter<Object>> futs = new ConcurrentLinkedDeque8<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/jvmtest/BlockingQueueTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/BlockingQueueTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/BlockingQueueTest.java index e9f626a..2ab70e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/BlockingQueueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/BlockingQueueTest.java @@ -106,7 +106,7 @@ public class BlockingQueueTest { X.println(">>> Starting test for: " + testName); - final LongAdder adder = new LongAdder(); + final LongAdder8 adder = new LongAdder8(); GridTestUtils.runMultiThreaded(new Callable<Object>() { @Override public Object call() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/lang/GridFutureListenPerformanceTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridFutureListenPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridFutureListenPerformanceTest.java index 12d7f74..61531b4 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridFutureListenPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridFutureListenPerformanceTest.java @@ -37,7 +37,7 @@ public class GridFutureListenPerformanceTest { * @throws InterruptedException If failed. */ public static void main(String[] args) throws InterruptedException { - final LongAdder cnt = new LongAdder(); + final LongAdder8 cnt = new LongAdder8(); final ConcurrentLinkedDeque8<GridFutureAdapter<Object>> futs = new ConcurrentLinkedDeque8<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java b/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java index 3394bf9..de180d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java @@ -18,7 +18,6 @@ package org.apache.ignite.loadtests.colocation; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; @@ -62,7 +61,7 @@ public class GridTestCacheStore extends CacheStoreAdapter<GridTestKey, Long> { assert cache != null; - final LongAdder adder = new LongAdder(); + final LongAdder8 adder = new LongAdder8(); for (int i = 0; i < numThreads; i++) { final int threadId = i; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark.java b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark.java index 74fdf5f..57c1765 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark.java @@ -63,7 +63,7 @@ public class GridIoManagerBenchmark { public static final int TEST_TOPIC = 1; /** */ - private static final LongAdder msgCntr = new LongAdder(); + private static final LongAdder8 msgCntr = new LongAdder8(); /** */ private static final Map<IgniteUuid, CountDownLatch> latches = new ConcurrentHashMap8<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClient.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClient.java b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClient.java index 861440a..b439bd1 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClient.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClient.java @@ -43,7 +43,7 @@ public class GridJobExecutionLoadTestClient implements Callable<Object> { private static Ignite g; /** Transaction count. */ - private static LongAdder txCnt = new LongAdder(); + private static LongAdder8 txCnt = new LongAdder8(); /** Finish flag. */ private static volatile boolean finish; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java index 327e2da..dd6c82d 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java @@ -46,7 +46,7 @@ public class GridJobExecutionLoadTestClientSemaphore implements Callable<Object> private static Ignite g; /** Transaction count. */ - private static LongAdder txCnt = new LongAdder(); + private static LongAdder8 txCnt = new LongAdder8(); /** Finish flag. */ private static volatile boolean finish; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java index d1665b5..11dd5d2 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java @@ -72,7 +72,7 @@ public class GridJobExecutionSingleNodeSemaphoreLoadTest { final int duration = args.length > 2 ? Integer.parseInt(args[2]) : 0; final String outputFileName = args.length > 3 ? args[3] : null; - final LongAdder execCnt = new LongAdder(); + final LongAdder8 execCnt = new LongAdder8(); try { final Ignite g = G.start("modules/tests/config/grid-job-load.xml"); @@ -161,7 +161,7 @@ public class GridJobExecutionSingleNodeSemaphoreLoadTest { * @param iterCntr Iteration counter. */ private static void runTest(final Ignite g, int threadCnt, int taskCnt, long dur, - final LongAdder iterCntr) { + final LongAdder8 iterCntr) { final Semaphore sem = new Semaphore(taskCnt); final IgniteInClosure<IgniteFuture> lsnr = new CI1<IgniteFuture>() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/GridExternalAffinityFunction.java ---------------------------------------------------------------------- diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/GridExternalAffinityFunction.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/GridExternalAffinityFunction.java index fced1aa..a9bfd79 100644 --- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/GridExternalAffinityFunction.java +++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/GridExternalAffinityFunction.java @@ -145,7 +145,7 @@ public class GridExternalAffinityFunction implements CacheAffinityFunction { /** {@inheritDoc} */ @Override public int partition(Object key) { - return key instanceof Integer ? 0 == key ? 0 : 1 : 1; + return key instanceof Integer ? 0 == (Integer)key ? 0 : 1 : 1; } /** {@inheritDoc} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java index 7fc4843..190fcab 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.query.h2.opt; -import org.apache.commons.codec.binary.*; import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.query.*; @@ -173,7 +172,7 @@ public class GridLuceneIndex implements Closeable { } } - String keyStr = Base64.encodeBase64String(marshaller.marshal(key)); + String keyStr = org.apache.commons.codec.binary.Base64.encodeBase64String(marshaller.marshal(key)); try { // Delete first to avoid duplicates. @@ -210,7 +209,7 @@ public class GridLuceneIndex implements Closeable { */ public void remove(Object key) throws IgniteCheckedException { try { - writer.deleteDocuments(new Term(KEY_FIELD_NAME, Base64.encodeBase64String(marshaller.marshal(key)))); + writer.deleteDocuments(new Term(KEY_FIELD_NAME, org.apache.commons.codec.binary.Base64.encodeBase64String(marshaller.marshal(key)))); } catch (IOException e) { throw new IgniteCheckedException(e); @@ -359,7 +358,7 @@ public class GridLuceneIndex implements Closeable { if (ctx != null && ctx.deploy().enabled()) ldr = ctx.cache().internalCache(spaceName).context().deploy().globalLoader(); - K k = marshaller.unmarshal(Base64.decodeBase64(keyStr), ldr); + K k = marshaller.unmarshal(org.apache.commons.codec.binary.Base64.decodeBase64(keyStr), ldr); byte[] valBytes = doc.getBinaryValue(VAL_FIELD_NAME); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java index 397397b..db7f580 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java @@ -425,8 +425,8 @@ public class GridSqlQueryParser { return res; } - if (expression instanceof Parameter) - return new GridSqlParameter(((Parameter)expression).getIndex()); + if (expression instanceof org.h2.expression.Parameter) + return new GridSqlParameter(((org.h2.expression.Parameter)expression).getIndex()); if (expression instanceof Aggregate) { GridSqlAggregateFunction res = new GridSqlAggregateFunction(DISTINCT.get((Aggregate)expression), http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1adfd615/modules/schema-import/pom.xml ---------------------------------------------------------------------- diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml index 3e8d32c..802fc4c 100644 --- a/modules/schema-import/pom.xml +++ b/modules/schema-import/pom.xml @@ -87,15 +87,15 @@ <value>Oracle Corporation</value> </property> </activation> - <dependencies> - <dependency> - <groupId>javafx</groupId> - <artifactId>jfxrt</artifactId> - <version>${java.version}</version> - <scope>system</scope> - <systemPath>${java.home}/lib/jfxrt.jar</systemPath> - </dependency> - </dependencies> + <!--<dependencies>--> + <!--<dependency>--> + <!--<groupId>javafx</groupId>--> + <!--<artifactId>jfxrt</artifactId>--> + <!--<version>${java.version}</version>--> + <!--<scope>system</scope>--> + <!--<systemPath>${java.home}/lib/jfxrt.jar</systemPath>--> + <!--</dependency>--> + <!--</dependencies>--> </profile> </profiles> </project>
