Navigation Menu

Skip to content

Commit

Permalink
ISPN-5933 Make RemoteQueryEngine a cache-level component
Browse files Browse the repository at this point in the history
* a ReflectionMatcher/ProtobufMatcher/CompatibilityReflectionMatcher is no longer instantiated for internal caches as they are not query-enabled
* perform query authorization only once
  • Loading branch information
anistor authored and gustavonalle committed Nov 13, 2015
1 parent dea9b17 commit 039aec7
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 66 deletions.
Expand Up @@ -5,8 +5,6 @@
import org.infinispan.objectfilter.ObjectFilter; import org.infinispan.objectfilter.ObjectFilter;
import org.infinispan.query.dsl.QueryFactory; import org.infinispan.query.dsl.QueryFactory;
import org.infinispan.query.dsl.impl.BaseQuery; import org.infinispan.query.dsl.impl.BaseQuery;
import org.infinispan.security.AuthorizationManager;
import org.infinispan.security.AuthorizationPermission;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
Expand Down Expand Up @@ -46,14 +44,6 @@ protected BaseEmbeddedQuery(QueryFactory queryFactory, AdvancedCache<?, ?> cache
String[] projection, long startOffset, int maxResults) { String[] projection, long startOffset, int maxResults) {
super(queryFactory, jpaQuery, namedParameters, projection, startOffset, maxResults); super(queryFactory, jpaQuery, namedParameters, projection, startOffset, maxResults);
this.cache = cache; this.cache = cache;
ensureAccessPermissions(cache);
}

private void ensureAccessPermissions(AdvancedCache<?, ?> cache) {
AuthorizationManager authorizationManager = SecurityActions.getCacheAuthorizationManager(cache);
if (authorizationManager != null) {
authorizationManager.checkPermission(AuthorizationPermission.BULK_READ);
}
} }


@Override @Override
Expand Down
Expand Up @@ -29,6 +29,8 @@
import org.infinispan.query.dsl.impl.BaseQuery; import org.infinispan.query.dsl.impl.BaseQuery;
import org.infinispan.query.dsl.impl.JPAQueryGenerator; import org.infinispan.query.dsl.impl.JPAQueryGenerator;
import org.infinispan.query.impl.ComponentRegistryUtils; import org.infinispan.query.impl.ComponentRegistryUtils;
import org.infinispan.security.AuthorizationManager;
import org.infinispan.security.AuthorizationPermission;
import org.infinispan.util.KeyValuePair; import org.infinispan.util.KeyValuePair;


import java.security.PrivilegedAction; import java.security.PrivilegedAction;
Expand All @@ -47,6 +49,8 @@ public class QueryEngine {


private static final int MAX_EXPANSION_COFACTORS = 16; private static final int MAX_EXPANSION_COFACTORS = 16;


private final AuthorizationManager authorizationManager;

protected final AdvancedCache<?, ?> cache; protected final AdvancedCache<?, ?> cache;


/** /**
Expand All @@ -73,9 +77,14 @@ public QueryEngine(AdvancedCache<?, ?> cache, SearchManager searchManager) {
this.queryCache = ComponentRegistryUtils.getQueryCache(cache); this.queryCache = ComponentRegistryUtils.getQueryCache(cache);
this.searchManager = searchManager; this.searchManager = searchManager;
searchFactory = searchManager != null ? searchManager.unwrap(SearchIntegrator.class) : null; searchFactory = searchManager != null ? searchManager.unwrap(SearchIntegrator.class) : null;
authorizationManager = SecurityActions.getCacheAuthorizationManager(cache);
} }


public BaseQuery buildQuery(QueryFactory queryFactory, String jpqlString, Map<String, Object> namedParameters, long startOffset, int maxResults) { public BaseQuery buildQuery(QueryFactory queryFactory, String jpqlString, Map<String, Object> namedParameters, long startOffset, int maxResults) {
if (authorizationManager != null) {
authorizationManager.checkPermission(AuthorizationPermission.BULK_READ);
}

checkParameters(namedParameters); checkParameters(namedParameters);


FilterParsingResult<?> parsingResult = parse(jpqlString, namedParameters); FilterParsingResult<?> parsingResult = parse(jpqlString, namedParameters);
Expand Down
43 changes: 20 additions & 23 deletions query/src/main/java/org/infinispan/query/impl/LifecycleManager.java
Expand Up @@ -51,6 +51,7 @@
import org.infinispan.query.continuous.impl.ContinuousQueryResult; import org.infinispan.query.continuous.impl.ContinuousQueryResult;
import org.infinispan.query.continuous.impl.JPAContinuousQueryCacheEventFilterConverter; import org.infinispan.query.continuous.impl.JPAContinuousQueryCacheEventFilterConverter;
import org.infinispan.query.spi.ProgrammaticSearchMappingProvider; import org.infinispan.query.spi.ProgrammaticSearchMappingProvider;
import org.infinispan.registry.InternalCacheRegistry;
import org.infinispan.registry.impl.ClusterRegistryImpl; import org.infinispan.registry.impl.ClusterRegistryImpl;
import org.infinispan.transaction.LockingMode; import org.infinispan.transaction.LockingMode;
import org.infinispan.util.logging.LogFactory; import org.infinispan.util.logging.LogFactory;
Expand Down Expand Up @@ -91,21 +92,22 @@ public class LifecycleManager extends AbstractModuleLifecycle {
*/ */
@Override @Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) { public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
cr.registerComponent(new ReflectionMatcher(null), ReflectionMatcher.class); InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);

if (!icr.isInternalCache(cacheName)) {
if (cfg.indexing().index().isEnabled()) { cr.registerComponent(new ReflectionMatcher(null), ReflectionMatcher.class);
log.registeringQueryInterceptor();
SearchIntegrator searchFactory = getSearchFactory(cfg.indexing().properties(), cr); if (cfg.indexing().index().isEnabled()) {
createQueryInterceptorIfNeeded(cr, cfg, searchFactory); log.registeringQueryInterceptor();
EmbeddedCacheManager cacheManager = cr.getGlobalComponentRegistry().getComponent(EmbeddedCacheManager.class); SearchIntegrator searchFactory = getSearchFactory(cfg.indexing().properties(), cr);
addCacheDependencyIfNeeded(cacheName, cacheManager, cfg.indexing().properties()); createQueryInterceptorIfNeeded(cr, cfg, searchFactory);
EmbeddedCacheManager cacheManager = cr.getGlobalComponentRegistry().getComponent(EmbeddedCacheManager.class);
addCacheDependencyIfNeeded(cacheName, cacheManager, cfg.indexing().properties());
}
} }
} }


private void addCacheDependencyIfNeeded(String cacheStarting, EmbeddedCacheManager cacheManager, Properties properties) { private void addCacheDependencyIfNeeded(String cacheStarting, EmbeddedCacheManager cacheManager, Properties properties) {
if (!ClusterRegistryImpl.GLOBAL_REGISTRY_CACHE_NAME.equals(cacheStarting)) { cacheManager.addCacheDependency(cacheStarting, ClusterRegistryImpl.GLOBAL_REGISTRY_CACHE_NAME);
cacheManager.addCacheDependency(cacheStarting, ClusterRegistryImpl.GLOBAL_REGISTRY_CACHE_NAME);
}
if (hasInfinispanDirectory(properties) && !DEFAULT_CACHES.contains(cacheStarting)) { if (hasInfinispanDirectory(properties) && !DEFAULT_CACHES.contains(cacheStarting)) {
String metadataCacheName = getMetadataCacheName(properties); String metadataCacheName = getMetadataCacheName(properties);
String lockingCacheName = getLockingCacheName(properties); String lockingCacheName = getLockingCacheName(properties);
Expand Down Expand Up @@ -187,11 +189,9 @@ public void cacheStarted(ComponentRegistry cr, String cacheName) {
registerQueryMBeans(cache.getAdvancedCache(), cr, cacheName); registerQueryMBeans(cache.getAdvancedCache(), cr, cacheName);
} }


private void registerQueryMBeans(AdvancedCache cache, private void registerQueryMBeans(AdvancedCache cache, ComponentRegistry cr, String cacheName) {
ComponentRegistry cr, String cacheName) {
Configuration cfg = cache.getCacheConfiguration(); Configuration cfg = cache.getCacheConfiguration();
SearchIntegrator sf = getSearchFactory( SearchIntegrator sf = getSearchFactory(cfg.indexing().properties(), cr);
cfg.indexing().properties(), cr);


// Resolve MBean server instance // Resolve MBean server instance
GlobalConfiguration globalCfg = GlobalConfiguration globalCfg =
Expand Down Expand Up @@ -221,8 +221,8 @@ private void registerQueryMBeans(AdvancedCache cache,
.toManageableComponentMetadata(); .toManageableComponentMetadata();
try { try {
// TODO: MassIndexer should be some kind of query cache component? // TODO: MassIndexer should be some kind of query cache component?
DistributedExecutorMassIndexer maxIndexer = new DistributedExecutorMassIndexer(cache, sf); DistributedExecutorMassIndexer massIndexer = new DistributedExecutorMassIndexer(cache, sf);
ResourceDMBean mbean = new ResourceDMBean(maxIndexer, massIndexerCompMetadata); ResourceDMBean mbean = new ResourceDMBean(massIndexer, massIndexerCompMetadata);
ObjectName massIndexerObjName = new ObjectName(jmxDomain + ":" ObjectName massIndexerObjName = new ObjectName(jmxDomain + ":"
+ queryGroupName + ",component=" + massIndexerCompMetadata.getJmxObjectName()); + queryGroupName + ",component=" + massIndexerCompMetadata.getJmxObjectName());
JmxUtil.registerMBean(mbean, massIndexerObjName, mbeanServer); JmxUtil.registerMBean(mbean, massIndexerObjName, mbeanServer);
Expand All @@ -237,10 +237,7 @@ private String getQueryGroupName(String cacheManagerName, String cacheName) {


private boolean verifyChainContainsQueryInterceptor(ComponentRegistry cr) { private boolean verifyChainContainsQueryInterceptor(ComponentRegistry cr) {
InterceptorChain interceptorChain = cr.getComponent(InterceptorChain.class); InterceptorChain interceptorChain = cr.getComponent(InterceptorChain.class);
if (interceptorChain == null) { return interceptorChain != null && interceptorChain.containsInterceptorType(QueryInterceptor.class, true);
return false;
}
return interceptorChain.containsInterceptorType(QueryInterceptor.class, true);
} }


private SearchIntegrator getSearchFactory(Properties indexingProperties, ComponentRegistry cr) { private SearchIntegrator getSearchFactory(Properties indexingProperties, ComponentRegistry cr) {
Expand All @@ -250,7 +247,7 @@ private SearchIntegrator getSearchFactory(Properties indexingProperties, Compone
searchFactory = (SearchIntegrator) component; searchFactory = (SearchIntegrator) component;
} }
//defend against multiple initialization: //defend against multiple initialization:
if (searchFactory==null) { if (searchFactory == null) {
GlobalComponentRegistry globalComponentRegistry = cr.getGlobalComponentRegistry(); GlobalComponentRegistry globalComponentRegistry = cr.getGlobalComponentRegistry();
EmbeddedCacheManager uninitializedCacheManager = globalComponentRegistry.getComponent(EmbeddedCacheManager.class); EmbeddedCacheManager uninitializedCacheManager = globalComponentRegistry.getComponent(EmbeddedCacheManager.class);
indexingProperties = addProgrammaticMappings(indexingProperties, cr); indexingProperties = addProgrammaticMappings(indexingProperties, cr);
Expand Down Expand Up @@ -332,7 +329,7 @@ public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguratio
QueryCache queryCache = new QueryCache(); QueryCache queryCache = new QueryCache();
gcr.registerComponent(queryCache, QueryCache.class); gcr.registerComponent(queryCache, QueryCache.class);


Map<Integer,AdvancedExternalizer<?>> externalizerMap = globalCfg.serialization().advancedExternalizers(); Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalCfg.serialization().advancedExternalizers();
externalizerMap.put(ExternalizerIds.JPA_FILTER_AND_CONVERTER, new JPAFilterAndConverter.JPAFilterAndConverterExternalizer()); externalizerMap.put(ExternalizerIds.JPA_FILTER_AND_CONVERTER, new JPAFilterAndConverter.JPAFilterAndConverterExternalizer());
externalizerMap.put(ExternalizerIds.JPA_FILTER_RESULT, new JPAFilterAndConverter.FilterResultExternalizer()); externalizerMap.put(ExternalizerIds.JPA_FILTER_RESULT, new JPAFilterAndConverter.FilterResultExternalizer());
externalizerMap.put(ExternalizerIds.JPA_CACHE_EVENT_FILTER_CONVERTER, new JPACacheEventFilterConverter.Externalizer()); externalizerMap.put(ExternalizerIds.JPA_CACHE_EVENT_FILTER_CONVERTER, new JPACacheEventFilterConverter.Externalizer());
Expand Down
@@ -1,5 +1,7 @@
package org.infinispan.query.remote.impl; package org.infinispan.query.remote.impl;


import org.infinispan.AdvancedCache;
import org.infinispan.Cache;
import org.infinispan.commons.CacheException; import org.infinispan.commons.CacheException;
import org.infinispan.commons.marshall.AdvancedExternalizer; import org.infinispan.commons.marshall.AdvancedExternalizer;
import org.infinispan.configuration.cache.Configuration; import org.infinispan.configuration.cache.Configuration;
Expand All @@ -8,6 +10,7 @@
import org.infinispan.configuration.cache.InterceptorConfiguration; import org.infinispan.configuration.cache.InterceptorConfiguration;
import org.infinispan.configuration.cache.InterceptorConfigurationBuilder; import org.infinispan.configuration.cache.InterceptorConfigurationBuilder;
import org.infinispan.configuration.global.GlobalConfiguration; import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.context.Flag;
import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.ComponentRegistry;
import org.infinispan.factories.GlobalComponentRegistry; import org.infinispan.factories.GlobalComponentRegistry;
import org.infinispan.factories.components.ComponentMetadataRepo; import org.infinispan.factories.components.ComponentMetadataRepo;
Expand All @@ -21,6 +24,9 @@
import org.infinispan.manager.DefaultCacheManager; import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.objectfilter.impl.ProtobufMatcher; import org.infinispan.objectfilter.impl.ProtobufMatcher;
import org.infinispan.protostream.SerializationContext;
import org.infinispan.query.Search;
import org.infinispan.query.SearchManager;
import org.infinispan.query.remote.ProtobufMetadataManager; import org.infinispan.query.remote.ProtobufMetadataManager;
import org.infinispan.query.remote.impl.filter.JPABinaryProtobufFilterAndConverter; import org.infinispan.query.remote.impl.filter.JPABinaryProtobufFilterAndConverter;
import org.infinispan.query.remote.impl.filter.JPAContinuousQueryProtobufCacheEventFilterConverter; import org.infinispan.query.remote.impl.filter.JPAContinuousQueryProtobufCacheEventFilterConverter;
Expand All @@ -29,6 +35,7 @@
import org.infinispan.query.remote.impl.indexing.ProtobufValueWrapper; import org.infinispan.query.remote.impl.indexing.ProtobufValueWrapper;
import org.infinispan.query.remote.impl.indexing.RemoteValueWrapperInterceptor; import org.infinispan.query.remote.impl.indexing.RemoteValueWrapperInterceptor;
import org.infinispan.query.remote.impl.logging.Log; import org.infinispan.query.remote.impl.logging.Log;
import org.infinispan.registry.InternalCacheRegistry;
import org.infinispan.util.logging.LogFactory; import org.infinispan.util.logging.LogFactory;
import org.kohsuke.MetaInfServices; import org.kohsuke.MetaInfServices;


Expand Down Expand Up @@ -106,7 +113,8 @@ private void unregisterProtobufMetadataManagerMBean(GlobalComponentRegistry gcr)
*/ */
@Override @Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) { public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
if (!cacheName.equals(ProtobufMetadataManager.PROTOBUF_METADATA_CACHE_NAME)) { InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
if (!icr.isInternalCache(cacheName)) {
ProtobufMetadataManagerImpl protobufMetadataManager = (ProtobufMetadataManagerImpl) cr.getGlobalComponentRegistry().getComponent(ProtobufMetadataManager.class); ProtobufMetadataManagerImpl protobufMetadataManager = (ProtobufMetadataManagerImpl) cr.getGlobalComponentRegistry().getComponent(ProtobufMetadataManager.class);


// ensure the protobuf metadata cache is created // ensure the protobuf metadata cache is created
Expand Down Expand Up @@ -147,7 +155,6 @@ private void createRemoteValueWrapperInterceptor(ComponentRegistry cr, Configura
} }
if (ic != null) { if (ic != null) {
cr.registerComponent(wrapperInterceptor, RemoteValueWrapperInterceptor.class); cr.registerComponent(wrapperInterceptor, RemoteValueWrapperInterceptor.class);
cr.registerComponent(wrapperInterceptor, wrapperInterceptor.getClass().getName(), true);
} }
cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
} }
Expand All @@ -156,24 +163,30 @@ private void createRemoteValueWrapperInterceptor(ComponentRegistry cr, Configura
@Override @Override
public void cacheStarted(ComponentRegistry cr, String cacheName) { public void cacheStarted(ComponentRegistry cr, String cacheName) {
Configuration configuration = cr.getComponent(Configuration.class); Configuration configuration = cr.getComponent(Configuration.class);
boolean remoteValueWrappingEnabled = configuration.indexing().index().isEnabled() && !configuration.compatibility().enabled(); boolean isIndexed = configuration.indexing().index().isEnabled();
if (!remoteValueWrappingEnabled) { boolean isCompatMode = configuration.compatibility().enabled();
if (verifyChainContainsRemoteValueWrapperInterceptor(cr)) { boolean remoteValueWrappingEnabled = isIndexed && !isCompatMode;
throw new IllegalStateException("It was NOT expected to find the RemoteValueWrapperInterceptor registered in the InterceptorChain as indexing was disabled, but it was found"); if (remoteValueWrappingEnabled) {
if (!verifyChainContainsRemoteValueWrapperInterceptor(cr)) {
throw new IllegalStateException("It was expected to find the RemoteValueWrapperInterceptor registered in the InterceptorChain but it wasn't found");
} }
return; } else if (verifyChainContainsRemoteValueWrapperInterceptor(cr)) {
throw new IllegalStateException("It was NOT expected to find the RemoteValueWrapperInterceptor registered in the InterceptorChain as indexing was disabled, but it was found");
} }
if (!verifyChainContainsRemoteValueWrapperInterceptor(cr)) {
throw new IllegalStateException("It was expected to find the RemoteValueWrapperInterceptor registered in the InterceptorChain but it wasn't found"); InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
if (!icr.isInternalCache(cacheName)) {
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache().withFlags(Flag.OPERATION_HOTROD);
SerializationContext serCtx = ProtobufMetadataManagerImpl.getSerializationContextInternal(cache.getCacheManager());
SearchManager searchManager = isIndexed ? Search.getSearchManager(cache) : null;
RemoteQueryEngine remoteQueryEngine = new RemoteQueryEngine(cache, searchManager, isCompatMode, serCtx);
cr.registerComponent(remoteQueryEngine, RemoteQueryEngine.class);
} }
} }


private boolean verifyChainContainsRemoteValueWrapperInterceptor(ComponentRegistry cr) { private boolean verifyChainContainsRemoteValueWrapperInterceptor(ComponentRegistry cr) {
InterceptorChain interceptorChain = cr.getComponent(InterceptorChain.class); InterceptorChain interceptorChain = cr.getComponent(InterceptorChain.class);
if (interceptorChain == null) { return interceptorChain != null && interceptorChain.containsInterceptorType(RemoteValueWrapperInterceptor.class, true);
return false;
}
return interceptorChain.containsInterceptorType(RemoteValueWrapperInterceptor.class, true);
} }


@Override @Override
Expand Down
Expand Up @@ -4,12 +4,9 @@
import org.hibernate.search.engine.impl.nullencoding.NullMarkerCodec; import org.hibernate.search.engine.impl.nullencoding.NullMarkerCodec;
import org.infinispan.AdvancedCache; import org.infinispan.AdvancedCache;
import org.infinispan.commons.logging.LogFactory; import org.infinispan.commons.logging.LogFactory;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.protostream.ProtobufUtil; import org.infinispan.protostream.ProtobufUtil;
import org.infinispan.protostream.SerializationContext; import org.infinispan.protostream.SerializationContext;
import org.infinispan.protostream.WrappedMessage; import org.infinispan.protostream.WrappedMessage;
import org.infinispan.query.Search;
import org.infinispan.query.SearchManager;
import org.infinispan.query.dsl.impl.BaseQuery; import org.infinispan.query.dsl.impl.BaseQuery;
import org.infinispan.query.remote.client.QueryRequest; import org.infinispan.query.remote.client.QueryRequest;
import org.infinispan.query.remote.client.QueryResponse; import org.infinispan.query.remote.client.QueryResponse;
Expand Down Expand Up @@ -49,19 +46,19 @@ public final class QueryFacadeImpl implements QueryFacade {


@Override @Override
public byte[] query(AdvancedCache<byte[], byte[]> cache, byte[] query) { public byte[] query(AdvancedCache<byte[], byte[]> cache, byte[] query) {
RemoteQueryEngine queryEngine = SecurityActions.getCacheComponentRegistry(cache).getComponent(RemoteQueryEngine.class);
if (queryEngine == null) {
throw log.queryingNotEnabled(cache.getName());
}

SerializationContext serCtx = ProtobufMetadataManagerImpl.getSerializationContextInternal(cache.getCacheManager());
try { try {
SerializationContext serCtx = ProtobufMetadataManagerImpl.getSerializationContextInternal(cache.getCacheManager());
QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class); QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class);


Configuration cacheConfiguration = SecurityActions.getCacheConfiguration(cache);
boolean isIndexed = cacheConfiguration.indexing().index().isEnabled();
boolean isCompatMode = cacheConfiguration.compatibility().enabled();
SearchManager searchManager = isIndexed ? Search.getSearchManager(cache) : null; // this also checks access permissions
RemoteQueryEngine queryEngine = new RemoteQueryEngine(cache, searchManager, isCompatMode, serCtx);

long startOffset = request.getStartOffset() == null ? -1 : request.getStartOffset(); long startOffset = request.getStartOffset() == null ? -1 : request.getStartOffset();
int maxResults = request.getMaxResults() == null ? -1 : request.getMaxResults(); int maxResults = request.getMaxResults() == null ? -1 : request.getMaxResults();
Map<String, Object> namedParameters = getNamedParameters(request); Map<String, Object> namedParameters = getNamedParameters(request);

BaseQuery q = queryEngine.buildQuery(null, request.getJpqlString(), namedParameters, startOffset, maxResults); BaseQuery q = queryEngine.buildQuery(null, request.getJpqlString(), namedParameters, startOffset, maxResults);


QueryResponse response = makeResponse(q); QueryResponse response = makeResponse(q);
Expand Down
@@ -1,11 +1,9 @@
package org.infinispan.query.remote.impl; package org.infinispan.query.remote.impl;


import org.infinispan.AdvancedCache; import org.infinispan.AdvancedCache;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.ComponentRegistry;
import org.infinispan.security.Security; import org.infinispan.security.Security;
import org.infinispan.security.actions.GetCacheComponentRegistryAction; import org.infinispan.security.actions.GetCacheComponentRegistryAction;
import org.infinispan.security.actions.GetCacheConfigurationAction;


import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
Expand All @@ -24,10 +22,6 @@ static <T> T doPrivileged(PrivilegedAction<T> action) {
AccessController.doPrivileged(action) : Security.doPrivileged(action); AccessController.doPrivileged(action) : Security.doPrivileged(action);
} }


static Configuration getCacheConfiguration(AdvancedCache<?, ?> cache) {
return doPrivileged(new GetCacheConfigurationAction(cache));
}

static ComponentRegistry getCacheComponentRegistry(AdvancedCache<?, ?> cache) { static ComponentRegistry getCacheComponentRegistry(AdvancedCache<?, ?> cache) {
return doPrivileged(new GetCacheComponentRegistryAction(cache)); return doPrivileged(new GetCacheComponentRegistryAction(cache));
} }
Expand Down
Expand Up @@ -23,4 +23,7 @@ public interface Log extends org.infinispan.util.logging.Log {


@Message(value = "An exception has occurred during query execution", id = 18003) @Message(value = "An exception has occurred during query execution", id = 18003)
CacheException errorExecutingQuery(@Cause Throwable cause); CacheException errorExecutingQuery(@Cause Throwable cause);

@Message(value = "Querying is not enabled on cache %s", id = 18004)
CacheException queryingNotEnabled(String cacheName);
} }
Expand Up @@ -5,7 +5,6 @@ import org.infinispan.configuration.cache.Configuration
import org.infinispan.server.core.Operation._ import org.infinispan.server.core.Operation._
import HotRodOperation._ import HotRodOperation._
import OperationStatus._ import OperationStatus._
import org.infinispan.stats.Stats
import org.infinispan.server.core._ import org.infinispan.server.core._
import collection.mutable import collection.mutable
import collection.immutable import collection.immutable
Expand Down Expand Up @@ -211,7 +210,7 @@ object Decoder10 extends AbstractVersionedDecoder with ServerConstants with Log
getKeyMetadata(h, k, cache) getKeyMetadata(h, k, cache)
case QueryRequest => case QueryRequest =>
val query = readRangedBytes(buffer) val query = readRangedBytes(buffer)
val result = server.getQueryFacades.head.query(cache, query) val result = server.query(cache, query)
new QueryResponse(h.version, h.messageId, h.cacheName, h.clientIntel, new QueryResponse(h.version, h.messageId, h.cacheName, h.clientIntel,
h.topologyId, result) h.topologyId, result)
} }
Expand Down
Expand Up @@ -367,7 +367,7 @@ object Decoder2x extends AbstractVersionedDecoder with ServerConstants with Log
getKeyMetadata(h, k, cache) getKeyMetadata(h, k, cache)
case QueryRequest => case QueryRequest =>
val query = readRangedBytes(buffer) val query = readRangedBytes(buffer)
val result = server.getQueryFacades.head.query(cache, query) val result = server.query(cache, query)
new QueryResponse(h.version, h.messageId, h.cacheName, h.clientIntel, new QueryResponse(h.version, h.messageId, h.cacheName, h.clientIntel,
h.topologyId, result) h.topologyId, result)
case AddClientListenerRequest => case AddClientListenerRequest =>
Expand Down
@@ -1,6 +1,7 @@
package org.infinispan.server.hotrod package org.infinispan.server.hotrod


import logging.Log import logging.Log
import org.infinispan.AdvancedCache
import org.infinispan.commons.marshall.Marshaller import org.infinispan.commons.marshall.Marshaller
import org.infinispan.filter.{ParamKeyValueFilterConverterFactory, KeyValueFilterConverterFactory} import org.infinispan.filter.{ParamKeyValueFilterConverterFactory, KeyValueFilterConverterFactory}
import org.infinispan.notifications.Listener import org.infinispan.notifications.Listener
Expand Down Expand Up @@ -62,7 +63,9 @@ class HotRodServer extends AbstractProtocolServer("HotRod") with Log {


def getMarshaller = marshaller def getMarshaller = marshaller


def getQueryFacades: Seq[QueryFacade] = queryFacades def query(cache: AdvancedCache[Array[Byte], Array[Byte]], query: Array[Byte]): Array[Byte] = {
queryFacades.head.query(cache, query)
}


def getClientListenerRegistry: ClientListenerRegistry = clientListenerRegistry def getClientListenerRegistry: ClientListenerRegistry = clientListenerRegistry


Expand Down

0 comments on commit 039aec7

Please sign in to comment.