[jboss-cvs] JBossAS SVN: r105397 - projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 29 11:25:23 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-05-29 11:25:23 -0400 (Sat, 29 May 2010)
New Revision: 105397
Removed:
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/MuxUpHandler.java
Log:
MuxUpHandler doesn't belong in ha-server-core
Deleted: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/MuxUpHandler.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/MuxUpHandler.java 2010-05-29 15:23:31 UTC (rev 105396)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/MuxUpHandler.java 2010-05-29 15:25:23 UTC (rev 105397)
@@ -1,155 +0,0 @@
-package org.jboss.ha.core.framework.server;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import org.jgroups.Event;
-import org.jgroups.Message;
-import org.jgroups.UpHandler;
-import org.jgroups.blocks.mux.MuxHeader;
-import org.jgroups.blocks.mux.MuxRequestCorrelator;
-import org.jgroups.blocks.mux.Muxer;
-import org.jgroups.blocks.mux.NoMuxHandler;
-import org.jgroups.conf.ClassConfigurator;
-import org.jgroups.logging.Log;
-import org.jgroups.logging.LogFactory;
-import org.jgroups.stack.StateTransferInfo;
-
-/**
- * Allows up handler multiplexing.
- *
- * @author Bela Ban
- * @author Paul Ferraro
- * @version $Id: MuxUpHandler.java,v 1.2 2010/04/15 20:05:22 ferraro Exp $
- */
-public class MuxUpHandler implements UpHandler, Muxer<UpHandler> {
-
- protected final Log log=LogFactory.getLog(getClass());
- protected final static short MUX_ID = ClassConfigurator.getProtocolId(MuxRequestCorrelator.class);
- private final Map<Short, UpHandler> handlers = new ConcurrentHashMap<Short, UpHandler>();
- private final Set<StateTransferFilter> stateTransferHandlers = new CopyOnWriteArraySet<StateTransferFilter>();
- private final List<UpHandler> basicHandlers = new CopyOnWriteArrayList<UpHandler>();
- private volatile UpHandler defaultHandler;
-
- /**
- * Creates a multiplexing up handler, with no default handler.
- */
- public MuxUpHandler() {
- this.defaultHandler = null;
- }
-
- /**
- * Creates a multiplexing up handler using the specified default handler.
- * @param defaultHandler a default up handler to handle messages with no {@link MuxHeader}
- */
- public MuxUpHandler(UpHandler defaultHandler) {
- this.defaultHandler = defaultHandler;
- }
-
- /**
- * {@inheritDoc}
- * @see org.jgroups.blocks.mux.Muxer#add(short, java.lang.Object)
- */
- @Override
- public void add(short id, UpHandler handler) {
- handlers.put(id, handler);
- if (handler instanceof StateTransferFilter)
- {
- stateTransferHandlers.add((StateTransferFilter) handler);
- }
- else
- {
- basicHandlers.add(handler);
- }
- }
-
- /**
- * {@inheritDoc}
- * @see org.jgroups.blocks.mux.Muxer#remove(short)
- */
- @Override
- public void remove(short id) {
- UpHandler handler = handlers.remove(id);
- if (handler instanceof StateTransferFilter)
- {
- stateTransferHandlers.remove(handler);
- }
- else
- {
- basicHandlers.remove(handler);
- }
- }
-
- /**
- * {@inheritDoc}
- * @see org.jgroups.UpHandler#up(org.jgroups.Event)
- */
- @Override
- public Object up(Event evt) {
- switch (evt.getType()) {
- case Event.MSG: {
- Message msg = (Message) evt.getArg();
- MuxHeader hdr = (MuxHeader) msg.getHeader(MUX_ID);
- if (hdr != null) {
- short id = hdr.getId();
- UpHandler handler = handlers.get(id);
- return (handler != null) ? handler.up(evt) : new NoMuxHandler(id);
- }
- break;
- }
- case Event.GET_APPLSTATE:
- case Event.GET_STATE_OK:
- case Event.STATE_TRANSFER_OUTPUTSTREAM:
- case Event.STATE_TRANSFER_INPUTSTREAM: {
- StateTransferInfo info=(StateTransferInfo)evt.getArg();
- String state_id=info.state_id;
- for (StateTransferFilter stup : stateTransferHandlers)
- {
- if (stup.accepts(state_id))
- {
- return ((UpHandler) stup).up(evt);
- }
- }
-
- int numBasic = basicHandlers.size();
-
- if (numBasic > 0)
- {
- if (numBasic > 1)
- {
- log.warn("Received state transfer related event with more " +
- "than one basic UpHandler registered. Arbitrarily " +
- "using first handler registered to handle request");
- }
-
- try
- {
- return basicHandlers.get(0).up(evt);
- }
- catch (IndexOutOfBoundsException ignored)
- {
- // must have been removed
- }
- }
- break;
- }
- case Event.VIEW_CHANGE:
- case Event.SET_LOCAL_ADDRESS:
- case Event.SUSPECT:
- case Event.BLOCK:
- case Event.UNBLOCK:
- default: {
- for (UpHandler handler: handlers.values()) {
- handler.up(evt);
- }
- return null;
- }
- }
-
- return (defaultHandler != null) ? defaultHandler.up(evt) : null;
- }
-}
More information about the jboss-cvs-commits
mailing list