use of org.infinispan.test.MultiCacheManagerCallable in project infinispan by infinispan.
the class CacheManagerTest method testCacheManagerRestartReusingConfigurations.
public void testCacheManagerRestartReusingConfigurations() {
withCacheManagers(new MultiCacheManagerCallable(createCacheManager(CacheMode.REPL_SYNC, false), createCacheManager(CacheMode.REPL_SYNC, false)) {
@Override
public void call() {
EmbeddedCacheManager cm1 = cms[0];
EmbeddedCacheManager cm2 = cms[1];
waitForNoRebalance(cm1.getCache(), cm2.getCache());
Cache<Object, Object> c1 = cm1.getCache();
GlobalConfiguration globalCfg = cm1.getCacheManagerConfiguration();
Configuration cfg = c1.getCacheConfiguration();
killCacheManagers(cm1);
ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder();
holder.getGlobalConfigurationBuilder().read(globalCfg);
holder.getNamedConfigurationBuilders().put(TestCacheManagerFactory.DEFAULT_CACHE_NAME, new ConfigurationBuilder().read(cfg));
withCacheManager(new CacheManagerCallable(new DefaultCacheManager(holder, true)) {
@Override
public void call() {
Cache<Object, Object> c = cm.getCache();
c.put(1, "v1");
assertEquals("v1", c.get(1));
}
});
}
});
}
use of org.infinispan.test.MultiCacheManagerCallable in project infinispan by infinispan.
the class ServerEventLoggerTest method testClusteredServerEventLogging.
@Test
public void testClusteredServerEventLogging() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
withCacheManagers(new MultiCacheManagerCallable(TestCacheManagerFactory.createClusteredCacheManager(amendGlobalConfiguration(GlobalConfigurationBuilder.defaultClusteredBuilder()), builder), TestCacheManagerFactory.createClusteredCacheManager(amendGlobalConfiguration(GlobalConfigurationBuilder.defaultClusteredBuilder()), builder), TestCacheManagerFactory.createClusteredCacheManager(amendGlobalConfiguration(GlobalConfigurationBuilder.defaultClusteredBuilder()), builder)) {
@Override
public void call() {
int msg = 1;
blockUntilViewReceived(cms[0].getCache(), 3);
// Fill all nodes with logs
for (int i = 0; i < cms.length; i++) {
EventLogger eventLogger = EventLogManager.getEventLogger(cms[i]);
assertTrue(eventLogger.getClass().getName(), eventLogger instanceof ServerEventLogger);
eventLogger.info(EventLogCategory.SECURITY, "message #" + msg++);
eventLogger.warn(EventLogCategory.SECURITY, "message #" + msg++);
eventLogger.info(EventLogCategory.TASKS, "message #" + msg++);
eventLogger.warn(EventLogCategory.TASKS, "message #" + msg++);
}
// query all nodes
for (int i = 0; i < cms.length; i++) {
log.debugf("Checking logs on %s", cms[i].getAddress());
EventLogger eventLogger = EventLogManager.getEventLogger(cms[i]);
List<EventLog> events = waitForEvents(2 * cms.length, eventLogger, EventLogCategory.TASKS, null);
for (EventLog event : events) {
assertEquals(EventLogCategory.TASKS, event.getCategory());
}
events = getLatestEvents(eventLogger, null, EventLogLevel.INFO);
for (EventLog event : events) {
assertEquals(EventLogLevel.INFO, event.getLevel());
}
}
}
});
}
use of org.infinispan.test.MultiCacheManagerCallable in project infinispan by infinispan.
the class ProtobufMetadataCacheStartedTest method testMetadataCacheStarted.
public void testMetadataCacheStarted() throws Exception {
String persistentStateLocation = CommonsTestingUtil.tmpDirectory(getClass());
Util.recursiveFileRemove(persistentStateLocation);
final String persistentStateLocation1 = persistentStateLocation + "/1";
final String persistentStateLocation2 = persistentStateLocation + "/2";
TestingUtil.withCacheManagers(new MultiCacheManagerCallable(createCacheManager(persistentStateLocation1), createCacheManager(persistentStateLocation2)) {
@Override
public void call() {
assertTrue(cms[0].isRunning(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME));
assertTrue(cms[1].isRunning(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME));
}
});
}
use of org.infinispan.test.MultiCacheManagerCallable in project infinispan by infinispan.
the class MultiStoresFunctionalTest method testStartStopOfBackupDoesntRewriteValue.
/**
* when a node that persisted KEY wakes up, it can't rewrite existing value.
*/
public void testStartStopOfBackupDoesntRewriteValue(Method m) throws Exception {
final List<ConfigurationBuilder> configs = configs(2, m);
withCacheManagers(new MultiCacheManagerCallable(TestCacheManagerFactory.createClusteredCacheManager(configs.get(0)), TestCacheManagerFactory.createClusteredCacheManager(configs.get(1))) {
@Override
public void call() {
final EmbeddedCacheManager cacheManager0 = cms[0];
final EmbeddedCacheManager cacheManager1 = cms[1];
final Cache<String, String> cache0 = cacheManager0.getCache();
final Cache<String, String> cache1 = cacheManager1.getCache();
TestingUtil.blockUntilViewsChanged(TIMEOUT, 2, cache0, cache1);
cache0.put("KEY", "VALUE V1");
assertEquals("VALUE V1", cache1.get("KEY"));
TestingUtil.killCacheManagers(cacheManager1);
TestingUtil.blockUntilViewsChanged(TIMEOUT, 1, cache0);
cache0.put("KEY", "VALUE V2");
assertEquals("VALUE V2", cache0.get("KEY"));
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createClusteredCacheManager(configs.get(1))) {
@Override
public void call() {
Cache<String, String> newCache = cm.getCache();
TestingUtil.blockUntilViewsChanged(TIMEOUT, 2, cache0, newCache);
assertEquals("VALUE V2", newCache.get("KEY"));
}
});
}
});
}
use of org.infinispan.test.MultiCacheManagerCallable in project infinispan by infinispan.
the class MultiStoresFunctionalTest method testStartStopOfBackupResurrectsDeletedKey.
/**
* When node that persisted KEY2 it will resurrect previous value of KEY2.
*/
public void testStartStopOfBackupResurrectsDeletedKey(Method m) throws Exception {
final List<ConfigurationBuilder> configs = configs(2, m);
withCacheManagers(new MultiCacheManagerCallable(TestCacheManagerFactory.createClusteredCacheManager(configs.get(0)), TestCacheManagerFactory.createClusteredCacheManager(configs.get(1))) {
@Override
public void call() {
final EmbeddedCacheManager cacheManager0 = cms[0];
final EmbeddedCacheManager cacheManager1 = cms[1];
final Cache<String, String> cache0 = cacheManager0.getCache();
final Cache<String, String> cache1 = cacheManager1.getCache();
TestingUtil.blockUntilViewsChanged(TIMEOUT, 2, cache0, cache1);
cache0.put("KEY2", "VALUE2 V1");
assertEquals("VALUE2 V1", cache1.get("KEY2"));
TestingUtil.killCacheManagers(cacheManager1);
TestingUtil.blockUntilViewsChanged(TIMEOUT, 1, cache0);
cache0.put("KEY2", "VALUE2 V2");
assertEquals("VALUE2 V2", cache0.get("KEY2"));
cache0.remove("KEY2");
assertEquals(null, cache0.get("KEY2"));
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createClusteredCacheManager(configs.get(1))) {
@Override
public void call() {
Cache<String, String> newCache = cm.getCache();
TestingUtil.blockUntilViewsChanged(TIMEOUT, 2, cache0, newCache);
assertEquals("VALUE2 V1", newCache.get("KEY2"));
}
});
}
});
}
Aggregations