Search in sources :

Example 46 with Member

use of org.apache.catalina.tribes.Member in project tomcat by apache.

the class FarmWarDeployer method remove.

/**
 * Remove an existing web application, attached to the specified context
 * name. If this application is successfully removed, a ContainerEvent of
 * type <code>REMOVE_EVENT</code> will be sent to all registered
 * listeners, with the removed <code>Context</code> as an argument.
 * Deletes the web application war file and/or directory if they exist in
 * the Host's appBase.
 *
 * @param contextName
 *            The context name of the application to be removed
 * @param undeploy
 *            boolean flag to remove web application from server
 *
 * @exception IllegalArgumentException
 *                if the specified context name is malformed
 * @exception IllegalArgumentException
 *                if the specified context name does not identify a
 *                currently installed web application
 * @exception IOException
 *                if an input/output error occurs during removal
 */
@Override
public void remove(String contextName, boolean undeploy) throws IOException {
    if (getCluster().getMembers().length > 0) {
        if (log.isInfoEnabled()) {
            log.info(sm.getString("farmWarDeployer.removeStart", contextName));
        }
        Member localMember = getCluster().getLocalMember();
        UndeployMessage msg = new UndeployMessage(localMember, System.currentTimeMillis(), "Undeploy:" + contextName + ":" + System.currentTimeMillis(), contextName);
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("farmWarDeployer.removeTxMsg", contextName));
        }
        cluster.send(msg);
    }
    // remove locally
    if (undeploy) {
        try {
            if (tryAddServiced(contextName)) {
                try {
                    remove(contextName);
                } finally {
                    removeServiced(contextName);
                }
                check(contextName);
            } else {
                log.error(sm.getString("farmWarDeployer.removeFailRemote", contextName));
            }
        } catch (Exception ex) {
            log.error(sm.getString("farmWarDeployer.removeFailLocal", contextName), ex);
        }
    }
}
Also used : Member(org.apache.catalina.tribes.Member) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException)

Example 47 with Member

use of org.apache.catalina.tribes.Member in project tomcat by apache.

the class DeltaManager method findSessionMasterMember.

/**
 * Find the master of the session state
 * @return master member of sessions
 */
protected Member findSessionMasterMember() {
    Member mbr = null;
    Member[] mbrs = cluster.getMembers();
    if (mbrs.length != 0) {
        mbr = mbrs[0];
    }
    if (mbr == null && log.isWarnEnabled()) {
        log.warn(sm.getString("deltaManager.noMasterMember", getName(), ""));
    }
    if (mbr != null && log.isDebugEnabled()) {
        log.debug(sm.getString("deltaManager.foundMasterMember", getName(), mbr));
    }
    return mbr;
}
Also used : Member(org.apache.catalina.tribes.Member)

Example 48 with Member

use of org.apache.catalina.tribes.Member in project tomcat70 by apache.

the class DeltaManager method findSessionMasterMember.

/**
 * Find the master of the session state
 * @return master member of sessions
 */
protected Member findSessionMasterMember() {
    Member mbr = null;
    Member[] mbrs = cluster.getMembers();
    if (mbrs.length != 0)
        mbr = mbrs[0];
    if (mbr == null && log.isWarnEnabled())
        log.warn(sm.getString("deltaManager.noMasterMember", getName(), ""));
    if (mbr != null && log.isDebugEnabled())
        log.warn(sm.getString("deltaManager.foundMasterMember", getName(), mbr));
    return mbr;
}
Also used : Member(org.apache.catalina.tribes.Member)

Example 49 with Member

use of org.apache.catalina.tribes.Member in project tomcat70 by apache.

the class FarmWarDeployer method remove.

/**
 * Remove an existing web application, attached to the specified context
 * name. If this application is successfully removed, a ContainerEvent of
 * type <code>REMOVE_EVENT</code> will be sent to all registered
 * listeners, with the removed <code>Context</code> as an argument.
 * Deletes the web application war file and/or directory if they exist in
 * the Host's appBase.
 *
 * @param contextName
 *            The context name of the application to be removed
 * @param undeploy
 *            boolean flag to remove web application from server
 *
 * @exception IllegalArgumentException
 *                if the specified context name is malformed
 * @exception IllegalArgumentException
 *                if the specified context name does not identify a
 *                currently installed web application
 * @exception IOException
 *                if an input/output error occurs during removal
 */
@Override
public void remove(String contextName, boolean undeploy) throws IOException {
    if (getCluster().getMembers().length > 0) {
        if (log.isInfoEnabled())
            log.info(sm.getString("farmWarDeployer.removeStart", contextName));
        Member localMember = getCluster().getLocalMember();
        UndeployMessage msg = new UndeployMessage(localMember, System.currentTimeMillis(), "Undeploy:" + contextName + ":" + System.currentTimeMillis(), contextName, undeploy);
        if (log.isDebugEnabled())
            log.debug(sm.getString("farmWarDeployer.removeTxMsg", contextName));
        cluster.send(msg);
    }
    // remove locally
    if (undeploy) {
        try {
            if (!isServiced(contextName)) {
                addServiced(contextName);
                try {
                    remove(contextName);
                } finally {
                    removeServiced(contextName);
                }
            } else
                log.error(sm.getString("farmWarDeployer.removeFailRemote", contextName));
        } catch (Exception ex) {
            log.error(sm.getString("farmWarDeployer.removeFailLocal", contextName), ex);
        }
    }
}
Also used : Member(org.apache.catalina.tribes.Member) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException)

Example 50 with Member

use of org.apache.catalina.tribes.Member in project tomcat70 by apache.

the class MessageDispatchInterceptor method sendAsyncData.

// run
protected LinkObject sendAsyncData(LinkObject link) {
    ChannelMessage msg = link.data();
    Member[] destination = link.getDestination();
    try {
        super.sendMessage(destination, msg, null);
        try {
            if (link.getHandler() != null)
                link.getHandler().handleCompletion(new UniqueId(msg.getUniqueId()));
        } catch (Exception ex) {
            log.error("Unable to report back completed message.", ex);
        }
    } catch (Exception x) {
        ChannelException cx = null;
        if (x instanceof ChannelException)
            cx = (ChannelException) x;
        else
            cx = new ChannelException(x);
        if (log.isDebugEnabled())
            log.debug("Error while processing async message.", x);
        try {
            if (link.getHandler() != null)
                link.getHandler().handleError(cx, new UniqueId(msg.getUniqueId()));
        } catch (Exception ex) {
            log.error("Unable to report back error message.", ex);
        }
    } finally {
        addAndGetCurrentSize(-msg.getMessage().getLength());
        link = link.next();
    }
    // try
    return link;
}
Also used : UniqueId(org.apache.catalina.tribes.UniqueId) Member(org.apache.catalina.tribes.Member) ChannelException(org.apache.catalina.tribes.ChannelException) ChannelMessage(org.apache.catalina.tribes.ChannelMessage) ChannelException(org.apache.catalina.tribes.ChannelException)

Aggregations

Member (org.apache.catalina.tribes.Member)93 ChannelException (org.apache.catalina.tribes.ChannelException)28 FaultyMember (org.apache.catalina.tribes.ChannelException.FaultyMember)17 Test (org.junit.Test)17 IOException (java.io.IOException)16 MemberImpl (org.apache.catalina.tribes.membership.MemberImpl)15 ReceiverBase (org.apache.catalina.tribes.transport.ReceiverBase)11 ArrayList (java.util.ArrayList)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 UniqueId (org.apache.catalina.tribes.UniqueId)9 Serializable (java.io.Serializable)6 BigDecimal (java.math.BigDecimal)6 DecimalFormat (java.text.DecimalFormat)6 Response (org.apache.catalina.tribes.group.Response)6 ChannelData (org.apache.catalina.tribes.io.ChannelData)6 XByteBuffer (org.apache.catalina.tribes.io.XByteBuffer)6 SelectionKey (java.nio.channels.SelectionKey)4 Selector (java.nio.channels.Selector)4 Membership (org.apache.catalina.tribes.membership.Membership)4 StaticMember (org.apache.catalina.tribes.membership.StaticMember)4