Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/ignite-sprint-4' into ig…
Browse files Browse the repository at this point in the history
…nite-758

Conflicts:
	modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
	modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
  • Loading branch information
ivasilinets committed Apr 17, 2015
2 parents 3b5fa57 + 357a715 commit 960b0a3
Show file tree
Hide file tree
Showing 25 changed files with 711 additions and 646 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,19 @@ private void checkAttributes(Iterable<ClusterNode> nodes) throws IgniteCheckedEx

Object locMode = locNode.attribute(ATTR_DEPLOYMENT_MODE);

int locJvmMajVer = nodeJavaMajorVersion(locNode);

boolean locP2pEnabled = locNode.attribute(ATTR_PEER_CLASSLOADING);

boolean warned = false;

for (ClusterNode n : nodes) {
int rmtJvmMajVer = nodeJavaMajorVersion(n);

if (locJvmMajVer != rmtJvmMajVer)
throw new IgniteCheckedException("Local node's java major version is different from remote node's one" +
" [locJvmMajVer=" + locJvmMajVer + ", rmtJvmMajVer=" + rmtJvmMajVer + "]");

String rmtPreferIpV4 = n.attribute("java.net.preferIPv4Stack");

if (!F.eq(rmtPreferIpV4, locPreferIpV4)) {
Expand Down Expand Up @@ -783,6 +791,26 @@ private void checkAttributes(Iterable<ClusterNode> nodes) throws IgniteCheckedEx
log.debug("Finished node attributes consistency check.");
}

/**
* Gets Java major version running on the node.
*
* @param node Cluster node.
* @return Java major version.
* @throws IgniteCheckedException If failed to get the version.
*/
private int nodeJavaMajorVersion(ClusterNode node) throws IgniteCheckedException {
try {
// The format is identical for Oracle JDK, OpenJDK and IBM JDK.
return Integer.parseInt(node.<String>attribute("java.version").split("\\.")[1]);
}
catch (Exception e) {
U.error(log, "Failed to get java major version (unknown 'java.version' format) [ver=" +
node.<String>attribute("java.version") + "]", e);

return 0;
}
}

/**
* @param nodes Nodes.
* @return Total CPUs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,4 @@ public interface GridCacheAtomicFuture<R> extends GridCacheFuture<R> {
* @return Future keys.
*/
public Collection<?> keys();

/**
* Checks if timeout occurred.
*
* @param timeout Timeout to check.
*/
public void checkTimeout(long timeout);
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ public void enter() {
/**
* Enter a cache call.
*
* @return {@code true} if enter successful, {@code false} if the cache or the node was stopped.
* @return {@code True} if enter successful, {@code false} if the cache or the node was stopped.
*/
public boolean enterIfNotClosed() {
if (ctx.deploymentEnabled())
ctx.deploy().onEnter();
onEnter();

// Must unlock in case of unexpected errors to avoid
// deadlocks during kernal stop.
Expand All @@ -85,17 +84,35 @@ public boolean enterIfNotClosed() {
return true;
}

/**
* Enter a cache call without lock.
*
* @return {@code True} if enter successful, {@code false} if the cache or the node was stopped.
*/
public boolean enterIfNotClosedNoLock() {
onEnter();

return !stopped;
}

/**
* Leave a cache call entered by {@link #enterNoLock} method.
*/
public void leaveNoLock() {
ctx.tm().resetContext();
ctx.mvcc().contextReset();

// Unwind eviction notifications.
if (!ctx.shared().closed(ctx))
CU.unwindEvicts(ctx);
}

/**
* Leave a cache call entered by {@link #enter()} method.
*/
public void leave() {
try {
ctx.tm().resetContext();
ctx.mvcc().contextReset();

// Unwind eviction notifications.
if (!ctx.shared().closed(ctx))
CU.unwindEvicts(ctx);
leaveNoLock();
}
finally {
rwLock.readUnlock();
Expand All @@ -108,8 +125,6 @@ public void leave() {
*/
@Nullable public CacheOperationContext enter(@Nullable CacheOperationContext prj) {
try {
ctx.itHolder().checkWeakQueue();

GridCacheAdapter<K, V> cache = ctx.cache();

GridCachePreloader<K, V> preldr = cache != null ? cache.preloader() : null;
Expand All @@ -125,27 +140,20 @@ public void leave() {
ctx.name() + "]", e);
}

if (ctx.deploymentEnabled())
ctx.deploy().onEnter();
onEnter();

rwLock.readLock();

if (stopped) {
rwLock.readUnlock();

throw new IllegalStateException("Dynamic cache has been stopped: " + ctx.name());
throw new IllegalStateException("Cache has been stopped: " + ctx.name());
}

// Must unlock in case of unexpected errors to avoid
// deadlocks during kernal stop.
try {
// Set thread local projection per call.
CacheOperationContext prev = ctx.operationContextPerCall();

if (prev != null || prj != null)
ctx.operationContextPerCall(prj);

return prev;
return setProjectionPerCall(prj);
}
catch (RuntimeException e) {
rwLock.readUnlock();
Expand All @@ -154,25 +162,70 @@ public void leave() {
}
}

/**
* @param prj Projection to guard.
* @return Previous projection set on this thread.
*/
@Nullable public GridCacheProjectionImpl<K, V> enterNoLock(@Nullable GridCacheProjectionImpl<K, V> prj) {
onEnter();

if (stopped)
throw new IllegalStateException("Cache has been stopped: " + ctx.name());

return setProjectionPerCall(prj);
}

/**
* Set thread local projection per call.
*
* @param prj Projection to guard.
* @return Previous projection set on this thread.
*/
private CacheOperationContext setProjectionPerCall(@Nullable CacheOperationContext prj) {
CacheOperationContext prev = ctx.operationContextPerCall();

if (prev != null || prj != null)
ctx.operationContextPerCall(prj);

return prev;
}

/**
* @param prev Previous.
*/
public void leave(CacheOperationContext prev) {
try {
ctx.tm().resetContext();
ctx.mvcc().contextReset();

// Unwind eviction notifications.
CU.unwindEvicts(ctx);

// Return back previous thread local operation context per call.
ctx.operationContextPerCall(prev);
leaveNoLock(prev);
}
finally {
rwLock.readUnlock();
}
}

/**
* @param prev Previous.
*/
public void leaveNoLock(CacheOperationContext prev) {
ctx.tm().resetContext();
ctx.mvcc().contextReset();

// Unwind eviction notifications.
CU.unwindEvicts(ctx);

// Return back previous thread local projection per call.
ctx.operationContextPerCall(prev);
}

/**
*
*/
private void onEnter() {
ctx.itHolder().checkWeakQueue();

if (ctx.deploymentEnabled())
ctx.deploy().onEnter();
}

/**
*
*/
Expand Down

0 comments on commit 960b0a3

Please sign in to comment.