use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class IndexCreationMsg method operateOnPartitionedRegion.
/**
* This method actually operates on the partitioned region and creates given list of indexes from
* a index creation message.
*
* @param dm distribution manager.
* @param pr partitioned region on which to create an index.
* @throws CacheException indicating a cache level error
* @throws ForceReattemptException if the peer is no longer available
*/
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion pr, long startTime) throws CacheException, ForceReattemptException {
// region exists
ReplyException replyEx = null;
boolean result = false;
List<Index> indexes = null;
List<String> failedIndexNames = new ArrayList<String>();
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
for (IndexCreationData icd : indexDefinitions) {
sb.append(icd.getIndexName()).append(" ");
}
logger.debug("Processing index creation message on this remote partitioned region vm for indexes: {}", sb);
}
try {
indexes = pr.createIndexes(true, indexDefinitions);
} catch (IndexCreationException e1) {
replyEx = new ReplyException(LocalizedStrings.IndexCreationMsg_REMOTE_INDEX_CREAION_FAILED.toLocalizedString(), e1);
} catch (MultiIndexCreationException exx) {
failedIndexNames.addAll(exx.getExceptionsMap().keySet());
if (logger.isDebugEnabled()) {
StringBuffer exceptionMsgs = new StringBuffer();
for (Exception ex : exx.getExceptionsMap().values()) {
exceptionMsgs.append(ex.getMessage()).append("\n");
}
logger.debug("Got an MultiIndexCreationException with \n: {}", exceptionMsgs);
logger.debug("{} indexes were created succesfully", failedIndexNames.size());
}
replyEx = new ReplyException(LocalizedStrings.IndexCreationMsg_REMOTE_INDEX_CREAION_FAILED.toLocalizedString(), exx);
}
if (null == replyEx) {
result = true;
}
if (result) {
Map<String, Integer> indexBucketsMap = new HashMap<String, Integer>();
for (Index index : indexes) {
PartitionedIndex prIndex = (PartitionedIndex) index;
indexBucketsMap.put(prIndex.getName(), prIndex.getNumberOfIndexedBuckets());
}
sendReply(getSender(), getProcessorId(), dm, replyEx, result, indexBucketsMap, pr.getDataStore().getAllLocalBuckets().size());
} else {
// add the indexes that were successfully created to the map
Map<String, Integer> indexBucketsMap = new HashMap<String, Integer>();
for (IndexCreationData icd : indexDefinitions) {
// if the index was successfully created
if (!failedIndexNames.contains(icd.getIndexName())) {
PartitionedIndex prIndex = (PartitionedIndex) pr.getIndex(icd.getIndexName());
indexBucketsMap.put(icd.getIndexName(), prIndex.getNumberOfIndexedBuckets());
}
}
sendReply(getSender(), getProcessorId(), dm, replyEx, result, indexBucketsMap, pr.getDataStore().getAllLocalBuckets().size());
}
if (logger.isDebugEnabled()) {
logger.debug("Multi Index creation completed on remote host and has sent the reply to the originating vm.");
}
return false;
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class InterestEventMessage method send.
/**
* Sends an InterestEventMessage message
*
* @param recipients the Set of members that the get message is being sent to
* @param region the PartitionedRegion for which interest event was received
* @param event the InterestRegistrationEvent to send
* @return the InterestEventResponse
* @throws ForceReattemptException if the peer is no longer available
*/
public static InterestEventResponse send(Set recipients, PartitionedRegion region, final InterestRegistrationEvent event) throws ForceReattemptException {
InterestEventResponse response = new InterestEventResponse(region.getSystem(), recipients);
InterestEventMessage m = new InterestEventMessage(recipients, region.getPRId(), response.getProcessorId(), event, response);
Set failures = region.getDistributionManager().putOutgoing(m);
if (failures != null && failures.size() > 0) {
throw new ForceReattemptException("Failed sending <" + m + "> to " + failures);
}
return response;
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class PRFunctionStreamingResultCollector method getResult.
@Override
public Object getResult() throws FunctionException {
if (this.resultCollected) {
throw new FunctionException("Result already collected");
}
this.resultCollected = true;
if (this.hasResult) {
try {
this.waitForCacheOrFunctionException(0);
if (!this.execution.getFailedNodes().isEmpty() && !this.execution.isClientServerMode()) {
// end the rc and clear it
endResults();
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(this.fn);
} else {
newRc = this.execution.execute(this.fn.getId());
}
return newRc.getResult();
}
if (!this.execution.getWaitOnExceptionFlag() && this.fites.size() > 0) {
throw new FunctionException(this.fites.get(0));
}
} catch (FunctionInvocationTargetException fite) {
// the function.
if (!execution.getWaitOnExceptionFlag()) {
if (!this.fn.isHA()) {
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException iFITE = new InternalFunctionInvocationTargetException(fite.getMessage(), this.execution.getFailedNodes());
throw new FunctionException(iFITE);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(this.fn);
} else {
newRc = this.execution.execute(this.fn.getId());
}
return newRc.getResult();
}
}
} catch (BucketMovedException e) {
if (!execution.getWaitOnExceptionFlag()) {
if (!this.fn.isHA()) {
// endResults();
FunctionInvocationTargetException fite = new FunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
// endResults();
clearResults();
FunctionInvocationTargetException fite = new InternalFunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else {
// endResults();
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(this.fn);
} else {
newRc = this.execution.execute(this.fn.getId());
}
return newRc.getResult();
}
}
} catch (CacheClosedException e) {
if (!execution.getWaitOnExceptionFlag()) {
if (!this.fn.isHA()) {
// endResults();
FunctionInvocationTargetException fite = new FunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
// endResults();
clearResults();
FunctionInvocationTargetException fite = new InternalFunctionInvocationTargetException(e.getMessage(), this.execution.getFailedNodes());
throw new FunctionException(fite);
} else {
// endResults();
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(this.fn);
} else {
newRc = this.execution.execute(this.fn.getId());
}
return newRc.getResult();
}
}
} catch (CacheException e) {
// endResults();
throw new FunctionException(e);
} catch (ForceReattemptException e) {
// the function.
if (!this.fn.isHA()) {
throw new FunctionException(e);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException iFITE = new InternalFunctionInvocationTargetException(e.getMessage(), this.execution.getFailedNodes());
throw new FunctionException(iFITE);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(this.fn);
} else {
newRc = this.execution.execute(this.fn.getId());
}
return newRc.getResult();
}
}
}
return this.userRC.getResult();
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class PrimaryRequestMessage method send.
/**
* Send request for primary election
*
* @param recipients those members which own the bucket
* @param r the Partitioned Region which uses/owns the bucket
* @param bucketId the idenity of the bucket
* @return a response object on which the caller waits for acknowledgement of which member is the
* primary
* @throws ForceReattemptException if the message was unable to be sent
*/
public static PrimaryResponse send(Set recipients, PartitionedRegion r, int bucketId) throws ForceReattemptException {
Assert.assertTrue(recipients != null, "PrimaryRequestMessage NULL recipient");
PrimaryResponse p = new PrimaryResponse(r.getSystem(), recipients);
PrimaryRequestMessage m = new PrimaryRequestMessage(recipients, r.getPRId(), p, bucketId);
Set failures = r.getDistributionManager().putOutgoing(m);
if (failures != null && failures.size() > 0) {
throw new ForceReattemptException(LocalizedStrings.PrimaryRequestMessage_FAILED_SENDING_0.toLocalizedString(m));
}
return p;
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class PutAllPRMessage method operateOnPartitionedRegion.
/**
* This method is called upon receipt and make the desired changes to the PartitionedRegion Note:
* It is very important that this message does NOT cause any deadlocks as the sender will wait
* indefinitely for the acknowledgement
*/
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion pr, long startTime) throws EntryExistsException, ForceReattemptException, DataLocationException {
boolean sendReply = true;
InternalDistributedMember eventSender = getSender();
long lastModified = 0L;
try {
result = doLocalPutAll(pr, eventSender, lastModified);
} catch (ForceReattemptException fre) {
sendReply(getSender(), getProcessorId(), dm, new ReplyException(fre), pr, startTime);
return false;
}
if (sendReply) {
sendReply(getSender(), getProcessorId(), dm, null, pr, startTime);
}
return false;
}
Aggregations