[teiid-commits] teiid SVN: r1143 - in trunk: embedded/src/main/java/com/metamatrix/dqp/embedded/services and 2 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Jul 16 16:56:43 EDT 2009
Author: rareddy
Date: 2009-07-16 16:56:43 -0400 (Thu, 16 Jul 2009)
New Revision: 1143
Modified:
trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
Log:
TEIID-485: removing the all the deprecated classes from Jboss cache.
Modified: trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-07-16 19:40:24 UTC (rev 1142)
+++ trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-07-16 20:56:43 UTC (rev 1143)
@@ -22,55 +22,45 @@
package com.metamatrix.cache.jboss;
-import java.lang.management.ManagementFactory;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.eviction.FIFOConfiguration;
-import org.jboss.cache.eviction.LFUConfiguration;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.MRUConfiguration;
-import org.jboss.cache.jmx.CacheJmxWrapper;
-import org.jboss.cache.jmx.CacheJmxWrapperMBean;
+import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
+import org.jboss.cache.eviction.LFUAlgorithmConfig;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import com.google.inject.name.Named;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.Cache.Type;
import com.metamatrix.cache.CacheConfiguration.Policy;
+import com.metamatrix.common.util.JMXUtil;
+import com.metamatrix.common.util.JMXUtil.FailedToRegisterException;
import com.metamatrix.core.MetaMatrixRuntimeException;
@Singleton
public class JBossCacheFactory implements CacheFactory {
+ private static final String NAME = "Cache"; //$NON-NLS-1$
private org.jboss.cache.Cache cacheStore;
private volatile boolean destroyed = false;
- private ObjectName jmxName;
@Inject
- public JBossCacheFactory(org.jboss.cache.Cache cacheStore, @Named("ProcessName") String processName) {
+ JMXUtil jmx;
+
+ @Inject
+ public JBossCacheFactory(org.jboss.cache.Cache cacheStore) {
try {
- CacheJmxWrapperMBean wrapper = new CacheJmxWrapper(cacheStore);
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- this.jmxName = new ObjectName("Teiid["+processName+"]:service=JBossCache,name=cache"); //$NON-NLS-1$ //$NON-NLS-2$
- mbs.registerMBean(wrapper, this.jmxName);
- wrapper.create();
- wrapper.start();
- this.cacheStore = wrapper.getCache();
- } catch (OperationsException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (MBeanRegistrationException e) {
- throw new MetaMatrixRuntimeException(e);
+ jmx.register(JMXUtil.MBeanType.SERVICE, NAME, cacheStore);
+ cacheStore.create();
+ cacheStore.start();
+ this.cacheStore = cacheStore;
+ } catch (FailedToRegisterException e) {
+ throw new MetaMatrixRuntimeException(e.getCause());
}
}
@@ -82,37 +72,37 @@
Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
Node node = cacheRoot.addChild(Fqn.fromString(type.location()));
-
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
- cacheRegion.setEvictionPolicy(buildEvictionPolicy(config));
+ EvictionRegionConfig erc = new EvictionRegionConfig(node.getFqn(), buildEvictionAlgorithmConfig(config));
+ cacheRegion.setEvictionRegionConfig(erc);
return new JBossCache(this.cacheStore, node.getFqn());
}
throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
}
- private EvictionPolicyConfig buildEvictionPolicy(CacheConfiguration config) {
- EvictionPolicyConfig evictionConfig = null;
+ private EvictionAlgorithmConfig buildEvictionAlgorithmConfig(CacheConfiguration config) {
+ EvictionAlgorithmConfig evictionConfig = null;
if (config.getPolicy() == Policy.LRU) {
- LRUConfiguration lru = new LRUConfiguration();
+ LRUAlgorithmConfig lru = new LRUAlgorithmConfig();
lru.setMaxNodes(config.getMaxNodes());
- lru.setMaxAgeSeconds(config.getMaxAgeInSeconds());
- lru.setTimeToLiveSeconds(0);
+ lru.setMaxAge(config.getMaxAgeInSeconds()*1000);
+ lru.setTimeToLive(0);
evictionConfig = lru;
}
else if (config.getPolicy() == Policy.MRU) {
- MRUConfiguration mru = new MRUConfiguration();
+ MRUAlgorithmConfig mru = new MRUAlgorithmConfig();
mru.setMaxNodes(config.getMaxNodes());
evictionConfig = mru;
}
else if (config.getPolicy() == Policy.FIFO) {
- FIFOConfiguration fifo = new FIFOConfiguration();
+ FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig();
fifo.setMaxNodes(config.getMaxNodes());
evictionConfig = fifo;
}
else if (config.getPolicy() == Policy.LFU) {
- LFUConfiguration lfu = new LFUConfiguration();
+ LFUAlgorithmConfig lfu = new LFUAlgorithmConfig();
lfu.setMaxNodes(config.getMaxNodes());
evictionConfig = lfu;
}
@@ -121,10 +111,8 @@
public void destroy() {
try {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- mbs.unregisterMBean(this.jmxName);
- } catch (InstanceNotFoundException e) {
- } catch (MBeanRegistrationException e) {
+ jmx.unregister(JMXUtil.MBeanType.SERVICE, NAME);
+ } catch (FailedToRegisterException e) {
} finally {
this.cacheStore.destroy();
this.destroyed = true;
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-07-16 19:40:24 UTC (rev 1142)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-07-16 20:56:43 UTC (rev 1143)
@@ -22,13 +22,10 @@
package com.metamatrix.dqp.embedded.services;
-import java.net.URL;
import java.util.Properties;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@@ -39,8 +36,6 @@
public static final String TRANSACTIONS_ENABLED = "metamatrix.xatxnmgr.enabled"; //$NON-NLS-1$
- @Inject @Named("BootstrapURL") URL bootstrapURL;
-
@Override
public void initialize(Properties props)
throws ApplicationInitializationException {
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-07-16 19:40:24 UTC (rev 1142)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-07-16 20:56:43 UTC (rev 1143)
@@ -153,7 +153,7 @@
this.jmxServer = new JMXUtil(dqpId);
- EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props);
+ EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, this.jmxServer);
Injector injector = Guice.createInjector(config);
ResourceFinder.setInjector(injector);
config.setInjector(injector);
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-07-16 19:40:24 UTC (rev 1142)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-07-16 20:56:43 UTC (rev 1143)
@@ -45,6 +45,7 @@
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.common.util.NetUtils;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -67,11 +68,13 @@
private Properties props;
private URL bootstrapURL;
+ private JMXUtil jmx;
Injector injector;
- public EmbeddedGuiceModule(URL bootstrapURL, Properties props) {
+ public EmbeddedGuiceModule(URL bootstrapURL, Properties props, JMXUtil jmxUtil) {
this.bootstrapURL = bootstrapURL;
this.props = props;
+ this.jmx = jmxUtil;
}
@Override
@@ -83,6 +86,7 @@
bindConstant().annotatedWith(Names.named("HostName")).to("embedded"); //$NON-NLS-1$ //$NON-NLS-2$
bindConstant().annotatedWith(Names.named("ProcessName")).to(props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY, "test")); //$NON-NLS-1$ //$NON-NLS-2$
bind(Properties.class).annotatedWith(Names.named("DQPProperties")).toInstance(this.props); //$NON-NLS-1$
+ bind(JMXUtil.class).toInstance(this.jmx);
InetAddress address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(address);
Modified: trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
===================================================================
--- trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-07-16 19:40:24 UTC (rev 1142)
+++ trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-07-16 20:56:43 UTC (rev 1143)
@@ -31,6 +31,7 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.metamatrix.common.protocol.URLHelper;
+import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.FakeAbstractService;
@@ -53,7 +54,7 @@
URL url = buildDQPUrl(UnitTestUtil.getTestDataPath() + "/bqt/fakebqt.properties"); //$NON-NLS-1$
p.load(url.openStream());
- EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p);
+ EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p, new JMXUtil("test")); //$NON-NLS-1$
Injector injector = Guice.createInjector(source);
source.setInjector(injector);
More information about the teiid-commits
mailing list