use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.
the class QueueManagerImpl method performTimeAction.
public void performTimeAction() {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "collecting message counts...");
Map cloned = null;
synchronized (qSemaphore) {
cloned = (Map) queueTable.clone();
}
for (Iterator iter = cloned.entrySet().iterator(); iter.hasNext(); ) {
ActiveQueue queue = (ActiveQueue) ((Map.Entry) iter.next()).getValue();
if (queue != null) {
AbstractQueue ac = queue.getAbstractQueue();
if (ac != null && ac.isRunning()) {
String queueName = ac.getLocalName();
Entity queueEntity = ctx.usageList.getEntity(queueName);
if (queueEntity != null) {
try {
Property prop = queueEntity.getProperty(PROP_MESSAGECOUNT);
int oldValue = ((Integer) prop.getValue()).intValue();
int actValue = (int) ac.getNumberQueueMessages();
if (oldValue != actValue) {
prop.setValue(new Integer(actValue));
}
prop = queueEntity.getProperty(PROP_MSG_CONSUME_RATE);
int oldCR = ((Integer) prop.getValue()).intValue();
int actCR = ac.getConsumingRate();
if (oldCR != actCR) {
prop.setValue(new Integer(actCR));
}
prop = queueEntity.getProperty(PROP_MSG_PRODUCE_RATE);
int oldPR = ((Integer) prop.getValue()).intValue();
int actPR = ac.getProducingRate();
if (oldPR != actPR) {
prop.setValue(new Integer(actPR));
}
prop = queueEntity.getProperty(PROP_TOTAL_CONSUMED);
int oldTC = ((Integer) prop.getValue()).intValue();
int actTC = ac.getConsumedTotal();
if (oldTC != actTC) {
prop.setValue(new Integer(actTC));
}
prop = queueEntity.getProperty(PROP_TOTAL_PRODUCED);
int oldTP = ((Integer) prop.getValue()).intValue();
int actTP = ac.getProducedTotal();
if (oldTP != actTP) {
prop.setValue(new Integer(actTP));
}
prop = queueEntity.getProperty(PROP_MCACHE_MESSAGES);
int oldCM = ((Integer) prop.getValue()).intValue();
int actCM = ac.getCurrentCacheSizeMessages();
if (oldCM != actCM) {
prop.setValue(new Integer(actCM));
}
prop = queueEntity.getProperty(PROP_MCACHE_SIZE_KB);
int oldS = ((Integer) prop.getValue()).intValue();
int actS = ac.getCurrentCacheSizeKB();
if (oldS != actS) {
prop.setValue(new Integer(actS));
}
prop = queueEntity.getProperty(PROP_FLOWCONTROL_DELAY);
long oldDelay = ((Long) prop.getValue()).longValue();
long actDelay = 0;
FlowController fc = ac.getFlowController();
if (fc != null)
actDelay = fc.getLastDelay();
if (oldDelay != actValue) {
prop.setValue(new Long(actDelay));
}
prop = queueEntity.getProperty(PROP_AMESSAGES_MAXIMUM);
int oldMax = ((Integer) prop.getValue()).intValue();
int actMax = ac.getMaxMessages();
if (oldMax != actMax) {
prop.setValue(new Integer(actMax));
}
prop = queueEntity.getProperty(PROP_ACACHE_SIZE);
int oldSize = ((Integer) prop.getValue()).intValue();
int actSize = ac.getCacheSize();
if (oldSize != actSize) {
prop.setValue(new Integer(actSize));
}
prop = queueEntity.getProperty(PROP_ACACHE_SIZE_KB);
int oldSizeKB = ((Integer) prop.getValue()).intValue();
int actSizeKB = ac.getCacheSizeKB();
if (oldSizeKB != actSizeKB) {
prop.setValue(new Integer(actSizeKB));
}
prop = queueEntity.getProperty(PROP_AFLOWCONTROL_QUEUE_SIZE);
int oldFC = ((Integer) prop.getValue()).intValue();
int actFC = 0;
fc = ac.getFlowController();
if (fc != null)
actFC = fc.getStartQueueSize();
if (oldFC != actFC) {
prop.setValue(new Integer(actFC));
}
prop = queueEntity.getProperty(PROP_ACLEANUP_INTERVAL);
long oldCU = ((Long) prop.getValue()).longValue();
long actCU = ac.getCleanUpInterval();
if (oldCU != actCU) {
prop.setValue(new Long(actCU));
}
} catch (Exception ignored) {
ignored.printStackTrace();
}
}
}
}
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "collecting message counts...DONE.");
}
use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.
the class Resetter method execute.
public String[] execute(String[] context, Entity entity, String[] cmd) {
if (cmd.length < 2)
return new String[] { TreeCommands.ERROR, "Invalid command, please try 'reset <queue>" };
String[] result = null;
try {
String queueName = cmd[1];
if (!ctx.queueManager.isQueueDefined(queueName))
throw new Exception("Queue '" + queueName + "' is undefined!");
AbstractQueue ac = ctx.queueManager.getQueueForInternalUse(queueName);
if (ac != null)
ac.resetCounters();
else
throw new Exception("Queue '" + queueName + "' not found!");
} catch (Exception e) {
result = new String[] { TreeCommands.ERROR, e.getMessage() };
}
return result;
}
use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.
the class ClusteredQueueFactory method createQueue.
public AbstractQueue createQueue(String queueName, Entity clusteredQueueEntity) throws QueueException {
AbstractQueue queue = new ClusteredQueue(ctx, ctx.dispatchPolicyRegistry.add(queueName, ctx.messageGroupDispatchPolicyFactory.create(ctx, clusteredQueueEntity, queueName, new RoundRobinDispatchPolicy(ctx, queueName))));
queue.setFlowController(new ClusteredQueueFlowController());
return queue;
}
use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.
the class CompositeQueue method createPushTransaction.
public Object createPushTransaction() throws QueueException {
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "createPushTransaction ...");
CompositeTransactionId cTxId = new CompositeTransactionId();
Map m = queueBindings.getEntities();
if (m != null && m.size() > 0) {
for (Iterator iter = m.entrySet().iterator(); iter.hasNext(); ) {
Entity entity = (Entity) ((Map.Entry) iter.next()).getValue();
AbstractQueue queue = ctx.queueManager.getQueueForInternalUse(entity.getName(), true);
if (queue == null) {
ctx.logSwiftlet.logError(ctx.queueManager.getName(), "Composite Queue '" + getQueueName() + "': Queue Binding, queue '" + entity.getName() + "' not found!");
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "Queue Binding, queue '" + entity.getName() + "' not found!");
} else {
cTxId.add(new CompositeTransactionIdEntry(true, queue, queue.createPushTransaction(), (MessageSelector) entity.getUserObject(), ((Boolean) entity.getProperty("generate-new-message-id").getValue()).booleanValue(), ((Boolean) entity.getProperty("change-destination").getValue()).booleanValue(), ((Boolean) entity.getProperty("default-delivery").getValue()).booleanValue(), entity.getName()));
}
}
}
m = topicBindings.getEntities();
if (m != null && m.size() > 0) {
for (Iterator iter = m.entrySet().iterator(); iter.hasNext(); ) {
Entity entity = (Entity) ((Map.Entry) iter.next()).getValue();
String queueName = ctx.topicManager.getQueueForTopic(entity.getName());
AbstractQueue queue = ctx.queueManager.getQueueForInternalUse(queueName, true);
if (queue == null) {
ctx.logSwiftlet.logError(ctx.queueManager.getName(), "Composite Queue '" + getQueueName() + "': Topic Binding, topic '" + entity.getName() + "' not found!");
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "Topic Binding, topic '" + entity.getName() + "' not found!");
} else {
cTxId.add(new CompositeTransactionIdEntry(false, queue, queue.createPushTransaction(), (MessageSelector) entity.getUserObject(), ((Boolean) entity.getProperty("generate-new-message-id").getValue()).booleanValue(), false, ((Boolean) entity.getProperty("default-delivery").getValue()).booleanValue(), entity.getName()));
}
}
}
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "createPushTransaction done, cTxId=" + cTxId);
return cTxId;
}
Aggregations