use of org.apache.geode.internal.cache.tier.sockets.Message in project geode by apache.
the class Get70 method writeResponse.
private void writeResponse(@Unretained Object data, Object callbackArg, Message origMsg, boolean isObject, VersionTag versionTag, boolean keyNotPresent, ServerConnection servConn) throws IOException {
Message responseMsg = servConn.getResponseMessage();
responseMsg.setMessageType(MessageType.RESPONSE);
responseMsg.setTransactionId(origMsg.getTransactionId());
int numParts = 2;
int flags = 0;
if (callbackArg != null) {
numParts++;
flags |= GetOp.HAS_CALLBACK_ARG;
}
if (versionTag != null) {
numParts++;
flags |= GetOp.HAS_VERSION_TAG;
}
if (keyNotPresent) {
flags |= GetOp.KEY_NOT_PRESENT;
} else if (data == null && isObject) {
flags |= GetOp.VALUE_IS_INVALID;
}
// logger.debug("returning flags " + Integer.toBinaryString(flags));
responseMsg.setNumberOfParts(numParts);
responseMsg.addPartInAnyForm(data, isObject);
responseMsg.addIntPart(flags);
if (callbackArg != null) {
responseMsg.addObjPart(callbackArg);
}
if (versionTag != null) {
responseMsg.addObjPart(versionTag);
}
servConn.getCache().getCancelCriterion().checkCancelInProgress(null);
responseMsg.send(servConn);
origMsg.clearParts();
}
use of org.apache.geode.internal.cache.tier.sockets.Message in project geode by apache.
the class GetClientPRMetadataCommand method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, ClassNotFoundException, InterruptedException {
String regionFullPath = null;
CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
regionFullPath = clientMessage.getPart(0).getString();
String errMessage = "";
if (regionFullPath == null) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GetClientPRMetadata_THE_INPUT_REGION_PATH_IS_NULL));
errMessage = LocalizedStrings.GetClientPRMetadata_THE_INPUT_REGION_PATH_IS_NULL.toLocalizedString();
writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PR_METADATA_ERROR, errMessage.toString(), serverConnection);
serverConnection.setAsTrue(RESPONDED);
} else {
Region region = crHelper.getRegion(regionFullPath);
if (region == null) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GetClientPRMetadata_REGION_NOT_FOUND_FOR_SPECIFIED_REGION_PATH, regionFullPath));
errMessage = LocalizedStrings.GetClientPRMetadata_REGION_NOT_FOUND.toLocalizedString() + regionFullPath;
writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PR_METADATA_ERROR, errMessage.toString(), serverConnection);
serverConnection.setAsTrue(RESPONDED);
} else {
try {
Message responseMsg = serverConnection.getResponseMessage();
responseMsg.setTransactionId(clientMessage.getTransactionId());
responseMsg.setMessageType(MessageType.RESPONSE_CLIENT_PR_METADATA);
PartitionedRegion prRgion = (PartitionedRegion) region;
Map<Integer, List<BucketServerLocation66>> bucketToServerLocations = prRgion.getRegionAdvisor().getAllClientBucketProfiles();
responseMsg.setNumberOfParts(bucketToServerLocations.size());
for (List<BucketServerLocation66> serverLocations : bucketToServerLocations.values()) {
List<BucketServerLocation> oldServerLocations = new ArrayList<BucketServerLocation>();
for (BucketServerLocation66 bs : serverLocations) {
oldServerLocations.add(new BucketServerLocation(bs.getBucketId(), bs.getPort(), bs.getHostName(), bs.isPrimary(), bs.getVersion()));
responseMsg.addObjPart(oldServerLocations);
}
}
responseMsg.send();
clientMessage.clearParts();
} catch (Exception e) {
writeException(clientMessage, e, false, serverConnection);
} finally {
serverConnection.setAsTrue(Command.RESPONDED);
}
}
}
}
use of org.apache.geode.internal.cache.tier.sockets.Message in project geode by apache.
the class GetClientPRMetadataCommand66 method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, ClassNotFoundException, InterruptedException {
String regionFullPath = null;
CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
regionFullPath = clientMessage.getPart(0).getString();
String errMessage = "";
if (regionFullPath == null) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GetClientPRMetadata_THE_INPUT_REGION_PATH_IS_NULL));
errMessage = LocalizedStrings.GetClientPRMetadata_THE_INPUT_REGION_PATH_IS_NULL.toLocalizedString();
writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PR_METADATA_ERROR, errMessage.toString(), serverConnection);
serverConnection.setAsTrue(RESPONDED);
} else {
Region region = crHelper.getRegion(regionFullPath);
if (region == null) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GetClientPRMetadata_REGION_NOT_FOUND_FOR_SPECIFIED_REGION_PATH, regionFullPath));
errMessage = LocalizedStrings.GetClientPRMetadata_REGION_NOT_FOUND.toLocalizedString() + regionFullPath;
writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PR_METADATA_ERROR, errMessage.toString(), serverConnection);
serverConnection.setAsTrue(RESPONDED);
} else {
try {
Message responseMsg = serverConnection.getResponseMessage();
responseMsg.setTransactionId(clientMessage.getTransactionId());
responseMsg.setMessageType(MessageType.RESPONSE_CLIENT_PR_METADATA);
PartitionedRegion prRgion = (PartitionedRegion) region;
Map<Integer, List<BucketServerLocation66>> bucketToServerLocations = prRgion.getRegionAdvisor().getAllClientBucketProfiles();
responseMsg.setNumberOfParts(bucketToServerLocations.size());
for (List<BucketServerLocation66> serverLocations : bucketToServerLocations.values()) {
responseMsg.addObjPart(serverLocations);
}
responseMsg.send();
clientMessage.clearParts();
} catch (Exception e) {
writeException(clientMessage, e, false, serverConnection);
} finally {
serverConnection.setAsTrue(Command.RESPONDED);
}
}
}
}
use of org.apache.geode.internal.cache.tier.sockets.Message in project geode by apache.
the class ContainsKey method writeContainsKeyResponse.
private static void writeContainsKeyResponse(boolean containsKey, Message origMsg, ServerConnection servConn) throws IOException {
Message responseMsg = servConn.getResponseMessage();
responseMsg.setMessageType(MessageType.RESPONSE);
responseMsg.setNumberOfParts(1);
responseMsg.setTransactionId(origMsg.getTransactionId());
responseMsg.addObjPart(containsKey ? Boolean.TRUE : Boolean.FALSE);
responseMsg.send(servConn);
}
use of org.apache.geode.internal.cache.tier.sockets.Message in project geode by apache.
the class ContainsKey66 method writeContainsKeyResponse.
private static void writeContainsKeyResponse(boolean containsKey, Message origMsg, ServerConnection servConn) throws IOException {
LogWriterI18n logger = servConn.getLogWriter();
Message responseMsg = servConn.getResponseMessage();
responseMsg.setMessageType(MessageType.RESPONSE);
responseMsg.setNumberOfParts(1);
responseMsg.setTransactionId(origMsg.getTransactionId());
responseMsg.addObjPart(containsKey ? Boolean.TRUE : Boolean.FALSE);
responseMsg.send(servConn);
}
Aggregations