[jboss-cvs] JBossAS SVN: r106657 - in projects/cluster/ha-server-cache-ispn/trunk: src/main/java/org/jboss/ha and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 13 15:05:34 EDT 2010
Author: pferraro
Date: 2010-07-13 15:05:32 -0400 (Tue, 13 Jul 2010)
New Revision: 106657
Added:
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/framework/
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/framework/server/
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/framework/
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/framework/server/
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImplTest.java
Removed:
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfiguration.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfigurationAdapter.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactory.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactoryImpl.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistry.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfiguration.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationEntry.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationSource.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSource.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSource.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/package-info.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/xml/
projects/cluster/ha-server-cache-ispn/trunk/src/main/resources/META-INF/
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerFactoryTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerRegistryTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSourceTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSourceTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/xml/
projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs-multiple.xml
projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs.xml
Modified:
projects/cluster/ha-server-cache-ispn/trunk/pom.xml
Log:
Refactor CacheManagerRegistry into ha-server-ispn project.
Add HAPartitionCacheHandler impl and test.
Modified: projects/cluster/ha-server-cache-ispn/trunk/pom.xml
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/pom.xml 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/pom.xml 2010-07-13 19:05:32 UTC (rev 106657)
@@ -29,11 +29,11 @@
</scm>
<properties>
- <version.jboss.ha.server.cache.spi>2.2.0.Final</version.jboss.ha.server.cache.spi>
+ <version.jboss.ha.server.cache.spi>2.2.1-SNAPSHOT</version.jboss.ha.server.cache.spi>
<version.jboss.ha.server.api>2.0.0.Alpha3</version.jboss.ha.server.api>
+ <version.jboss.ha.server.ispn>1.0.0-SNAPSHOT</version.jboss.ha.server.ispn>
<version.jboss.common.core>2.2.17.GA</version.jboss.common.core>
<version.jboss.logging>3.0.0.Beta2</version.jboss.logging>
- <version.infinispan>4.1.0.CR1</version.infinispan>
<version.org.jboss.naming>5.0.5.Final</version.org.jboss.naming>
<version.suffix.org.jboss.javaee>.GA</version.suffix.org.jboss.javaee>
<version.org.jboss.metadata.war>2.0.0.Alpha14</version.org.jboss.metadata.war>
@@ -85,6 +85,12 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.cluster</groupId>
+ <artifactId>jboss-ha-server-ispn</artifactId>
+ <version>${version.jboss.ha.server.ispn}</version>
+ </dependency>
<dependency>
<groupId>org.jboss</groupId>
@@ -98,27 +104,6 @@
<version>${version.jboss.logging}</version>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.infinispan</groupId>
- <artifactId>infinispan-core</artifactId>
- <version>${version.infinispan}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </exclusion>
- <!--exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion-->
- <exclusion>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<!-- For the JTA 1.1 API; consuming projects can safely
exclude this and replace with any valid source of this API -->
Added: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java (rev 0)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -0,0 +1,137 @@
+package org.jboss.ha.framework.server;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.infinispan.Cache;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.jboss.ha.framework.server.spi.HAPartitionCacheHandler;
+import org.jboss.ha.ispn.CacheContainerRegistry;
+import org.jgroups.ChannelFactory;
+
+ at SuppressWarnings("deprecation")
+public class HAPartitionCacheHandlerImpl implements HAPartitionCacheHandler
+{
+ private final CacheContainerRegistry registry;
+ private final AtomicReference<Cache<Object, Object>> cacheReference = new AtomicReference<Cache<Object, Object>>();
+ private final AtomicInteger acquireCount = new AtomicInteger();
+
+ private volatile String cacheContainerName;
+ private volatile String cacheName;
+
+ public HAPartitionCacheHandlerImpl(CacheContainerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ @Override
+ public void acquireCache()
+ {
+ if (this.cacheReference.get() == null)
+ {
+ CacheContainer container = this.registry.getCacheContainer(this.cacheContainerName);
+
+ String name = this.cacheName;
+
+ this.cacheReference.compareAndSet(null, (name != null) ? container.getCache(name) : container.getCache());
+ }
+
+ this.acquireCount.incrementAndGet();
+ }
+
+ @Override
+ public void startCache()
+ {
+ Cache<Object, Object> cache = this.cacheReference.get();
+
+ if (cache == null)
+ {
+ throw new IllegalStateException("You must first acquire a cache before starting it.");
+ }
+
+ if (cache.getStatus() != ComponentStatus.RUNNING)
+ {
+ cache.start();
+ }
+ }
+
+ @Override
+ public void releaseCache()
+ {
+ int count = this.acquireCount.decrementAndGet();
+
+ if (count == 0)
+ {
+ Cache<Object, Object> cache = this.cacheReference.getAndSet(null);
+
+ if ((cache != null) && (cache.getStatus() == ComponentStatus.RUNNING))
+ {
+ cache.stop();
+ }
+ }
+ else if (count < 0)
+ {
+ // Attempt to resolve
+ this.acquireCount.compareAndSet(count, count + 1);
+
+ throw new IllegalStateException("Attempt to release cache that was not acquired.");
+ }
+ }
+
+ @Override
+ public String getChannelStackName()
+ {
+ return this.getTransportProperties().getProperty("stack");
+ }
+
+ @Override
+ public ChannelFactory getCacheChannelFactory()
+ {
+ return (ChannelFactory) this.getTransportProperties().get("channelFactory");
+ }
+
+ private Properties getTransportProperties()
+ {
+ Cache<Object, Object> cache = this.cacheReference.get();
+
+ if (cache == null)
+ {
+ throw new IllegalStateException("Must acquire cache before getting channel stack name");
+ }
+
+ CacheContainer container = cache.getCacheManager();
+
+ if (!(container instanceof EmbeddedCacheManager))
+ {
+ throw new IllegalStateException(String.format("Cache container [%s] is not of the expected type: %s", container.getClass().getName(), EmbeddedCacheManager.class.getName()));
+ }
+
+ EmbeddedCacheManager manager = (EmbeddedCacheManager) container;
+
+ return manager.getGlobalConfiguration().getTransportProperties();
+ }
+
+ @Override
+ public String getCacheConfigName()
+ {
+ return this.cacheName;
+ }
+
+ public void setCacheConfigName(String cacheName)
+ {
+ this.cacheName = cacheName;
+ }
+
+ public String getCacheContainerName()
+ {
+ return this.cacheContainerName;
+ }
+
+ public void setCacheContainerName(String cacheContainerName)
+ {
+ this.cacheContainerName = cacheContainerName;
+ }
+}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfiguration.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfiguration.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfiguration.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan;
-
-import java.util.Collection;
-
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
-
-/**
- * Represents an Infinispan cache manager configuration.
- * @author Paul Ferraro
- */
-public interface CacheManagerConfiguration
-{
- /**
- * The general configuration shared by all caches.
- * @return a global configuration
- */
- GlobalConfiguration getGlobalConfiguration();
-
- /**
- * The default configuration inherited by any named caches.
- * @return the default cache configuration
- */
- Configuration getDefaultConfiguration();
-
- /**
- * The name cache configurations.
- * @return a collection of named cache configuration
- */
- Collection<Configuration> getConfigurations();
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfigurationAdapter.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfigurationAdapter.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerConfigurationAdapter.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,39 +0,0 @@
-package org.jboss.ha.infinispan;
-
-import java.util.Collection;
-
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.config.InfinispanConfiguration;
-
-/**
- * Adapts an {@link InfinispanConfiguration} to the {@link CacheManagerConfiguration} interface.
- * @author Paul Ferraro
- */
-public class CacheManagerConfigurationAdapter implements CacheManagerConfiguration
-{
- private final InfinispanConfiguration configuration;
-
- public CacheManagerConfigurationAdapter(InfinispanConfiguration configuration)
- {
- this.configuration = configuration;
- }
-
- @Override
- public GlobalConfiguration getGlobalConfiguration()
- {
- return this.configuration.parseGlobalConfiguration();
- }
-
- @Override
- public Configuration getDefaultConfiguration()
- {
- return this.configuration.parseDefaultConfiguration();
- }
-
- @Override
- public Collection<Configuration> getConfigurations()
- {
- return this.configuration.parseNamedConfigurations().values();
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactory.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactory.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactory.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan;
-
-import org.infinispan.manager.CacheContainer;
-
-/**
- * Creates an Infinispan {@link CacheManager} instance from configuration.
- *
- * @author Paul Ferraro
- */
-public interface CacheManagerFactory
-{
- /**
- * Creates a {@link CacheManager} from the specified configuration.
- * @param configuration a cache manager configuration
- * @return an Infinispan cache manager
- */
- CacheContainer createCacheManager(CacheManagerConfiguration configuration);
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactoryImpl.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactoryImpl.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerFactoryImpl.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan;
-
-import java.util.Properties;
-
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.manager.CacheContainer;
-import org.infinispan.manager.DefaultCacheManager;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.infinispan.remoting.transport.jgroups.JGroupsChannelLookup;
-import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
-import org.jgroups.Channel;
-import org.jgroups.ChannelFactory;
-
-/**
- * An Infinispan cache manager factory that injects its channel from a channel factory.
- *
- * @author Paul Ferraro
- */
- at SuppressWarnings("deprecation")
-public class CacheManagerFactoryImpl implements CacheManagerFactory
-{
- private static final String CHANNEL_ID = "channelId";
- private static final String CHANNEL_FACTORY = "channelFactory";
-
- private final ChannelFactory channelFactory;
-
- /**
- * Creates a new CacheManagerFactoryImpl using the specified channel factory.
- * @param channelFactory a channel factory
- */
- public CacheManagerFactoryImpl(ChannelFactory channelFactory)
- {
- this.channelFactory = channelFactory;
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.ha.infinispan.CacheManagerFactory#createCacheManager(org.jboss.ha.infinispan.CacheManagerConfiguration)
- */
- @Override
- public CacheContainer createCacheManager(CacheManagerConfiguration configuration)
- {
- GlobalConfiguration globalConfiguration = configuration.getGlobalConfiguration();
- Properties properties = globalConfiguration.getTransportProperties();
- properties.put(CHANNEL_FACTORY, this.channelFactory);
- properties.setProperty(CHANNEL_ID, globalConfiguration.getClusterName());
- properties.setProperty(JGroupsTransport.CHANNEL_LOOKUP, ChannelFactoryChannelLookup.class.getName());
-
- EmbeddedCacheManager manager = new DefaultCacheManager(globalConfiguration, configuration.getDefaultConfiguration(), false);
-
- // Add named configurations
- for (Configuration config: configuration.getConfigurations())
- {
- manager.defineConfiguration(config.getName(), config);
- }
-
- manager.start();
-
- return manager;
- }
-
- /**
- * JGroupsChannelLookup implementation that uses a channel factory.
- */
- public static class ChannelFactoryChannelLookup implements JGroupsChannelLookup
- {
- public static final String STACK = "stack";
- public static final String DEFAULT_STACK = "udp";
-
- @Override
- public Channel getJGroupsChannel(Properties properties)
- {
- String stack = properties.getProperty(STACK, DEFAULT_STACK);
- String id = properties.getProperty(CHANNEL_ID);
- ChannelFactory factory = (ChannelFactory) properties.get(CHANNEL_FACTORY);
-
- try
- {
- return factory.createMultiplexerChannel(stack, id);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-
- @Override
- public boolean shouldStartAndConnect()
- {
- return true;
- }
-
- @Override
- public boolean shouldStopAndDisconnect()
- {
- return true;
- }
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistry.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistry.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistry.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan;
-
-import java.util.Set;
-
-import org.infinispan.manager.CacheContainer;
-
-/**
- * A registry of Infinispan cache managers.
- * @author Paul Ferraro
- */
-public interface CacheManagerRegistry
-{
- /**
- * Returns the default cache manager.
- * Equivalent to getCacheManager(null).
- * @return an Infinispan cache manager.
- */
- CacheContainer getDefaultCacheManager();
-
- /**
- * Returns the cache manager associated with the specified identifier,
- * or the default cache manager if there is no associated cache manager
- * or the specified id is null.
- * @param id a cache manager identifier
- * @return an Infinispan cache manager.
- */
- CacheContainer getCacheManager(String id);
-
- /**
- * Returns the identifiers of all cache managers in this registry.
- * @return a set of cache manager identifiers.
- */
- Set<String> getCacheManagers();
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,181 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan;
-
-import java.util.AbstractMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.infinispan.manager.CacheContainer;
-import org.jboss.ha.infinispan.config.CacheManagerRegistryConfiguration;
-import org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationEntry;
-import org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationSource;
-import org.jboss.logging.Logger;
-
-/**
- * Cache manager registry that populates itself using a specified factory from configuration from a specified source.
- * All cache managers in the registry are bound to jndi.
- * @author Paul Ferraro
- */
-public class CacheManagerRegistryImpl implements CacheManagerRegistry
-{
- private static Logger logger = Logger.getLogger(CacheManagerRegistryImpl.class);
-
- private final CacheManagerFactory factory;
- private final CacheManagerRegistryConfigurationSource source;
- private final Context context;
- private final Map<String, Map.Entry<String, CacheContainer>> cacheManagers = new ConcurrentHashMap<String, Map.Entry<String, CacheContainer>>();
-
- private CacheContainer defaultCacheManager;
-
- /**
- * Creates a new CacheManagerRegistryImpl using the specified factory and source.
- * @param factory used to create cache manager instances from configuration
- * @param source source of cache manager configurations.
- * @throws NamingException if inital context could not be created
- */
- public CacheManagerRegistryImpl(CacheManagerFactory factory, CacheManagerRegistryConfigurationSource source) throws NamingException
- {
- this(factory, source, new InitialContext());
- }
-
- /**
- * Creates a new CacheManagerRegistryImpl using the specified factory and source.
- * @param factory used to create cache manager instances from configuration
- * @param source source of cache manager configurations.
- * @param context jndi context to which to bind cache managers.
- */
- public CacheManagerRegistryImpl(CacheManagerFactory factory, CacheManagerRegistryConfigurationSource source, Context context)
- {
- this.factory = factory;
- this.source = source;
- this.context = context;
- }
-
- public void start() throws Exception
- {
- CacheManagerRegistryConfiguration registry = this.source.getRegistryConfiguration();
-
- for (CacheManagerRegistryConfigurationEntry entry: registry.getEntries())
- {
- if (entry.getJndiName() == null)
- {
- entry.setJndiName(this.context.composeName(entry.getId(), registry.getBaseJndiName()));
- }
-
- this.add(entry);
- }
-
- CacheManagerRegistryConfigurationEntry defaultEntry = registry.getDefaultEntry();
-
- if (defaultEntry == null)
- {
- defaultEntry = registry.getEntries().get(0);
- }
-
- this.defaultCacheManager = this.cacheManagers.get(defaultEntry.getId()).getValue();
- }
-
- public void stop() throws Exception
- {
- for (Map.Entry<String, CacheContainer> entry: this.cacheManagers.values())
- {
- try
- {
- this.context.unbind(entry.getKey());
- }
- catch (NamingException e)
- {
- logger.warn(e.getMessage(), e);
- }
-
- entry.getValue().stop();
- }
-
- this.cacheManagers.clear();
- this.defaultCacheManager = null;
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.ha.infinispan.CacheManagerRegistry#getCacheManagers()
- */
- @Override
- public Set<String> getCacheManagers()
- {
- return Collections.unmodifiableSet(this.cacheManagers.keySet());
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.ha.infinispan.CacheManagerRegistry#getDefaultCacheManager()
- */
- @Override
- public CacheContainer getDefaultCacheManager()
- {
- return this.defaultCacheManager;
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.ha.infinispan.CacheManagerRegistry#getCacheManager(java.lang.String)
- */
- @Override
- public CacheContainer getCacheManager(String name)
- {
- Map.Entry<String, CacheContainer> entry = (name != null) ? this.cacheManagers.get(name) : null;
-
- // Return default cache manager, if name was not found or if it was null
- return (entry != null) ? entry.getValue() : this.defaultCacheManager;
- }
-
- public void add(CacheManagerRegistryConfigurationEntry entry) throws NamingException
- {
- CacheContainer manager = this.factory.createCacheManager(new CacheManagerConfigurationAdapter(entry.getConfiguration()));
-
- String jndiName = entry.getJndiName();
-
- // Store cache managers with jndi name, so they can be unbound during stop()
- this.cacheManagers.put(entry.getId(), new AbstractMap.SimpleImmutableEntry<String, CacheContainer>(jndiName, manager));
-
- // Bind cache manager to jndi
- this.context.bind(jndiName, manager);
- }
-
- public void remove(CacheManagerRegistryConfigurationEntry config) throws NamingException
- {
- Map.Entry<String, CacheContainer> entry = this.cacheManagers.remove(config.getId());
-
- if (entry != null)
- {
- entry.getValue().stop();
-
- this.context.unbind(entry.getKey());
- }
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfiguration.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfiguration.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfiguration.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan.config;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlIDREF;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * Root element for cache manager registry configuration.
- * @author Paul Ferraro
- */
- at XmlRootElement(name = "infinispan-configs")
- at XmlAccessorType(XmlAccessType.FIELD)
- at XmlType
-public class CacheManagerRegistryConfiguration
-{
- @XmlIDREF
- @XmlAttribute(name = "default", required = false)
- private CacheManagerRegistryConfigurationEntry defaultEntry;
-
- @XmlAttribute(name = "base-jndi-name", required = false)
- private String baseJndiName = "java:CacheManager";
-
- @XmlElement(name = "infinispan-config")
- private List<CacheManagerRegistryConfigurationEntry> entries;
-
- public CacheManagerRegistryConfigurationEntry getDefaultEntry()
- {
- return this.defaultEntry;
- }
-
- public void setDefaultEntry(CacheManagerRegistryConfigurationEntry defaultEntry)
- {
- this.defaultEntry = defaultEntry;
- }
-
- public List<CacheManagerRegistryConfigurationEntry> getEntries()
- {
- return this.entries;
- }
-
- public void setEntries(List<CacheManagerRegistryConfigurationEntry> entries)
- {
- this.entries = entries;
- }
-
- public String getBaseJndiName()
- {
- return this.baseJndiName;
- }
-
- public void setBaseJndiName(String baseJndiName)
- {
- this.baseJndiName = baseJndiName;
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationEntry.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationEntry.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationEntry.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan.config;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElementRef;
-import javax.xml.bind.annotation.XmlID;
-import javax.xml.bind.annotation.XmlType;
-
-import org.infinispan.config.InfinispanConfiguration;
-
-/**
- * A cache manager registry configuration entry.
- * @author Paul Ferraro
- */
- at XmlAccessorType(XmlAccessType.FIELD)
- at XmlType
-public class CacheManagerRegistryConfigurationEntry
-{
- @XmlID
- @XmlAttribute(name = "name", required = true)
- private String id;
- @XmlAttribute(name = "jndi-name", required = false)
- private String jndiName;
-
- @XmlElementRef
- private InfinispanConfiguration configuration;
-
- public String getId()
- {
- return this.id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public String getJndiName()
- {
- return this.jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public InfinispanConfiguration getConfiguration()
- {
- return this.configuration;
- }
-
- public void setConfiguration(InfinispanConfiguration configuration)
- {
- this.configuration = configuration;
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationSource.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationSource.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/CacheManagerRegistryConfigurationSource.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan.config;
-
-/**
- * A source of cache manager registry configuration.
- * @author Paul Ferraro
- */
-public interface CacheManagerRegistryConfigurationSource
-{
- /**
- * Retrieves a cache manager registry configuration.
- * @return a cache manager registry configuration
- * @throws Exception if the configuration could not be retrieved.
- */
- CacheManagerRegistryConfiguration getRegistryConfiguration() throws Exception;
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSource.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSource.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSource.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan.config;
-
-/**
- * A trivial cache manager registry source implementation.
- * @author Paul Ferraro
- */
-public class SimpleCacheManagerRegistryConfigurationSource implements CacheManagerRegistryConfigurationSource
-{
- private final CacheManagerRegistryConfiguration configuration;
-
- /**
- * Creates a new SimpleCacheManagerRegistryConfigurationSource using the specified configuration.
- * @param configuration the cache manager registry configuration.
- */
- public SimpleCacheManagerRegistryConfigurationSource(CacheManagerRegistryConfiguration configuration)
- {
- this.configuration = configuration;
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationSource#getRegistryConfiguration()
- */
- @Override
- public CacheManagerRegistryConfiguration getRegistryConfiguration()
- {
- return this.configuration;
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSource.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSource.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSource.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.infinispan.config;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import org.infinispan.config.InfinispanConfiguration;
-
-/**
- * A source for a cache manager registry that parses an single Infinispan cache manager configuration file.
- * @author Paul Ferraro
- */
-public class SingleCacheManagerRegistryConfigurationSource implements CacheManagerRegistryConfigurationSource
-{
- public static final String DEFAULT_ID = "default";
-
- private final String resource;
-
- private String id = DEFAULT_ID;
- private String jndiName;
-
- /**
- * Creates a new SingleCacheManagerRegistryConfigurationSource
- * @param id the identifier of the singleton cache manager
- * @param jndiName the jndi name for the cache manager
- * @param resource the classpath resource containing the infinispan cache manager configuration.
- */
- public SingleCacheManagerRegistryConfigurationSource(String resource)
- {
- this.resource = resource;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationSource#getRegistryConfiguration()
- */
- @Override
- public CacheManagerRegistryConfiguration getRegistryConfiguration() throws IOException
- {
- CacheManagerRegistryConfigurationEntry entry = new CacheManagerRegistryConfigurationEntry();
- entry.setId(this.id);
- entry.setJndiName(this.jndiName);
- entry.setConfiguration(InfinispanConfiguration.newInfinispanConfiguration(this.resource));
-
- CacheManagerRegistryConfiguration registry = new CacheManagerRegistryConfiguration();
- registry.setDefaultEntry(entry);
- registry.setEntries(Collections.singletonList(entry));
-
- return registry;
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/package-info.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/package-info.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/config/package-info.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,26 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.
- */
- at XmlSchema(namespace = "urn:jboss:infinispan-configs:1.0", elementFormDefault = XmlNsForm.QUALIFIED)
-package org.jboss.ha.infinispan.config;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
\ No newline at end of file
Added: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImplTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImplTest.java (rev 0)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImplTest.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -0,0 +1,440 @@
+package org.jboss.ha.framework.server;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.easymock.EasyMock;
+import org.infinispan.Cache;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.jboss.ha.framework.server.spi.HAPartitionCacheHandler;
+import org.jboss.ha.ispn.CacheContainerRegistry;
+import org.jgroups.ChannelFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+ at SuppressWarnings("deprecation")
+public class HAPartitionCacheHandlerImplTest
+{
+ @Test
+ public void defaults() throws Exception
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+ CacheContainer container = EasyMock.createStrictMock(CacheContainer.class);
+ @SuppressWarnings("unchecked")
+ Cache<Object, Object> cache = EasyMock.createStrictMock(Cache.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ EasyMock.expect(registry.getCacheContainer(null)).andReturn(container);
+ EasyMock.expect(container.getCache()).andReturn(cache);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Release w/out start
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.INSTANTIATED);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.releaseCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Re-acquire
+ EasyMock.expect(registry.getCacheContainer(null)).andReturn(container);
+ EasyMock.expect(container.getCache()).andReturn(cache);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // start cache
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.INSTANTIATED);
+ cache.start();
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.startCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Already started
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.RUNNING);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.startCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Release
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.RUNNING);
+ cache.stop();
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.releaseCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+ }
+
+ @Test
+ public void custom() throws Exception
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+ CacheContainer container = EasyMock.createStrictMock(CacheContainer.class);
+ @SuppressWarnings("unchecked")
+ Cache<Object, Object> cache = EasyMock.createStrictMock(Cache.class);
+
+ HAPartitionCacheHandlerImpl handler = new HAPartitionCacheHandlerImpl(registry);
+ handler.setCacheContainerName("container");
+ handler.setCacheConfigName("cache");
+
+ EasyMock.expect(registry.getCacheContainer("container")).andReturn(container);
+ EasyMock.expect(container.getCache("cache")).andReturn(cache);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Release w/out start
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.INSTANTIATED);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.releaseCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Re-acquire
+ EasyMock.expect(registry.getCacheContainer("container")).andReturn(container);
+ EasyMock.expect(container.getCache("cache")).andReturn(cache);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // start cache
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.INSTANTIATED);
+ cache.start();
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.startCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Already started
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.RUNNING);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.startCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ // Release
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.RUNNING);
+ cache.stop();
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.releaseCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+ }
+
+ @Test
+ public void concurrent() throws Exception
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+ CacheContainer container = EasyMock.createStrictMock(CacheContainer.class);
+ @SuppressWarnings("unchecked")
+ final Cache<Object, Object> cache = EasyMock.createStrictMock(Cache.class);
+
+ final HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ // Acquire and start cache
+ EasyMock.expect(registry.getCacheContainer(null)).andReturn(container);
+ EasyMock.expect(container.getCache()).andReturn(cache);
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.INSTANTIATED);
+ cache.start();
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+ handler.startCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ EasyMock.makeThreadSafe(cache, true);
+
+ Callable<Void> task = new Callable<Void>()
+ {
+ @Override
+ public Void call() throws Exception
+ {
+ handler.acquireCache();
+
+ try
+ {
+ handler.startCache();
+ }
+ finally
+ {
+ handler.releaseCache();
+ }
+
+ return null;
+ }
+ };
+
+ int tasks = 100;
+
+ ExecutorService executor = Executors.newFixedThreadPool(tasks);
+ List<Future<Void>> futures = new ArrayList<Future<Void>>(tasks);
+
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.RUNNING).times(tasks);
+
+ EasyMock.replay(registry, container, cache);
+
+ List<Throwable> exceptions = new LinkedList<Throwable>();
+
+ try
+ {
+ for (int i = 0; i < tasks; ++i)
+ {
+ futures.add(executor.submit(task));
+ }
+
+ for (Future<Void> future: futures)
+ {
+ try
+ {
+ future.get();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ catch (ExecutionException e)
+ {
+ exceptions.add(e.getCause());
+ }
+ }
+ }
+ finally
+ {
+ executor.shutdown();
+ }
+
+ EasyMock.verify(registry, container, cache);
+
+ Assert.assertTrue(exceptions.toString(), exceptions.isEmpty());
+
+ EasyMock.reset(registry, container, cache);
+
+ // Release
+ EasyMock.expect(cache.getStatus()).andReturn(ComponentStatus.RUNNING);
+ cache.stop();
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.releaseCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+ }
+
+ @Test
+ public void startBeforeAcquire()
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ EasyMock.replay(registry);
+
+ try
+ {
+ handler.startCache();
+
+ Assert.fail("Cache was not yet acquired");
+ }
+ catch (Exception e)
+ {
+ Assert.assertEquals(IllegalStateException.class.getName(), e.getClass().getName());
+ }
+
+ EasyMock.verify(registry);
+ }
+
+ @Test
+ public void releaseBeforeAcquire()
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ EasyMock.replay(registry);
+
+ try
+ {
+ handler.releaseCache();
+
+ Assert.fail("Cache was not yet acquired");
+ }
+ catch (Exception e)
+ {
+ Assert.assertEquals(IllegalStateException.class.getName(), e.getClass().getName());
+ }
+
+ EasyMock.verify(registry);
+ }
+
+ @Test
+ public void getCacheChannelFactoryBeforeAcquire()
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ try
+ {
+ handler.getCacheChannelFactory();
+
+ Assert.fail("Cache was not yet acquired");
+ }
+ catch (Exception e)
+ {
+ Assert.assertEquals(IllegalStateException.class.getName(), e.getClass().getName());
+ }
+ }
+
+ @Test
+ public void getChannelStackNameBeforeAcquire()
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ try
+ {
+ handler.getChannelStackName();
+
+ Assert.fail("Cache was not yet acquired");
+ }
+ catch (Exception e)
+ {
+ Assert.assertEquals(IllegalStateException.class.getName(), e.getClass().getName());
+ }
+ }
+
+ @Test
+ public void getCacheChannelFactory() throws Exception
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+ CacheContainer container = EasyMock.createStrictMock(CacheContainer.class);
+ @SuppressWarnings("unchecked")
+ Cache<Object, Object> cache = EasyMock.createStrictMock(Cache.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ EasyMock.expect(registry.getCacheContainer(null)).andReturn(container);
+ EasyMock.expect(container.getCache()).andReturn(cache);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ EmbeddedCacheManager manager = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+ ChannelFactory factory = EasyMock.createStrictMock(ChannelFactory.class);
+ GlobalConfiguration configuration = new GlobalConfiguration();
+ configuration.getTransportProperties().put("channelFactory", factory);
+
+ EasyMock.expect(cache.getCacheManager()).andReturn(manager);
+ EasyMock.expect(manager.getGlobalConfiguration()).andReturn(configuration);
+
+ EasyMock.replay(registry, container, cache, manager, factory);
+
+ ChannelFactory result = handler.getCacheChannelFactory();
+
+ EasyMock.verify(registry, container, cache, manager, factory);
+
+ Assert.assertSame(factory, result);
+
+ EasyMock.reset(registry, container, cache, manager, factory);
+ }
+
+ @Test
+ public void getChannelStackName() throws Exception
+ {
+ CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
+ CacheContainer container = EasyMock.createStrictMock(CacheContainer.class);
+ @SuppressWarnings("unchecked")
+ Cache<Object, Object> cache = EasyMock.createStrictMock(Cache.class);
+
+ HAPartitionCacheHandler handler = new HAPartitionCacheHandlerImpl(registry);
+
+ EasyMock.expect(registry.getCacheContainer(null)).andReturn(container);
+ EasyMock.expect(container.getCache()).andReturn(cache);
+
+ EasyMock.replay(registry, container, cache);
+
+ handler.acquireCache();
+
+ EasyMock.verify(registry, container, cache);
+ EasyMock.reset(registry, container, cache);
+
+ EmbeddedCacheManager manager = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+ GlobalConfiguration configuration = new GlobalConfiguration();
+ configuration.getTransportProperties().setProperty("stack", "udp");
+
+ EasyMock.expect(cache.getCacheManager()).andReturn(manager);
+ EasyMock.expect(manager.getGlobalConfiguration()).andReturn(configuration);
+
+ EasyMock.replay(registry, container, cache, manager);
+
+ String result = handler.getChannelStackName();
+
+ EasyMock.verify(registry, container, cache, manager);
+
+ Assert.assertEquals("udp", result);
+
+ EasyMock.reset(registry, container, cache, manager);
+ }
+}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerFactoryTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerFactoryTest.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerFactoryTest.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,100 +0,0 @@
-package org.jboss.ha.infinispan;
-
-import java.net.URL;
-import java.util.Collections;
-
-import junit.framework.Assert;
-
-import org.easymock.EasyMock;
-import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.lifecycle.ComponentStatus;
-import org.infinispan.manager.CacheContainer;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
-import org.jgroups.ChannelFactory;
-import org.jgroups.JChannel;
-import org.junit.Test;
-
- at SuppressWarnings("deprecation")
-public class CacheManagerFactoryTest
-{
- @Test
- public void test() throws Exception
- {
- CacheManagerConfiguration configuration = EasyMock.createStrictMock(CacheManagerConfiguration.class);
- ChannelFactory channelFactory = EasyMock.createStrictMock(ChannelFactory.class);
- GlobalConfiguration globalConfiguration = new GlobalConfiguration();
- globalConfiguration.setTransportClass(JGroupsTransport.class.getName());
- globalConfiguration.setClusterName("mychannel");
-
- Configuration defaultConfiguration = new Configuration();
- Configuration namedConfiguration = new NamedConfiguration("custom");
-
- CacheManagerFactory factory = new CacheManagerFactoryImpl(channelFactory);
-
- EasyMock.expect(configuration.getGlobalConfiguration()).andReturn(globalConfiguration);
- EasyMock.expect(configuration.getDefaultConfiguration()).andReturn(defaultConfiguration);
- EasyMock.expect(configuration.getConfigurations()).andReturn(Collections.singletonList(namedConfiguration));
-
- EasyMock.replay(configuration, channelFactory);
-
- CacheContainer result = factory.createCacheManager(configuration);
-
- try
- {
- EasyMock.verify(configuration, channelFactory);
-
- Assert.assertTrue(result instanceof EmbeddedCacheManager);
- EmbeddedCacheManager manager = (EmbeddedCacheManager) result;
-
- Assert.assertEquals(globalConfiguration, manager.getGlobalConfiguration());
- Assert.assertEquals(defaultConfiguration, manager.getDefaultConfiguration());
- Assert.assertEquals(Collections.singleton("custom"), manager.getCacheNames());
- Assert.assertSame(ComponentStatus.INSTANTIATED, manager.getStatus());
- Assert.assertEquals("mychannel", manager.getClusterName());
- Assert.assertFalse(manager.isCoordinator());
- Assert.assertNull(manager.getAddress());
- Assert.assertNull(manager.getMembers());
-
- EasyMock.reset(configuration, channelFactory);
-
- URL url = Thread.currentThread().getContextClassLoader().getResource("config-samples/jgroups-udp.xml");
- EasyMock.expect(channelFactory.createMultiplexerChannel(CacheManagerFactoryImpl.ChannelFactoryChannelLookup.DEFAULT_STACK, "mychannel")).andReturn(new JChannel(url));
-
- EasyMock.replay(channelFactory);
-
- Cache<?, ?> cache = manager.getCache();
-
- try
- {
- EasyMock.verify(channelFactory);
-
- Assert.assertSame(ComponentStatus.RUNNING, cache.getStatus());
- Assert.assertSame(manager, cache.getCacheManager());
- Assert.assertSame(ComponentStatus.RUNNING, manager.getStatus());
- Assert.assertTrue(manager.isCoordinator());
- Assert.assertEquals(Collections.singletonList(manager.getAddress()), manager.getMembers());
- }
- finally
- {
- cache.stop();
- }
- }
- finally
- {
- result.stop();
- }
- }
-
- public static class NamedConfiguration extends Configuration
- {
- private static final long serialVersionUID = -6362167959914418561L;
-
- public NamedConfiguration(String name)
- {
- this.name = name;
- }
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerRegistryTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerRegistryTest.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/CacheManagerRegistryTest.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,183 +0,0 @@
-package org.jboss.ha.infinispan;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Context;
-
-import junit.framework.Assert;
-
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.easymock.EasyMock;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.InfinispanConfiguration;
-import org.infinispan.manager.CacheContainer;
-import org.jboss.ha.infinispan.config.CacheManagerRegistryConfiguration;
-import org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationEntry;
-import org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationSource;
-import org.junit.Test;
-
-public class CacheManagerRegistryTest
-{
- /**
- * Test with unspecified default config and default base jndi name
- * @throws Exception
- */
- @Test
- public void defaults() throws Exception
- {
- CacheManagerFactory factory = EasyMock.createStrictMock(CacheManagerFactory.class);
- CacheManagerRegistryConfigurationSource source = EasyMock.createStrictMock(CacheManagerRegistryConfigurationSource.class);
- CacheContainer defaultCacheManager = EasyMock.createStrictMock(CacheContainer.class);
- CacheContainer otherCacheManager = EasyMock.createStrictMock(CacheContainer.class);
- Context context = EasyMock.createStrictMock(Context.class);
- Capture<CacheManagerConfiguration> capturedConfiguration = new Capture<CacheManagerConfiguration>(CaptureType.ALL);
-
- InfinispanConfiguration config = InfinispanConfiguration.newInfinispanConfiguration("config-samples/minimal.xml");
-
- CacheManagerRegistryConfigurationEntry entry1 = new CacheManagerRegistryConfigurationEntry();
-
- entry1.setId("default");
- entry1.setConfiguration(config);
-
- CacheManagerRegistryConfigurationEntry entry2 = new CacheManagerRegistryConfigurationEntry();
-
- entry2.setId("other");
- entry2.setConfiguration(config);
-
- CacheManagerRegistryConfiguration configRegistry = new CacheManagerRegistryConfiguration();
- configRegistry.setEntries(Arrays.asList(entry1, entry2));
-
- CacheManagerRegistryImpl registry = new CacheManagerRegistryImpl(factory, source, context);
-
- EasyMock.expect(source.getRegistryConfiguration()).andReturn(configRegistry);
-
- EasyMock.expect(factory.createCacheManager(EasyMock.capture(capturedConfiguration))).andReturn(defaultCacheManager);
- EasyMock.expect(context.composeName("default", "java:CacheManager")).andReturn("java:CacheManager/default");
-
- context.bind("java:CacheManager/default", defaultCacheManager);
-
- EasyMock.expect(factory.createCacheManager(EasyMock.capture(capturedConfiguration))).andReturn(otherCacheManager);
- EasyMock.expect(context.composeName("other", "java:CacheManager")).andReturn("java:CacheManager/other");
-
- context.bind("java:CacheManager/other", otherCacheManager);
-
- EasyMock.replay(factory, source, context, defaultCacheManager, otherCacheManager);
-
- registry.start();
-
- EasyMock.verify(factory, source, context, defaultCacheManager, otherCacheManager);
-
- Set<String> names = registry.getCacheManagers();
- Assert.assertEquals(2, names.size());
- Assert.assertTrue(names.contains("default"));
- Assert.assertTrue(names.contains("other"));
-
- Assert.assertSame(defaultCacheManager, registry.getCacheManager(null));
- Assert.assertSame(defaultCacheManager, registry.getCacheManager("default"));
- Assert.assertSame(defaultCacheManager, registry.getCacheManager("unknown"));
- Assert.assertSame(otherCacheManager, registry.getCacheManager("other"));
-
- List<CacheManagerConfiguration> configurations = capturedConfiguration.getValues();
- Assert.assertEquals(2, configurations.size());
-
- for (CacheManagerConfiguration configuration: configurations)
- {
- Assert.assertSame(config.parseGlobalConfiguration(), configuration.getGlobalConfiguration());
- Assert.assertSame(config.parseDefaultConfiguration(), configuration.getDefaultConfiguration());
- Map<String, Configuration> namedConfigurations = config.parseNamedConfigurations();
- Collection<Configuration> configs = configuration.getConfigurations();
- Assert.assertEquals(namedConfigurations.size(), configs.size());
- for (Configuration c: configs)
- {
- Assert.assertSame(namedConfigurations.get(c.getName()), c);
- }
- }
-
- EasyMock.reset(factory, source, context, defaultCacheManager, otherCacheManager);
- }
-
- /**
- * Test with custom default config and custom base jndi name
- * @throws Exception
- */
- @Test
- public void custom() throws Exception
- {
- CacheManagerFactory factory = EasyMock.createStrictMock(CacheManagerFactory.class);
- CacheManagerRegistryConfigurationSource provider = EasyMock.createStrictMock(CacheManagerRegistryConfigurationSource.class);
- CacheContainer defaultCacheManager = EasyMock.createStrictMock(CacheContainer.class);
- CacheContainer otherCacheManager = EasyMock.createStrictMock(CacheContainer.class);
- Context context = EasyMock.createStrictMock(Context.class);
- Capture<CacheManagerConfiguration> capturedConfiguration = new Capture<CacheManagerConfiguration>(CaptureType.ALL);
-
- InfinispanConfiguration config = InfinispanConfiguration.newInfinispanConfiguration("config-samples/minimal.xml");
-
- CacheManagerRegistryConfigurationEntry entry1 = new CacheManagerRegistryConfigurationEntry();
-
- entry1.setId("other");
- entry1.setConfiguration(config);
- entry1.setJndiName("java:other");
-
- CacheManagerRegistryConfigurationEntry entry2 = new CacheManagerRegistryConfigurationEntry();
-
- entry2.setId("default");
- entry2.setConfiguration(config);
-
- CacheManagerRegistryConfiguration configRegistry = new CacheManagerRegistryConfiguration();
- configRegistry.setEntries(Arrays.asList(entry1, entry2));
- configRegistry.setDefaultEntry(entry2);
- configRegistry.setBaseJndiName("java:Infinispan");
-
- CacheManagerRegistryImpl registry = new CacheManagerRegistryImpl(factory, provider, context);
-
- EasyMock.expect(provider.getRegistryConfiguration()).andReturn(configRegistry);
-
- EasyMock.expect(factory.createCacheManager(EasyMock.capture(capturedConfiguration))).andReturn(otherCacheManager);
-
- context.bind("java:other", otherCacheManager);
-
- EasyMock.expect(factory.createCacheManager(EasyMock.capture(capturedConfiguration))).andReturn(defaultCacheManager);
- EasyMock.expect(context.composeName("default", "java:Infinispan")).andReturn("java:Infinispan/default");
-
- context.bind("java:Infinispan/default", defaultCacheManager);
-
- EasyMock.replay(factory, provider, context, defaultCacheManager, otherCacheManager);
-
- registry.start();
-
- EasyMock.verify(factory, provider, context, defaultCacheManager, otherCacheManager);
-
- Set<String> names = registry.getCacheManagers();
- Assert.assertEquals(2, names.size());
- Assert.assertTrue(names.contains("default"));
- Assert.assertTrue(names.contains("other"));
-
- Assert.assertSame(defaultCacheManager, registry.getCacheManager(null));
- Assert.assertSame(defaultCacheManager, registry.getCacheManager("default"));
- Assert.assertSame(defaultCacheManager, registry.getCacheManager("unknown"));
- Assert.assertSame(otherCacheManager, registry.getCacheManager("other"));
-
- List<CacheManagerConfiguration> configurations = capturedConfiguration.getValues();
- Assert.assertEquals(2, configurations.size());
-
- for (CacheManagerConfiguration configuration: configurations)
- {
- Assert.assertSame(config.parseGlobalConfiguration(), configuration.getGlobalConfiguration());
- Assert.assertSame(config.parseDefaultConfiguration(), configuration.getDefaultConfiguration());
- Map<String, Configuration> namedConfigurations = config.parseNamedConfigurations();
- Collection<Configuration> configs = configuration.getConfigurations();
- Assert.assertEquals(namedConfigurations.size(), configs.size());
- for (Configuration c: configs)
- {
- Assert.assertSame(namedConfigurations.get(c.getName()), c);
- }
- }
-
- EasyMock.reset(factory, provider, context, defaultCacheManager, otherCacheManager);
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSourceTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSourceTest.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SimpleCacheManagerRegistryConfigurationSourceTest.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,17 +0,0 @@
-package org.jboss.ha.infinispan.config;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SimpleCacheManagerRegistryConfigurationSourceTest
-{
- @Test
- public void test() throws Exception
- {
- CacheManagerRegistryConfiguration configuration = new CacheManagerRegistryConfiguration();
-
- CacheManagerRegistryConfigurationSource source = new SimpleCacheManagerRegistryConfigurationSource(configuration);
-
- Assert.assertSame(configuration, source.getRegistryConfiguration());
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSourceTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSourceTest.java 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/ha/infinispan/config/SingleCacheManagerRegistryConfigurationSourceTest.java 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,56 +0,0 @@
-package org.jboss.ha.infinispan.config;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SingleCacheManagerRegistryConfigurationSourceTest
-{
- @Test
- public void testDefault() throws Exception
- {
- CacheManagerRegistryConfigurationSource source = new SingleCacheManagerRegistryConfigurationSource("config-samples/minimal.xml");
-
- CacheManagerRegistryConfiguration configuration = source.getRegistryConfiguration();
-
- Assert.assertEquals("java:CacheManager", configuration.getBaseJndiName());
-
- List<CacheManagerRegistryConfigurationEntry> entries = configuration.getEntries();
-
- Assert.assertEquals(1, entries.size());
-
- CacheManagerRegistryConfigurationEntry entry = entries.get(0);
-
- Assert.assertSame(entry, configuration.getDefaultEntry());
-
- Assert.assertEquals("default", entry.getId());
- Assert.assertNull(entry.getJndiName());
- Assert.assertEquals(0, entry.getConfiguration().parseNamedConfigurations().size());
- }
-
- @Test
- public void testCustom() throws Exception
- {
- SingleCacheManagerRegistryConfigurationSource source = new SingleCacheManagerRegistryConfigurationSource("config-samples/minimal.xml");
-
- source.setId("custom");
- source.setJndiName("java:SingleCacheManager");
-
- CacheManagerRegistryConfiguration configuration = source.getRegistryConfiguration();
-
- Assert.assertEquals("java:CacheManager", configuration.getBaseJndiName());
-
- List<CacheManagerRegistryConfigurationEntry> entries = configuration.getEntries();
-
- Assert.assertEquals(1, entries.size());
-
- CacheManagerRegistryConfigurationEntry entry = entries.get(0);
-
- Assert.assertSame(entry, configuration.getDefaultEntry());
-
- Assert.assertEquals("custom", entry.getId());
- Assert.assertEquals("java:SingleCacheManager", entry.getJndiName());
- Assert.assertEquals(0, entry.getConfiguration().parseNamedConfigurations().size());
- }
-}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs-multiple.xml
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs-multiple.xml 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs-multiple.xml 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<infinispan-configs default="manager1" base-jndi-name="java:CacheManagers" xmlns="urn:jboss:infinispan-configs:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:infinispan-configs:1.0 ../../src/main/resources/infinispan-configs.xsd">
- <infinispan-config name="manager0">
- <infinispan xmlns="urn:infinispan:config:4.0"/>
- </infinispan-config>
- <infinispan-config name="manager1">
- <infinispan xmlns="urn:infinispan:config:4.0"/>
- </infinispan-config>
- <infinispan-config name="manager2" jndi-name="java:CacheManager2">
- <infinispan xmlns="urn:infinispan:config:4.0"/>
- </infinispan-config>
-</infinispan-configs>
\ No newline at end of file
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs.xml
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs.xml 2010-07-13 19:02:38 UTC (rev 106656)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/resources/infinispan-configs.xml 2010-07-13 19:05:32 UTC (rev 106657)
@@ -1,219 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<infinispan-configs xmlns="urn:jboss:infinispan-configs:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:infinispan-configs:1.0 ../../src/main/resources/infinispan-configs.xsd">
- <infinispan-config name="default">
- <!-- *************************** -->
- <!-- System-wide global settings -->
- <!-- *************************** -->
- <infinispan xmlns="urn:infinispan:config:4.0">
-
- <global>
-
- <!-- Note that if these are left blank, defaults are used. See the user guide for what these defaults are -->
- <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
- <properties>
- <property name="maxThreads" value="5"/>
- <property name="threadNamePrefix" value="AsyncListenerThread"/>
- </properties>
- </asyncListenerExecutor>
-
- <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
- <properties>
- <property name="maxThreads" value="25"/>
- <property name="threadNamePrefix" value="AsyncSerializationThread"/>
- </properties>
- </asyncTransportExecutor>
-
- <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
- <properties>
- <property name="threadNamePrefix" value="EvictionThread"/>
- </properties>
- </evictionScheduledExecutor>
-
- <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
- <properties>
- <property name="threadNamePrefix" value="ReplicationQueueThread"/>
- </properties>
- </replicationQueueScheduledExecutor>
-
- <globalJmxStatistics enabled="true" jmxDomain="infinispan"/>
-
- <!--
- If the transport is omitted, there is no way to create distributed or clustered caches.
- There is no added cost to defining a transport but not creating a cache that uses one, since the transport
- is created and initialized lazily.
- -->
- <transport clusterName="infinispan-cluster" distributedSyncTimeout="50000" nodeName="Jalapeno"/>
- <!-- Note that the JGroups transport uses sensible defaults if no configuration property is defined. -->
- <!-- See the JGroupsTransport javadocs for more flags -->
-
- <!-- Again, sensible defaults are used here if this is omitted. -->
- <serialization marshallerClass="org.infinispan.marshall.VersionAwareMarshaller" version="1.0"/>
-
- <!--
- Used to register JVM shutdown hooks.
- hookBehavior: DEFAULT, REGISTER, DONT_REGISTER
- -->
- <shutdown hookBehavior="DEFAULT"/>
- </global>
-
- <!-- *************************** -->
- <!-- Default "template" settings -->
- <!-- *************************** -->
- <!-- this is used as a "template" configuration for all caches in the system. -->
- <default xmlns="urn:infinispan:config:4.0">
- <!--
- isolation levels supported: READ_COMMITTED and REPEATABLE_READ
- -->
- <locking
- isolationLevel="REPEATABLE_READ"
- lockAcquisitionTimeout="20000"
- writeSkewCheck="false"
- concurrencyLevel="500"
- useLockStriping="true"
- />
-
- <!--
- Used to register a transaction manager and participate in ongoing transactions.
- -->
- <transaction
- transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
- syncRollbackPhase="false"
- syncCommitPhase="false"
- useEagerLocking="false"/>
-
- <!--
- Used to register JMX statistics in any available MBean server
- -->
- <jmxStatistics enabled="false"/>
-
- <lazyDeserialization enabled="false"/>
-
- <!--
- Used to enable invocation batching and allow the use of Cache.startBatch()/endBatch() methods.
- -->
- <invocationBatching enabled="false"/>
-
- <!--
- This element specifies that the cache is clustered.
- modes supported: distribution (d), replication (r) or invalidation (i).
- -->
- <clustering mode="replication">
-
- <!--
- Defines whether to retrieve state on startup
- -->
- <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
-
- <!--
- Network calls are synchronous.
- -->
- <sync replTimeout="20000"/>
- <!--
- Uncomment this for async replication.
- -->
- <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500"/>-->
- </clustering>
-
- </default>
-
- <!-- ************************************** -->
- <!-- Individually configured "named" caches -->
- <!-- ************************************** -->
-
- <namedCache name="asyncCache">
- <clustering mode="replication">
- <async asyncMarshalling="true"/>
- </clustering>
- </namedCache>
-
- <!-- Note that any of the elements appearing in a namedCache section can also appear in the default section as a template. -->
- <namedCache name="evictionCache">
-
- <!--
- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means
- the eviction thread will never run. A separate executor is used for eviction in each cache.
- -->
- <eviction wakeUpInterval="500" maxEntries="5000" strategy="FIFO" threadPolicy="PIGGYBACK"/>
- <expiration lifespan="60000" maxIdle="1000"/>
- </namedCache>
-
-
- <namedCache name="persistentCache">
- <!--
- Cache loaders.
-
- If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state
- is accessed again, it is removed from the cache loaderold and loaded into memory.
-
- Otherwise, state is always maintained in the cache loaderold as well as in memory.
-
- Set 'shared' to true if all instances in the cluster use the same cache loaderold instance, e.g., are talking to the
- same database.
-
- If "preload" is true, all keys are loaded from the cache loaderold into memory upon starting the cache.
- -->
- <loaders passivation="false" shared="false" preload="true">
-
- <!--
- We can have multiple cache loaders, which get chained
- -->
- <loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="true"
- ignoreModifications="true" purgeOnStartup="true">
-
- <!-- See the documentation for more configuration examples and flags. -->
- <properties>
- <property name="location" value="${java.io.tmpdir}"/>
- </properties>
- <singletonStore enabled="true" pushStateWhenCoordinator="true" pushStateTimeout="20000"/>
- <async enabled="true" flushLockTimeout="15000" threadPoolSize="5"/>
- </loader>
- </loaders>
-
- <deadlockDetection enabled="true" spinDuration="1000"/>
-
- </namedCache>
-
- <namedCache name="distributedCache">
- <clustering mode="distribution">
- <sync/>
- <!--
- num owners: number of owners for each key. The larger this number is, the safer your data will be, but the
- slower the cluster will be.
-
- rehashRpcTimeout: timeout used for RPC calls relating to rehashing. This defaults to 600000 (10 minutes).
- -->
- <hash numOwners="3" rehashWait="120000" rehashRpcTimeout="600000"/>
- <l1 enabled="true" lifespan="600000"/>
- </clustering>
- </namedCache>
-
- <namedCache name="withReplicatinQueue">
- <clustering>
- <async useReplQueue="true" replQueueInterval="100" replQueueMaxElements="200"/>
- </clustering>
- </namedCache>
-
- <namedCache name="lockPerEntry">
- <locking useLockStriping="false" />
- </namedCache>
-
- <namedCache name="cacheWithCustomInterceptors">
- <!--
- Define custom interceptors. All custom interceptors need to extend org.jboss.cache.interceptors.base.CommandInterceptor
- -->
- <!--
- <customInterceptors>
- <interceptor position="first" class="com.mycompany.CustomInterceptor1">
- <property name="com.mycompany.attributeOne" value="value1" />
- <property name="com.mycompany.attributeTwo" value="value2" />
- </interceptor>
- <interceptor position="last" class="com.mycompany.CustomInterceptor2"/>
- <interceptor index="3" class="com.mycompany.CustomInterceptor1"/>
- <interceptor before="org.infinispanpan.interceptors.CallInterceptor" class="com.mycompany.CustomInterceptor2"/>
- <interceptor after="org.infinispanpan.interceptors.CallInterceptor" class="com.mycompany.CustomInterceptor1"/>
- </customInterceptors>
- -->
- </namedCache>
- </infinispan>
- </infinispan-config>
-</infinispan-configs>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list