Search in sources :

Example 26 with StringId

use of org.apache.geode.i18n.StringId in project geode by apache.

the class DiskStoreImpl method handleDiskAccessException.

void handleDiskAccessException(final DiskAccessException dae) {
    boolean causedByRDE = LocalRegion.causedByRDE(dae);
    // I think they need to keep working (for other regions) in this case.
    if (causedByRDE) {
        return;
    }
    // If another thread has already hit a DAE and is cleaning up, do nothing
    if (!diskException.compareAndSet(null, dae)) {
        return;
    }
    // log the error
    final StringId sid = LocalizedStrings.LocalRegion_A_DISKACCESSEXCEPTION_HAS_OCCURRED_WHILE_WRITING_TO_THE_DISK_FOR_DISKSTORE_0_THE_CACHE_WILL_BE_CLOSED;
    logger.error(LocalizedMessage.create(sid, DiskStoreImpl.this.getName()), dae);
    final ThreadGroup exceptionHandlingGroup = LoggingThreadGroup.createThreadGroup("Disk Store Exception Handling Group", logger);
    Thread thread = new Thread(exceptionHandlingGroup, "Disk store exception handler") {

        public void run() {
            try {
                // now close the cache
                getCache().close(sid.toLocalizedString(DiskStoreImpl.this.getName(), dae), dae);
                _testHandleDiskAccessException.countDown();
            } catch (Exception e) {
                logger.error(LocalizedMessage.create(LocalizedStrings.LocalRegion_AN_EXCEPTION_OCCURRED_WHILE_CLOSING_THE_CACHE), e);
            }
        }
    };
    thread.start();
}
Also used : StringId(org.apache.geode.i18n.StringId) LoggingThreadGroup(org.apache.geode.internal.logging.LoggingThreadGroup) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) ClosedByInterruptException(java.nio.channels.ClosedByInterruptException) IOException(java.io.IOException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheClosedException(org.apache.geode.cache.CacheClosedException)

Example 27 with StringId

use of org.apache.geode.i18n.StringId in project geode by apache.

the class InitialImageFlowControl method basicWait.

private void basicWait(long startWaitTime) throws InterruptedException {
    long timeout = getAckWaitThreshold() * 1000L;
    long timeSoFar = System.currentTimeMillis() - startWaitTime;
    if (timeout <= 0) {
        timeout = Long.MAX_VALUE;
    }
    if (!aborted.get() && !permits.tryAcquire(timeout - timeSoFar - 1, TimeUnit.MILLISECONDS)) {
        checkCancellation();
        Set activeMembers = dm.getDistributionManagerIds();
        final Object[] msgArgs = new Object[] { getAckWaitThreshold(), this, dm.getId(), activeMembers };
        final StringId msg = LocalizedStrings.ReplyProcessor21_0_SEC_HAVE_ELAPSED_WHILE_WAITING_FOR_REPLIES_1_ON_2_WHOSE_CURRENT_MEMBERSHIP_LIST_IS_3;
        logger.warn(LocalizedMessage.create(msg, msgArgs));
        permits.acquire();
        // Give an info message since timeout gave a warning.
        logger.info(LocalizedMessage.create(LocalizedStrings.ReplyProcessor21_WAIT_FOR_REPLIES_COMPLETED_1, "InitialImageFlowControl"));
    }
}
Also used : Set(java.util.Set) StringId(org.apache.geode.i18n.StringId)

Example 28 with StringId

use of org.apache.geode.i18n.StringId in project geode by apache.

the class UnregisterInterest method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws ClassNotFoundException, IOException {
    Part regionNamePart = null, keyPart = null;
    String regionName = null;
    Object key = null;
    int interestType = 0;
    StringId errMessage = null;
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    regionNamePart = clientMessage.getPart(0);
    interestType = clientMessage.getPart(1).getInt();
    keyPart = clientMessage.getPart(2);
    Part isClosingPart = clientMessage.getPart(3);
    byte[] isClosingPartBytes = (byte[]) isClosingPart.getObject();
    boolean isClosing = isClosingPartBytes[0] == 0x01;
    regionName = regionNamePart.getString();
    try {
        key = keyPart.getStringOrObject();
    } catch (Exception e) {
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean keepalive = false;
    try {
        Part keepalivePart = clientMessage.getPart(4);
        byte[] keepaliveBytes = (byte[]) keepalivePart.getObject();
        keepalive = keepaliveBytes[0] != 0x00;
    } catch (Exception e) {
        writeException(clientMessage, e, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Received unregister interest request ({} bytes) from {} for region {} key {}", serverConnection.getName(), clientMessage.getPayloadLength(), serverConnection.getSocketString(), regionName, key);
    }
    // Process the unregister interest request
    if ((key == null) && (regionName == null)) {
        errMessage = LocalizedStrings.UnRegisterInterest_THE_INPUT_REGION_NAME_AND_KEY_FOR_THE_UNREGISTER_INTEREST_REQUEST_ARE_NULL;
    } else if (key == null) {
        errMessage = LocalizedStrings.UnRegisterInterest_THE_INPUT_KEY_FOR_THE_UNREGISTER_INTEREST_REQUEST_IS_NULL;
    } else if (regionName == null) {
        errMessage = LocalizedStrings.UnRegisterInterest_THE_INPUT_REGION_NAME_FOR_THE_UNREGISTER_INTEREST_REQUEST_IS_NULL;
        String s = errMessage.toLocalizedString();
        logger.warn("{}: {}", serverConnection.getName(), s);
        writeErrorResponse(clientMessage, MessageType.UNREGISTER_INTEREST_DATA_ERROR, s, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    try {
        if (interestType == InterestType.REGULAR_EXPRESSION) {
            this.securityService.authorizeRegionRead(regionName);
        } else {
            this.securityService.authorizeRegionRead(regionName, key.toString());
        }
    } catch (NotAuthorizedException ex) {
        writeException(clientMessage, ex, false, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
    if (authzRequest != null) {
        if (!DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
            try {
                UnregisterInterestOperationContext unregisterContext = authzRequest.unregisterInterestAuthorize(regionName, key, interestType);
                key = unregisterContext.getKey();
            } catch (NotAuthorizedException ex) {
                writeException(clientMessage, ex, false, serverConnection);
                serverConnection.setAsTrue(RESPONDED);
                return;
            }
        }
    }
    // Yogesh : bug fix for 36457 :
    /*
     * Region destroy message from server to client results in client calling unregister to server
     * (an unnecessary callback). The unregister encounters an error because the region has been
     * destroyed on the server and hence falsely marks the server dead.
     */
    /*
     * Region region = crHelper.getRegion(regionName); if (region == null) {
     * logger.warning(this.name + ": Region named " + regionName + " was not found during unregister
     * interest request"); writeErrorResponse(msg, MessageType.UNREGISTER_INTEREST_DATA_ERROR);
     * responded = true; } else {
     */
    // Unregister interest irrelevent of whether the region is present it or
    // not
    serverConnection.getAcceptor().getCacheClientNotifier().unregisterClientInterest(regionName, key, interestType, isClosing, serverConnection.getProxyID(), keepalive);
    // Update the statistics and write the reply
    // bserverStats.incLong(processDestroyTimeId,
    // DistributionStats.getStatTime() - start);
    // start = DistributionStats.getStatTime();
    writeReply(clientMessage, serverConnection);
    serverConnection.setAsTrue(RESPONDED);
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Sent unregister interest response for region {} key {}", serverConnection.getName(), regionName, key);
    }
// bserverStats.incLong(writeDestroyResponseTimeId,
// DistributionStats.getStatTime() - start);
// bserverStats.incInt(destroyResponsesId, 1);
// }
}
Also used : StringId(org.apache.geode.i18n.StringId) AuthorizeRequest(org.apache.geode.internal.security.AuthorizeRequest) Part(org.apache.geode.internal.cache.tier.sockets.Part) UnregisterInterestOperationContext(org.apache.geode.cache.operations.UnregisterInterestOperationContext) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) IOException(java.io.IOException) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException)

Example 29 with StringId

use of org.apache.geode.i18n.StringId in project geode by apache.

the class RegisterInterest method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, InterruptedException {
    Part regionNamePart = null, keyPart = null;
    String regionName = null;
    Object key = null;
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
    // bserverStats.incLong(readDestroyRequestTimeId,
    // DistributionStats.getStatTime() - start);
    // bserverStats.incInt(destroyRequestsId, 1);
    // start = DistributionStats.getStatTime();
    // Retrieve the data from the message parts
    regionNamePart = clientMessage.getPart(0);
    regionName = regionNamePart.getString();
    InterestResultPolicy policy = null;
    // Retrieve the interest type
    int interestType = clientMessage.getPart(1).getInt();
    // Retrieve the InterestResultPolicy
    try {
        policy = (InterestResultPolicy) clientMessage.getPart(2).getObject();
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean isDurable = false;
    try {
        Part durablePart = clientMessage.getPart(3);
        byte[] durablePartBytes = (byte[]) durablePart.getObject();
        isDurable = durablePartBytes[0] == 0x01;
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // Retrieve the key
    keyPart = clientMessage.getPart(4);
    regionName = regionNamePart.getString();
    try {
        key = keyPart.getStringOrObject();
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean sendUpdatesAsInvalidates = false;
    // time being until refactoring into a new command version.
    if (clientMessage.getNumberOfParts() > 5) {
        try {
            Part notifyPart = clientMessage.getPart(5);
            byte[] notifyPartBytes = (byte[]) notifyPart.getObject();
            sendUpdatesAsInvalidates = notifyPartBytes[0] == 0x01;
        } catch (Exception e) {
            writeChunkedException(clientMessage, e, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Received register interest request ({} bytes) from {} for region {} key {}", serverConnection.getName(), clientMessage.getPayloadLength(), serverConnection.getSocketString(), regionName, key);
    }
    // Process the register interest request
    if (key == null || regionName == null) {
        StringId message = null;
        if (key == null) {
            message = LocalizedStrings.RegisterInterest_THE_INPUT_KEY_FOR_THE_REGISTER_INTEREST_REQUEST_IS_NULL;
        }
        if (regionName == null) {
            message = LocalizedStrings.RegisterInterest_THE_INPUT_REGION_NAME_FOR_THE_REGISTER_INTEREST_REQUEST_IS_NULL;
        }
        logger.warn("{}: {}", serverConnection.getName(), message.toLocalizedString());
        writeChunkedErrorResponse(clientMessage, MessageType.REGISTER_INTEREST_DATA_ERROR, message.toLocalizedString(), serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // input key not null
    LocalRegion region = (LocalRegion) serverConnection.getCache().getRegion(regionName);
    if (region == null) {
        logger.info(LocalizedMessage.create(LocalizedStrings.RegisterInterest_0_REGION_NAMED_1_WAS_NOT_FOUND_DURING_REGISTER_INTEREST_REQUEST, new Object[] { serverConnection.getName(), regionName }));
    // writeChunkedErrorResponse(msg,
    // MessageType.REGISTER_INTEREST_DATA_ERROR, message);
    // responded = true;
    }
    // Register interest
    try {
        if (interestType == InterestType.REGULAR_EXPRESSION) {
            this.securityService.authorizeRegionRead(regionName);
        } else {
            this.securityService.authorizeRegionRead(regionName, key.toString());
        }
        AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
        if (authzRequest != null) {
            if (!DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
                RegisterInterestOperationContext registerContext = authzRequest.registerInterestAuthorize(regionName, key, interestType, policy);
                key = registerContext.getKey();
            }
        }
        serverConnection.getAcceptor().getCacheClientNotifier().registerClientInterest(regionName, key, serverConnection.getProxyID(), interestType, isDurable, sendUpdatesAsInvalidates, false, 0, true);
    } catch (Exception e) {
        // If an interrupted exception is thrown , rethrow it
        checkForInterrupt(serverConnection, e);
        // Otherwise, write an exception message and continue
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // System.out.println("Received register interest for " + regionName);
    // Update the statistics and write the reply
    // bserverStats.incLong(processDestroyTimeId,
    // DistributionStats.getStatTime() - start);
    // start = DistributionStats.getStatTime();
    CacheClientProxy ccp = serverConnection.getAcceptor().getCacheClientNotifier().getClientProxy(serverConnection.getProxyID());
    if (ccp == null) {
        // fix for 37593
        IOException ioex = new IOException(LocalizedStrings.RegisterInterest_CACHECLIENTPROXY_FOR_THIS_CLIENT_IS_NO_LONGER_ON_THE_SERVER_SO_REGISTERINTEREST_OPERATION_IS_UNSUCCESSFUL.toLocalizedString());
        writeChunkedException(clientMessage, ioex, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean isPrimary = ccp.isPrimary();
    ChunkedMessage chunkedResponseMsg = serverConnection.getRegisterInterestResponseMessage();
    if (!isPrimary) {
        chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_SECONDARY);
        chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId());
        chunkedResponseMsg.sendHeader();
        chunkedResponseMsg.setLastChunk(true);
        if (logger.isDebugEnabled()) {
            logger.debug("{}: Sending register interest response chunk from secondary for region: {} for key: {} chunk=<{}>", serverConnection.getName(), regionName, key, chunkedResponseMsg);
        }
        chunkedResponseMsg.sendChunk(serverConnection);
    } else // !isPrimary
    {
        // isPrimary
        // Send header which describes how many chunks will follow
        chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_PRIMARY);
        chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId());
        chunkedResponseMsg.sendHeader();
        // Send chunk response
        try {
            fillAndSendRegisterInterestResponseChunks(region, key, interestType, policy, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
        } catch (Exception e) {
            writeChunkedException(clientMessage, e, serverConnection, chunkedResponseMsg);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
        if (logger.isDebugEnabled()) {
            // logger.debug(getName() + ": Sent chunk (1 of 1) of register interest
            // response (" + chunkedResponseMsg.getBufferLength() + " bytes) for
            // region " + regionName + " key " + key);
            logger.debug("{}: Sent register interest response for region {} key {}", serverConnection.getName(), regionName, key);
        }
    // bserverStats.incLong(writeDestroyResponseTimeId,
    // DistributionStats.getStatTime() - start);
    // bserverStats.incInt(destroyResponsesId, 1);
    }
// isPrimary
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) AuthorizeRequest(org.apache.geode.internal.security.AuthorizeRequest) RegisterInterestOperationContext(org.apache.geode.cache.operations.RegisterInterestOperationContext) LocalRegion(org.apache.geode.internal.cache.LocalRegion) IOException(java.io.IOException) IOException(java.io.IOException) InterestResultPolicy(org.apache.geode.cache.InterestResultPolicy) StringId(org.apache.geode.i18n.StringId) Part(org.apache.geode.internal.cache.tier.sockets.Part) ChunkedMessage(org.apache.geode.internal.cache.tier.sockets.ChunkedMessage)

Example 30 with StringId

use of org.apache.geode.i18n.StringId in project geode by apache.

the class RegisterInterest61 method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, InterruptedException {
    Part regionNamePart = null, keyPart = null;
    String regionName = null;
    Object key = null;
    CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
    // bserverStats.incLong(readDestroyRequestTimeId,
    // DistributionStats.getStatTime() - start);
    // bserverStats.incInt(destroyRequestsId, 1);
    // start = DistributionStats.getStatTime();
    // Retrieve the data from the message parts
    regionNamePart = clientMessage.getPart(0);
    regionName = regionNamePart.getString();
    InterestResultPolicy policy = null;
    // Retrieve the interest type
    int interestType = clientMessage.getPart(1).getInt();
    // Retrieve the InterestResultPolicy
    try {
        policy = (InterestResultPolicy) clientMessage.getPart(2).getObject();
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean isDurable = false;
    try {
        Part durablePart = clientMessage.getPart(3);
        byte[] durablePartBytes = (byte[]) durablePart.getObject();
        isDurable = durablePartBytes[0] == 0x01;
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // region data policy
    byte[] regionDataPolicyPartBytes;
    boolean serializeValues = false;
    try {
        Part regionDataPolicyPart = clientMessage.getPart(clientMessage.getNumberOfParts() - 1);
        regionDataPolicyPartBytes = (byte[]) regionDataPolicyPart.getObject();
        if (serverConnection.getClientVersion().compareTo(Version.GFE_80) >= 0) {
            // The second byte here is serializeValues
            serializeValues = regionDataPolicyPartBytes[1] == (byte) 0x01;
        }
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // Retrieve the key
    keyPart = clientMessage.getPart(4);
    regionName = regionNamePart.getString();
    try {
        key = keyPart.getStringOrObject();
    } catch (Exception e) {
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean sendUpdatesAsInvalidates = false;
    // time being until refactoring into a new command version.
    if (clientMessage.getNumberOfParts() > 5) {
        try {
            Part notifyPart = clientMessage.getPart(5);
            byte[] notifyPartBytes = (byte[]) notifyPart.getObject();
            sendUpdatesAsInvalidates = notifyPartBytes[0] == 0x01;
        } catch (Exception e) {
            writeChunkedException(clientMessage, e, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Received register interest 61 request ({} bytes) from {} for region {} key {}", serverConnection.getName(), clientMessage.getPayloadLength(), serverConnection.getSocketString(), regionName, key);
    }
    if (VMOTION_DURING_REGISTER_INTEREST_FLAG) {
        VMotionObserver vmo = VMotionObserverHolder.getInstance();
        vmo.vMotionBeforeRegisterInterest();
    }
    // Process the register interest request
    if (key == null || regionName == null) {
        StringId message = null;
        if (key == null) {
            message = LocalizedStrings.RegisterInterest_THE_INPUT_KEY_FOR_THE_REGISTER_INTEREST_REQUEST_IS_NULL;
        }
        if (regionName == null) {
            message = LocalizedStrings.RegisterInterest_THE_INPUT_REGION_NAME_FOR_THE_REGISTER_INTEREST_REQUEST_IS_NULL;
        }
        logger.warn("{}: {}", serverConnection.getName(), message.toLocalizedString());
        writeChunkedErrorResponse(clientMessage, MessageType.REGISTER_INTEREST_DATA_ERROR, message.toLocalizedString(), serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // input key not null
    LocalRegion region = (LocalRegion) serverConnection.getCache().getRegion(regionName);
    if (region == null) {
        logger.info(LocalizedMessage.create(LocalizedStrings.RegisterInterest_0_REGION_NAMED_1_WAS_NOT_FOUND_DURING_REGISTER_INTEREST_REQUEST, new Object[] { serverConnection.getName(), regionName }));
    // writeChunkedErrorResponse(msg,
    // MessageType.REGISTER_INTEREST_DATA_ERROR, message);
    // responded = true;
    }
    // Register interest
    try {
        if (interestType == InterestType.REGULAR_EXPRESSION) {
            this.securityService.authorizeRegionRead(regionName);
        } else {
            this.securityService.authorizeRegionRead(regionName, key.toString());
        }
        AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
        if (authzRequest != null) {
            if (!DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
                RegisterInterestOperationContext registerContext = authzRequest.registerInterestAuthorize(regionName, key, interestType, policy);
                key = registerContext.getKey();
            }
        }
        serverConnection.getAcceptor().getCacheClientNotifier().registerClientInterest(regionName, key, serverConnection.getProxyID(), interestType, isDurable, sendUpdatesAsInvalidates, true, regionDataPolicyPartBytes[0], true);
    } catch (Exception e) {
        // If an interrupted exception is thrown , rethrow it
        checkForInterrupt(serverConnection, e);
        // Otherwise, write an exception message and continue
        writeChunkedException(clientMessage, e, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    // System.out.println("Received register interest for " + regionName);
    // Update the statistics and write the reply
    // bserverStats.incLong(processDestroyTimeId,
    // DistributionStats.getStatTime() - start);
    // start = DistributionStats.getStatTime();
    CacheClientProxy ccp = serverConnection.getAcceptor().getCacheClientNotifier().getClientProxy(serverConnection.getProxyID());
    if (ccp == null) {
        // fix for 37593
        IOException ioex = new IOException(LocalizedStrings.RegisterInterest_CACHECLIENTPROXY_FOR_THIS_CLIENT_IS_NO_LONGER_ON_THE_SERVER_SO_REGISTERINTEREST_OPERATION_IS_UNSUCCESSFUL.toLocalizedString());
        writeChunkedException(clientMessage, ioex, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        return;
    }
    boolean isPrimary = ccp.isPrimary();
    ChunkedMessage chunkedResponseMsg = serverConnection.getRegisterInterestResponseMessage();
    if (!isPrimary) {
        chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_SECONDARY);
        chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId());
        chunkedResponseMsg.sendHeader();
        chunkedResponseMsg.setLastChunk(true);
        if (logger.isDebugEnabled()) {
            logger.debug("{}: Sending register interest response chunk from secondary for region: {} for key: {} chunk=<{}>", serverConnection.getName(), regionName, key, chunkedResponseMsg);
        }
        chunkedResponseMsg.sendChunk(serverConnection);
    } else // !isPrimary
    {
        // isPrimary
        // Send header which describes how many chunks will follow
        chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_PRIMARY);
        chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId());
        chunkedResponseMsg.sendHeader();
        // Send chunk response
        try {
            fillAndSendRegisterInterestResponseChunks(region, key, interestType, serializeValues, policy, serverConnection);
            serverConnection.setAsTrue(RESPONDED);
        } catch (Exception e) {
            writeChunkedException(clientMessage, e, serverConnection, chunkedResponseMsg);
            serverConnection.setAsTrue(RESPONDED);
            return;
        }
        if (logger.isDebugEnabled()) {
            // logger.debug(getName() + ": Sent chunk (1 of 1) of register interest
            // response (" + chunkedResponseMsg.getBufferLength() + " bytes) for
            // region " + regionName + " key " + key);
            logger.debug("{}: Sent register interest response for region {} key {}", serverConnection.getName(), regionName, key);
        }
    // bserverStats.incLong(writeDestroyResponseTimeId,
    // DistributionStats.getStatTime() - start);
    // bserverStats.incInt(destroyResponsesId, 1);
    }
// isPrimary
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) AuthorizeRequest(org.apache.geode.internal.security.AuthorizeRequest) RegisterInterestOperationContext(org.apache.geode.cache.operations.RegisterInterestOperationContext) VMotionObserver(org.apache.geode.internal.cache.vmotion.VMotionObserver) LocalRegion(org.apache.geode.internal.cache.LocalRegion) IOException(java.io.IOException) IOException(java.io.IOException) CachedRegionHelper(org.apache.geode.internal.cache.tier.CachedRegionHelper) InterestResultPolicy(org.apache.geode.cache.InterestResultPolicy) StringId(org.apache.geode.i18n.StringId) Part(org.apache.geode.internal.cache.tier.sockets.Part) ChunkedMessage(org.apache.geode.internal.cache.tier.sockets.ChunkedMessage)

Aggregations

StringId (org.apache.geode.i18n.StringId)43 IOException (java.io.IOException)14 AuthorizeRequest (org.apache.geode.internal.security.AuthorizeRequest)11 LocalRegion (org.apache.geode.internal.cache.LocalRegion)10 CachedRegionHelper (org.apache.geode.internal.cache.tier.CachedRegionHelper)8 Part (org.apache.geode.internal.cache.tier.sockets.Part)8 TimeoutException (org.apache.geode.cache.TimeoutException)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 CancelException (org.apache.geode.CancelException)4 InterestResultPolicy (org.apache.geode.cache.InterestResultPolicy)4 RegisterInterestOperationContext (org.apache.geode.cache.operations.RegisterInterestOperationContext)4 CqClosedException (org.apache.geode.cache.query.CqClosedException)4 CqException (org.apache.geode.cache.query.CqException)4 CqExistsException (org.apache.geode.cache.query.CqExistsException)4 QueryException (org.apache.geode.cache.query.QueryException)4 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)4 LinkedHashSet (java.util.LinkedHashSet)3