-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-1091 HotRod clients can failover upon receiving SuspectException
- Loading branch information
Showing
5 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...ient/src/main/java/org/infinispan/client/hotrod/exceptions/RemoteNodeSuspecException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011 Red Hat Inc. and/or its affiliates and other | ||
* contributors as indicated by the @author tags. All rights reserved. | ||
* See the copyright.txt 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.infinispan.client.hotrod.exceptions; | ||
|
||
/** | ||
* When a remote node is suspected and evicted from the cluster while an | ||
* operation is ongoing, the Hot Rod client emits this exception. | ||
* | ||
* @author Galder Zamarreño | ||
* @since 4.2 | ||
*/ | ||
public class RemoteNodeSuspecException extends HotRodClientException { | ||
|
||
public RemoteNodeSuspecException(String msgFromServer, long messageId, short status) { | ||
super(msgFromServer, messageId, status); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...otrod-client/src/test/java/org/infinispan/client/hotrod/retry/ServerFailureRetryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011 Red Hat Inc. and/or its affiliates and other | ||
* contributors as indicated by the @author tags. All rights reserved. | ||
* See the copyright.txt 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.infinispan.client.hotrod.retry; | ||
|
||
import org.infinispan.config.Configuration; | ||
import org.infinispan.notifications.Listener; | ||
import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated; | ||
import org.infinispan.notifications.cachelistener.event.CacheEntryEvent; | ||
import org.infinispan.remoting.transport.jgroups.SuspectException; | ||
import org.testng.annotations.Test; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import static org.infinispan.test.TestingUtil.k; | ||
import static org.infinispan.test.TestingUtil.v; | ||
|
||
/** | ||
* Test different server error situations and check how clients behave under | ||
* those circumstances. Also verify whether failover is happening accordingly. | ||
* | ||
* @author Galder Zamarreño | ||
* @since 4.2 | ||
*/ | ||
@Test(groups = "functional", testName = "client.hotrod.retry.ServerFailureRetryTest") | ||
public class ServerFailureRetryTest extends AbstractRetryTest { | ||
|
||
@Override | ||
protected Configuration getCacheConfig() { | ||
return getDefaultClusteredConfig(Configuration.CacheMode.REPL_SYNC); | ||
} | ||
|
||
public void testRetryWithSuspectException(Method m) { | ||
ErrorInducingListener listener = new ErrorInducingListener(); | ||
manager(0).getCache().addListener(listener); | ||
remoteCache.put(k(m), v(m)); | ||
} | ||
|
||
@Listener | ||
public static class ErrorInducingListener { | ||
boolean induceError = true; | ||
|
||
@CacheEntryCreated | ||
public void entryCreated(CacheEntryEvent event) throws Exception { | ||
if (!event.isPre() && event.isOriginLocal() && induceError) { | ||
throw new SuspectException("Simulated suspicion"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters