[jboss-cvs] JBossAS SVN: r105398 - in projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core: framework/server and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 29 11:37:45 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-05-29 11:37:45 -0400 (Sat, 29 May 2010)
New Revision: 105398
Added:
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/MuxUpHandler.java
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/StateTransferFilter.java
Removed:
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/StateTransferFilter.java
Modified:
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/CoreGroupCommunicationService.java
projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/DelegatingStateTransferUpHandler.java
Log:
Move org.jgroups.blocks.mux improvements to separate package
Modified: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/CoreGroupCommunicationService.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/CoreGroupCommunicationService.java 2010-05-29 15:25:23 UTC (rev 105397)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/CoreGroupCommunicationService.java 2010-05-29 15:37:45 UTC (rev 105398)
@@ -48,6 +48,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+import org.jboss.ha.core.jgroups.blocks.mux.StateTransferFilter;
import org.jboss.ha.framework.interfaces.ClusterNode;
import org.jboss.ha.framework.interfaces.GroupCommunicationService;
import org.jboss.ha.framework.interfaces.GroupMembershipListener;
Modified: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/DelegatingStateTransferUpHandler.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/DelegatingStateTransferUpHandler.java 2010-05-29 15:25:23 UTC (rev 105397)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/DelegatingStateTransferUpHandler.java 2010-05-29 15:37:45 UTC (rev 105398)
@@ -22,6 +22,7 @@
package org.jboss.ha.core.framework.server;
+import org.jboss.ha.core.jgroups.blocks.mux.StateTransferFilter;
import org.jgroups.Event;
import org.jgroups.UpHandler;
Deleted: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/StateTransferFilter.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/StateTransferFilter.java 2010-05-29 15:25:23 UTC (rev 105397)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/StateTransferFilter.java 2010-05-29 15:37:45 UTC (rev 105398)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.ha.core.framework.server;
-
-
-/**
- *
- *
- * @author Brian Stansberry
- *
- * @version $Revision$
- */
-public interface StateTransferFilter
-{
- boolean accepts(String state_id);
-}
Added: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/MuxUpHandler.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/MuxUpHandler.java (rev 0)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/MuxUpHandler.java 2010-05-29 15:37:45 UTC (rev 105398)
@@ -0,0 +1,157 @@
+package org.jboss.ha.core.jgroups.blocks.mux;
+
+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
+ * @author Brian Stansberry
+ *
+ * @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;
+ }
+}
Copied: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/StateTransferFilter.java (from rev 105344, projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/framework/server/StateTransferFilter.java)
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/StateTransferFilter.java (rev 0)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/jgroups/blocks/mux/StateTransferFilter.java 2010-05-29 15:37:45 UTC (rev 105398)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ha.core.jgroups.blocks.mux;
+
+
+/**
+ *
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision$
+ */
+public interface StateTransferFilter
+{
+ boolean accepts(String state_id);
+}
More information about the jboss-cvs-commits
mailing list