Permalink
Browse files

ISPN-1824 Cross-datacentre replication

  • Loading branch information...
1 parent 404d8b2 commit 225396eabcdcd2a037d43189ee96681ef3a6ed09 Mircea Markus committed with galderz Sep 17, 2012
Showing with 6,473 additions and 133 deletions.
  1. +20 −0 bin/xsitetestrunner.sh
  2. +11 −11 client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerNotStartedTest.java
  3. +13 −13 client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerStoppedTest.java
  4. +31 −0 core/src/main/java/org/infinispan/atomic/PutOperation.java
  5. +4 −0 core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
  6. +3 −2 core/src/main/java/org/infinispan/configuration/Builder.java
  7. +5 −0 core/src/main/java/org/infinispan/configuration/cache/AbstractConfigurationChildBuilder.java
  8. +117 −0 core/src/main/java/org/infinispan/configuration/cache/BackupConfiguration.java
  9. +187 −0 core/src/main/java/org/infinispan/configuration/cache/BackupConfigurationBuilder.java
  10. +30 −0 core/src/main/java/org/infinispan/configuration/cache/BackupFailurePolicy.java
  11. +120 −0 core/src/main/java/org/infinispan/configuration/cache/BackupForBuilder.java
  12. +84 −0 core/src/main/java/org/infinispan/configuration/cache/BackupForConfiguration.java
  13. +19 −12 core/src/main/java/org/infinispan/configuration/cache/Configuration.java
  14. +10 −2 core/src/main/java/org/infinispan/configuration/cache/ConfigurationBuilder.java
  15. +3 −1 core/src/main/java/org/infinispan/configuration/cache/ConfigurationChildBuilder.java
  16. +0 −2 core/src/main/java/org/infinispan/configuration/cache/HashConfigurationBuilder.java
  17. +103 −0 core/src/main/java/org/infinispan/configuration/cache/SitesConfiguration.java
  18. +105 −0 core/src/main/java/org/infinispan/configuration/cache/SitesConfigurationBuilder.java
  19. +5 −0 core/src/main/java/org/infinispan/configuration/global/AbstractGlobalConfigurationBuilder.java
  20. +2 −2 core/src/main/java/org/infinispan/configuration/global/ExecutorFactoryConfigurationBuilder.java
  21. +9 −5 core/src/main/java/org/infinispan/configuration/global/GlobalConfiguration.java
  22. +14 −2 core/src/main/java/org/infinispan/configuration/global/GlobalConfigurationBuilder.java
  23. +2 −0 core/src/main/java/org/infinispan/configuration/global/GlobalConfigurationChildBuilder.java
  24. +64 −0 core/src/main/java/org/infinispan/configuration/global/SiteConfiguration.java
  25. +89 −0 core/src/main/java/org/infinispan/configuration/global/SiteConfigurationBuilder.java
  26. +79 −0 core/src/main/java/org/infinispan/configuration/global/SitesConfiguration.java
  27. +120 −0 core/src/main/java/org/infinispan/configuration/global/SitesConfigurationBuilder.java
  28. +7 −2 core/src/main/java/org/infinispan/configuration/parsing/Attribute.java
  29. +6 −1 core/src/main/java/org/infinispan/configuration/parsing/Element.java
  30. +114 −11 core/src/main/java/org/infinispan/configuration/parsing/Parser52.java
  31. +6 −1 core/src/main/java/org/infinispan/context/Flag.java
  32. +5 −1 core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java
  33. +8 −1 core/src/main/java/org/infinispan/factories/EmptyConstructorNamedCacheFactory.java
  34. +16 −0 core/src/main/java/org/infinispan/factories/InterceptorChainFactory.java
  35. +7 −1 core/src/main/java/org/infinispan/interceptors/base/BaseRpcInterceptor.java
  36. +41 −0 core/src/main/java/org/infinispan/interceptors/xsite/BaseBackupInterceptor.java
  37. +73 −0 core/src/main/java/org/infinispan/interceptors/xsite/NonTransactionalBackupInterceptor.java
  38. +89 −0 core/src/main/java/org/infinispan/interceptors/xsite/OptimisticBackupInterceptor.java
  39. +59 −0 core/src/main/java/org/infinispan/interceptors/xsite/PessimisticBackupInterceptor.java
  40. +0 −1 core/src/main/java/org/infinispan/loaders/CacheLoaderConfig.java
  41. +34 −0 core/src/main/java/org/infinispan/remoting/transport/BackupResponse.java
  42. +4 −7 core/src/main/java/org/infinispan/remoting/transport/Transport.java
  43. +22 −6 core/src/main/java/org/infinispan/remoting/transport/jgroups/CommandAwareRpcDispatcher.java
  44. +101 −0 core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsBackupResponse.java
  45. +29 −2 core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java
  46. +1 −1 core/src/main/java/org/infinispan/statetransfer/StateConsumerImpl.java
  47. +1 −2 core/src/main/java/org/infinispan/topology/ClusterTopologyManagerImpl.java
  48. +1 −2 core/src/main/java/org/infinispan/topology/LocalTopologyManagerImpl.java
  49. +17 −0 core/src/main/java/org/infinispan/transaction/LocalTransaction.java
  50. +12 −0 core/src/main/java/org/infinispan/util/logging/Log.java
  51. +73 −0 core/src/main/java/org/infinispan/xsite/AbstractCustomFailurePolicy.java
  52. +51 −0 core/src/main/java/org/infinispan/xsite/BackupFailureException.java
  53. +219 −0 core/src/main/java/org/infinispan/xsite/BackupReceiver.java
  54. +40 −0 core/src/main/java/org/infinispan/xsite/BackupReceiverRepository.java
  55. +145 −0 core/src/main/java/org/infinispan/xsite/BackupReceiverRepositoryImpl.java
  56. +59 −0 core/src/main/java/org/infinispan/xsite/BackupSender.java
  57. +262 −0 core/src/main/java/org/infinispan/xsite/BackupSenderImpl.java
  58. +64 −0 core/src/main/java/org/infinispan/xsite/CustomFailurePolicy.java
  59. +49 −0 core/src/main/java/org/infinispan/xsite/XSiteBackup.java
  60. +40 −15 core/src/main/resources/config-samples/sample.xml
  61. +146 −0 core/src/main/resources/schema/infinispan-config-5.2.xsd
  62. +0 −1 core/src/test/java/org/infinispan/replication/InvokeRemotelyInFutureTest.java
  63. +8 −0 core/src/test/java/org/infinispan/test/SingleCacheManagerTest.java
  64. +41 −17 core/src/test/java/org/infinispan/test/fwk/JGroupsConfigBuilder.java
  65. +35 −2 core/src/test/java/org/infinispan/test/fwk/TransportFlags.java
  66. +102 −0 core/src/test/java/org/infinispan/xsite/AbstractTwoSitesTest.java
  67. +201 −0 core/src/test/java/org/infinispan/xsite/AbstractXSiteTest.java
  68. +55 −0 core/src/test/java/org/infinispan/xsite/AtomicMapBackupTest.java
  69. +69 −0 core/src/test/java/org/infinispan/xsite/BackupForConfigTest.java
  70. +123 −0 core/src/test/java/org/infinispan/xsite/BaseCacheOperationsTest.java
  71. +43 −0 core/src/test/java/org/infinispan/xsite/BaseDistCacheOperationsTest.java
  72. +82 −0 core/src/test/java/org/infinispan/xsite/CountingCustomFailurePolicy.java
  73. +87 −0 core/src/test/java/org/infinispan/xsite/NoTxDistCacheOperationsTest.java
  74. +224 −0 core/src/test/java/org/infinispan/xsite/NonTxAsyncBackupTest.java
  75. +63 −0 core/src/test/java/org/infinispan/xsite/NonTxReplCacheOperationsTest.java
  76. +68 −0 core/src/test/java/org/infinispan/xsite/OptDistCacheOperationsTest.java
  77. +63 −0 core/src/test/java/org/infinispan/xsite/OptReplCacheOperationsTest.java
  78. +75 −0 core/src/test/java/org/infinispan/xsite/PessDistCacheOperationsTest.java
  79. +70 −0 core/src/test/java/org/infinispan/xsite/PessReplCacheOperationsTest.java
  80. +110 −0 core/src/test/java/org/infinispan/xsite/TestBackupForNotSpecified.java
  81. +39 −0 core/src/test/java/org/infinispan/xsite/TxAsyncBackupTest.java
  82. +102 −0 core/src/test/java/org/infinispan/xsite/XSiteCacheConfigurationTest.java
  83. +85 −0 core/src/test/java/org/infinispan/xsite/XSiteFileParsing2Test.java
  84. +106 −0 core/src/test/java/org/infinispan/xsite/XSiteFileParsingTest.java
  85. +101 −0 core/src/test/java/org/infinispan/xsite/XSiteGlobalConfigurationTest.java
  86. +182 −0 core/src/test/java/org/infinispan/xsite/backupfailure/BaseBackupFailureTest.java
  87. +87 −0 core/src/test/java/org/infinispan/xsite/backupfailure/CustomFailurePolicyTest.java
  88. +141 −0 core/src/test/java/org/infinispan/xsite/backupfailure/NonTxBackupFailureTest.java
  89. +75 −0 core/src/test/java/org/infinispan/xsite/backupfailure/OptDistBackupFailure2Test.java
  90. +70 −0 core/src/test/java/org/infinispan/xsite/backupfailure/OptDistBackupFailureTest.java
  91. +75 −0 core/src/test/java/org/infinispan/xsite/backupfailure/OptReplBackupFailure2Test.java
  92. +72 −0 core/src/test/java/org/infinispan/xsite/backupfailure/OptReplBackupFailureTest.java
  93. +63 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/BaseBackupTxFailureTest.java
  94. +59 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/BaseLocalClusterTxFailureTest.java
  95. +59 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/CustomFailurePolicyTxTest.java
  96. +50 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/DistBackupTxFailureTest.java
  97. +50 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/DistLocalClusterFailure.java
  98. +54 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/DistLocalClusterTxBackupFailure.java
  99. +50 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/ReplBackupTxFailureTest.java
  100. +51 −0 core/src/test/java/org/infinispan/xsite/backupfailure/tx/ReplLocalClusterFailure.java
  101. +100 −0 core/src/test/resources/configs/xsite/bridge.xml
  102. +49 −0 core/src/test/resources/configs/xsite/relay-config.xml
  103. +89 −0 core/src/test/resources/configs/xsite/xsite-test.xml
  104. +75 −0 core/src/test/resources/configs/xsite/xsite-test2.xml
  105. +2 −0 core/src/test/resources/stacks/tcp.xml
  106. +2 −0 core/src/test/resources/stacks/udp.xml
  107. +7 −0 parent/pom.xml
  108. +9 −7 spring/src/test/java/org/infinispan/spring/mock/MockTransport.java
View
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+
+########################
+# Script that allows the run of the xsite test suite or of an xsite individual test.
+########################
+
+
+if [ "x$1" = "x" ] ; then
+ for testfile in `grep -lr 'groups[ ]*=[ ]*"xsite"' .`
+ do
+ filename=$(basename "$testfile")
+ filename="${filename%.*}"
+ mvn test -Ptest-xsite -Dinfinispan.test.parallel.threads=1 -Dtest=$filename | grep 'Test '
+ done
+else
+ mvn test -Ptest-xsite -Dinfinispan.test.parallel.threads=1 -Dtest=$1
+fi
+
+
@@ -94,55 +94,55 @@ public void testGetCacheOperations3() {
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testPut() {
- cache().put("k", "v");
+ remoteCache().put("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testPutAsync() {
- cache().putAsync("k", "v");
+ remoteCache().putAsync("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testGet() {
- cache().get("k");
+ remoteCache().get("k");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testReplace() {
- cache().replace("k", "v");
+ remoteCache().replace("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testReplaceAsync() {
- cache().replaceAsync("k", "v");
+ remoteCache().replaceAsync("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testPutAll() {
- cache().putAll(new HashMap<Object, Object>());
+ remoteCache().putAll(new HashMap<Object, Object>());
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testPutAllAsync() {
- cache().putAllAsync(new HashMap<Object, Object>());
+ remoteCache().putAllAsync(new HashMap<Object, Object>());
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testVersionedGet() {
- cache().getVersioned("key");
+ remoteCache().getVersioned("key");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testVersionedRemove() {
- cache().removeWithVersion("key", 12312321l);
+ remoteCache().removeWithVersion("key", 12312321l);
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
public void testVersionedRemoveAsync() {
- cache().removeWithVersionAsync("key", 12312321l);
+ remoteCache().removeWithVersionAsync("key", 12312321l);
}
- private RemoteCache<Object, Object> cache() {
+ private RemoteCache<Object, Object> remoteCache() {
return remoteCacheManager.getCache();
}
}
@@ -67,8 +67,8 @@ public void release() {
public void testGetCacheOperations() {
assert remoteCacheManager.getCache() != null;
assert remoteCacheManager.getCache(CACHE_NAME) != null;
- cache().put("k", "v");
- assert cache().get("k").equals("v");
+ remoteCache().put("k", "v");
+ assert remoteCache().get("k").equals("v");
}
@Test (dependsOnMethods = "testGetCacheOperations")
@@ -92,55 +92,55 @@ public void testGetCacheOperations3() {
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testPut() {
- cache().put("k", "v");
+ remoteCache().put("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testPutAsync() {
- cache().putAsync("k", "v");
+ remoteCache().putAsync("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testGet() {
- cache().get("k");
+ remoteCache().get("k");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testReplace() {
- cache().replace("k", "v");
+ remoteCache().replace("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testReplaceAsync() {
- cache().replaceAsync("k", "v");
+ remoteCache().replaceAsync("k", "v");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testPutAll() {
- cache().putAll(new HashMap<Object, Object>());
+ remoteCache().putAll(new HashMap<Object, Object>());
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testPutAllAsync() {
- cache().putAllAsync(new HashMap<Object, Object>());
+ remoteCache().putAllAsync(new HashMap<Object, Object>());
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testVersionedGet() {
- cache().getVersioned("key");
+ remoteCache().getVersioned("key");
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testVersionedRemove() {
- cache().removeWithVersion("key", 12312321l);
+ remoteCache().removeWithVersion("key", 12312321l);
}
@Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
public void testVersionedRemoveAsync() {
- cache().removeWithVersionAsync("key", 12312321l);
+ remoteCache().removeWithVersionAsync("key", 12312321l);
}
- private RemoteCache<Object, Object> cache() {
+ private RemoteCache<Object, Object> remoteCache() {
return remoteCacheManager.getCache();
}
}
@@ -73,6 +73,37 @@ public K keyAffected() {
return key;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof PutOperation)) return false;
+
+ PutOperation that = (PutOperation) o;
+
+ if (key != null ? !key.equals(that.key) : that.key != null) return false;
+ if (newValue != null ? !newValue.equals(that.newValue) : that.newValue != null) return false;
+ if (oldValue != null ? !oldValue.equals(that.oldValue) : that.oldValue != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = key != null ? key.hashCode() : 0;
+ result = 31 * result + (oldValue != null ? oldValue.hashCode() : 0);
+ result = 31 * result + (newValue != null ? newValue.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "PutOperation{" +
+ "key=" + key +
+ ", oldValue=" + oldValue +
+ ", newValue=" + newValue +
+ '}';
+ }
+
public static class Externalizer extends AbstractExternalizer<PutOperation> {
@Override
public void writeObject(ObjectOutput output, PutOperation put) throws IOException {
@@ -192,4 +192,8 @@ public void setParameters(int commandId, Object[] parameters) {
public boolean ignoreCommandOnStatus(ComponentStatus status) {
return false;
}
+
+ public Object getValue() {
+ return value;
+ }
}
@@ -41,8 +41,9 @@
* Reads the configuration from an already created configuration bean into this builder.
* Returns an appropriate builder to allow fluent configuration
*
- * @param template
- * @return
+ *
+ * @param template the configuration from which to "clone" this config if needed.
+ *
*/
Builder<?> read(T template);
}
@@ -103,6 +103,11 @@ public UnsafeConfigurationBuilder unsafe() {
return builder.unsafe();
}
+ @Override
+ public SitesConfigurationBuilder sites() {
+ return builder.sites();
+ }
+
protected ConfigurationBuilder getBuilder() {
return builder;
}
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012 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 copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.infinispan.configuration.cache;
+
+/**
+ * @author Mircea.Markus@jboss.com
+ * @since 5.2
+ */
+public class BackupConfiguration {
+
+ private final String site;
+ private final BackupStrategy strategy;
+ private long timeout;
+ private final BackupFailurePolicy backupFailurePolicy;
+ private final String failurePolicyClass;
+
+ public BackupConfiguration(String site, BackupStrategy strategy, long timeout, BackupFailurePolicy backupFailurePolicy, String failurePolicyClass) {
+ this.site = site;
+ this.strategy = strategy;
+ this.timeout = timeout;
+ this.backupFailurePolicy = backupFailurePolicy;
+ this.failurePolicyClass = failurePolicyClass;
+ }
+
+ /**
+ * Returns the name of the site where this cache backups its data.
+ */
+ public String site() {
+ return site;
+ }
+
+ /**
+ * How does the backup happen: sync or async.
+ */
+ public BackupStrategy strategy() {
+ return strategy;
+ }
+
+ /**
+ * If the failure policy is set to {@link BackupFailurePolicy#CUSTOM} then the failurePolicyClass is required and
+ * should return the fully qualified name of a class implementing {@link org.infinispan.xsite.CustomFailurePolicy}
+ */
+ public String failurePolicyClass() {
+ return failurePolicyClass;
+ }
+
+ public boolean isAsyncBackup() {
+ return strategy() == BackupStrategy.ASYNC;
+ }
+
+ public long replicationTimeout() {
+ return timeout;
+ }
+
+ public BackupFailurePolicy backupFailurePolicy() {
+ return backupFailurePolicy;
+ }
+
+ public enum BackupStrategy {
+ SYNC, ASYNC
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof BackupConfiguration)) return false;
+
+ BackupConfiguration that = (BackupConfiguration) o;
+
+ if (timeout != that.timeout) return false;
+ if (backupFailurePolicy != that.backupFailurePolicy) return false;
+ if (failurePolicyClass != null ? !failurePolicyClass.equals(that.failurePolicyClass) : that.failurePolicyClass != null)
+ return false;
+ if (site != null ? !site.equals(that.site) : that.site != null) return false;
+ if (strategy != that.strategy) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = site != null ? site.hashCode() : 0;
+ result = 31 * result + (strategy != null ? strategy.hashCode() : 0);
+ result = 31 * result + (int) (timeout ^ (timeout >>> 32));
+ result = 31 * result + (backupFailurePolicy != null ? backupFailurePolicy.hashCode() : 0);
+ result = 31 * result + (failurePolicyClass != null ? failurePolicyClass.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "BackupConfiguration{" +
+ "site='" + site + '\'' +
+ ", strategy=" + strategy +
+ ", timeout=" + timeout +
+ ", backupFailurePolicy=" + backupFailurePolicy +
+ ", failurePolicyClass='" + failurePolicyClass + '\'' +
+ '}';
+ }
+}
Oops, something went wrong.

0 comments on commit 225396e

Please sign in to comment.