Skip to content

Commit

Permalink
ignite-96 debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakov Zhdanov committed Feb 12, 2015
1 parent 2a7b090 commit f93ba09
Showing 1 changed file with 34 additions and 17 deletions.
Expand Up @@ -81,10 +81,10 @@ public class GridCacheConcurrentMap<K, V> {
protected final GridCacheContext<K, V> ctx;

/** */
private final LongAdder mapPubSize = new LongAdder();
private final AtomicLong mapPubSize = new AtomicLong();

/** */
private final LongAdder mapSize = new LongAdder();
private final AtomicLong mapSize = new AtomicLong();

/** Filters cache internal entry. */
private static final P1<Cache.Entry<?, ?>> NON_INTERNAL =
Expand Down Expand Up @@ -329,7 +329,7 @@ private static <K, V> IgnitePredicate<Cache.Entry<K, V>>[] nonInternal(
* @return {@code True} if this map is empty.
*/
public boolean isEmpty() {
return mapSize.sum() == 0;
return mapSize.get() == 0;
}

/**
Expand All @@ -345,7 +345,7 @@ public int size() {
* @return Public size.
*/
public int publicSize() {
return mapPubSize.intValue();
return (int)mapPubSize.get();
}

/**
Expand All @@ -357,7 +357,9 @@ public void decrementSize(GridCacheMapEntry<K, V> e) {
assert e.deletedUnlocked();
assert ctx.deferredDelete();

mapPubSize.decrement();
long l = mapPubSize.decrementAndGet();

assert l >= 0 : l;

segmentFor(e.hash()).decrementPublicSize();
}
Expand All @@ -371,7 +373,9 @@ public void incrementSize(GridCacheMapEntry<K, V> e) {
assert !e.deletedUnlocked();
assert ctx.deferredDelete();

mapPubSize.increment();
long l = mapPubSize.incrementAndGet();

assert l > 0 : l;

segmentFor(e.hash()).incrementPublicSize();
}
Expand Down Expand Up @@ -407,7 +411,7 @@ public Collection<V> allValues(IgnitePredicate<Cache.Entry<K, V>>[] filter) {
checkWeakQueue();

while (true) {
if (mapPubSize.sum() == 0)
if (mapPubSize.get() == 0)
return null;

// Desired and current indexes.
Expand Down Expand Up @@ -640,7 +644,7 @@ public Collection<V> values(IgnitePredicate<Cache.Entry<K, V>>... filter) {

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridCacheConcurrentMap.class, this, "size", mapSize, "pubSize", mapPubSize);
return S.toString(GridCacheConcurrentMap.class, this, "size", mapSize, "pubSize", mapPubSize.get());
}

/**
Expand Down Expand Up @@ -777,7 +781,7 @@ private class Segment extends ReentrantLock {
private volatile SegmentHeader<K, V> hdr;

/** The number of public elements in this segment's region. */
private final LongAdder pubSize = new LongAdder();
private final AtomicLong pubSize = new AtomicLong();

/**
* The load factor for the hash table. Even though this value
Expand Down Expand Up @@ -958,13 +962,15 @@ private GridCacheMapEntry<K, V> put0(K key, int hash, V val, long topVer, long t

// Modify counters.
if (!retVal.isInternal()) {
mapPubSize.increment();
long l = mapPubSize.incrementAndGet();

assert l > 0 : l;

pubSize.increment();
pubSize.incrementAndGet();
}
}

mapSize.increment();
mapSize.incrementAndGet();

hdr.size(c);
}
Expand Down Expand Up @@ -1148,13 +1154,17 @@ void rehash() {
// Modify counters.
synchronized (e) {
if (!e.isInternal() && !e.deleted()) {
mapPubSize.decrement();
long l = mapPubSize.decrementAndGet();

pubSize.decrement();
assert l >= 0 : l;

pubSize.decrementAndGet();
}
}

mapSize.decrement();
long l = mapSize.decrementAndGet();

assert l >= 0 : l;

hdr.decrementSize();
}
Expand Down Expand Up @@ -1187,14 +1197,16 @@ int publicSize() {
* Decrements segment public size.
*/
void decrementPublicSize() {
pubSize.decrement();
long l = pubSize.decrementAndGet();

assert l >= 0 : l;
}

/**
* Decrements segment public size.
*/
void incrementPublicSize() {
pubSize.increment();
pubSize.incrementAndGet();
}

/**
Expand Down Expand Up @@ -2296,6 +2308,11 @@ private Values(GridCacheConcurrentMap<K, V> map, IgnitePredicate<Cache.Entry<K,
set.clear();
}

/** {@inheritDoc} */
@Override public boolean isEmpty() {
return set.isEmpty();
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(set);
Expand Down

0 comments on commit f93ba09

Please sign in to comment.