use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.
the class GetDurableCQs method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, InterruptedException {
AcceptorImpl acceptor = serverConnection.getAcceptor();
CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
ClientProxyMembershipID id = serverConnection.getProxyID();
CacheServerStats stats = serverConnection.getCacheServerStats();
serverConnection.setAsTrue(REQUIRES_RESPONSE);
serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
if (logger.isDebugEnabled()) {
logger.debug("{}: Received {} request from {}", serverConnection.getName(), MessageType.getString(clientMessage.getMessageType()), serverConnection.getSocketString());
}
DefaultQueryService qService = null;
CqService cqServiceForExec = null;
try {
qService = (DefaultQueryService) crHelper.getCache().getLocalQueryService();
this.securityService.authorizeClusterRead();
// Authorization check
AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
if (authzRequest != null) {
authzRequest.getDurableCQsAuthorize();
}
cqServiceForExec = qService.getCqService();
List<String> durableCqs = cqServiceForExec.getAllDurableClientCqs(id);
ChunkedMessage chunkedResponseMsg = serverConnection.getChunkedResponseMessage();
chunkedResponseMsg.setMessageType(MessageType.RESPONSE);
chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId());
chunkedResponseMsg.sendHeader();
List durableCqList = new ArrayList(MAXIMUM_CHUNK_SIZE);
final boolean isTraceEnabled = logger.isTraceEnabled();
for (Iterator it = durableCqs.iterator(); it.hasNext(); ) {
Object durableCqName = it.next();
durableCqList.add(durableCqName);
if (isTraceEnabled) {
logger.trace("{}: getDurableCqsResponse <{}>; list size was {}", serverConnection.getName(), durableCqName, durableCqList.size());
}
if (durableCqList.size() == MAXIMUM_CHUNK_SIZE) {
// Send the chunk and clear the list
sendDurableCqsResponseChunk(durableCqList, false, serverConnection);
durableCqList.clear();
}
}
// Send the last chunk even if the list is of zero size.
sendDurableCqsResponseChunk(durableCqList, true, serverConnection);
} catch (CqException cqe) {
sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe, serverConnection);
return;
} catch (Exception e) {
writeChunkedException(clientMessage, e, serverConnection);
return;
}
}
use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.
the class StopCQ method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException {
CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
ClientProxyMembershipID id = serverConnection.getProxyID();
CacheServerStats stats = serverConnection.getCacheServerStats();
// Based on MessageType.QUERY
// Added by Rao 2/1/2007
serverConnection.setAsTrue(REQUIRES_RESPONSE);
serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
start = DistributionStats.getStatTime();
// Retrieve the data from the message parts
String cqName = clientMessage.getPart(0).getString();
if (logger.isDebugEnabled()) {
logger.debug("{}: Received stop CQ request from {} cqName: {}", serverConnection.getName(), serverConnection.getSocketString(), cqName);
}
// Process the query request
if (cqName == null) {
String err = LocalizedStrings.StopCQ_THE_CQNAME_FOR_THE_CQ_STOP_REQUEST_IS_NULL.toLocalizedString();
sendCqResponse(MessageType.CQDATAERROR_MSG_TYPE, err, clientMessage.getTransactionId(), null, serverConnection);
return;
}
// Process CQ stop request
try {
// Append Client ID to CQ name
CqService cqService = crHelper.getCache().getCqService();
cqService.start();
// String cqNameWithClientId = new String(cqName + "__" +
// getMembershipID());
String serverCqName = cqName;
if (id != null) {
serverCqName = cqService.constructServerCqName(cqName, id);
}
InternalCqQuery cqQuery = cqService.getCq(serverCqName);
this.securityService.authorizeDataManage();
AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
if (authzRequest != null) {
String queryStr = null;
Set cqRegionNames = null;
if (cqQuery != null) {
queryStr = cqQuery.getQueryString();
cqRegionNames = new HashSet();
cqRegionNames.add(((CqQueryImpl) cqQuery).getRegionName());
}
authzRequest.stopCQAuthorize(cqName, queryStr, cqRegionNames);
}
cqService.stopCq(cqName, id);
if (cqQuery != null)
serverConnection.removeCq(cqName, cqQuery.isDurable());
} catch (CqException cqe) {
sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe, serverConnection);
return;
} catch (Exception e) {
String err = LocalizedStrings.StopCQ_EXCEPTION_WHILE_STOPPING_CQ_NAMED_0.toLocalizedString(cqName);
sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, err, clientMessage.getTransactionId(), e, serverConnection);
return;
}
// Send OK to client
sendCqResponse(MessageType.REPLY, LocalizedStrings.StopCQ_CQ_STOPPED_SUCCESSFULLY.toLocalizedString(), clientMessage.getTransactionId(), null, serverConnection);
serverConnection.setAsTrue(RESPONDED);
{
long oldStart = start;
start = DistributionStats.getStatTime();
stats.incProcessStopCqTime(start - oldStart);
}
}
use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.
the class WANTestBase method checkExceptionStats.
public static void checkExceptionStats(int exceptionsOccurred) {
Set<GatewayReceiver> gatewayReceivers = cache.getGatewayReceivers();
GatewayReceiver receiver = gatewayReceivers.iterator().next();
CacheServerStats stats = ((CacheServerImpl) receiver.getServer()).getAcceptor().getStats();
assertTrue(stats instanceof GatewayReceiverStats);
GatewayReceiverStats gatewayReceiverStats = (GatewayReceiverStats) stats;
if (exceptionsOccurred == 0) {
assertEquals(exceptionsOccurred, gatewayReceiverStats.getExceptionsOccurred());
} else {
assertTrue(gatewayReceiverStats.getExceptionsOccurred() >= exceptionsOccurred);
}
}
use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.
the class WANTestBase method checkMinimumGatewayReceiverStats.
public static void checkMinimumGatewayReceiverStats(int processBatches, int eventsReceived) {
Set<GatewayReceiver> gatewayReceivers = cache.getGatewayReceivers();
GatewayReceiver receiver = gatewayReceivers.iterator().next();
CacheServerStats stats = ((CacheServerImpl) receiver.getServer()).getAcceptor().getStats();
assertTrue(stats instanceof GatewayReceiverStats);
GatewayReceiverStats gatewayReceiverStats = (GatewayReceiverStats) stats;
assertTrue(gatewayReceiverStats.getProcessBatchRequests() >= processBatches);
assertTrue(gatewayReceiverStats.getEventsReceived() >= eventsReceived);
}
use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.
the class ContainsKeyTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Region region = mock(LocalRegion.class);
when(region.containsKey(isA(String.class))).thenReturn(true);
InternalCache cache = mock(InternalCache.class);
when(cache.getRegion(isA(String.class))).thenReturn(region);
CacheServerStats cacheServerStats = mock(CacheServerStats.class);
when(this.serverConnection.getCache()).thenReturn(cache);
when(this.serverConnection.getCacheServerStats()).thenReturn(cacheServerStats);
when(this.serverConnection.getResponseMessage()).thenReturn(this.replyMessage);
when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest);
when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage);
Part regionNamePart = mock(Part.class);
when(regionNamePart.getString()).thenReturn(REGION_NAME);
Part keyPart = mock(Part.class);
when(keyPart.getStringOrObject()).thenReturn(KEY);
when(this.message.getPart(eq(0))).thenReturn(regionNamePart);
when(this.message.getPart(eq(1))).thenReturn(keyPart);
}
Aggregations