use of com.sun.messaging.jmq.jmsserver.data.TransactionUID in project openmq by eclipse-ee4j.
the class RaptorProtocol method receivedTransactionInquiry.
public void receivedTransactionInquiry(GPacket pkt, BrokerAddress from) {
ClusterTxnInquiryInfo cii = ClusterTxnInquiryInfo.newInstance(pkt);
if (DEBUG_CLUSTER_TXN) {
logger.log(logger.INFO, "Received transaction inquiry " + cii.toString() + " from " + from);
}
TransactionUID tid = new TransactionUID(cii.getTransactionID().longValue());
BrokerAddress txnHomeBroker = cii.getTransactionHome();
TransactionBroker thb = null;
if (txnHomeBroker != null) {
thb = new TransactionBroker(txnHomeBroker);
}
Object[] oo = TransactionList.getTransListAndState(tid, null, true, false);
TransactionState ts = null;
if (oo != null) {
// tl = (TransactionList)oo[0];
ts = (TransactionState) oo[1];
}
if (ts == null && DEBUG_CLUSTER_TXN) {
logger.log(logger.INFO, "Transaction " + tid + " not found in local transactions");
}
if (ts != null) {
BrokerAddress currba = (thb == null ? null : thb.getCurrentBrokerAddress());
if (currba != null && !currba.equals(Globals.getMyAddress())) {
logger.log(logger.INFO, "Transaction " + tid + " home broker current address " + currba + ", old address " + txnHomeBroker + " inquired from " + from);
}
sendClusterTransactionInfo(tid, from, cii.getXid());
return;
}
if (thb != null) {
BrokerAddress currba = thb.getCurrentBrokerAddress();
if (currba != null && Globals.getMyAddress().equals(currba)) {
sendClusterTransactionInfo(tid, from, cii.getXid());
return;
}
}
sendRemoteTransactionInfo(tid, from, cii.getXid(), false);
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionUID in project openmq by eclipse-ee4j.
the class BaseTransactionManager method writePreparedTransactionsToPreparedTxnStoreOnCheckpoint.
// on checkpoint, we need to store any newly logged prepared transactions to the preparedTxnStore
// as the transaction log is about to be reset
void writePreparedTransactionsToPreparedTxnStoreOnCheckpoint() throws BrokerException {
if (Store.getDEBUG()) {
String msg = getPrefix() + " writePreparedTransactionsToPreparedTxnStoreOnCheckpoint" + " num incompleteUnstored=" + incompleteUnstored.size();
logger.log(Logger.DEBUG, msg);
}
ArrayList<TransactionUID> incmps = null;
synchronized (incompleteUnstored) {
incmps = new ArrayList<>(incompleteUnstored.keySet());
}
TransactionUID tid = null;
BaseTransaction baseTxn = null;
Iterator<TransactionUID> iter = incmps.iterator();
while (iter.hasNext()) {
tid = iter.next();
if (!preparedTxnStore.containsTransaction(tid)) {
baseTxn = incompleteUnstored.get(tid);
if (baseTxn == null) {
continue;
}
if (Store.getDEBUG()) {
String msg = getPrefix() + " transaction storing preparedTransaction " + baseTxn;
logger.log(Logger.DEBUG, msg);
}
try {
preparedTxnStore.storeTransaction(baseTxn, true);
addToIncompleteStored(baseTxn);
} catch (IOException ioe) {
throw new BrokerException("failed to store transaction in preparedTxnStore " + baseTxn, ioe);
}
} else {
String msg = getPrefix() + " transaction already exists in preparedTxnStore " + tid + "[" + incompleteUnstored.get(tid) + "]";
logger.log(Logger.INFO, msg);
}
}
incompleteUnstored.clear();
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionUID in project openmq by eclipse-ee4j.
the class TransactionManagerConfig method getTransactionIDs.
public String[] getTransactionIDs() throws MBeanException {
TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
// PART
TransactionList tl = tls[0];
Vector transactions = tl.getTransactions(-1);
String[] ids;
if ((transactions == null) || (transactions.size() == 0)) {
return (null);
}
ids = new String[transactions.size()];
Enumeration e = transactions.elements();
int i = 0;
while (e.hasMoreElements()) {
TransactionUID tid = (TransactionUID) e.nextElement();
long txnID = tid.longValue();
String id;
try {
id = Long.toString(txnID);
ids[i] = id;
} catch (Exception ex) {
handleOperationException(TransactionOperations.GET_TRANSACTION_IDS, ex);
}
i++;
}
return (ids);
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionUID in project openmq by eclipse-ee4j.
the class TransactionManagerConfig method doRollbackCommit.
public void doRollbackCommit(String transactionID, boolean rollback) throws MBeanException {
try {
long longTid = 0;
if (transactionID == null) {
throw new Exception("Null transaction ID");
}
try {
longTid = Long.parseLong(transactionID);
} catch (Exception e) {
throw new Exception("Invalid transaction ID: " + transactionID);
}
TransactionUID tid = new TransactionUID(longTid);
TransactionList[] tls = Globals.getDestinationList().getTransactionList(null);
TransactionList tl = null;
TransactionState ts = null;
for (int i = 0; i < tls.length; i++) {
tl = tls[i];
if (tl == null) {
continue;
}
ts = tl.retrieveState(tid);
if (ts == null) {
continue;
}
break;
}
if (ts == null) {
throw new Exception(rb.getString(rb.E_NO_SUCH_TRANSACTION, tid));
}
if (ts.getState() != TransactionState.PREPARED) {
throw new Exception(rb.getString(rb.E_TRANSACTION_NOT_PREPARED, tid));
}
JMQXid xid = tl.UIDToXid(tid);
if (xid == null) {
throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Could not find Xid for " + tid));
}
PacketRouter pr = Globals.getPacketRouter(0);
if (pr == null) {
throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Could not locate Packet Router"));
}
TransactionHandler thandler = (TransactionHandler) pr.getHandler(PacketType.ROLLBACK_TRANSACTION);
if (thandler == null) {
throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Could not locate Transaction Handler"));
}
if (rollback) {
thandler.doRollback(tl, tid, xid, null, ts, null, null, RollbackReason.ADMIN);
} else {
thandler.doCommit(tl, tid, xid, Integer.valueOf(XAResource.TMNOFLAGS), ts, null, false, null, null);
}
} catch (Exception e) {
String opName;
if (rollback) {
opName = TransactionOperations.ROLLBACK;
} else {
opName = TransactionOperations.COMMIT;
}
handleOperationException(opName, e);
}
}
use of com.sun.messaging.jmq.jmsserver.data.TransactionUID in project openmq by eclipse-ee4j.
the class Destination method txnByteSize.
public long txnByteSize(Set<PacketReference> msgset) {
Set<PacketReference> msgs = msgset;
if (msgs == null) {
synchronized (destMessages) {
msgs = new HashSet<>(destMessages.values());
}
}
Iterator<PacketReference> itr = msgs.iterator();
long sz = 0L;
TransactionList tl = DL.getTransactionList();
while (itr.hasNext()) {
PacketReference ref = itr.next();
TransactionUID tid = ref.getTransactionID();
if (tid == null) {
continue;
}
TransactionState ts = tl.retrieveState(tid, true);
if (ts == null || ts.getState() == TransactionState.COMMITTED) {
continue;
}
sz += ref.getSize();
}
return sz;
}
Aggregations