use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class TransactedQueueSession method visit.
public void visit(CreateProducerRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreateProducerRequest");
CreateProducerReply reply = (CreateProducerReply) req.createReply();
try {
ctx.activeLogin.getResourceLimitGroup().incProducers();
} catch (ResourceLimitException e) {
reply.setOk(false);
reply.setException(new JMSException(e.toString()));
reply.send();
return;
}
QueueImpl queue = req.getQueue();
try {
int producerId;
QueueProducer producer;
producerId = ArrayListTool.setFirstFreeOrExpand(producerList, null);
producer = new QueueProducer(ctx, queue.getQueueName());
producerList.set(producerId, producer);
reply.setQueueProducerId(producerId);
reply.setOk(true);
if (senderEntityList != null) {
Entity senderEntity = senderEntityList.createEntity();
senderEntity.setName(queue.getQueueName() + "-" + producerId);
senderEntity.setDynamicObject(producer);
senderEntity.createCommands();
Property prop = senderEntity.getProperty("queue");
prop.setValue(queue.getQueueName());
prop.setReadOnly(true);
senderEntityList.addEntity(senderEntity);
}
// enlist it at the transaction manager
transactionManager.addTransactionFactory(producer);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/exception creating producer: " + e.getMessage());
ctx.logSwiftlet.logError("sys$jms", ctx.tracePrefix + "/exception creating producer: " + e.getMessage());
reply.setOk(false);
reply.setException(e);
ctx.activeLogin.getResourceLimitGroup().decProducers();
}
reply.send();
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class ConnectionManagerImpl method collectByteCounts.
public synchronized void collectByteCounts() {
long actTime = System.currentTimeMillis();
double deltas = (actTime - lastCollectTime) / 1000.0;
for (Object o : ctx.usageList.getEntities().entrySet()) {
Entity entity = (Entity) ((Map.Entry) o).getValue();
Property input = entity.getProperty("throughput-input");
Property output = entity.getProperty("throughput-output");
Connection connection = (Connection) entity.getDynamicObject();
if (connection != null) {
Countable in = (Countable) connection.getInputStream();
Countable out = (Countable) connection.getOutputStream();
if (lastCollectTime != -1) {
try {
input.setValue(formatter.format(new Double(((double) in.getByteCount() / 1024.0) / deltas)));
output.setValue(formatter.format(new Double(((double) out.getByteCount() / 1024.0) / deltas)));
} catch (Exception ignored) {
}
} else {
try {
input.setValue(0.0);
output.setValue(0.0);
} catch (Exception ignored) {
}
}
in.resetByteCount();
out.resetByteCount();
}
}
lastCollectTime = actTime;
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class MQTTSession method createRegistryUsage.
private void createRegistryUsage(Subscription subscription) {
try {
Entity subUsage = ((EntityList) registryUsage.getEntity("subscriptions")).createEntity();
subUsage.setName(subscription.getTopicName());
subscription.fillRegistryUsage(subUsage);
subUsage.createCommands();
registryUsage.getEntity("subscriptions").addEntity(subUsage);
} catch (EntityAddException e) {
}
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class Role method isContextGrantedAndReadOnly.
public boolean isContextGrantedAndReadOnly(String context) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/isContextGrantedAndReadOnly, context: " + context);
boolean granted = false;
boolean ro = false;
EntityList filters = (EntityList) roleEntity.getEntity("context-filters");
if (filters != null) {
Map map = filters.getEntities();
if (map != null && map.size() > 0) {
boolean wasIncludeGranted = false;
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
Entity filter = (Entity) ((Map.Entry) iter.next()).getValue();
String predicate = (String) filter.getProperty("cli-context-predicate").getValue();
String type = (String) filter.getProperty("type").getValue();
boolean readOnly = (Boolean) filter.getProperty("read-only").getValue();
if (LikeComparator.compare(context, predicate, '\\')) {
if (type.equals("include")) {
granted = true;
wasIncludeGranted = true;
ro = readOnly;
} else {
granted = false;
wasIncludeGranted = false;
}
} else {
if (!wasIncludeGranted)
granted = false;
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/isContextGrantedAndReadOnly, predicate: " + predicate + ", type: " + type + ", readOnly: " + readOnly + ", granted=" + granted);
}
}
}
return granted && ro;
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class Role method getGrantedCommands.
public String[] getGrantedCommands(String context) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/getGrantedCommands, context: " + context);
EntityList filters = (EntityList) roleEntity.getEntity("context-filters");
if (filters != null) {
Map map = filters.getEntities();
if (map != null && map.size() > 0) {
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
Entity filter = (Entity) ((Map.Entry) iter.next()).getValue();
String predicate = (String) filter.getProperty("cli-context-predicate").getValue();
if (LikeComparator.compare(context, predicate, '\\')) {
String cmds = (String) filter.getProperty("granted-commands").getValue();
if (cmds != null)
return SwiftUtilities.tokenize(cmds, " ,");
}
}
}
}
return new String[0];
}
Aggregations