Search in sources :

Example 11 with CacheServerStats

use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.

the class CacheServerStatsJUnitTest method init.

public void init() {
    cacheServerStats = new CacheServerStats("Test Sock Name");
    bridge = new CacheServerBridge();
    bridge.addCacheServerStats(cacheServerStats);
}
Also used : CacheServerStats(org.apache.geode.internal.cache.tier.sockets.CacheServerStats) CacheServerBridge(org.apache.geode.management.internal.beans.CacheServerBridge)

Example 12 with CacheServerStats

use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.

the class Get70 method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long startparam) throws IOException {
    long start = startparam;
    Part regionNamePart = null, keyPart = null, valuePart = null;
    String regionName = null;
    Object callbackArg = null, key = null;
    CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
    CacheServerStats stats = serverConnection.getCacheServerStats();
    StringId errMessage = null;
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    // requiresResponse = true;
    {
        long oldStart = start;
        start = DistributionStats.getStatTime();
        stats.incReadGetRequestTime(start - oldStart);
    }
    // Retrieve the data from the message parts
    int parts = clientMessage.getNumberOfParts();
    regionNamePart = clientMessage.getPart(0);
    keyPart = clientMessage.getPart(1);
    // valuePart = null; (redundant assignment)
    if (parts > 2) {
        valuePart = clientMessage.getPart(2);
        try {
            callbackArg = valuePart.getObject();
        } catch (Exception e) {
            writeException(clientMessage, e, false, serverConnection);
            // responded = true;
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
    }
    regionName = regionNamePart.getString();
    try {
        key = keyPart.getStringOrObject();
    } catch (Exception e) {
        writeException(clientMessage, e, false, serverConnection);
        // responded = true;
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Received 7.0 get request ({} bytes) from {} for region {} key {} txId {}", serverConnection.getName(), clientMessage.getPayloadLength(), serverConnection.getSocketString(), regionName, key, clientMessage.getTransactionId());
    }
    // Process the get request
    if (key == null || regionName == null) {
        if ((key == null) && (regionName == null)) {
            errMessage = LocalizedStrings.Request_THE_INPUT_REGION_NAME_AND_KEY_FOR_THE_GET_REQUEST_ARE_NULL;
        } else if (key == null) {
            errMessage = LocalizedStrings.Request_THE_INPUT_KEY_FOR_THE_GET_REQUEST_IS_NULL;
        } else if (regionName == null) {
            errMessage = LocalizedStrings.Request_THE_INPUT_REGION_NAME_FOR_THE_GET_REQUEST_IS_NULL;
        }
        String s = errMessage.toLocalizedString();
        logger.warn("{}: {}", serverConnection.getName(), s);
        writeErrorResponse(clientMessage, MessageType.REQUESTDATAERROR, s, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    Region region = serverConnection.getCache().getRegion(regionName);
    if (region == null) {
        String reason = LocalizedStrings.Request__0_WAS_NOT_FOUND_DURING_GET_REQUEST.toLocalizedString(regionName);
        writeRegionDestroyedEx(clientMessage, regionName, reason, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    GetOperationContext getContext = null;
    try {
        // for integrated security
        this.securityService.authorizeRegionRead(regionName, key.toString());
        AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
        if (authzRequest != null) {
            getContext = authzRequest.getAuthorize(regionName, key, callbackArg);
            callbackArg = getContext.getCallbackArg();
        }
    } catch (NotAuthorizedException ex) {
        writeException(clientMessage, ex, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // Get the value and update the statistics. Do not deserialize
    // the value if it is a byte[].
    Entry entry;
    try {
        entry = getEntry(region, key, callbackArg, serverConnection);
    } catch (Exception e) {
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    @Retained final Object originalData = entry.value;
    Object data = originalData;
    try {
        boolean isObject = entry.isObject;
        VersionTag versionTag = entry.versionTag;
        boolean keyNotPresent = entry.keyNotPresent;
        try {
            AuthorizeRequestPP postAuthzRequest = serverConnection.getPostAuthzRequest();
            if (postAuthzRequest != null) {
                try {
                    getContext = postAuthzRequest.getAuthorize(regionName, key, data, isObject, getContext);
                    GetOperationContextImpl gci = (GetOperationContextImpl) getContext;
                    Object newData = gci.getRawValue();
                    if (newData != data) {
                        // user changed the value
                        isObject = getContext.isObject();
                        data = newData;
                    }
                } finally {
                    if (getContext != null) {
                        ((GetOperationContextImpl) getContext).release();
                    }
                }
            }
        } catch (NotAuthorizedException ex) {
            writeException(clientMessage, ex, false, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
        // post process
        data = this.securityService.postProcess(regionName, key, data, entry.isObject);
        long oldStart = start;
        start = DistributionStats.getStatTime();
        stats.incProcessGetTime(start - oldStart);
        if (region instanceof PartitionedRegion) {
            PartitionedRegion pr = (PartitionedRegion) region;
            if (pr.getNetworkHopType() != PartitionedRegion.NETWORK_HOP_NONE) {
                writeResponseWithRefreshMetadata(data, callbackArg, clientMessage, isObject, serverConnection, pr, pr.getNetworkHopType(), versionTag, keyNotPresent);
                pr.clearNetworkHopData();
            } else {
                writeResponse(data, callbackArg, clientMessage, isObject, versionTag, keyNotPresent, serverConnection);
            }
        } else {
            writeResponse(data, callbackArg, clientMessage, isObject, versionTag, keyNotPresent, serverConnection);
        }
    } finally {
        OffHeapHelper.release(originalData);
    }
    serverConnection.setAsTrue(RESPONDED);
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Wrote get response back to {} for region {} {}", serverConnection.getName(), serverConnection.getSocketString(), regionName, entry);
    }
    stats.incWriteGetResponseTime(DistributionStats.getStatTime() - start);
}
Also used : AuthorizeRequest(org.apache.geode.internal.security.AuthorizeRequest) AuthorizeRequestPP(org.apache.geode.internal.security.AuthorizeRequestPP) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) GetOperationContextImpl(org.apache.geode.cache.operations.internal.GetOperationContextImpl) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) IOException(java.io.IOException) GetOperationContext(org.apache.geode.cache.operations.GetOperationContext) CachedRegionHelper(org.apache.geode.internal.cache.tier.CachedRegionHelper) StringId(org.apache.geode.i18n.StringId) Retained(org.apache.geode.internal.offheap.annotations.Retained) CacheServerStats(org.apache.geode.internal.cache.tier.sockets.CacheServerStats) Part(org.apache.geode.internal.cache.tier.sockets.Part) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Example 13 with CacheServerStats

use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.

the class Destroy65 method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, InterruptedException {
    Part regionNamePart;
    Part keyPart;
    Part callbackArgPart;
    Part eventPart;
    Part expectedOldValuePart;
    Object operation = null;
    Object expectedOldValue = null;
    String regionName = null;
    Object callbackArg = null, key = null;
    StringBuffer errMessage = new StringBuffer();
    CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
    CacheServerStats stats = serverConnection.getCacheServerStats();
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    long now = DistributionStats.getStatTime();
    stats.incReadDestroyRequestTime(now - start);
    // Retrieve the data from the message parts
    regionNamePart = clientMessage.getPart(0);
    keyPart = clientMessage.getPart(1);
    expectedOldValuePart = clientMessage.getPart(2);
    try {
        operation = clientMessage.getPart(3).getObject();
        if (((operation instanceof Operation) && ((Operation) operation == Operation.REMOVE)) || ((operation instanceof Byte) && (Byte) operation == OpType.DESTROY)) {
            expectedOldValue = expectedOldValuePart.getObject();
        }
    } catch (Exception e) {
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    eventPart = clientMessage.getPart(4);
    if (clientMessage.getNumberOfParts() > 5) {
        callbackArgPart = clientMessage.getPart(5);
        try {
            callbackArg = callbackArgPart.getObject();
        } catch (Exception e) {
            writeException(clientMessage, e, false, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
    }
    regionName = regionNamePart.getString();
    try {
        key = keyPart.getStringOrObject();
    } catch (Exception e) {
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Received destroy65 request ({} bytes; op={}) from {} for region {} key {}{} txId {}", serverConnection.getName(), clientMessage.getPayloadLength(), operation, serverConnection.getSocketString(), regionName, key, (operation == Operation.REMOVE ? " value=" + expectedOldValue : ""), clientMessage.getTransactionId());
    }
    boolean entryNotFoundForRemove = false;
    // Process the destroy request
    if (key == null || regionName == null) {
        if (key == null) {
            logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL, serverConnection.getName()));
            errMessage.append(LocalizedStrings.Destroy__THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
        }
        if (regionName == null) {
            logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL, serverConnection.getName()));
            errMessage.append(LocalizedStrings.Destroy__THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
        }
        writeErrorResponse(clientMessage, MessageType.DESTROY_DATA_ERROR, errMessage.toString(), serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    LocalRegion region = (LocalRegion) serverConnection.getCache().getRegion(regionName);
    if (region == null) {
        String reason = LocalizedStrings.Destroy__0_WAS_NOT_FOUND_DURING_DESTROY_REQUEST.toLocalizedString(regionName);
        writeRegionDestroyedEx(clientMessage, regionName, reason, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // Destroy the entry
    ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart.getSerializedForm());
    long threadId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
    long sequenceId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
    EventID eventId = new EventID(serverConnection.getEventMemberIDByteArray(), threadId, sequenceId);
    EventIDHolder clientEvent = new EventIDHolder(eventId);
    Breadcrumbs.setEventId(eventId);
    // msg.isRetry might be set by v7.0 and later clients
    if (clientMessage.isRetry()) {
        // if (logger.isDebugEnabled()) {
        // logger.debug("DEBUG: encountered isRetry in Destroy65");
        // }
        clientEvent.setPossibleDuplicate(true);
        if (region.getAttributes().getConcurrencyChecksEnabled()) {
            // recover the version tag from other servers
            clientEvent.setRegion(region);
            if (!recoverVersionTagForRetriedOperation(clientEvent)) {
                // no-one has seen this event
                clientEvent.setPossibleDuplicate(false);
            }
        }
    }
    try {
        // for integrated security
        this.securityService.authorizeRegionWrite(regionName, key.toString());
        AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
        if (authzRequest != null) {
            if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
                RegionDestroyOperationContext destroyContext = authzRequest.destroyRegionAuthorize((String) key, callbackArg);
                callbackArg = destroyContext.getCallbackArg();
            } else {
                DestroyOperationContext destroyContext = authzRequest.destroyAuthorize(regionName, key, callbackArg);
                callbackArg = destroyContext.getCallbackArg();
            }
        }
        if (operation == null || operation == Operation.DESTROY) {
            region.basicBridgeDestroy(key, callbackArg, serverConnection.getProxyID(), true, clientEvent);
        } else {
            // this throws exceptions if expectedOldValue checks fail
            try {
                if (expectedOldValue == null) {
                    expectedOldValue = Token.INVALID;
                }
                if (operation == Operation.REMOVE && clientMessage.isRetry() && clientEvent.getVersionTag() != null) {
                    // success status
                    if (logger.isDebugEnabled()) {
                        logger.debug("remove(k,v) operation was successful last time with version {}", clientEvent.getVersionTag());
                    }
                    // try the operation anyway to ensure that it's been distributed to all servers
                    try {
                        region.basicBridgeRemove(key, expectedOldValue, callbackArg, serverConnection.getProxyID(), true, clientEvent);
                    } catch (EntryNotFoundException e) {
                    // ignore, and don't set entryNotFoundForRemove because this was a successful
                    // operation - bug #51664
                    }
                } else {
                    region.basicBridgeRemove(key, expectedOldValue, callbackArg, serverConnection.getProxyID(), true, clientEvent);
                    if (logger.isDebugEnabled()) {
                        logger.debug("region.remove succeeded");
                    }
                }
            } catch (EntryNotFoundException e) {
                serverConnection.setModificationInfo(true, regionName, key);
                if (logger.isDebugEnabled()) {
                    logger.debug("writing entryNotFound response");
                }
                entryNotFoundForRemove = true;
            }
        }
        serverConnection.setModificationInfo(true, regionName, key);
    } catch (EntryNotFoundException e) {
        // Don't send an exception back to the client if this
        // exception happens. Just log it and continue.
        logger.info(LocalizedMessage.create(LocalizedStrings.Destroy_0_DURING_ENTRY_DESTROY_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] { serverConnection.getName(), key }));
        entryNotFoundForRemove = true;
    } catch (RegionDestroyedException rde) {
        writeException(clientMessage, rde, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    } catch (Exception e) {
        // If an interrupted exception is thrown , rethrow it
        checkForInterrupt(serverConnection, e);
        // If an exception occurs during the destroy, preserve the connection
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        if (e instanceof GemFireSecurityException) {
            // logged by the security logger
            if (logger.isDebugEnabled()) {
                logger.debug("{}: Unexpected Security exception", serverConnection.getName(), e);
            }
        } else {
            logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_UNEXPECTED_EXCEPTION, serverConnection.getName()), e);
        }
        return;
    }
    // Update the statistics and write the reply
    now = DistributionStats.getStatTime();
    stats.incProcessDestroyTime(now - start);
    if (region instanceof PartitionedRegion) {
        PartitionedRegion pr = (PartitionedRegion) region;
        if (pr.getNetworkHopType() != PartitionedRegion.NETWORK_HOP_NONE) {
            writeReplyWithRefreshMetadata(clientMessage, serverConnection, pr, entryNotFoundForRemove, pr.getNetworkHopType(), clientEvent.getVersionTag());
            pr.clearNetworkHopData();
        } else {
            writeReply(clientMessage, serverConnection, entryNotFoundForRemove | clientEvent.getIsRedestroyedEntry(), clientEvent.getVersionTag());
        }
    } else {
        writeReply(clientMessage, serverConnection, entryNotFoundForRemove | clientEvent.getIsRedestroyedEntry(), clientEvent.getVersionTag());
    }
    serverConnection.setAsTrue(RESPONDED);
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Sent destroy response for region {} key {}", serverConnection.getName(), regionName, key);
    }
    stats.incWriteDestroyResponseTime(DistributionStats.getStatTime() - start);
}
Also used : AuthorizeRequest(org.apache.geode.internal.security.AuthorizeRequest) EventIDHolder(org.apache.geode.internal.cache.EventIDHolder) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) Operation(org.apache.geode.cache.Operation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) ByteBuffer(java.nio.ByteBuffer) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) IOException(java.io.IOException) DestroyOperationContext(org.apache.geode.cache.operations.DestroyOperationContext) RegionDestroyOperationContext(org.apache.geode.cache.operations.RegionDestroyOperationContext) CachedRegionHelper(org.apache.geode.internal.cache.tier.CachedRegionHelper) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) RegionDestroyOperationContext(org.apache.geode.cache.operations.RegionDestroyOperationContext) CacheServerStats(org.apache.geode.internal.cache.tier.sockets.CacheServerStats) Part(org.apache.geode.internal.cache.tier.sockets.Part) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) EventID(org.apache.geode.internal.cache.EventID)

Example 14 with CacheServerStats

use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.

the class ClearRegion method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, InterruptedException {
    Part regionNamePart = null, callbackArgPart = null;
    String regionName = null;
    Object callbackArg = null;
    Part eventPart = null;
    CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
    CacheServerStats stats = serverConnection.getCacheServerStats();
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    {
        long oldStart = start;
        start = DistributionStats.getStatTime();
        stats.incReadClearRegionRequestTime(start - oldStart);
    }
    // Retrieve the data from the message parts
    regionNamePart = clientMessage.getPart(0);
    eventPart = clientMessage.getPart(1);
    // callbackArgPart = null; (redundant assignment)
    if (clientMessage.getNumberOfParts() > 2) {
        callbackArgPart = clientMessage.getPart(2);
        try {
            callbackArg = callbackArgPart.getObject();
        } catch (Exception e) {
            writeException(clientMessage, e, false, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
    }
    regionName = regionNamePart.getString();
    if (logger.isDebugEnabled()) {
        logger.debug(serverConnection.getName() + ": Received clear region request (" + clientMessage.getPayloadLength() + " bytes) from " + serverConnection.getSocketString() + " for region " + regionName);
    }
    // Process the clear region request
    if (regionName == null) {
        logger.warn(LocalizedMessage.create(LocalizedStrings.ClearRegion_0_THE_INPUT_REGION_NAME_FOR_THE_CLEAR_REGION_REQUEST_IS_NULL, serverConnection.getName()));
        String errMessage = LocalizedStrings.ClearRegion_THE_INPUT_REGION_NAME_FOR_THE_CLEAR_REGION_REQUEST_IS_NULL.toLocalizedString();
        writeErrorResponse(clientMessage, MessageType.CLEAR_REGION_DATA_ERROR, errMessage, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    LocalRegion region = (LocalRegion) crHelper.getRegion(regionName);
    if (region == null) {
        String reason = LocalizedStrings.ClearRegion_WAS_NOT_FOUND_DURING_CLEAR_REGION_REGUEST.toLocalizedString();
        writeRegionDestroyedEx(clientMessage, regionName, reason, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart.getSerializedForm());
    long threadId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
    long sequenceId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
    EventID eventId = new EventID(serverConnection.getEventMemberIDByteArray(), threadId, sequenceId);
    try {
        // Clear the region
        this.securityService.authorizeRegionWrite(regionName);
        AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
        if (authzRequest != null) {
            RegionClearOperationContext clearContext = authzRequest.clearAuthorize(regionName, callbackArg);
            callbackArg = clearContext.getCallbackArg();
        }
        region.basicBridgeClear(callbackArg, serverConnection.getProxyID(), true, /* boolean from cache Client */
        eventId);
    } catch (Exception e) {
        // If an interrupted exception is thrown , rethrow it
        checkForInterrupt(serverConnection, e);
        // If an exception occurs during the clear, preserve the connection
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // Update the statistics and write the reply
    {
        long oldStart = start;
        start = DistributionStats.getStatTime();
        stats.incProcessClearRegionTime(start - oldStart);
    }
    writeReply(clientMessage, serverConnection);
    serverConnection.setAsTrue(RESPONDED);
    if (logger.isDebugEnabled()) {
        logger.debug(serverConnection.getName() + ": Sent clear region response for region " + regionName);
    }
    stats.incWriteClearRegionResponseTime(DistributionStats.getStatTime() - start);
}
Also used : CachedRegionHelper(org.apache.geode.internal.cache.tier.CachedRegionHelper) CacheServerStats(org.apache.geode.internal.cache.tier.sockets.CacheServerStats) AuthorizeRequest(org.apache.geode.internal.security.AuthorizeRequest) Part(org.apache.geode.internal.cache.tier.sockets.Part) EventID(org.apache.geode.internal.cache.EventID) LocalRegion(org.apache.geode.internal.cache.LocalRegion) RegionClearOperationContext(org.apache.geode.cache.operations.RegionClearOperationContext) ByteBuffer(java.nio.ByteBuffer) IOException(java.io.IOException)

Example 15 with CacheServerStats

use of org.apache.geode.internal.cache.tier.sockets.CacheServerStats in project geode by apache.

the class CloseConnection method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException {
    CacheServerStats stats = serverConnection.getCacheServerStats();
    long oldStart = start;
    boolean respondToClient = serverConnection.getClientVersion().compareTo(Version.GFE_90) >= 0;
    start = DistributionStats.getStatTime();
    stats.incReadCloseConnectionRequestTime(start - oldStart);
    if (respondToClient) {
        // newer clients will wait for a response or EOFException
        serverConnection.setAsTrue(REQUIRES_RESPONSE);
    }
    try {
        serverConnection.setClientDisconnectCleanly();
        String clientHost = serverConnection.getSocketHost();
        int clientPort = serverConnection.getSocketPort();
        if (logger.isDebugEnabled()) {
            logger.debug("{}: Received close request ({} bytes) from {}:{}", serverConnection.getName(), clientMessage.getPayloadLength(), clientHost, clientPort);
        }
        Part keepalivePart = clientMessage.getPart(0);
        byte[] keepaliveByte = keepalivePart.getSerializedForm();
        boolean keepalive = (keepaliveByte == null || keepaliveByte[0] == 0) ? false : true;
        serverConnection.getAcceptor().getCacheClientNotifier().setKeepAlive(serverConnection.getProxyID(), keepalive);
        if (logger.isDebugEnabled()) {
            logger.debug("{}: Processed close request from {}:{}, keepAlive: {}", serverConnection.getName(), clientHost, clientPort, keepalive);
        }
    } finally {
        if (respondToClient) {
            writeReply(clientMessage, serverConnection);
        }
        serverConnection.setFlagProcessMessagesAsFalse();
        stats.incProcessCloseConnectionTime(DistributionStats.getStatTime() - start);
    }
}
Also used : CacheServerStats(org.apache.geode.internal.cache.tier.sockets.CacheServerStats) Part(org.apache.geode.internal.cache.tier.sockets.Part)

Aggregations

CacheServerStats (org.apache.geode.internal.cache.tier.sockets.CacheServerStats)31 IOException (java.io.IOException)23 Part (org.apache.geode.internal.cache.tier.sockets.Part)21 AuthorizeRequest (org.apache.geode.internal.security.AuthorizeRequest)21 LocalRegion (org.apache.geode.internal.cache.LocalRegion)18 CachedRegionHelper (org.apache.geode.internal.cache.tier.CachedRegionHelper)18 ByteBuffer (java.nio.ByteBuffer)12 EventID (org.apache.geode.internal.cache.EventID)12 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)11 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)11 ResourceException (org.apache.geode.cache.ResourceException)7 GemFireSecurityException (org.apache.geode.security.GemFireSecurityException)7 EventIDHolder (org.apache.geode.internal.cache.EventIDHolder)6 CqException (org.apache.geode.cache.query.CqException)5 CqService (org.apache.geode.cache.query.internal.cq.CqService)5 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)5 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)5 Set (java.util.Set)4 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)4 PutAllPartialResultException (org.apache.geode.internal.cache.PutAllPartialResultException)4