use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class HeuristicHandler method getXids.
public List getXids() {
Map map = ctx.heuristicUsageList.getEntities();
if (map != null && map.size() > 0) {
List list = new ArrayList();
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
Entity entity = (Entity) ((Map.Entry) iter.next()).getValue();
list.add(entity.getUserObject());
}
return list;
} else
return null;
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class HeuristicHandler method addHeuristic.
public void addHeuristic(XidImpl xid, boolean commit) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/addHeuristic, xid=" + xid);
Entity entity = ctx.heuristicUsageList.createEntity();
if (maxId == Integer.MAX_VALUE)
maxId = 0;
entity.setName(String.valueOf(++maxId));
entity.setUserObject(xid);
entity.getProperty("xid").setValue(xid.toString());
entity.getProperty("operation").setValue(commit ? "COMMIT" : "ROLLBACK");
entity.createCommands();
ctx.heuristicUsageList.addEntity(entity);
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class HeuristicHandler method findHeuristic.
private Entity findHeuristic(XidImpl xid) {
Map map = ctx.heuristicUsageList.getEntities();
if (map != null && map.size() > 0) {
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
Entity entity = (Entity) ((Map.Entry) iter.next()).getValue();
XidImpl thatXid = (XidImpl) entity.getUserObject();
if (thatXid.equals(xid))
return entity;
}
}
return null;
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class HeuristicHandler method loadHeuristics.
public void loadHeuristics() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/loadHeuristics");
duringLoad = true;
try {
if (!ctx.queueManager.isQueueDefined(HEURISTIC_QUEUE))
ctx.queueManager.createQueue(HEURISTIC_QUEUE, (ActiveLogin) null);
QueueReceiver receiver = ctx.queueManager.createQueueReceiver(HEURISTIC_QUEUE, null, null);
QueuePullTransaction t = receiver.createTransaction(false);
MessageEntry entry = null;
while ((entry = t.getMessage(0)) != null) {
Entity entity = ctx.heuristicUsageList.createEntity();
MessageImpl msg = entry.getMessage();
maxId = Math.max(maxId, msg.getIntProperty(PROP_IID));
messageToEntity(msg, entity);
entity.createCommands();
ctx.heuristicUsageList.addEntity(entity);
}
t.rollback();
receiver.close();
} finally {
duringLoad = false;
}
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class XALiveContextImpl method registerUsageList.
// Will be called from a Timer
synchronized void registerUsageList() {
if (registeredUsageList || closed || !prepared)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/registerUsageList...");
Entity entity = ctx.preparedUsageList.createEntity();
entity.setName(Integer.toString(incCount()));
entity.setDynamicObject(xid);
entity.createCommands();
try {
ctx.preparedUsageList.addEntity(entity);
entity.getProperty("xid").setValue(signature);
} catch (Exception e) {
}
registeredUsageList = true;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/registerUsageList done");
}
Aggregations