use of com.hazelcast.transaction.impl.xa.SerializableXID in project hazelcast by hazelcast.
the class XAResourceProxy method finalizeTransactionRemotely.
private void finalizeTransactionRemotely(Xid xid, boolean isCommit) {
SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
SerializationService serializationService = getContext().getSerializationService();
Data xidData = serializationService.toData(serializableXID);
ClientMessage request = XATransactionFinalizeCodec.encodeRequest(serializableXID, isCommit);
invoke(request, xidData);
}
use of com.hazelcast.transaction.impl.xa.SerializableXID in project hazelcast by hazelcast.
the class XAResourceProxy method clearRemoteTransactions.
private void clearRemoteTransactions(Xid xid) {
SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
SerializationService serializationService = getContext().getSerializationService();
Data xidData = serializationService.toData(serializableXID);
ClientMessage request = XATransactionClearRemoteCodec.encodeRequest(serializableXID);
invoke(request, xidData);
}
use of com.hazelcast.transaction.impl.xa.SerializableXID in project hazelcast by hazelcast.
the class ClientXATest method testRecovery.
@Test
public void testRecovery() throws Exception {
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
Hazelcast.newHazelcastInstance();
Hazelcast.newHazelcastInstance();
HazelcastXAResource xaResource = instance.getXAResource();
Xid myXid = new SerializableXID(42, "globalTransactionId".getBytes(), "branchQualifier".getBytes());
xaResource.start(myXid, 0);
TransactionContext context1 = xaResource.getTransactionContext();
TransactionalMap<Object, Object> map = context1.getMap("map");
map.put("key", "value");
xaResource.prepare(myXid);
instance.shutdown();
HazelcastInstance client = HazelcastClient.newHazelcastClient();
HazelcastXAResource clientXaResource = client.getXAResource();
Xid[] recovered = clientXaResource.recover(0);
for (Xid xid : recovered) {
clientXaResource.commit(xid, false);
}
assertEquals("value", client.getMap("map").get("key"));
}
use of com.hazelcast.transaction.impl.xa.SerializableXID in project hazelcast by hazelcast.
the class CollectRemoteTransactionsOperation method run.
@Override
public void run() throws Exception {
XAService xaService = getService();
NodeEngine nodeEngine = getNodeEngine();
Set<SerializableXID> xids = xaService.getPreparedXids();
List<Data> xidSet = new ArrayList<Data>();
for (SerializableXID xid : xids) {
xidSet.add(nodeEngine.toData(xid));
}
this.xidSet = new SerializableList(xidSet);
}
use of com.hazelcast.transaction.impl.xa.SerializableXID in project hazelcast by hazelcast.
the class HazelcastXATest method startTX.
private void startTX(final HazelcastInstance instance, final CountDownLatch nodeShutdownLatch) {
new Thread(new Runnable() {
@Override
public void run() {
try {
HazelcastXAResource xaResource = instance.getXAResource();
Xid xid = new SerializableXID(42, "globalTransactionId".getBytes(), "branchQualifier".getBytes());
xaResource.start(xid, XAResource.TMNOFLAGS);
TransactionContext context = xaResource.getTransactionContext();
final TransactionalMap<Object, Object> map = context.getMap("map");
map.put("key", "value");
xaResource.prepare(xid);
instance.shutdown();
nodeShutdownLatch.countDown();
} catch (XAException e) {
e.printStackTrace();
}
}
}).start();
}
Aggregations