Search in sources :

Example 36 with CqService

use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.

the class MonitorCQ method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException {
    CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
    int op = clientMessage.getPart(0).getInt();
    if (op < 1) {
        // This should have been taken care at the client - remove?
        String err = LocalizedStrings.MonitorCQ__0_THE_MONITORCQ_OPERATION_IS_INVALID.toLocalizedString(serverConnection.getName());
        sendCqResponse(MessageType.CQDATAERROR_MSG_TYPE, err, clientMessage.getTransactionId(), null, serverConnection);
        return;
    }
    String regionName = null;
    if (clientMessage.getNumberOfParts() == 2) {
        // This will be enable/disable on region.
        regionName = clientMessage.getPart(1).getString();
        if (regionName == null) {
            // This should have been taken care at the client - remove?
            String err = LocalizedStrings.MonitorCQ__0_A_NULL_REGION_NAME_WAS_PASSED_FOR_MONITORCQ_OPERATION.toLocalizedString(serverConnection.getName());
            sendCqResponse(MessageType.CQDATAERROR_MSG_TYPE, err, clientMessage.getTransactionId(), null, serverConnection);
            return;
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Received MonitorCq request from {} op: {}{}", serverConnection.getName(), serverConnection.getSocketString(), op, (regionName != null) ? " RegionName: " + regionName : "");
    }
    this.securityService.authorizeClusterRead();
    try {
        CqService cqService = crHelper.getCache().getCqService();
        cqService.start();
        // Should never come.
        throw new CqException(LocalizedStrings.CqService_INVALID_CQ_MONITOR_REQUEST_RECEIVED.toLocalizedString());
    } catch (CqException cqe) {
        sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe, serverConnection);
        return;
    } catch (Exception e) {
        String err = LocalizedStrings.MonitorCQ_EXCEPTION_WHILE_HANDLING_THE_MONITOR_REQUEST_OP_IS_0.toLocalizedString(Integer.valueOf(op));
        sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, err, clientMessage.getTransactionId(), e, serverConnection);
        return;
    }
}
Also used : CachedRegionHelper(org.apache.geode.internal.cache.tier.CachedRegionHelper) CqException(org.apache.geode.cache.query.CqException) CqService(org.apache.geode.cache.query.internal.cq.CqService) CqException(org.apache.geode.cache.query.CqException) IOException(java.io.IOException)

Aggregations

CqService (org.apache.geode.cache.query.internal.cq.CqService)36 InternalCqQuery (org.apache.geode.cache.query.internal.cq.InternalCqQuery)15 CacheException (org.apache.geode.cache.CacheException)11 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)11 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)10 IOException (java.io.IOException)9 Collection (java.util.Collection)9 Set (java.util.Set)8 CqException (org.apache.geode.cache.query.CqException)8 HashSet (java.util.HashSet)7 Region (org.apache.geode.cache.Region)7 ServerCQImpl (org.apache.geode.cache.query.internal.cq.ServerCQImpl)7 Host (org.apache.geode.test.dunit.Host)7 VM (org.apache.geode.test.dunit.VM)7 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)7 Test (org.junit.Test)7 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)6 Portfolio (org.apache.geode.cache.query.data.Portfolio)5 CachedRegionHelper (org.apache.geode.internal.cache.tier.CachedRegionHelper)5 CacheServerStats (org.apache.geode.internal.cache.tier.sockets.CacheServerStats)5