Search in sources :

Example 31 with InternalGemFireException

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());
    }
}
Also used : IndexCreationData(org.apache.geode.cache.query.internal.index.IndexCreationData) InternalGemFireException(org.apache.geode.InternalGemFireException)

Example 32 with InternalGemFireException

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());
    }
}
Also used : IndexCreationData(org.apache.geode.cache.query.internal.index.IndexCreationData) InternalGemFireException(org.apache.geode.InternalGemFireException)

Example 33 with InternalGemFireException

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;
}
Also used : HashMap(java.util.HashMap) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) InternalGemFireException(org.apache.geode.InternalGemFireException) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) CacheClosedException(org.apache.geode.cache.CacheClosedException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) GetAllOpImpl(org.apache.geode.cache.client.internal.GetAllOp.GetAllOpImpl) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) Iterator(java.util.Iterator) Future(java.util.concurrent.Future) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) List(java.util.List) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 34 with InternalGemFireException

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;
}
Also used : HashMap(java.util.HashMap) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) InternalGemFireException(org.apache.geode.InternalGemFireException) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) PutAllPartialResultException(org.apache.geode.internal.cache.PutAllPartialResultException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) Iterator(java.util.Iterator) Future(java.util.concurrent.Future) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) List(java.util.List) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 35 with InternalGemFireException

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
    }
}
Also used : DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) PooledDistributionMessage(org.apache.geode.distributed.internal.PooledDistributionMessage) InternalGemFireException(org.apache.geode.InternalGemFireException) ReplyException(org.apache.geode.distributed.internal.ReplyException)

Aggregations

InternalGemFireException (org.apache.geode.InternalGemFireException)46 IOException (java.io.IOException)12 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)8 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)8 ExecutionException (java.util.concurrent.ExecutionException)7 UnknownHostException (java.net.UnknownHostException)6 Future (java.util.concurrent.Future)6 Method (java.lang.reflect.Method)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 List (java.util.List)4 CancelException (org.apache.geode.CancelException)4 CacheException (org.apache.geode.cache.CacheException)4 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)4 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)4 NoSuchElementException (java.util.NoSuchElementException)3 Set (java.util.Set)3 ExecutorService (java.util.concurrent.ExecutorService)3