use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlParser method startFunctionalIndex.
/**
* When a <code>functional</code> element is encounter, we pop the IndexCreationData object from
* the Stack. Set the required parameters in the IndexCreationData object & set it in
* RegionCreation object.
*
*/
private void startFunctionalIndex(Attributes atts) {
boolean throwExcep = false;
IndexCreationData icd = (IndexCreationData) this.stack.peek();
// icd.setIndexType(FUNCTIONAL);
int len = -1;
if ((len = atts.getLength()) > 1) {
String fromClause = atts.getValue(FROM_CLAUSE);
String expression = atts.getValue(EXPRESSION);
String importStr = null;
if (len == 3)
importStr = atts.getValue(IMPORTS);
if (fromClause == null || expression == null) {
throwExcep = true;
} else {
icd.setIndexData(IndexType.FUNCTIONAL, fromClause, expression, importStr);
}
} else {
throwExcep = true;
}
if (throwExcep) {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_CACHEXMLPARSERSTARTFUNCTIONALINDEXINDEX_CREATION_ATTRIBUTE_NOT_CORRECTLY_SPECIFIED.toLocalizedString());
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlParser method startPrimaryKeyIndex.
/**
* When a <code>primary-key</code> element is encounter, we pop the IndexCreationData object from
* the Stack. Set the required parameters in the IndexCreationData object & set it in
* RegionCreation object.
*
*/
private void startPrimaryKeyIndex(Attributes atts) {
IndexCreationData icd = (IndexCreationData) this.stack.peek();
// icd.setIndexType(PRIMARY_KEY);
boolean throwExcep = false;
if (atts.getLength() == 1) {
String field = atts.getValue(FIELD);
if (field == null) {
throwExcep = true;
} else {
icd.setIndexData(IndexType.PRIMARY_KEY, null, field, null);
}
} else {
throwExcep = true;
}
if (throwExcep) {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_CACHEXMLPARSERSTARTPRIMARYKEYINDEXPRIMARYKEY_INDEX_CREATION_FIELD_IS_NULL.toLocalizedString());
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class SingleHopClientExecutor method submitGetAll.
static Map<ServerLocation, Object> submitGetAll(Map<ServerLocation, HashSet> serverToFilterMap, List callableTasks, ClientMetadataService cms, LocalRegion region) {
if (callableTasks != null && !callableTasks.isEmpty()) {
Map<ServerLocation, Object> resultMap = new HashMap<ServerLocation, Object>();
List futures = null;
try {
futures = execService.invokeAll(callableTasks);
} catch (RejectedExecutionException rejectedExecutionEx) {
throw rejectedExecutionEx;
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
}
if (futures != null) {
Iterator futureItr = futures.iterator();
Iterator taskItr = callableTasks.iterator();
while (futureItr.hasNext() && !execService.isShutdown() && !execService.isTerminated()) {
Future fut = (Future) futureItr.next();
SingleHopOperationCallable task = (SingleHopOperationCallable) taskItr.next();
List keys = ((GetAllOpImpl) task.getOperation()).getKeyList();
ServerLocation server = task.getServer();
try {
VersionedObjectList valuesFromServer = (VersionedObjectList) fut.get();
valuesFromServer.setKeys(keys);
for (VersionedObjectList.Iterator it = valuesFromServer.iterator(); it.hasNext(); ) {
VersionedObjectList.Entry entry = it.next();
Object key = entry.getKey();
Object value = entry.getValue();
if (!entry.isKeyNotOnServer()) {
if (value instanceof Throwable) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GetAll_0_CAUGHT_THE_FOLLOWING_EXCEPTION_ATTEMPTING_TO_GET_VALUE_FOR_KEY_1, new Object[] { value, key }), (Throwable) value);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("GetAllOp#got result from {}: {}", server, valuesFromServer);
}
resultMap.put(server, valuesFromServer);
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
} catch (ExecutionException ee) {
if (ee.getCause() instanceof ServerOperationException) {
if (logger.isDebugEnabled()) {
logger.debug("GetAllOp#ExecutionException.ServerOperationException : Caused by :{}", ee.getCause());
}
throw (ServerOperationException) ee.getCause();
} else if (ee.getCause() instanceof ServerConnectivityException) {
if (logger.isDebugEnabled()) {
logger.debug("GetAllOp#ExecutionException.ServerConnectivityException : Caused by :{} The failed server is: {}", ee.getCause(), server);
}
try {
cms = region.getCache().getClientMetadataService();
} catch (CacheClosedException e) {
return null;
}
cms.removeBucketServerLocation(server);
cms.scheduleGetPRMetaData((LocalRegion) region, false);
resultMap.put(server, ee.getCause());
} else {
throw executionThrowable(ee.getCause());
}
}
}
return resultMap;
}
}
return null;
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class SingleHopClientExecutor method submitBulkOp.
/**
* execute bulk op (putAll or removeAll) on multiple PR servers, returning a map of the results.
* Results are either a VersionedObjectList or a BulkOpPartialResultsException
*
* @param callableTasks
* @param cms
* @param region
* @param failedServers
* @return the per-server results
*/
static Map<ServerLocation, Object> submitBulkOp(List callableTasks, ClientMetadataService cms, LocalRegion region, Map<ServerLocation, RuntimeException> failedServers) {
if (callableTasks != null && !callableTasks.isEmpty()) {
Map<ServerLocation, Object> resultMap = new HashMap<ServerLocation, Object>();
boolean anyPartialResults = false;
List futures = null;
try {
futures = execService.invokeAll(callableTasks);
} catch (RejectedExecutionException rejectedExecutionEx) {
throw rejectedExecutionEx;
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
}
if (futures != null) {
Iterator futureItr = futures.iterator();
Iterator taskItr = callableTasks.iterator();
RuntimeException rte = null;
final boolean isDebugEnabled = logger.isDebugEnabled();
while (futureItr.hasNext() && !execService.isShutdown() && !execService.isTerminated()) {
Future fut = (Future) futureItr.next();
SingleHopOperationCallable task = (SingleHopOperationCallable) taskItr.next();
ServerLocation server = task.getServer();
try {
VersionedObjectList versions = (VersionedObjectList) fut.get();
if (logger.isDebugEnabled()) {
logger.debug("submitBulkOp#got result from {}:{}", server, versions);
}
resultMap.put(server, versions);
} catch (InterruptedException e) {
InternalGemFireException ige = new InternalGemFireException(e);
// only to make this server as failed server, not to throw right now
failedServers.put(server, ige);
if (rte == null) {
rte = ige;
}
} catch (ExecutionException ee) {
if (ee.getCause() instanceof ServerOperationException) {
if (logger.isDebugEnabled()) {
logger.debug("submitBulkOp#ExecutionException from server {}", server, ee);
}
ServerOperationException soe = (ServerOperationException) ee.getCause();
// only to make this server as failed server, not to throw right now
failedServers.put(server, soe);
if (rte == null) {
rte = soe;
}
} else if (ee.getCause() instanceof ServerConnectivityException) {
if (logger.isDebugEnabled()) {
logger.debug("submitBulkOp#ExecutionException for server {}", server, ee);
}
cms = region.getCache().getClientMetadataService();
cms.removeBucketServerLocation(server);
cms.scheduleGetPRMetaData(region, false);
failedServers.put(server, (ServerConnectivityException) ee.getCause());
} else {
Throwable t = ee.getCause();
if (t instanceof PutAllPartialResultException) {
resultMap.put(server, t);
anyPartialResults = true;
failedServers.put(server, (PutAllPartialResultException) t);
} else {
RuntimeException other_rte = executionThrowable(ee.getCause());
failedServers.put(server, other_rte);
if (rte == null) {
rte = other_rte;
}
}
}
}
// catch
}
// so the partial results can be processed
if (rte != null && !anyPartialResults) {
throw rte;
}
}
return resultMap;
}
return null;
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class StreamingOperation method getDataFromAll.
/**
* Returns normally if succeeded to get data, otherwise throws an exception
*
* @throws InterruptedException TODO-javadocs
*/
public void getDataFromAll(Set recipients) throws org.apache.geode.cache.TimeoutException, InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
if (recipients.isEmpty())
return;
StreamingProcessor processor = new StreamingProcessor(this.sys, recipients);
DistributionMessage m = createRequestMessage(recipients, processor);
this.sys.getDistributionManager().putOutgoing(m);
// while() loop removed for bug 36983 - you can't loop on waitForReplies()
try {
// should we allow this to timeout?
processor.waitForRepliesUninterruptibly();
} catch (InternalGemFireException ex) {
Throwable cause = ex.getCause();
if (cause instanceof org.apache.geode.cache.TimeoutException) {
throw (org.apache.geode.cache.TimeoutException) cause;
}
throw ex;
} catch (ReplyException e) {
e.handleAsUnexpected();
// throws exception
}
}
Aggregations