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();
}
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"));
}
}
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);
// }
}
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
}
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
}
Aggregations