Search in sources :

Example 61 with Entity

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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) JMSException(javax.jms.JMSException) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) QueueImpl(com.swiftmq.jms.QueueImpl) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Example 62 with Entity

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;
}
Also used : Entity(com.swiftmq.mgmt.Entity) Connection(com.swiftmq.swiftlet.net.Connection) Property(com.swiftmq.mgmt.Property) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 63 with Entity

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) {
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityAddException(com.swiftmq.mgmt.EntityAddException) EntityList(com.swiftmq.mgmt.EntityList)

Example 64 with Entity

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;
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) Map(java.util.Map)

Example 65 with Entity

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];
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) Map(java.util.Map)

Aggregations

Entity (com.swiftmq.mgmt.Entity)179 Property (com.swiftmq.mgmt.Property)154 JMSException (javax.jms.JMSException)149 InvalidSelectorException (javax.jms.InvalidSelectorException)147 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)140 InvalidDestinationException (javax.jms.InvalidDestinationException)105 TopicImpl (com.swiftmq.jms.TopicImpl)42 QueueImpl (com.swiftmq.jms.QueueImpl)35 com.swiftmq.jms (com.swiftmq.jms)16 EntityList (com.swiftmq.mgmt.EntityList)15 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)11 Map (java.util.Map)10 Iterator (java.util.Iterator)9 MessageSelector (com.swiftmq.ms.MessageSelector)7 EntityAddException (com.swiftmq.mgmt.EntityAddException)5 QueueException (com.swiftmq.swiftlet.queue.QueueException)2 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)2 JobException (com.swiftmq.swiftlet.scheduler.JobException)2 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)2 HashMap (java.util.HashMap)2