Skip to content

Commit

Permalink
# IGNITE-45 - Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Goncharuk committed Mar 12, 2015
1 parent 25e1fbd commit 65d22d5
Show file tree
Hide file tree
Showing 23 changed files with 306 additions and 269 deletions.
Expand Up @@ -431,6 +431,7 @@ public IgniteConfiguration(IgniteConfiguration cfg) {
cacheSanityCheckEnabled = cfg.isCacheSanityCheckEnabled();
connectorCfg = cfg.getConnectorConfiguration();
classLdr = cfg.getClassLoader();
clientMode = cfg.isClientMode();
clockSyncFreq = cfg.getClockSyncFrequency();
clockSyncSamples = cfg.getClockSyncSamples();
deployMode = cfg.getDeploymentMode();
Expand Down
Expand Up @@ -2258,7 +2258,7 @@ public <K, V> GridCache<K, V> cache(@Nullable String name) {
guard();

try {
ctx.cache().dynamicStartCache(cacheCfg).get();
ctx.cache().dynamicStartCache(cacheCfg, null).get();

return ctx.cache().publicJCache(cacheCfg.getName());
}
Expand All @@ -2273,14 +2273,37 @@ public <K, V> GridCache<K, V> cache(@Nullable String name) {
/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg,
@Nullable NearCacheConfiguration<K, V> nearCfg) {
// TODO: implement.
return null;
guard();

try {
ctx.cache().dynamicStartCache(cacheCfg, nearCfg).get();

return ctx.cache().publicJCache(cacheCfg.getName());
}
catch (IgniteCheckedException e) {
throw new CacheException(e);
}
finally {
unguard();
}

}

/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(@Nullable NearCacheConfiguration<K, V> nearCfg) {
// TODO: implement.
return null;
guard();

try {
ctx.cache().dynamicStartCache(null, nearCfg).get();

return ctx.cache().publicJCache(nearCfg.getName());
}
catch (IgniteCheckedException e) {
throw new CacheException(e);
}
finally {
unguard();
}
}

/** {@inheritDoc} */
Expand Down
Expand Up @@ -1915,6 +1915,7 @@ private static CacheConfiguration marshallerSystemCache(boolean client) {
cache.setPreloadMode(SYNC);
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setAffinity(new CacheRendezvousAffinityFunction(false, 100));
cache.setNodeFilter(CacheConfiguration.ALL_NODES);

return cache;
}
Expand Down
Expand Up @@ -333,8 +333,14 @@ else if (ids.size() == 1) {
guard();

try {
if (p != null)
ctx.resource().injectGeneric(p);

return new ClusterGroupAdapter(ctx, subjId, this.p != null ? F.and(p, this.p) : p);
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
}
finally {
unguard();
}
Expand Down
Expand Up @@ -18,7 +18,7 @@
package org.apache.ignite.internal.processors.cache;

import org.apache.ignite.internal.*;
import org.apache.ignite.internal.managers.discovery.*;
import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.future.*;
import org.apache.ignite.internal.util.tostring.*;
Expand All @@ -38,7 +38,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {

/** Topology snapshot. */
@GridToStringInclude
private final GridDiscoveryTopologySnapshot topSnapshot;
private final AffinityTopologyVersion topVer;

/** Pending candidates. */
@GridToStringInclude
Expand All @@ -49,31 +49,31 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
private final GridFutureAdapter<Object> releaseFut = new GridFutureAdapter<>();

/**
* @param topSnapshot Topology snapshot.
* @param topVer Topology version.
* @param cand Candidate.
*/
public GridCacheExplicitLockSpan(GridDiscoveryTopologySnapshot topSnapshot, GridCacheMvccCandidate cand) {
this.topSnapshot = topSnapshot;
public GridCacheExplicitLockSpan(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand) {
this.topVer = topVer;

ensureDeque(cand.key()).addFirst(cand);
}

/**
* Adds candidate to a lock span.
*
* @param topSnapshot Topology snapshot for which candidate is added.
* @param topVer Topology snapshot for which candidate is added.
* @param cand Candidate to add.
* @return {@code True} if candidate was added, {@code false} if this span is empty and
* new span should be created.
*/
public boolean addCandidate(GridDiscoveryTopologySnapshot topSnapshot, GridCacheMvccCandidate cand) {
public boolean addCandidate(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand) {
lock();

try {
if (cands.isEmpty())
return false;

assert this.topSnapshot.topologyVersion() == topSnapshot.topologyVersion();
assert this.topVer.equals(this.topVer);

Deque<GridCacheMvccCandidate> deque = ensureDeque(cand.key());

Expand Down Expand Up @@ -234,8 +234,8 @@ public void markOwned(KeyCacheObject key) {
*
* @return Topology snapshot or {@code null} if candidate list is empty.
*/
@Nullable public GridDiscoveryTopologySnapshot topologySnapshot() {
return releaseFut.isDone() ? null : topSnapshot;
@Nullable public AffinityTopologyVersion topologyVersion() {
return releaseFut.isDone() ? null : topVer;
}

/**
Expand Down
Expand Up @@ -736,14 +736,14 @@ public void contextReset() {
*
* @param threadId Thread ID.
* @param cand Candidate to add.
* @param snapshot Topology snapshot.
* @param topVer Topology version.
*/
public void addExplicitLock(long threadId, GridCacheMvccCandidate cand, GridDiscoveryTopologySnapshot snapshot) {
public void addExplicitLock(long threadId, GridCacheMvccCandidate cand, AffinityTopologyVersion topVer) {
while (true) {
GridCacheExplicitLockSpan span = pendingExplicit.get(cand.threadId());

if (span == null) {
span = new GridCacheExplicitLockSpan(snapshot, cand);
span = new GridCacheExplicitLockSpan(topVer, cand);

GridCacheExplicitLockSpan old = pendingExplicit.putIfAbsent(threadId, span);

Expand All @@ -754,7 +754,7 @@ public void addExplicitLock(long threadId, GridCacheMvccCandidate cand, GridDisc
}

// Either span was not empty, or concurrent put did not succeed.
if (span.addCandidate(snapshot, cand))
if (span.addCandidate(topVer, cand))
break;
else
pendingExplicit.remove(threadId, span);
Expand Down Expand Up @@ -887,10 +887,10 @@ public GridCacheMvccCandidate removeExplicitLock(long threadId,
* @param threadId Thread ID.
* @return Topology snapshot for last acquired and not released lock.
*/
@Nullable public GridDiscoveryTopologySnapshot lastExplicitLockTopologySnapshot(long threadId) {
@Nullable public AffinityTopologyVersion lastExplicitLockTopologyVersion(long threadId) {
GridCacheExplicitLockSpan span = pendingExplicit.get(threadId);

return span != null ? span.topologySnapshot() : null;
return span != null ? span.topologyVersion() : null;
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -944,9 +944,9 @@ public IgniteInternalFuture<?> finishExplicitLocks(AffinityTopologyVersion topVe
GridCompoundFuture<Object, Object> res = new GridCompoundFuture<>();

for (GridCacheExplicitLockSpan span : pendingExplicit.values()) {
GridDiscoveryTopologySnapshot snapshot = span.topologySnapshot();
AffinityTopologyVersion snapshot = span.topologyVersion();

if (snapshot != null && snapshot.topologyVersion() < topVer.topologyVersion())
if (snapshot != null && snapshot.compareTo(topVer) < 0)
res.add(span.releaseFuture());
}

Expand Down

0 comments on commit 65d22d5

Please sign in to comment.