Package org.apache.geronimo.kernel.management

Examples of org.apache.geronimo.kernel.management.State


     */
    final void fail() {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";

        synchronized (this) {
            State state = getStateInstance();
            if (state == State.STOPPED || state == State.FAILED) {
                return;
            }
        }

View Full Code Here


                }

                int stateValue = kernel.getGBeanState(name);
                if (stateValue != State.RUNNING_INDEX) {
                    GBeanData data = kernel.getGBeanData(name);
                    State state = State.fromInt(stateValue);
                    StringBuffer buf = new StringBuffer();
                    buf.append("(").append(state.getName());
                    // Since it's not unusual for a failure to be caused by a port binding failure
                    //    we'll see if there's a likely looking port attribute in the config data
                    //    for the GBean.  It's a long shot, but hey.
                    if (data != null && data.getAttributes() != null) {
                        Map map = data.getAttributes();
View Full Code Here

                    try {
                        configName = Configuration.getConfigurationObjectName(configID);
                    } catch (MalformedObjectNameException e) {
                        throw new AssertionError("Store returned invalid configID: " + configID);
                    }
                    State state;
                    if (kernel.isLoaded(configName)) {
                        try {
                            state = State.fromInteger((Integer) kernel.getAttribute(configName, "state"));
                        } catch (Exception e) {
                            state = null;
View Full Code Here

    public final void start() throws Exception {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";

        // Move to the starting state
        synchronized (this) {
            State state = getStateInstance();
            if (state == State.STARTING || state == State.RUNNING) {
                return;
            }
            if (!enabled) {
                throw new IllegalStateException("A disabled GBean can not be started: objectName=" + objectName);
View Full Code Here

     * @throws java.lang.Exception if a problem occurs will starting this MBean or any child MBean
     */
    public final void startRecursive() throws Exception {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";

        State state = getStateInstance();
        if (state != State.STOPPED && state != State.FAILED) {
            // Cannot startRecursive while in the stopping state
            // Dain: I don't think we can throw an exception here because there is no way for the caller
            // to lock the instance and check the state before calling
            return;
View Full Code Here

    public final void stop() throws Exception {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a syncrhonized lock on this";

        // move to the stopping state
        synchronized (this) {
            State state = getStateInstance();
            if (state == State.STOPPED || state == State.STOPPING) {
                return;
            }
            setStateInstance(State.STOPPING);
        }
View Full Code Here

     */
    final void fail() {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";

        synchronized (this) {
            State state = getStateInstance();
            if (state == State.STOPPED || state == State.FAILED) {
                return;
            }
            doSafeFail();
            setStateInstance(State.FAILED);
View Full Code Here

     * Note: Do not call this from within a synchronized block as it makes may send a JMX notification
     */
    void attemptFullStart() throws Exception {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";

        State newState = null;
        try {
            synchronized (this) {
                try {
                    // if we are still trying to start and can start now... start
                    if (getStateInstance() != State.STARTING) {
                        return;
                    }

                    // check if an mbean is blocking us from starting
                    blocker = dependencyManager.checkBlocker(objectName);
                    if (blocker != null) {
                        try {
                            // register for state change with the blocker
                            NotificationFilterSupport stoppedFilter = new NotificationFilterSupport();
                            stoppedFilter.enableType(NotificationType.STATE_STOPPED);
                            stoppedFilter.enableType(NotificationType.STATE_FAILED);
                            stoppedFilter.enableType(NotificationType.OBJECT_DELETED);
                            server.addNotificationListener(blocker, this, stoppedFilter, null);

                            // watch for the blocker to unregister
                            NotificationFilterSupport mbeanServerFilter = new NotificationFilterSupport();
                            mbeanServerFilter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
                            server.addNotificationListener(JMXUtil.DELEGATE_NAME, this, mbeanServerFilter, null);

                            // done for now... wait for the blocker to die
                            return;
                        } catch (InstanceNotFoundException e) {
                            // blocker died before we could get going... not a big deal
                        }
                    }

                    // check if all of the mbeans we depend on are running
                    Set parents = dependencyManager.getParents(objectName);
                    for (Iterator i = parents.iterator(); i.hasNext();) {
                        ObjectName parent = (ObjectName) i.next();
                        if (!server.isRegistered(parent)) {
                            log.trace("Cannot run because parent is not registered: parent=" + parent);
                            return;
                        }
                        try {
                            log.trace("Checking if parent is running: parent=" + parent);
                            if (((Integer) server.getAttribute(parent, "state")).intValue() != State.RUNNING_INDEX) {
                                log.trace("Cannot run because parent is not running: parent=" + parent);
                                return;
                            }
                            log.trace("Parent is running: parent=" + parent);
                        } catch (AttributeNotFoundException e) {
                            // ok -- parent is not a startable
                            log.trace("Parent does not have a State attibute");
                        } catch (InstanceNotFoundException e) {
                            // depended on instance was removed bewteen the register check and the invoke
                            log.trace("Cannot run because parent is not registered: parent=" + parent);
                            return;
                        } catch (Exception e) {
                            // problem getting the attribute, parent has most likely failed
                            log.trace("Cannot run because an error occurred while checking if parent is running: parent=" + parent);
                            return;
                        }
                    }

                    // remove any open watches on a blocker
                    // todo is this correct if we are returning to a waiting state?
                    if (blocker != null) {
                        // remove any open watches on a blocker
                        try {
                            server.removeNotificationListener(blocker, this);
                        } catch (JMException ignore) {
                            // don't care, just cleaning up... blocker is most likely dead
                        }
                        try {
                            server.removeNotificationListener(JMXUtil.DELEGATE_NAME, this);
                        } catch (JMException ignore) {
                            // this should never happen... maybe server is dead
                        }
                        blocker = null;
                    }

                    try {
                        doStart();
                    } catch (WaitingException e) {
                        log.debug("Waiting to start: objectName=\"" + objectName + "\" reason=\"" + e.getMessage() + "\"");
                        return;
                    }
                    setStateInstance(State.RUNNING);
                    newState = State.RUNNING;
                } catch (Exception e) {
                    doSafeFail();
                    setStateInstance(State.FAILED);
                    newState = State.FAILED;
                    throw e;
                } catch (Error e) {
                    doSafeFail();
                    setStateInstance(State.FAILED);
                    newState = State.FAILED;
                    throw e;
                }
            }
        } finally {
            if (newState != null) {
                sendNotification(newState.getEventTypeValue());
            }
        }
    }
View Full Code Here

     * Note: Do not call this from within a synchronized block as it may send a JMX notification
     */
    void attemptFullStop() throws Exception {
        assert !Thread.holdsLock(this): "This method cannot be called while holding a synchronized lock on this";

        State newState = null;
        try {
            synchronized (this) {
                // if we are still trying to stop...
                if (getStateInstance() != State.STOPPING) {
                    return;
                }
                try {
                    // check if all of the mbeans depending on us are stopped
                    Set children = dependencyManager.getChildren(objectName);
                    for (Iterator i = children.iterator(); i.hasNext();) {
                        ObjectName child = (ObjectName) i.next();
                        if (server.isRegistered(child)) {
                            try {
                                log.trace("Checking if child is stopped: child=" + child);
                                int state = ((Integer) server.getAttribute(child, "State")).intValue();
                                if (state == State.RUNNING_INDEX) {
                                    log.trace("Cannot stop because child is still running: child=" + child);
                                    return;
                                }
                            } catch (AttributeNotFoundException e) {
                                // ok -- dependect bean is not state manageable
                                log.trace("Child does not have a State attibute");
                            } catch (InstanceNotFoundException e) {
                                // depended on instance was removed between the register check and the invoke
                            } catch (Exception e) {
                                // problem getting the attribute, depended on bean has most likely failed
                                log.trace("Cannot run because an error occurred while checking if child is stopped: child=" + child);
                                return;
                            }
                        }
                    }

                    // if we can stop, stop
                    try {
                        doStop();
                    } catch (WaitingException e) {
                        log.debug("Waiting to stop: objectName=\"" + objectName + "\" reason=\"" + e.getMessage() + "\"");
                        return;
                    }
                    setStateInstance(State.STOPPED);
                    newState = State.STOPPED;
                } catch (Exception e) {
                    doSafeFail();
                    setStateInstance(State.FAILED);
                    newState = State.FAILED;
                    throw e;
                } catch (Error e) {
                    doSafeFail();
                    setStateInstance(State.FAILED);
                    newState = State.FAILED;
                    throw e;
                }
            }
        } finally {
            if (newState != null) {
                sendNotification(newState.getEventTypeValue());
            }
        }
    }
View Full Code Here

            maximizedView.include(renderRequest, renderResponse);
        }
    }

    private State getConfigurationState(ConfigurationInfo configurationInfo) {
        State configurationState = configurationInfo.getState();
        if (configurationState.isRunning()) {
            // Check whether the Configuration's sub-gbeans are running
            try {
                Configuration configuration = PortletManager.getConfigurationManager().getConfiguration(configurationInfo.getConfigID());
                Map<AbstractName, GBeanData> abstractNameGBeanDataMap = configuration.getGBeans();
                // Check one sub-GBean's state, if one gbean fails to start, all will be shutdown
View Full Code Here

TOP

Related Classes of org.apache.geronimo.kernel.management.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.