Search in sources :

Example 1 with Agent

use of com.sun.messaging.jmq.jmsserver.management.agent.Agent in project openmq by eclipse-ee4j.

the class GetJMXConnectorsHandler method handle.

/**
 * Handle the incomming administration message.
 *
 * @param con The Connection the message came in on.
 * @param cmd_msg The administration message
 * @param cmd_props The properties from the administration message
 */
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
    if (DEBUG) {
        logger.log(Logger.DEBUG, this.getClass().getName() + ": " + "GetJMXConnectorsHandler: " + cmd_props);
    }
    Agent agent = Globals.getAgent();
    ConnectorServerManager csm;
    Vector v = null;
    int status = Status.OK;
    if (agent != null) {
        csm = agent.getConnectorServerManager();
        if (csm != null) {
            v = csm.getConnectorInfo();
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    setProperties(reply, MessageType.GET_JMX_REPLY, status, null);
    setBodyObject(reply, v);
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Agent(com.sun.messaging.jmq.jmsserver.management.agent.Agent) ConnectorServerManager(com.sun.messaging.jmq.jmsserver.management.agent.ConnectorServerManager) Vector(java.util.Vector)

Example 2 with Agent

use of com.sun.messaging.jmq.jmsserver.management.agent.Agent in project openmq by eclipse-ee4j.

the class ServiceManager method pauseService.

/**
 * Pause a service by name either stoping just new connections or stopping all interaction
 */
public void pauseService(String servicename, boolean pause_all) throws BrokerException {
    ServiceInfo info = (ServiceInfo) services.get(servicename);
    if (info != null) {
        info.pause(pause_all);
        setServiceStateProp(servicename, ServiceState.PAUSED);
        Agent agent = Globals.getAgent();
        if (agent != null) {
            agent.notifyServicePause(servicename);
        }
    } else {
    // handle error
    }
}
Also used : Agent(com.sun.messaging.jmq.jmsserver.management.agent.Agent)

Example 3 with Agent

use of com.sun.messaging.jmq.jmsserver.management.agent.Agent in project openmq by eclipse-ee4j.

the class DestinationList method addDestination.

private void addDestination(Destination d, boolean throwRT) {
    synchronized (destinationList) {
        if (destinationList.get(d.getDestinationUID()) != null) {
            if (throwRT) {
                throw new RuntimeException("Destination " + d + " is also being" + " created by another broker");
            }
            return;
        }
        destinationList.put(d.getDestinationUID(), d);
        Agent agent = Globals.getAgent();
        if (agent != null) {
            agent.registerDestination(d);
            agent.notifyDestinationCreate(d);
        }
    }
}
Also used : Agent(com.sun.messaging.jmq.jmsserver.management.agent.Agent)

Example 4 with Agent

use of com.sun.messaging.jmq.jmsserver.management.agent.Agent in project openmq by eclipse-ee4j.

the class Destination method pauseDestination.

public void pauseDestination(int type) {
    assert type != DestState.UNKNOWN;
    assert type != DestState.RUNNING;
    assert type <= DestState.PAUSED;
    // assert state == DestState.RUNNING;
    int oldstate = state;
    boolean pauseCon = false, pauseProd = false;
    boolean resumeCon = false, resumeProd = false;
    /*
         * If requested state matches existing, return right away
         */
    if (oldstate == type) {
        return;
    }
    if (oldstate == DestState.RUNNING) {
        if (type == DestState.PRODUCERS_PAUSED || type == DestState.PAUSED) {
            /*
                 * Old state = RUNNING, new state = PRODUCERS_PAUSED or PAUSED - pause producers
                 */
            pauseProd = true;
        }
        if (type == DestState.CONSUMERS_PAUSED || type == DestState.PAUSED) {
            /*
                 * Old state = RUNNING, new state = CONSUMERS_PAUSED or PAUSED - pause consumers
                 */
            pauseCon = true;
        }
    } else if (oldstate == DestState.PAUSED) {
        if (type == DestState.CONSUMERS_PAUSED) {
            /*
                 * Old state = PAUSED, new state = CONSUMERS_PAUSED - resume producers
                 */
            resumeProd = true;
        } else if (type == DestState.PRODUCERS_PAUSED) {
            /*
                 * Old state = PAUSED, new state = PRODUCERS_PAUSED - resume consumers
                 */
            resumeCon = true;
        }
    } else if (oldstate == DestState.CONSUMERS_PAUSED) {
        if (type == DestState.PAUSED) {
            /*
                 * Old state = CONSUMERS_PAUSED, new state = PAUSED - pause producers
                 */
            pauseProd = true;
        } else if (type == DestState.PRODUCERS_PAUSED) {
            /*
                 * Old state = CONSUMERS_PAUSED, new state = PRODUCERS_PAUSED - resume consumers - pause producers
                 */
            resumeCon = true;
            pauseProd = true;
        }
    } else if (oldstate == DestState.PRODUCERS_PAUSED) {
        if (type == DestState.PAUSED) {
            /*
                 * Old state = PRODUCERS_PAUSED, new state = PAUSED - pause consumers
                 */
            pauseCon = true;
        } else if (type == DestState.CONSUMERS_PAUSED) {
            /*
                 * Old state = PRODUCERS_PAUSED, new state = CONSUMERS_PAUSED - pause consumers - resume producers
                 */
            pauseCon = true;
            resumeProd = true;
        }
    }
    state = type;
    if (resumeProd) {
        producerFlow.updateAllProducers(DEST_RESUME, "Destination is resumed");
    }
    if (resumeCon) {
        synchronized (consumers) {
            Iterator itr = consumers.values().iterator();
            while (itr.hasNext()) {
                Consumer c = (Consumer) itr.next();
                c.resume("Destination.RESUME");
            }
        }
    }
    if (pauseProd) {
        producerFlow.updateAllProducers(DEST_PAUSE, "Destination is paused");
    }
    if (pauseCon) {
        synchronized (consumers) {
            Iterator itr = consumers.values().iterator();
            while (itr.hasNext()) {
                Object o = itr.next();
                Consumer c = (Consumer) o;
                c.pause("Destination PAUSE");
            }
        }
    }
    Agent agent = Globals.getAgent();
    if (agent != null) {
        agent.notifyDestinationPause(this, type);
    }
}
Also used : Agent(com.sun.messaging.jmq.jmsserver.management.agent.Agent)

Example 5 with Agent

use of com.sun.messaging.jmq.jmsserver.management.agent.Agent in project openmq by eclipse-ee4j.

the class Destination method purgeDestination.

public void purgeDestination(boolean noerrnotfound) throws BrokerException {
    if (!loaded) {
        load(noerrnotfound);
    }
    try {
        MemoryManager mm = Globals.getMemManager();
        int maxpurge = destMessages.size();
        long removedCount = 0L;
        long indeliveryCount = 0L;
        boolean do1 = false;
        boolean oomed = false;
        List<SysMessageID> list = null;
        int count = 0;
        while (maxpurge > 0 && count < maxpurge) {
            do1 = false;
            if (oomed) {
                do1 = true;
                oomed = false;
            } else if (mm != null && mm.getCurrentLevel() > 0) {
                do1 = true;
            }
            if (!do1) {
                try {
                    list = new ArrayList<>(destMessages.getAllKeys());
                    count = maxpurge;
                } catch (OutOfMemoryError oom) {
                    oomed = true;
                    continue;
                }
            } else {
                list = destMessages.getFirstKeys(1);
            }
            if (list.isEmpty()) {
                break;
            }
            count += list.size();
            RemoveMessageReturnInfo ret = null;
            SysMessageID sysid = null;
            Iterator<SysMessageID> itr = list.iterator();
            while (itr.hasNext()) {
                sysid = itr.next();
                ret = _removeMessage(sysid, RemoveReason.PURGED, null, null, true);
                if (ret.removed) {
                    removedCount++;
                } else if (ret.indelivery) {
                    indeliveryCount++;
                }
            }
        }
        // while maxpurge
        logger.log(logger.INFO, br.getKString(br.I_NUM_MSGS_PURGED_FROM_DEST, removedCount, uid.getLocalizedName()));
        if (indeliveryCount > 0) {
            logger.log(logger.INFO, br.getKString(br.I_NUM_MSGS_INDELIVERY_NOT_PURGED_FROM_DEST, indeliveryCount, uid.getLocalizedName()));
        }
        Agent agent = Globals.getAgent();
        if (agent != null) {
            agent.notifyDestinationPurge(this);
        }
    } catch (Exception ex) {
        if (BrokerStateHandler.isShuttingDown()) {
            logger.log(Logger.INFO, BrokerResources.E_PURGE_DST_FAILED, getName(), ex);
        } else {
            logger.logStack(Logger.WARNING, BrokerResources.E_PURGE_DST_FAILED, getName(), ex);
        }
        if (ex instanceof BrokerException) {
            throw (BrokerException) ex;
        }
        throw new BrokerException(br.getKString(BrokerResources.E_PURGE_DST_FAILED, getName()), ex);
    }
}
Also used : Agent(com.sun.messaging.jmq.jmsserver.management.agent.Agent) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) MemoryManager(com.sun.messaging.jmq.jmsserver.memory.MemoryManager) DestinationNotFoundException(com.sun.messaging.jmq.jmsserver.util.DestinationNotFoundException) ConsumerAlreadyAddedException(com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Aggregations

Agent (com.sun.messaging.jmq.jmsserver.management.agent.Agent)23 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)6 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)3 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)3 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)3 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)3 CacheHashMap (com.sun.messaging.jmq.util.CacheHashMap)3 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)2 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)2 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)2 BaseTransaction (com.sun.messaging.jmq.jmsserver.data.BaseTransaction)2 LocalTransaction (com.sun.messaging.jmq.jmsserver.data.LocalTransaction)2 AckEntryNotFoundException (com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)2 BrokerDownException (com.sun.messaging.jmq.jmsserver.util.BrokerDownException)2 MaxConsecutiveRollbackException (com.sun.messaging.jmq.jmsserver.util.MaxConsecutiveRollbackException)2