Author: rareddy
Date: 2010-08-30 14:58:21 -0400 (Mon, 30 Aug 2010)
New Revision: 2505
Added:
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
Removed:
branches/7.1.x/console/src/main/java/org/teiid/rhq/comm/
branches/7.1.x/console/src/main/java/org/teiid/rhq/embedded/
branches/7.1.x/console/src/main/java/org/teiid/rhq/enterprise/
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/log/
Modified:
branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1104, TEIID-1209: Adding distributed resultset caching based upon the buffer
manager. The buffer manager acts like a cache loader and nodes look up tuple batches in
remote nodes before issuing the source query.
Modified: branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
---
branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -36,6 +36,7 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.CacheStatistics;
import org.teiid.adminapi.ProcessObject;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
@@ -229,7 +230,13 @@
throws AdminException {
return getAdmin().getWorkManagerStats(identifier);
}
-
+
+ @Doc(text = "Get cache statistics for given cache type")
+ public static CacheStatistics getCacheStats(@Doc(text = "cacheType") String
identifier)
+ throws AdminException {
+ return getAdmin().getCacheStats(identifier);
+ }
+
@Doc(text = "Remove a role for the data policy")
public static void removeDataRoleMapping(
@Doc(text = "vdb name") String vdbName,
Added:
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
===================================================================
---
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
(rev 0)
+++
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ If you are running JBoss AS in clustered mode, to enable the clustered cache in
+ the Teiid rename this file to "teiid-cache-manager-jboss-beans.xml"
+ -->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Factory/registry for JBoss Cache and PojoCache instances used in the AS
-->
+ <bean name="TeiidCacheManager"
class="org.jboss.ha.cachemanager.CacheManager">
+ <property
name="jndiName">java:TeiidCacheManager</property>
+ <property name="configurationRegistry">
+ <inject bean="TeiidCacheConfigurationRegistry" />
+ </property>
+ <property name="channelFactory">
+ <inject bean="JChannelFactory" />
+ </property>
+
+ <!-- Aliases for cache names. Allows caches to be shared across
+ services that may expect different cache config names. -->
+ <property name="configAliases">
+ <map keyClass="java.lang.String"
valueClass="java.lang.String">
+ <!-- Use the HAPartition cache for ClusteredSSO caching -->
+ <entry>
+ <key>teiid-resultset-cache</key>
+ <value>teiid-resultset-cache</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <!--
+ | Registry of named JBoss Cache configurations. Users of the CacheManager
+ | request a cache with a particular configuration by providing the name
+ | of one of these configurations.
+ -->
+ <bean name="TeiidCacheConfigurationRegistry"
class="org.jboss.ha.cachemanager.DependencyInjectedConfigurationRegistry">
+
+ <!-- The configurations. A Map<String name, Configuration config>
-->
+ <property name="newConfigurations">
+ <map keyClass="java.lang.String"
valueClass="org.jboss.cache.config.Configuration">
+
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at
startup,
+ which can be expensive. Uses mvcc locking. -->
+ <entry>
+ <key>teiid-resultset-cache</key>
+ <value>
+ <bean
class="org.jboss.cache.config.Configuration">
+
+ <!-- Node locking scheme -->
+ <property
name="nodeLockingScheme">MVCC</property>
+ <!-- READ_COMMITTED is as strong as necessary for most
+ 2nd Level Cache use cases. -->
+ <property
name="isolationLevel">READ_COMMITTED</property>
+ <property
name="useLockStriping">false</property>
+
+ <!-- Must use REPL since used for timestamp caching.
+ Must use SYNC to maintain cache coherency for entities.
-->
+ <property
name="cacheMode">REPL_SYNC</property>
+
+ <!-- Name of cluster. Needs to be the same for all members
-->
+ <property
name="clusterName">${jboss.partition.name:DefaultPartition}-resultset-cache</property>
+ <!-- Use a UDP (multicast) based stack. Need JGroups flow
control (FC)
+ because timestamp communication will not require a
synchronous response. -->
+ <property
name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>
+ <!-- Used for timestamps, so must fetch state. -->
+ <property
name="fetchInMemoryState">true</property>
+
+ <!-- The max amount of time (in milliseconds) we wait
until the
+ state (ie. the contents of the cache) are retrieved
from
+ existing members at startup. Ignored if
FetchInMemoryState=false. -->
+ <property
name="stateRetrievalTimeout">60000</property>
+
+ <!-- Number of milliseconds to wait until all responses
for a
+ synchronous call have been received. -->
+ <property
name="syncReplTimeout">17500</property>
+
+ <!-- Max number of milliseconds to wait for a lock
acquisition -->
+ <property
name="lockAcquisitionTimeout">15000</property>
+
+ <!-- Hibernate 2LC can replicate custom types, so we use
marshalling -->
+ <property
name="useRegionBasedMarshalling">true</property>
+ <!-- Must match the value of
"useRegionBasedMarshalling" -->
+ <property
name="inactiveOnStartup">true</property>
+
+ <!-- Disable asynchronous RPC marshalling/sending -->
+ <property
name="serializationExecutorPoolSize">0</property>
+ <!-- We have no asynchronous notification listeners
-->
+ <property
name="listenerAsyncPoolSize">0</property>
+
+ <property name="evictionConfig">
+ <bean
class="org.jboss.cache.config.EvictionConfig">
+ <property
name="wakeupInterval">5000</property>
+ <!-- Overall default -->
+ <property
name="defaultEvictionRegionConfig">
+ <bean
class="org.jboss.cache.config.EvictionRegionConfig">
+ <property
name="regionName">/</property>
+ <property
name="evictionAlgorithmConfig">
+ <bean
class="org.jboss.cache.eviction.LRUAlgorithmConfig">
+ <!-- Evict LRU node once we have
more than this number of nodes -->
+ <property
name="maxNodes">10000</property>
+ <!-- And, evict any node that
hasn't been accessed in this many seconds -->
+ <property
name="timeToLiveSeconds">1000</property>
+ <!-- Don't evict a node
that's been accessed within this many seconds.
+ Set this to a value greater than
your max expected transaction length. -->
+ <property
name="minTimeToLiveSeconds">120</property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <property name="cacheLoaderConfig">
+ <bean
class="org.jboss.cache.config.CacheLoaderConfig">
+ <!-- Do not change these -->
+ <property
name="passivation">false</property>
+ <property
name="shared">false</property>
+
+ <property
name="individualCacheLoaderConfigs">
+ <list>
+ <bean
class="org.teiid.cache.jboss.TupleBatchCacheLoaderConfig">
+ <property
name="bufferService"><inject bean="BufferService"
/></property>
+ <property
name="ignoreModifications">true</property>
+ <property
name="timeout">10000</property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
Property changes on:
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
---
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-08-30
18:58:21 UTC (rev 2505)
@@ -46,7 +46,8 @@
<bean name="CacheFactory"
class="org.teiid.cache.jboss.ClusterableCacheFactory">
<property name="enabled">true</property>
- <property name="clusteredCacheName">mvcc-shared</property>
+ <property
name="cacheManager">java:TeiidCacheManager</property>
+ <property
name="resultsetCacheName">teiid-resultset-cache</property>
</bean>
<!-- Configuration for result set caching.
Modified:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
===================================================================
---
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -37,8 +37,9 @@
public class ClusterableCacheFactory implements CacheFactory, Serializable {
private static final long serialVersionUID = -1992994494154581234L;
private CacheFactory delegate;
- private String cacheName;
+ private String resultsetCacheName;
private boolean enabled = false;
+ private String cacheManagerName;
@Override
public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
@@ -49,7 +50,7 @@
}
else {
try {
- this.delegate = new JBossCacheFactory(this.cacheName, cacheManager);
+ this.delegate = new JBossCacheFactory(this.resultsetCacheName, cacheManager);
} catch (Exception e) {
throw new TeiidRuntimeException("Failed to obtain the clusted cache");
//$NON-NLS-1$
}
@@ -58,8 +59,8 @@
return delegate.get(type, config);
}
- public void setClusteredCacheName(String name) {
- this.cacheName = name;
+ public void setResultsetCacheName(String name) {
+ this.resultsetCacheName = name;
}
@Override
@@ -70,10 +71,10 @@
}
private Object getClusteredCache() {
- if (this.enabled) {
+ if (this.enabled && this.cacheManagerName != null) {
try {
Context ctx = new InitialContext();
- return ctx.lookup("java:CacheManager"); //$NON-NLS-1$
+ return ctx.lookup(this.cacheManagerName);
} catch (NamingException e) {
return null;
}
@@ -84,4 +85,8 @@
public void setEnabled(boolean value) {
this.enabled = value;
}
+
+ public void setCacheManager(String mgrName) {
+ this.cacheManagerName = mgrName;
+ }
}
Added:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java
===================================================================
---
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java
(rev 0)
+++
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.ReplicationException;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.cache.lock.StripedLock;
+import org.jgroups.Address;
+import org.jgroups.blocks.GroupRequest;
+import org.jgroups.blocks.RspFilter;
+
+class ClusteredTupleBatchCacheLoader extends AbstractCacheLoader {
+ private StripedLock lock = new StripedLock();
+ private TupleBatchCacheLoaderConfig config;
+ private CommandsFactory commandsFactory;
+
+ private boolean init = false;
+
+ @Override
+ public void start() {
+ init();
+ }
+
+ private void init() {
+ if (!this.init) {
+ setCommandsFactory(cache.getComponentRegistry().getComponent(CommandsFactory.class));
+ this.init = true;
+ }
+ }
+
+ /**
+ * A test to check whether the cache is in its started state. If not, calls
+ * should not be made as the channel may not have properly started, blocks
+ * due to state transfers may be in progress, etc.
+ *
+ * @return true if the cache is in its STARTED state.
+ */
+ protected boolean isCacheReady() {
+ return cache.getCacheStatus() == CacheStatus.STARTED;
+ }
+
+ @Inject
+ public void setCommandsFactory(CommandsFactory commandsFactory) {
+ this.commandsFactory = commandsFactory;
+ }
+
+ /**
+ * Sets the configuration. A property <code>timeout</code> is used as the
+ * timeout value.
+ */
+ public void setConfig(IndividualCacheLoaderConfig base) {
+ this.config = (TupleBatchCacheLoaderConfig) base;
+ }
+
+ public IndividualCacheLoaderConfig getConfig() {
+ return config;
+ }
+
+ public Set getChildrenNames(Fqn fqn) throws Exception {
+ return Collections.emptySet();
+ }
+
+ private List<Object> callRemote(DataCommand dataCommand) throws Exception {
+ ClusteredGetCommand clusteredGet = commandsFactory .buildClusteredGetCommand(false,
dataCommand);
+ List resps;
+ // JBCACHE-1186
+ resps = cache.getRPCManager().callRemoteMethods(null, clusteredGet,
GroupRequest.GET_ALL, config.getTimeout(), new ResponseValidityFilter(cache.getMembers(),
cache.getLocalAddress(), dataCommand), false);
+
+ if (resps == null) {
+ throw new ReplicationException("No replies to call " + dataCommand + ".
Perhaps we're alone in the cluster?"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return resps;
+ }
+
+ public Map get(Fqn name) throws Exception {
+ return get0(name);
+ }
+
+ protected Map get0(Fqn name) throws Exception {
+ // DON'T make a remote call if this is a remote call in the first place
+ // - leads to deadlocks - JBCACHE-1103
+ if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) {
+ return null;
+ }
+ // return Collections.emptyMap();
+ lock.acquireLock(name, true);
+ try {
+ init();
+ GetDataMapCommand command = commandsFactory.buildGetDataMapCommand(name);
+ List resps = callRemote(command);
+
+ Map result = Collections.EMPTY_MAP;
+ for (Object o:resps) {
+ if (o != null && !(o instanceof Exception)) {
+ List clusteredGetResp = (List) o;
+ if ((Boolean)clusteredGetResp.get(0)) {
+ Map resp = (Map)clusteredGetResp.get(1);
+ if (!resp.isEmpty()) {
+ result = resp;
+ }
+ }
+ }
+ }
+ return result;
+ } finally {
+ lock.releaseLock(name);
+ }
+ }
+
+ public boolean exists(Fqn name) throws Exception {
+ // DON'T make a remote call if this is a remote call in the first place
+ // - leads to deadlocks - JBCACHE-1103
+ if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) {
+ return false;
+ }
+
+ lock.acquireLock(name, false);
+ try {
+ init();
+ ExistsCommand command = commandsFactory.buildExistsNodeCommand(name);
+ List resps = callRemote(command);
+ boolean result = false;
+ for (Object o:resps) {
+ if (o != null && !(o instanceof Exception)) {
+ List<Boolean> clusteredGetResp = (List<Boolean>) o;
+ if (clusteredGetResp.get(0)) {
+ if (clusteredGetResp.get(1)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ } finally {
+ lock.releaseLock(name);
+ }
+ }
+
+ public Object put(Fqn name, Object key, Object value) throws Exception {
+ return null;
+ }
+
+ /**
+ * Does nothing; replication handles put.
+ */
+ public void put(Fqn name, Map attributes) throws Exception {
+ }
+
+ /**
+ * Does nothing; replication handles put.
+ */
+ @Override
+ public void put(List<Modification> modifications) throws Exception {
+ }
+
+ /**
+ * Fetches the remove value, does not remove. Replication handles removal.
+ */
+ public Object remove(Fqn name, Object key) throws Exception {
+ return null;
+ }
+
+ /**
+ * Does nothing; replication handles removal.
+ */
+ public void remove(Fqn name) throws Exception {
+ // do nothing
+ }
+
+ /**
+ * Does nothing; replication handles removal.
+ */
+ public void removeData(Fqn name) throws Exception {
+ }
+
+ /**
+ * Does nothing.
+ */
+ @Override
+ public void prepare(Object tx, List modifications, boolean one_phase)
+ throws Exception {
+ }
+
+ /**
+ * Does nothing.
+ */
+ @Override
+ public void commit(Object tx) throws Exception {
+ }
+
+ /**
+ * Does nothing.
+ */
+ @Override
+ public void rollback(Object tx) {
+ }
+
+ @Override
+ public void loadEntireState(ObjectOutputStream os) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void storeEntireState(ObjectInputStream is) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void storeState(Fqn subtree, ObjectInputStream is) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void setRegionManager(RegionManager manager) {
+ }
+
+ public static class ResponseValidityFilter implements RspFilter {
+ private int numValidResponses = 0;
+ private List<Address> pendingResponders;
+ private DataCommand command;
+
+ public ResponseValidityFilter(List<Address> expected,Address localAddress,
DataCommand command) {
+ this.pendingResponders = new ArrayList<Address>(expected);
+ // We'll never get a response from ourself
+ this.pendingResponders.remove(localAddress);
+ this.command = command;
+ }
+
+ public boolean isAcceptable(Object object, Address address) {
+ pendingResponders.remove(address);
+
+ if (object instanceof List) {
+ List response = (List) object;
+ Boolean foundResult = (Boolean) response.get(0);
+ if (foundResult) {
+ if (command instanceof ExistsCommand) {
+ Boolean resp = (Boolean)response.get(1);
+ if (resp) {
+ numValidResponses++;
+ }
+ }
+ else if (command instanceof GetDataMapCommand) {
+ Map resp = (Map)response.get(1);
+ if (!resp.isEmpty()) {
+ numValidResponses++;
+ }
+ }
+ }
+ }
+ // always return true to make sure a response is logged by the
+ // JGroups RpcDispatcher.
+ return true;
+ }
+
+ public boolean needMoreResponses() {
+ return numValidResponses < 1 && pendingResponders.size() > 0;
+ }
+
+ }
+}
Property changes on:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
---
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -21,9 +21,6 @@
*/
package org.teiid.cache.jboss;
-import java.util.HashSet;
-import java.util.Set;
-
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -37,20 +34,6 @@
}
@Override
- public V get(K key) {
- Node<K, V> node = getRootNode();
- Node child = node.getChild(getFqn(key));
- if (child != null) {
- return (V)child.get(key);
- }
- return null;
- }
-
- private Fqn<String> getFqn(K key) {
- return Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode()));
- }
-
- @Override
public V put(K key, V value) {
return this.put(key, value, null);
}
@@ -64,32 +47,4 @@
child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
return (V)child.put(key, value);
}
-
- @Override
- public V remove(K key) {
- Node<K, V> node = getRootNode();
- Node child = node.getChild(getFqn(key));
- if (child != null) {
- return (V)child.remove(key);
- }
- return null;
- }
-
- @Override
- public void clear() {
- Node<K, V> node = getRootNode();
- node.clearData();
- Set<Node<K,V>> nodes = new HashSet<Node<K,
V>>(node.getChildren());
- for (Node<K, V> child : nodes) {
- child.clearData();
- node.removeChild(child.getFqn());
- }
- }
-
- @Override
- public int size() {
- Node<K, V> node = getRootNode();
- return node.getChildren().size();
- }
-
}
Modified:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
---
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -22,10 +22,7 @@
package org.teiid.cache.jboss;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.HashSet;
import java.util.Set;
import org.jboss.cache.Fqn;
@@ -50,56 +47,61 @@
this.rootFqn = fqn;
}
+ @Override
public V get(K key) {
- return this.cacheStore.get(this.rootFqn, key);
+ Node<K, V> node = getRootNode();
+ Node child = node.getChild(getFqn(key));
+ if (child != null) {
+ return (V)child.get(key);
+ }
+ return null;
}
+ protected Fqn<String> getFqn(K key) {
+ if (key.getClass().isPrimitive() || key instanceof String) {
+ return Fqn.fromString(String.valueOf(key));
+ }
+ return Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode()));
+ }
+
public V put(K key, V value) {
- return this.cacheStore.put(this.rootFqn, key, value);
+ Node<K, V> node = getRootNode();
+ Node<K, V> child = node.addChild(getFqn(key));
+ return child.put(key, value);
}
+ @Override
public V put(K key, V value, Long ttl) {
return this.put(key, value);
}
+ @Override
public V remove(K key) {
- return this.cacheStore.remove(this.rootFqn, key);
- }
-
- public Set<K> keySet() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- return node.getKeys();
+ Node<K, V> node = getRootNode();
+ Node child = node.getChild(getFqn(key));
+ if (child != null) {
+ return (V)child.remove(key);
}
- return Collections.emptySet();
+ return null;
}
+ @Override
public int size() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- return node.dataSize();
- }
- return 0;
+ Node<K, V> node = getRootNode();
+ return node.getChildren().size();
}
+ @Override
public void clear() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- node.clearData();
+ Node<K, V> node = getRootNode();
+ node.clearData();
+ Set<Node<K,V>> nodes = new HashSet<Node<K,
V>>(node.getChildren());
+ for (Node<K, V> child : nodes) {
+ child.clearData();
+ node.removeChild(child.getFqn());
}
}
- public Collection<V> values() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- return node.getData().values();
- }
- return Collections.emptyList();
- }
-
- /**
- * {@inheritDoc}
- */
public synchronized void addListener(CacheListener listener) {
this.cacheListener = new JBossCacheListener(this.rootFqn, listener);
this.cacheStore.addCacheListener(this.cacheListener);
@@ -110,21 +112,6 @@
this.cacheListener = null;
}
- public Cache<K, V> addChild(String name) {
- Node<K, V> node = getRootNode();
- Node<K, V> childNode = node.addChild(Fqn.fromString(name));
- return new JBossCache<K, V>(this.cacheStore, childNode.getFqn());
- }
-
- public Cache<K, V> getChild(String name) {
- Node<K, V> node = getRootNode();
- Node<K, V> child = node.getChild(Fqn.fromString(name));
- if (child != null) {
- return new JBossCache<K, V>(this.cacheStore, child.getFqn());
- }
- return null;
- }
-
protected Node<K, V> getRootNode() {
Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
if (node == null) {
@@ -132,25 +119,7 @@
}
return node;
}
-
- public List<Cache> getChildren() {
- Node<K, V> node = getRootNode();
- Set<Node<K,V>> nodes = node.getChildren();
- if (nodes.isEmpty()) {
- return Collections.emptyList();
- }
- List<Cache> children = new ArrayList<Cache>();
- for(Node<K, V> child: nodes) {
- children.add(new JBossCache<K, V>(this.cacheStore, child.getFqn()));
- }
- return children;
- }
- public boolean removeChild(String name) {
- Node<K, V> node = getRootNode();
- return node.removeChild(Fqn.fromString(name));
- }
-
@Override
public String getName() {
return this.rootFqn.toString();
Added:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java
===================================================================
---
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java
(rev 0)
+++
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidRuntimeException;
+
+public class TupleBatchCacheLoader extends ClusteredTupleBatchCacheLoader {
+
+ private BufferManager bufferMgr;
+ private IndividualCacheLoaderConfig config;
+
+ @Override
+ public boolean exists(Fqn fqn) throws Exception {
+ String id = fqn.getLastElementAsString();
+ int index = id.indexOf(',');
+ if (index != -1) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Map<Object, Object> get(Fqn fqn) throws Exception {
+ String id = fqn.getLastElementAsString();
+ int index = id.indexOf(',');
+ if (index != -1) {
+ String uuid = id.substring(0, index);
+ int row = Integer.parseInt(id.substring(index+1));
+ TupleBuffer tb = this.bufferMgr.getTupleBuffer(uuid);
+ if (tb != null) {
+ Map map = new HashMap();
+ TupleBatch b = tb.getBatch(row);
+ b.preserveTypes();
+ map.put(id, b);
+ return map;
+ }
+ }
+ return super.get(fqn);
+ }
+
+ @Override
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception {
+ return super.getChildrenNames(fqn);
+ }
+
+ @Override
+ public IndividualCacheLoaderConfig getConfig() {
+ return this.config;
+ }
+
+ @Override
+ public Object put(Fqn fqn, Object key, Object value) throws Exception {
+ return super.put(fqn, key, value);
+ }
+
+ @Override
+ public void remove(Fqn fqn) throws Exception {
+ super.remove(fqn);
+ }
+
+ @Override
+ public Object remove(Fqn fqn, Object key) throws Exception {
+ return super.remove(fqn, key);
+ }
+
+ @Override
+ public void removeData(Fqn fqn) throws Exception {
+ super.removeData(fqn);
+ }
+
+ @Override
+ public void setConfig(IndividualCacheLoaderConfig config) {
+ if (!(config instanceof TupleBatchCacheLoaderConfig)) {
+ throw new TeiidRuntimeException("Wrong Configuration"); //$NON-NLS-1$
+ }
+ this.config = config;
+ TupleBatchCacheLoaderConfig bmc = (TupleBatchCacheLoaderConfig)config;
+ this.bufferMgr = bmc.getBufferService().getBufferManager();
+ super.setConfig(config);
+ }
+
+}
Property changes on:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java
===================================================================
---
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java
(rev 0)
+++
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.teiid.dqp.service.BufferService;
+
+public class TupleBatchCacheLoaderConfig extends IndividualCacheLoaderConfig {
+ private static final long serialVersionUID = -5926642610388245871L;
+ private BufferService service;
+ private long timeout;
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public TupleBatchCacheLoaderConfig() {
+ setClassName(TupleBatchCacheLoader.class.getName());
+ }
+
+ public TupleBatchCacheLoaderConfig(IndividualCacheLoaderConfig config) {
+ setClassName(TupleBatchCacheLoader.class.getName());
+ populateFromBaseConfig(config);
+ }
+
+
+ public void setBufferService(BufferService service) {
+ this.service = service;
+ }
+
+ public BufferService getBufferService() {
+ return this.service;
+ }
+}
Property changes on:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java 2010-08-30 17:14:35
UTC (rev 2504)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java 2010-08-30 18:58:21
UTC (rev 2505)
@@ -189,7 +189,16 @@
*/
void clearCache(String cacheType) throws AdminException;
+
/**
+ * Get the Cache Statistics for the given type
+ * @param cacheType Cache Type
+ * @return {@link CacheStatistics}
+ * @throws AdminException
+ */
+ CacheStatistics getCacheStats(String cacheType) throws AdminException;
+
+ /**
* Terminate the Session
*
* @param identifier Session Identifier {@link org.teiid.adminapi.Session}.
Added: branches/7.1.x/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
(rev 0)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/CacheStatistics.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+public interface CacheStatistics extends AdminObject {
+
+ double getHitRatio();
+
+ int getTotalEntries();
+
+ int getRequestCount();
+
+}
Property changes on:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
===================================================================
---
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
(rev 0)
+++
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.teiid.adminapi.CacheStatistics;
+
+(a)MetaMapping(CacheStatisticsMetadataMapper.class)
+public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
+
+ private static final long serialVersionUID = -3514505497661004560L;
+
+ private double hitRatio;
+ private int totalEntries;
+ private int requestCount;
+
+ @Override
+ @ManagementProperty(description="Number of total requests made to the cache",
readOnly=true)
+ public int getRequestCount() {
+ return requestCount;
+ }
+
+ public void setRequestCount(int count) {
+ this.requestCount = count;
+ }
+
+ @Override
+ @ManagementProperty(description="Cache hit ratio", readOnly=true)
+ public double getHitRatio() {
+ return this.hitRatio;
+ }
+
+ @Override
+ @ManagementProperty(description="Total number of cache entries",
readOnly=true)
+ public int getTotalEntries() {
+ return this.totalEntries;
+ }
+
+ public void setHitRatio(double value) {
+ this.hitRatio = value;
+ }
+
+ public void setTotalEntries(int value) {
+ this.totalEntries = value;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("hitRatio=").append(hitRatio);//$NON-NLS-1$
+ sb.append("; totalEntries=").append(totalEntries); //$NON-NLS-1$
+ sb.append("; requestCount=").append(requestCount); //$NON-NLS-1$
+ return sb.toString();
+ }
+}
Property changes on:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
===================================================================
---
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
(rev 0)
+++
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+public class CacheStatisticsMetadataMapper extends
MetaMapper<CacheStatisticsMetadata> {
+ private static final String HITRATIO = "hitRatio"; //$NON-NLS-1$
+ private static final String TOTAL_ENTRIES = "totalEntries"; //$NON-NLS-1$
+ private static final String REQUEST_COUNT = "requestCount"; //$NON-NLS-1$
+ private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
+ private static final MutableCompositeMetaType metaType;
+
+ static {
+ metaType = new MutableCompositeMetaType(CacheStatisticsMetadata.class.getName(),
"The Cache statistics"); //$NON-NLS-1$
+ metaType.addItem(TOTAL_ENTRIES, TOTAL_ENTRIES, SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.addItem(HITRATIO, HITRATIO, SimpleMetaType.DOUBLE_PRIMITIVE);
+ metaType.addItem(REQUEST_COUNT, REQUEST_COUNT, SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.freeze();
+ }
+
+ @Override
+ public Type mapToType() {
+ return CacheStatisticsMetadata.class;
+ }
+
+ @Override
+ public MetaType getMetaType() {
+ return metaType;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, CacheStatisticsMetadata object) {
+ if (object == null)
+ return null;
+ if (metaType instanceof CompositeMetaType) {
+ CompositeMetaType composite = (CompositeMetaType) metaType;
+ CompositeValueSupport cache = new CompositeValueSupport(composite);
+
+ cache.set(TOTAL_ENTRIES, SimpleValueSupport.wrap(object.getTotalEntries()));
+ cache.set(HITRATIO, SimpleValueSupport.wrap(object.getHitRatio()));
+ cache.set(REQUEST_COUNT, SimpleValueSupport.wrap(object.getRequestCount()));
+
+ return cache;
+ }
+ throw new IllegalArgumentException("Cannot convert cache statistics " +
object); //$NON-NLS-1$
+ }
+
+ @Override
+ public CacheStatisticsMetadata unwrapMetaValue(MetaValue metaValue) {
+ if (metaValue == null)
+ return null;
+
+ if (metaValue instanceof CompositeValue) {
+ CompositeValue compositeValue = (CompositeValue) metaValue;
+
+ CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
+ cache.setTotalEntries((Integer)
metaValueFactory.unwrap(compositeValue.get(TOTAL_ENTRIES)));
+ cache.setHitRatio((Double) metaValueFactory.unwrap(compositeValue.get(HITRATIO)));
+ cache.setRequestCount((Integer)
metaValueFactory.unwrap(compositeValue.get(REQUEST_COUNT)));
+ return cache;
+ }
+ throw new IllegalStateException("Unable to unwrap cache statistics " +
metaValue); //$NON-NLS-1$
+ }
+
+}
Property changes on:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
---
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -42,4 +42,5 @@
void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int
targetVDBVersion) throws AdminException;
List<RequestMetadata> getLongRunningRequests();
List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion)
throws AdminException;
+ CacheStatisticsMetadata getCacheStatistics(String cacheType);
}
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -24,7 +24,6 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -40,10 +39,14 @@
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValueSupport;
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
+import org.teiid.adminapi.Admin;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
import org.teiid.adminapi.Transaction;
@@ -59,29 +62,22 @@
public class DQPManagementView implements PluginConstants {
private static ManagedComponent mc = null;
- private static final Log LOG = LogFactory
- .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static final MetaValueFactory metaValueFactory = MetaValueFactory
- .getInstance();
+ private static final Log LOG =
LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
public DQPManagementView() {
-
}
/*
* Metric methods
*/
- public Object getMetric(ProfileServiceConnection connection,
- String componentType, String identifier, String metric,
- Map<String, Object> valueMap) {
+ public Object getMetric(ProfileServiceConnection connection, String componentType,
String identifier, String metric, Map<String, Object> valueMap) {
Object resultObject = new Object();
if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(connection, componentType, metric,
- valueMap);
+ resultObject = getPlatformMetric(connection, componentType, metric, valueMap);
} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(connection, componentType, identifier,
- metric, valueMap);
+ resultObject = getVdbMetric(connection, componentType, identifier,metric, valueMap);
}
return resultObject;
@@ -92,36 +88,36 @@
Object resultObject = new Object();
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+ if (metric .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
- } else {
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount(connection).doubleValue());
- } else {
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(connection),
- longRunningQueries);
- resultObject = new Double(longRunningQueries.size());
- } else {
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE)) {
- try {
- resultObject = ProfileServiceUtil.doubleValue(getUsedBufferSpace(connection));
- } catch (Exception e) {
- final String msg = "Exception executing operation: " +
Platform.Operations.GET_BUFFER_USAGE; //$NON-NLS-1$
- LOG.error(msg, e);
- }
- }
- }
+ } else if
(metric .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+ resultObject = new Double(getSessionCount(connection).doubleValue());
+ } else if
(metric .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+ Collection<Request> longRunningQueries = new ArrayList<Request>();
+ getRequestCollectionValue(getLongRunningQueries(connection), longRunningQueries);
+ resultObject = new Double(longRunningQueries.size());
+ } else if (metric.equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE))
{
+ try {
+ resultObject = ProfileServiceUtil.doubleValue(getUsedBufferSpace(connection));
+ } catch (Exception e) {
+ final String msg = "Exception executing operation: " +
Platform.Operations.GET_BUFFER_USAGE; //$NON-NLS-1$
+ LOG.error(msg, e);
}
+ } else if (metric.startsWith(Admin.Cache.PREPARED_PLAN_CACHE.toString()+".")
//$NON-NLS-1$
+ ||
metric.startsWith(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString()+".")) {
//$NON-NLS-1$
+ return getCacheProperty(connection, metric);
}
-
return resultObject;
}
+
+ private Object getCacheProperty(ProfileServiceConnection connection, String metric) {
+ int dotIndex = metric.indexOf('.');
+ String cacheType = metric.substring(0, dotIndex);
+ String property = metric.substring(dotIndex+1);
+ CompositeValueSupport mv = (CompositeValueSupport)getCacheStats(connection, cacheType);
+ MetaValue v = mv.get(property);
+ return ((SimpleValue)v).getValue();
+ }
private Object getVdbMetric(ProfileServiceConnection connection,
String componentType, String identifier, String metric,
@@ -129,31 +125,21 @@
Object resultObject = new Object();
- if (metric
- .equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
+ if (metric .equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getErrorCount(connection, (String) valueMap
- .get(VDB.NAME));
- } else if (metric
- .equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
+ resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
+ } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getVDBStatus(connection, (String) valueMap
- .get(VDB.NAME));
- } else if (metric
- .equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
+ resultObject = getVDBStatus(connection, (String) valueMap.get(VDB.NAME));
+ } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
- } else if (metric
- .equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
+ } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
resultObject = new Double(getSessionCount(connection).doubleValue());
- } else if (metric
- .equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
+ } else if
(metric.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(connection),
- longRunningQueries);
+ getRequestCollectionValue(getLongRunningQueries(connection), longRunningQueries);
resultObject = new Double(longRunningQueries.size());
-
}
-
return resultObject;
}
@@ -161,19 +147,13 @@
* Operation methods
*/
- public void executeOperation(ProfileServiceConnection connection,
- ExecutedResult operationResult, final Map<String, Object> valueMap) {
+ public void executeOperation(ProfileServiceConnection connection, ExecutedResult
operationResult, final Map<String, Object> valueMap) {
- if (operationResult.getComponentType().equals(
- PluginConstants.ComponentType.Platform.NAME)) {
- executePlatformOperation(connection, operationResult,
- operationResult.getOperationName(), valueMap);
- } else if (operationResult.getComponentType().equals(
- PluginConstants.ComponentType.VDB.NAME)) {
- executeVdbOperation(connection, operationResult, operationResult
- .getOperationName(), valueMap);
+ if
(operationResult.getComponentType().equals(PluginConstants.ComponentType.Platform.NAME))
{
+ executePlatformOperation(connection,
operationResult, operationResult.getOperationName(), valueMap);
+ } else if
(operationResult.getComponentType().equals( PluginConstants.ComponentType.VDB.NAME)) {
+ executeVdbOperation(connection, operationResult, operationResult .getOperationName(),
valueMap);
}
-
}
private void executePlatformOperation(ProfileServiceConnection connection,
@@ -552,6 +532,16 @@
}
return count;
}
+
+ protected MetaValue getCacheStats(ProfileServiceConnection connection, String type) {
+ try {
+ return executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
+ Platform.Operations.GET_CACHE_STATS, SimpleValueSupport.wrap(type));
+ } catch (Exception e) {
+ LOG.error("Exception executing operation: " +
Platform.Operations.GET_CACHE_STATS, e); //$NON-NLS-1$
+ }
+ return null;
+ }
protected MetaValue getLongRunningQueries(
ProfileServiceConnection connection) {
@@ -586,20 +576,16 @@
return usedBufferSpace;
}
- private void getRequestCollectionValue(MetaValue pValue,
- Collection<Request> list) {
+ private void getRequestCollectionValue(MetaValue pValue,Collection<Request> list)
{
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
RequestMetadataMapper rmm = new RequestMetadataMapper();
- RequestMetadata request = (RequestMetadata) rmm
- .unwrapMetaValue(value);
+ RequestMetadata request = rmm.unwrapMetaValue(value);
list.add(request);
} else {
- throw new IllegalStateException(pValue
- + " is not a Composite type"); //$NON-NLS-1$
+ throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
}
}
}
@@ -609,15 +595,12 @@
Collection<Transaction> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- Transaction transaction = (Transaction) MetaValueFactory
- .getInstance().unwrap(value);
+ Transaction transaction = (Transaction)
MetaValueFactory.getInstance().unwrap(value);
list.add(transaction);
} else {
- throw new IllegalStateException(pValue
- + " is not a Composite type"); //$NON-NLS-1$
+ throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
}
}
}
@@ -627,15 +610,12 @@
Collection<Session> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- Session Session = (Session) MetaValueFactory.getInstance()
- .unwrap(value);
+ Session Session = (Session) MetaValueFactory.getInstance().unwrap(value);
list.add(Session);
} else {
- throw new IllegalStateException(pValue
- + " is not a Composite type"); //$NON-NLS-1$
+ throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
}
}
}
@@ -645,17 +625,14 @@
Collection<Session> list, String vdbName) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- Session session = (Session) MetaValueFactory.getInstance()
- .unwrap(value);
+ Session session = (Session) MetaValueFactory.getInstance().unwrap(value);
if (session.getVDBName().equals(vdbName)) {
list.add(session);
}
} else {
- throw new IllegalStateException(pValue
- + " is not a Composite type"); //$NON-NLS-1$
+ throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
}
}
}
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -43,11 +43,8 @@
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jbossas5.ApplicationServerComponent;
-import org.rhq.plugins.jbossas5.ProfileServiceComponent;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -59,22 +56,14 @@
*
*/
public class PlatformComponent extends Facet {
- private final Log LOG = LogFactory
- .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer",
- "BufferService", "SessionService",
"JdbcSocketConfiguration" };
+ String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer", //$NON-NLS-1$
+ "BufferService", "SessionService",
"JdbcSocketConfiguration" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- /*
- * (non-Javadoc)
- *
- * @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
- * ResourceContext)
- */
@Override
public void start(ResourceContext context) {
- this.setComponentName(context.getPluginConfiguration().getSimpleValue(
- "name", null));
+ this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name",
null)); //$NON-NLS-1$
this.resourceConfiguration = context.getPluginConfiguration();
super.start(context);
}
@@ -93,22 +82,15 @@
RunState runState;
try {
- runState = ProfileServiceUtil.getRuntimeEngineDeployer(getConnection())
- .getRunState();
+ runState =
ProfileServiceUtil.getRuntimeEngineDeployer(getConnection()).getRunState();
} catch (NamingException e) {
- LOG
- .error("Naming exception getting: "
- + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ LOG .debug("Naming exception getting: " +
PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE); //$NON-NLS-1$
return AvailabilityType.DOWN;
} catch (Exception e) {
- LOG
- .error("Exception getting: "
- + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ LOG .debug("Exception getting: " +
PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE); //$NON-NLS-1$
return AvailabilityType.DOWN;
}
- return (runState == RunState.RUNNING) ? AvailabilityType.UP
- : AvailabilityType.DOWN;
-
+ return (runState == RunState.RUNNING) ? AvailabilityType.UP: AvailabilityType.DOWN;
}
@Override
@@ -116,23 +98,17 @@
Configuration configuration, Map<String, Object> valueMap) {
// Parameter logic for System Operations
if (name.equals(Platform.Operations.KILL_REQUEST)) {
- valueMap.put(Operation.Value.REQUEST_ID, configuration.getSimple(
- Operation.Value.REQUEST_ID).getLongValue());
- valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
- Operation.Value.SESSION_ID).getLongValue());
+ valueMap.put(Operation.Value.REQUEST_ID,
configuration.getSimple(Operation.Value.REQUEST_ID).getLongValue());
+ valueMap.put(Operation.Value.SESSION_ID,
configuration.getSimple(Operation.Value.SESSION_ID).getLongValue());
} else if (name.equals(Platform.Operations.KILL_REQUEST)) {
- valueMap.put(Operation.Value.TRANSACTION_ID, configuration
- .getSimple(Operation.Value.TRANSACTION_ID).getLongValue());
+ valueMap.put(Operation.Value.TRANSACTION_ID,
configuration.getSimple(Operation.Value.TRANSACTION_ID).getLongValue());
} else if (name.equals(Platform.Operations.KILL_SESSION)) {
- valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
- Operation.Value.SESSION_ID).getLongValue());
+ valueMap.put(Operation.Value.SESSION_ID,
configuration.getSimple(Operation.Value.SESSION_ID).getLongValue());
}
-
}
@Override
- public void getValues(MeasurementReport report,
- Set<MeasurementScheduleRequest> requests) throws Exception {
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest>
requests) throws Exception {
DQPManagementView view = new DQPManagementView();
@@ -146,56 +122,27 @@
// Initialize any parameters to be used in the retrieval of
// metric values
- Object metricReturnObject = view.getMetric(getConnection(),
+ Object metric = view.getMetric(getConnection(),
getComponentType(), this.getComponentIdentifier(),
name, valueMap);
- try {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- report.addData(new MeasurementDataNumeric(
- request, (Double) metricReturnObject));
- } else {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE)) {
- report.addData(new MeasurementDataNumeric(
- request,
- (Double) metricReturnObject));
- }
- }
- }
- }
-
- } catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- throw (e);
+ if (metric instanceof Double) {
+ report.addData(new MeasurementDataNumeric(request, (Double) metric));
}
+ else if (metric instanceof Integer ){
+ report.addData(new MeasurementDataNumeric(request, new
Double(((Integer)metric).doubleValue())));
+ }
+ else if (metric instanceof Long){
+ report.addData(new MeasurementDataNumeric(request, new
Double(((Long)metric).longValue())));
+ }
+ else {
+ LOG.error("Metric value must be a numeric value"); //$NON-NLS-1$
+ }
}
} catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
+ LOG.error("Failed to obtain measurement [" + name + "]. Cause: "
+ e); //$NON-NLS-1$ //$NON-NLS-2$
throw (e);
}
-
}
@Override
@@ -204,13 +151,6 @@
super.stop();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.teiid.rhq.plugin.Facet#updateResourceConfiguration(org.rhq.core.pluginapi
- * .configuration.ConfigurationUpdateReport)
- */
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -231,27 +171,23 @@
for (String serviceName : PLATFORM_SERVICES_NAMES) {
- managedComponent = managementView.getComponent(serviceName,
- componentType);
- Map<String, ManagedProperty> managedProperties = managedComponent
- .getProperties();
+ managedComponent = managementView.getComponent(serviceName, componentType);
+ Map<String, ManagedProperty> managedProperties =
managedComponent.getProperties();
- ProfileServiceUtil.convertConfigurationToManagedProperties(
- managedProperties, resourceConfig, resourceContext
- .getResourceType());
+ ProfileServiceUtil.convertConfigurationToManagedProperties(managedProperties,
resourceConfig, resourceContext.getResourceType());
try {
managementView.updateComponent(managedComponent);
} catch (Exception e) {
- LOG.error("Unable to update component ["
- + managedComponent.getName() + "] of type "
- + componentType + ".", e);
+ LOG.error("Unable to update component [" //$NON-NLS-1$
+ + managedComponent.getName() + "] of type " //$NON-NLS-1$
+ + componentType + ".", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
}
} catch (Exception e) {
- LOG.error("Unable to process update request", e);
+ LOG.error("Unable to process update request", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
@@ -285,20 +221,14 @@
// Get all ManagedComponents of type Teiid and subtype dqp
Set<ManagedComponent> mcSet = null;
try {
- mcSet = ProfileServiceUtil
- .getManagedComponents(
- getConnection(),
- new org.jboss.managed.api.ComponentType(
+ mcSet = ProfileServiceUtil.getManagedComponents(getConnection(),
+ new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
} catch (NamingException e) {
- LOG
- .error("NamingException getting components in Platform loadConfiguration():
"
- + e.getMessage());
+ LOG.error("NamingException getting components in Platform loadConfiguration():
" + e.getMessage()); //$NON-NLS-1$
} catch (Exception e) {
- LOG
- .error("Exception getting components in Platform loadConfiguration(): "
- + e.getMessage());
+ LOG.error("Exception getting components in Platform loadConfiguration(): " +
e.getMessage()); //$NON-NLS-1$
}
for (ManagedComponent mc : mcSet) {
@@ -319,22 +249,18 @@
PropertySimple prop = new PropertySimple(mProp.getName(), value);
configuration.put(prop);
} catch (Exception e) {
- LOG
- .error("Exception setting properties in Platform loadConfiguration(): "
- + e.getMessage());
+ LOG.error("Exception setting properties in Platform loadConfiguration():
" + e.getMessage()); //$NON-NLS-1$
}
}
}
@Override
public ProfileServiceConnection getConnection() {
- return ((ApplicationServerComponent) this.resourceContext
- .getParentResourceComponent()).getConnection();
+ return ((ApplicationServerComponent)
this.resourceContext.getParentResourceComponent()).getConnection();
}
@Override
public EmsConnection getEmsConnection() {
- // TODO Auto-generated method stub
return null;
}
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -96,7 +96,7 @@
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
+ log.debug("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
return discoveredResources;
}
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -75,16 +75,14 @@
public final static String GET_TRANSACTIONS = "getTransactions";
//$NON-NLS-1$
public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
public final static String GET_BUFFER_USAGE = "userBufferSpace";
//$NON-NLS-1$
-
+ public final static String GET_CACHE_STATS = "getCacheStatistics";
//$NON-NLS-1$
}
public static interface Metrics {
-
public final static String QUERY_COUNT = "queryCount"; //$NON-NLS-1$
public final static String SESSION_COUNT = "sessionCount"; //$NON-NLS-1$
public final static String LONG_RUNNING_QUERIES = "longRunningQueries";
//$NON-NLS-1$
- public final static String BUFFER_USAGE = "userBufferSpace"; //$NON-NLS-1$
-
+ public final static String BUFFER_USAGE = "userBufferSpace"; //$NON-NLS-1$
}
}
Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-08-30 17:14:35
UTC (rev 2504)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-08-30 18:58:21
UTC (rev 2505)
@@ -256,6 +256,30 @@
displayType="detail" category="throughput"
property="userBufferSpace"
description="The currently used file buffer space in MB." />
+ <metric displayName="Prepared Plan Cache Hit Ratio %"
defaultOn="true"
+ displayType="detail" category="performance"
property="PREPARED_PLAN_CACHE.hitRatio"
+ description="Prepared plan cache hit ratio" />
+
+ <metric displayName="Prepared Plan Cache Size"
defaultOn="true"
+ displayType="detail" category="performance"
property="PREPARED_PLAN_CACHE.totalEntries"
+ description="Prepared plan cache size" />
+
+ <metric displayName="Prepared Plan Cache # of Requests"
defaultOn="true"
+ displayType="detail" category="performance"
property="PREPARED_PLAN_CACHE.requestCount"
+ description="Prepared plan cache # Requests made aginst cache"
/>
+
+ <metric displayName="ResultSet Cache Hit Ratio %"
defaultOn="true"
+ displayType="detail" category="performance"
property="QUERY_SERVICE_RESULT_SET_CACHE.hitRatio"
+ description="ResultSet cache hit ratio" />
+
+ <metric displayName="ResultSet Cache Size"
defaultOn="true"
+ displayType="detail" category="performance"
property="QUERY_SERVICE_RESULT_SET_CACHE.totalEntries"
+ description="ResultSet cache Size" />
+
+ <metric displayName="ResultSet Cache # of Requests"
defaultOn="true"
+ displayType="detail" category="performance"
property="QUERY_SERVICE_RESULT_SET_CACHE.requestCount"
+ description="ResultSet cache # Requests made aginst cache" />
+
<resource-configuration>
<c:group name="teiidProperties" displayName="Runtime Engine
Properties"
hiddenByDefault="false">
Modified: branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/BufferManager.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/BufferManager.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -116,4 +116,7 @@
STree createSTree(final List elements, String groupName, int keyLength);
+ void addTupleBuffer(TupleBuffer tb);
+
+ TupleBuffer getTupleBuffer(String id);
}
Modified: branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-08-30
17:14:35 UTC (rev 2504)
+++ branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -176,6 +176,7 @@
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
+ rowOffset = in.readInt();
terminationFlag = in.readBoolean();
preservedTypes = (String[])in.readObject();
if (types == null) {
@@ -187,6 +188,7 @@
}
}
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(this.rowOffset);
out.writeBoolean(terminationFlag);
out.writeObject(this.preservedTypes);
BatchSerializer.writeBatch(out, types, getAllTuples());
Modified: branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -76,6 +76,7 @@
private LobManager lobManager;
private int[] lobIndexes;
+ private String uuid;
public TupleBuffer(BatchManager manager, String id, List<?> schema, int[]
lobIndexes, int batchSize) {
this.manager = manager;
@@ -86,9 +87,16 @@
if (this.lobIndexes != null) {
this.lobManager = new LobManager();
}
- this.batchSize = batchSize;
+ this.batchSize = batchSize;
}
+ public String getId() {
+ if (this.uuid == null) {
+ this.uuid = java.util.UUID.randomUUID().toString();
+ }
+ return this.uuid;
+ }
+
public boolean isLobs() {
return lobIndexes != null;
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -29,6 +29,7 @@
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -391,7 +392,10 @@
private volatile int activeBatchColumnCount = 0;
private Map<String, TupleBufferInfo> activeBatches = new
LinkedHashMap<String, TupleBufferInfo>();
+ private Map<String, TupleReference> tupleBufferMap = new
ConcurrentHashMap<String, TupleReference>();
+ private ReferenceQueue<TupleBuffer> tupleBufferQueue = new
ReferenceQueue<TupleBuffer>();
+
private StorageManager diskMgr;
private AtomicLong tsId = new AtomicLong();
@@ -614,5 +618,38 @@
public void shutdown() {
}
-
+
+ @Override
+ public void addTupleBuffer(TupleBuffer tb) {
+ cleanDefunctTupleBuffers();
+ this.tupleBufferMap.put(tb.getId(), new TupleReference(tb, this.tupleBufferQueue));
+ }
+
+ @Override
+ public TupleBuffer getTupleBuffer(String id) {
+ cleanDefunctTupleBuffers();
+ Reference<TupleBuffer> r = this.tupleBufferMap.get(id);
+ if (r != null) {
+ return r.get();
+ }
+ return null;
+ }
+
+ private void cleanDefunctTupleBuffers() {
+ while (true) {
+ Reference r = this.tupleBufferQueue.poll();
+ if (r == null) {
+ break;
+ }
+ this.tupleBufferMap.remove(((TupleReference)r).id);
+ }
+ }
+
+ static class TupleReference extends WeakReference<TupleBuffer>{
+ String id;
+ public TupleReference(TupleBuffer referent, ReferenceQueue<? super TupleBuffer>
q) {
+ super(referent, q);
+ id = referent.getId();
+ }
+ }
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -219,15 +219,15 @@
// Create the execution based on mode
final Execution exec = connector.createExecution(this.translatedCommand,
this.securityContext, rmd, this.connection);
if (this.translatedCommand instanceof Call) {
- this.execution = Assertion.isInstanceOf(this.execution,
ProcedureExecution.class, "Call Executions are expected to be
ProcedureExecutions"); //$NON-NLS-1$
+ this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class,
"Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
StoredProcedure proc = (StoredProcedure)command;
if (proc.returnParameters()) {
- this.procedureBatchHandler = new
ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
+ this.procedureBatchHandler = new
ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)exec);
}
} else if (this.translatedCommand instanceof QueryExpression){
- this.execution = Assertion.isInstanceOf(this.execution,
ResultSetExecution.class, "QueryExpression Executions are expected to be
ResultSetExecutions"); //$NON-NLS-1$
+ this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class,
"QueryExpression Executions are expected to be ResultSetExecutions");
//$NON-NLS-1$
} else {
- Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update
Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
+ Assertion.isInstanceOf(exec, UpdateExecution.class, "Update Executions are
expected to be UpdateExecutions"); //$NON-NLS-1$
this.execution = new ResultSetExecution() {
private int[] results;
private int index;
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -25,7 +25,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.util.UUID;
import org.teiid.api.exception.query.QueryParserException;
import org.teiid.api.exception.query.QueryResolverException;
@@ -62,8 +61,12 @@
private String[] types;
private CacheHint hint;
private int batchSize;
+ private String uuid;
+ private int rowCount;
- protected ArrayList<UUID> cachedBatches = new ArrayList<UUID>();
+ public String getId() {
+ return this.uuid;
+ }
public AnalysisRecord getAnalysisRecord() {
return analysisRecord;
@@ -81,6 +84,8 @@
this.results = results;
this.batchSize = results.getBatchSize();
this.types = TupleBuffer.getTypeNames(results.getSchema());
+ this.rowCount = results.getRowCount();
+ this.uuid = results.getId();
}
public void setCommand(Command command) {
@@ -107,19 +112,8 @@
@Override
public boolean prepare(Cache cache, BufferManager bufferManager) {
Assertion.assertTrue(!this.results.isForwardOnly());
- try {
- for (int row = 1; row <= this.results.getRowCount();
row+=this.results.getBatchSize()) {
- TupleBatch batch = results.getBatch(row);
- UUID uuid = java.util.UUID.randomUUID();
- batch.preserveTypes();
- cache.put(uuid, batch, this.hint != null?this.hint.getTtl():null);
- this.cachedBatches.add(uuid);
- }
- return true;
- } catch (TeiidComponentException e) {
- LogManager.logDetail(LogConstants.CTX_DQP,
DQPPlugin.Util.getString("failed_to_put_in_cache")); //$NON-NLS-1$
- }
- return false;
+ bufferManager.addTupleBuffer(this.results);
+ return true;
}
@Override
@@ -137,13 +131,15 @@
if (this.hint != null) {
buffer.setPrefersMemory(this.hint.getPrefersMemory());
}
- for (UUID uuid : this.cachedBatches) {
- TupleBatch batch = (TupleBatch)cache.get(uuid);
+
+ for (int row = 1; row <= this.rowCount; row+=this.batchSize) {
+ TupleBatch batch = (TupleBatch)cache.get(uuid+","+row); //$NON-NLS-1$
if (batch != null) {
buffer.addTupleBatch(batch, true);
- }
+ }
}
- this.results = buffer;
+ this.results = buffer;
+ bufferManager.addTupleBuffer(this.results);
}
return true;
} catch (TeiidComponentException e) {
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -41,6 +41,7 @@
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.Request.ProcessingState;
import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.cache.Cache;
@@ -554,7 +555,25 @@
}
}
+ public CacheStatisticsMetadata getCacheStatistics(String cacheType) {
+ if (cacheType.equalsIgnoreCase(Admin.Cache.PREPARED_PLAN_CACHE.toString())) {
+ return buildCacheStats(Admin.Cache.PREPARED_PLAN_CACHE.toString(),
this.prepPlanCache);
+ }
+ else if
(cacheType.equalsIgnoreCase(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString())) {
+ return buildCacheStats(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString(),
this.rsCache);
+ }
+ return null;
+ }
+ private CacheStatisticsMetadata buildCacheStats(String name, SessionAwareCache cache) {
+ CacheStatisticsMetadata stats = new CacheStatisticsMetadata();
+ stats.setName(name);
+ stats.setHitRatio(cache.getRequestCount() ==
0?0:(cache.getCacheHitCount()/cache.getRequestCount())*100);
+ stats.setTotalEntries(cache.getTotalCacheEntries());
+ stats.setRequestCount(cache.getRequestCount());
+ return stats;
+ }
+
public Collection<String> getCacheTypes(){
ArrayList<String> caches = new ArrayList<String>();
caches.add(Admin.Cache.PREPARED_PLAN_CACHE.toString());
@@ -639,6 +658,9 @@
this.exceptionOnMaxSourceRows = config.isExceptionOnMaxSourceRows();
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
+
+ //get buffer manager
+ this.bufferManager = bufferService.getBufferManager();
//result set cache
CacheConfiguration rsCacheConfig = config.getResultsetCacheConfig();
@@ -651,9 +673,7 @@
prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory,
Cache.Type.PREPAREDPLAN, new CacheConfiguration(Policy.LRU, 60*60*8,
config.getPreparedPlanCacheMaxCount()));
prepPlanCache.setBufferManager(this.bufferManager);
- //get buffer manager
- this.bufferManager = bufferService.getBufferManager();
-
+
this.processWorkerPool = new
ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,
@@ -809,6 +829,6 @@
public void setCacheFactory(CacheFactory factory) {
this.cacheFactory = factory;
- }
+ }
}
\ No newline at end of file
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -55,6 +55,7 @@
private int maxSize = DEFAULT_MAX_SIZE_TOTAL;
private AtomicInteger cacheHit = new AtomicInteger();
+ private AtomicInteger totalRequests = new AtomicInteger();
private BufferManager bufferManager;
@@ -82,6 +83,8 @@
}
public T get(CacheID id){
+
+ this.totalRequests.getAndIncrement();
id.setSessionId(id.originalSessionId);
T result = localCache.get(id);
@@ -114,7 +117,18 @@
public int getCacheHitCount() {
return cacheHit.get();
}
+
+ public int getRequestCount() {
+ return this.totalRequests.get();
+ }
+ public int getTotalCacheEntries() {
+ if (this.localCache == this.distributedCache) {
+ return this.localCache.size();
+ }
+ return localCache.size() + distributedCache.size();
+ }
+
public void put(CacheID id, int determinismLevel, T t, Long ttl){
if (determinismLevel >= FunctionMethod.SESSION_DETERMINISTIC) {
id.setSessionId(id.originalSessionId);
@@ -249,16 +263,11 @@
}
- //for testing purpose
- int getSpaceUsed() {
- return localCache.size();
- }
int getSpaceAllowed() {
return maxSize;
}
public void setBufferManager(BufferManager bufferManager) {
this.bufferManager = bufferManager;
- }
-
+ }
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -105,15 +105,6 @@
private SessionAwareCache<CachedResults> cache;
private Executor executor;
- public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager
bufferManager) {
- this(processorDataManager, bufferManager, new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- }, new SessionAwareCache<CachedResults>());
- }
-
public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager
bufferManager,
Executor executor, SessionAwareCache<CachedResults> cache){
this.processorDataManager = processorDataManager;
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -21,7 +21,8 @@
*/
package org.teiid.dqp.internal.process;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -34,6 +35,7 @@
import org.teiid.cache.Cache;
import org.teiid.cache.DefaultCache;
import org.teiid.common.buffer.BatchManager;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.core.TeiidComponentException;
@@ -93,12 +95,20 @@
tb.close();
+ BufferManager bm = fbs.getBufferManager();
CachedResults results = new CachedResults();
results.setResults(tb);
results.setCommand(new Query());
Cache cache = new DefaultCache("dummy"); //$NON-NLS-1$
- results.prepare(cache, fbs.getBufferManager());
+ // simulate the jboss-cache remote transport, where the batches are remotely looked up
+ // in cache
+ for (int row=1; row<=tb.getRowCount();row+=4) {
+ cache.put(results.getId()+","+row, tb.getBatch(row), null); //$NON-NLS-1$
+ }
+
+ results.prepare(cache, bm);
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(results);
@@ -108,7 +118,7 @@
CachedResults cachedResults = (CachedResults)ois.readObject();
ois.close();
- cachedResults.restore(cache, fbs.getBufferManager());
+ cachedResults.restore(cache, bm);
// since restored, simulate a async cache flush
cache.clear();
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -109,7 +109,7 @@
helpPutPreparedPlans(cache, token2, 0, 121);
helpPutPreparedPlans(cache, token, 0, 50);
- assertTrue(cache.getSpaceUsed() <= 100);
+ assertTrue(cache.getTotalCacheEntries() <= 100);
}
@Test public void testZeroSizeCache() {
@@ -120,12 +120,12 @@
// Add 1 plan and verify it is not in the cache
helpPutPreparedPlans(cache, token, 0, 1);
assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
- assertEquals(0, cache.getSpaceUsed());
+ assertEquals(0, cache.getTotalCacheEntries());
// Add another plan and verify it is not in the cache
helpPutPreparedPlans(cache, token, 1, 1);
assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1)));
- assertEquals(0, cache.getSpaceUsed());
+ assertEquals(0, cache.getTotalCacheEntries());
}
// set init size to negative number, which should default to 100 (default)
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -27,12 +27,16 @@
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Executor;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.QueryProcessorFactoryImpl;
+import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
@@ -59,7 +63,17 @@
hdm.addData("SELECT matsrc.x FROM matsrc", new List[]
{Arrays.asList((String)null), Arrays.asList("one"),
Arrays.asList("two"), Arrays.asList("three")});
hdm.addData("SELECT mattable.info.e1, mattable.info.e2 FROM mattable.info",
new List[] {Arrays.asList("a", 1), Arrays.asList("a", 2)});
hdm.addData("SELECT mattable.info.e2, mattable.info.e1 FROM mattable.info",
new List[] {Arrays.asList(1, "a"), Arrays.asList(2, "a")});
- dataManager = new TempTableDataManager(hdm,
BufferManagerFactory.getStandaloneBufferManager());
+
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ SessionAwareCache<CachedResults> cache = new
SessionAwareCache<CachedResults>();
+ cache.setBufferManager(bm);
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ dataManager = new TempTableDataManager(hdm, bm, executor, cache);
}
private void execute(String sql, List<?>... expectedResults) throws Exception {
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -39,6 +39,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.concurrent.Executor;
import org.junit.Test;
import org.teiid.client.metadata.ParameterInfo;
@@ -54,6 +55,7 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.XMLType;
+import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.PreparedPlan;
import org.teiid.dqp.internal.process.QueryProcessorFactoryImpl;
import org.teiid.dqp.internal.process.SessionAwareCache;
@@ -244,7 +246,15 @@
context.setGlobalTableStore(new TempTableStore("SYSTEM"));
}
if (!(dataManager instanceof TempTableDataManager)) {
- dataManager = new TempTableDataManager(dataManager, bufferMgr);
+ SessionAwareCache<CachedResults> cache = new
SessionAwareCache<CachedResults>();
+ cache.setBufferManager(bufferMgr);
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ dataManager = new TempTableDataManager(dataManager, bufferMgr, executor,
cache);
}
if (context.getQueryProcessorFactory() == null) {
context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(bufferMgr,
dataManager, new DefaultCapabilitiesFinder(), null, context.getMetadata()));
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -27,11 +27,15 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.Executor;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
@@ -60,9 +64,18 @@
metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(),
tempStore.getMetadataStore());
FakeDataManager fdm = new FakeDataManager();
TestProcessor.sampleData1(fdm);
- dataManager = new TempTableDataManager(fdm,
BufferManagerFactory.getStandaloneBufferManager());
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ SessionAwareCache<CachedResults> cache = new
SessionAwareCache<CachedResults>();
+ cache.setBufferManager(bm);
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ dataManager = new TempTableDataManager(fdm, bm, executor, cache);
}
-
+
@Test public void testInsertWithQueryExpression() throws Exception {
execute("create local temporary table x (e1 string, e2 integer)", new List[]
{Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[]
{Arrays.asList(6)}); //$NON-NLS-1$
Modified:
branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
---
branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -55,6 +55,7 @@
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminObject;
import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.CacheStatistics;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
@@ -64,6 +65,7 @@
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.WorkerPoolStatistics;
import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.PropertyDefinitionMetadata;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.SessionMetadata;
@@ -699,4 +701,15 @@
}
return matched;
}
+
+ @Override
+ public CacheStatistics getCacheStats(String cacheType) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getCacheStatistics",
SimpleValueSupport.wrap(cacheType));//$NON-NLS-1$
+ return (CacheStatistics)MetaValueFactory.getInstance().unwrap(value,
CacheStatisticsMetadata.class);
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
}
Modified:
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-08-30
17:14:35 UTC (rev 2504)
+++
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-08-30
18:58:21 UTC (rev 2505)
@@ -49,6 +49,7 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.DQPManagement;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.SessionMetadata;
@@ -149,14 +150,14 @@
if (this.jdbcSocketConfiguration.isEnabled()) {
this.jdbcSocket = new SocketListener(this.jdbcSocketConfiguration, csr,
this.dqpCore.getBufferManager(), offset);
- LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("socket_enabled","Teiid JDBC =
",(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()+offset));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("socket_enabled","Teiid JDBC =
",(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+(this.jdbcSocketConfiguration.getPortNumber()+offset)));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("socket_not_enabled", "jdbc
connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (this.adminSocketConfiguration.isEnabled()) {
this.adminSocket = new SocketListener(this.adminSocketConfiguration, csr,
this.dqpCore.getBufferManager(), offset);
- LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin",
(this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()+offset));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin",
(this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+(this.adminSocketConfiguration.getPortNumber()+offset)));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("socket_not_enabled", "admin
connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -164,7 +165,7 @@
if (this.odbcSocketConfiguration.isEnabled()) {
this.vdbRepository.odbcEnabled();
this.odbcSocket = new ODBCSocketListener(this.odbcSocketConfiguration, csr,
this.dqpCore.getBufferManager(), offset);
- LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("odbc_enabled","Teiid ODBC - SSL=",
(this.odbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"ON":"OFF")+"
Host = "+this.odbcSocketConfiguration.getHostAddress().getHostName()+" Port =
"+this.odbcSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("odbc_enabled","Teiid ODBC - SSL=",
(this.odbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"ON":"OFF")+"
Host = "+this.odbcSocketConfiguration.getHostAddress().getHostName()+" Port =
"+(this.odbcSocketConfiguration.getPortNumber()+offset))); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("odbc_not_enabled")); //$NON-NLS-1$
}
@@ -382,6 +383,12 @@
}
@Override
+ @ManagementOperation(description="Get the cache statistics",
impact=Impact.ReadOnly)
+ public CacheStatisticsMetadata getCacheStatistics(String cacheType) {
+ return this.dqpCore.getCacheStatistics(cacheType);
+ }
+
+ @Override
@ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
public Collection<SessionMetadata> getActiveSessions() throws AdminException {
try {