Skip to content

Commit

Permalink
IGNITE-591 Make GridCacheXAResource shared.
Browse files Browse the repository at this point in the history
  • Loading branch information
sevdokimov committed Jul 1, 2015
1 parent 1a21477 commit 4b06e77
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Expand Up @@ -30,7 +30,7 @@
*/ */
public class CacheJtaManager extends CacheJtaManagerAdapter { public class CacheJtaManager extends CacheJtaManagerAdapter {
/** */ /** */
private final ThreadLocal<GridCacheXAResource> xaRsrc = new ThreadLocal<>(); private final static ThreadLocal<GridCacheXAResource> xaRsrc = new ThreadLocal<>();


/** */ /** */
private TransactionManager jtaTm; private TransactionManager jtaTm;
Expand Down Expand Up @@ -89,7 +89,7 @@ public class CacheJtaManager extends CacheJtaManagerAdapter {
); );
} }


rsrc = new GridCacheXAResource(tx, cctx); rsrc = new GridCacheXAResource(tx, cctx.kernalContext());


if (!jtaTx.enlistResource(rsrc)) if (!jtaTx.enlistResource(rsrc))
throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction."); throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction.");
Expand Down
Expand Up @@ -18,7 +18,7 @@
package org.apache.ignite.internal.processors.cache.jta; package org.apache.ignite.internal.processors.cache.jta;


import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.transactions.*; import org.apache.ignite.transactions.*;
Expand All @@ -41,9 +41,6 @@ public final class GridCacheXAResource implements XAResource {
/** */ /** */
private static final Xid[] NO_XID = new Xid[] {}; private static final Xid[] NO_XID = new Xid[] {};


/** Context. */
private GridCacheContext cctx;

/** Cache transaction. */ /** Cache transaction. */
private IgniteInternalTx cacheTx; private IgniteInternalTx cacheTx;


Expand All @@ -52,17 +49,16 @@ public final class GridCacheXAResource implements XAResource {


/** /**
* @param cacheTx Cache jta. * @param cacheTx Cache jta.
* @param cctx Cache context. * @param ctx Kernal context.
*/ */
public GridCacheXAResource(IgniteInternalTx cacheTx, GridCacheContext cctx) { public GridCacheXAResource(IgniteInternalTx cacheTx, GridKernalContext ctx) {
assert cacheTx != null; assert cacheTx != null;
assert cctx != null; assert ctx != null;


this.cctx = cctx;
this.cacheTx = cacheTx; this.cacheTx = cacheTx;


if (log == null) if (log == null)
log = U.logger(cctx.kernalContext(), logRef, GridCacheXAResource.class); log = U.logger(ctx, logRef, GridCacheXAResource.class);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down Expand Up @@ -229,7 +225,7 @@ private StringBuilder addFlag(StringBuilder sb, int flags, int mask, String flag


GridCacheXAResource other = (GridCacheXAResource)xar; GridCacheXAResource other = (GridCacheXAResource)xar;


return cctx == other.cctx; return cacheTx == other.cacheTx;
} }


/** /**
Expand Down
Expand Up @@ -151,8 +151,6 @@ public void testJta() throws Exception {
*/ */
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public void testJtaTwoCaches() throws Exception { public void testJtaTwoCaches() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-591");

UserTransaction jtaTx = jotm.getUserTransaction(); UserTransaction jtaTx = jotm.getUserTransaction();


IgniteEx ignite = grid(0); IgniteEx ignite = grid(0);
Expand Down

0 comments on commit 4b06e77

Please sign in to comment.