### Eclipse Workspace Patch 1.0 #P cluster Index: src/main/org/jboss/ha/jndi/LookupSucceededFilter.java =================================================================== --- src/main/org/jboss/ha/jndi/LookupSucceededFilter.java (revision 0) +++ src/main/org/jboss/ha/jndi/LookupSucceededFilter.java (revision 0) @@ -0,0 +1,66 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2008, Red Hat Middleware LLC, 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.jndi; + +import org.jboss.ha.framework.interfaces.ClusterNode; +import org.jboss.ha.framework.interfaces.ResponseFilter; +import org.jboss.ha.framework.server.ClusterPartition.NoHandlerForRPC; +import org.jboss.logging.Logger; + +/** + * LookupSucceededFilter. + * + * Todo: Note about ResponseFilter/RspFilter API. If needMoreResponses() took response and sender + * as well, class implementations could be immutable. As it is right now, they can't and new + * instances need to be generated for every lookup. + * + * @author Galder Zamarreno + */ +public class LookupSucceededFilter implements ResponseFilter +{ + private static final Logger log = Logger.getLogger(LookupSucceededFilter.class); + private static final boolean trace = log.isTraceEnabled(); + private boolean lookupSucceeded; + + public boolean isAcceptable(Object response, ClusterNode sender) + { + if (trace) + { + log.trace("isAcceptable (" + response + ") from " + sender); + } + + lookupSucceeded = (response != null) && !(response instanceof Exception) && !(response instanceof NoHandlerForRPC); + if (trace && lookupSucceeded) + { + log.trace("Lookup succeded from " + sender); + } + + /* Todo: Discuss with Brian S: Could response filtering done in ClusterPartition.processResponseList() + * be moved here? Any NoHandlerForRPC would be caught here immediately and would avoid double processing. */ + return true; + } + + public boolean needMoreResponses() + { + return !(lookupSucceeded); + } +} Index: src/main/org/jboss/ha/jndi/HAJNDI.java =================================================================== --- src/main/org/jboss/ha/jndi/HAJNDI.java (revision 86676) +++ src/main/org/jboss/ha/jndi/HAJNDI.java (working copy) @@ -244,7 +244,7 @@ { log.trace("calling lookupLocally(" + name + ") on HAJNDI cluster"); } - rsp = this.partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, new Class[] { Name.class }, true); + rsp = this.partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, new Class[] { Name.class }, true, new LookupSucceededFilter()); } catch (Exception ignored) { Index: src/main/org/jboss/ha/framework/server/ClusterPartition.java =================================================================== --- src/main/org/jboss/ha/framework/server/ClusterPartition.java (revision 86676) +++ src/main/org/jboss/ha/framework/server/ClusterPartition.java (working copy) @@ -130,7 +130,7 @@ /** * Returned when an RPC call arrives for a service that isn't registered. */ - private static class NoHandlerForRPC implements Serializable + public static class NoHandlerForRPC implements Serializable { static final long serialVersionUID = -1263095408483622838L; }