Search in sources :

Example 11 with TransactionException

use of org.apache.geode.cache.TransactionException in project geode by apache.

the class LocalRegion method basicRemoveAll.

VersionedObjectList basicRemoveAll(final Collection<Object> keys, final DistributedRemoveAllOperation removeAllOp, final List<VersionTag> retryVersions) {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    final boolean isTraceEnabled = logger.isTraceEnabled();
    final EntryEventImpl event = removeAllOp.getBaseEvent();
    EventID eventId = event.getEventId();
    if (eventId == null && generateEventID()) {
        // We need to "reserve" the eventIds for the entries in map here
        event.reserveNewEventId(this.cache.getDistributedSystem(), keys.size());
        eventId = event.getEventId();
    }
    verifyRemoveAllKeys(keys);
    VersionedObjectList proxyResult = null;
    boolean partialResult = false;
    RuntimeException runtimeException = null;
    if (hasServerProxy()) {
        // send message to bridge server
        if (isTX()) {
            TXStateProxyImpl txState = (TXStateProxyImpl) this.cache.getTxManager().getTXState();
            txState.getRealDeal(null, this);
        }
        try {
            proxyResult = getServerProxy().removeAll(keys, eventId, event.getCallbackArgument());
            if (isDebugEnabled) {
                logger.debug("removeAll received response from server: {}", proxyResult);
            }
        } catch (PutAllPartialResultException e) {
            // adjust the map to only add succeeded entries, then apply the adjustedMap
            proxyResult = e.getSucceededKeysAndVersions();
            partialResult = true;
            if (isDebugEnabled) {
                logger.debug("removeAll in client encountered a BulkOpPartialResultException: {}{}. Adjusted keys are: {}", e.getMessage(), getLineSeparator(), proxyResult.getKeys());
            }
            Throwable txException = e.getFailure();
            while (txException != null) {
                if (txException instanceof TransactionException) {
                    runtimeException = (RuntimeException) txException;
                    break;
                }
                txException = txException.getCause();
            }
            if (runtimeException == null) {
                runtimeException = new ServerOperationException(LocalizedStrings.Region_RemoveAll_Applied_PartialKeys_At_Server_0.toLocalizedString(getFullPath()), e.getFailure());
            }
        }
    }
    final VersionedObjectList succeeded = new VersionedObjectList(keys.size(), true, this.concurrencyChecksEnabled);
    // If this is a transactional removeAll, we will not have version information as it is only
    // generated at commit
    // so treat transactional removeAll as if the server is not versioned.
    // If we have no storage then act as if the server is not versioned.
    final boolean serverIsVersioned = proxyResult != null && proxyResult.regionIsVersioned() && !isTX() && getDataPolicy().withStorage();
    if (!serverIsVersioned && !partialResult) {
        // since the server is not versioned and we do not have a partial result
        // get rid of the proxyResult info returned by the server.
        proxyResult = null;
    }
    lockRVVForBulkOp();
    try {
        try {
            int size = proxyResult == null ? keys.size() : proxyResult.size();
            if (isInternalRegion()) {
                if (isTraceEnabled) {
                    logger.trace("size of removeAll result is {} keys are {} proxyResult is {}", size, keys, proxyResult);
                } else {
                    if (isTraceEnabled) {
                        logger.trace("size of removeAll result is {} keys are {} proxyResult is {}", size, keys, proxyResult);
                    }
                }
            } else {
                if (isTraceEnabled) {
                    logger.trace("size of removeAll result is {} keys are {} proxyResult is {}", size, keys, proxyResult);
                }
            }
            final PutAllPartialResult partialKeys = new PutAllPartialResult(size);
            final Iterator iterator;
            final boolean isVersionedResults;
            if (proxyResult != null) {
                iterator = proxyResult.iterator();
                isVersionedResults = true;
            } else {
                iterator = keys.iterator();
                isVersionedResults = false;
            }
            // TODO: refactor this mess
            Runnable task = new Runnable() {

                @Override
                public void run() {
                    int offset = 0;
                    VersionTagHolder tagHolder = new VersionTagHolder();
                    while (iterator.hasNext()) {
                        stopper.checkCancelInProgress(null);
                        tagHolder.setVersionTag(null);
                        Object key;
                        VersionTag versionTag = null;
                        if (isVersionedResults) {
                            Map.Entry mapEntry = (Map.Entry) iterator.next();
                            key = mapEntry.getKey();
                            versionTag = ((VersionedObjectList.Entry) mapEntry).getVersionTag();
                            if (isDebugEnabled) {
                                logger.debug("removeAll key {} version={}", key, versionTag);
                            }
                            if (versionTag == null) {
                                if (isDebugEnabled) {
                                    logger.debug("removeAll found invalid version tag, which means the entry is not found at server for key={}.", key);
                                }
                                succeeded.addKeyAndVersion(key, null);
                                continue;
                            }
                        // No need for special handling here in removeAll.
                        // We can just remove this key from the client with versionTag set to null.
                        } else {
                            key = iterator.next();
                            if (isTraceEnabled) {
                                logger.trace("removeAll {}", key);
                            }
                        }
                        try {
                            if (serverIsVersioned) {
                                if (isDebugEnabled) {
                                    logger.debug("associating version tag with {} version={}", key, versionTag);
                                }
                                // If we have received a version tag from a server, add it to the event
                                tagHolder.setVersionTag(versionTag);
                                tagHolder.setFromServer(true);
                            } else if (retryVersions != null) {
                                VersionTag versionTag1 = retryVersions.get(offset);
                                if (versionTag1 != null) {
                                    // If this is a retried event, and we have a version tag for the retry,
                                    // add it to the event.
                                    tagHolder.setVersionTag(versionTag1);
                                }
                            }
                            basicEntryRemoveAll(key, removeAllOp, offset, tagHolder);
                            // now we must check again since the cache may have closed during
                            // distribution causing this process to not receive and queue the
                            // event for clients
                            stopper.checkCancelInProgress(null);
                            succeeded.addKeyAndVersion(key, tagHolder.getVersionTag());
                        } catch (Exception ex) {
                            partialKeys.saveFailedKey(key, ex);
                        }
                        offset++;
                    }
                }
            };
            syncBulkOp(task, eventId);
            if (partialKeys.hasFailure()) {
                // Bug 51725: Now succeeded contains an order key list, may be missing the version tags.
                // Save reference of succeeded into partialKeys. The succeeded may be modified by
                // postRemoveAll() to fill in the version tags.
                partialKeys.setSucceededKeysAndVersions(succeeded);
                logger.info(LocalizedMessage.create(LocalizedStrings.Region_RemoveAll_Applied_PartialKeys_0_1, new Object[] { getFullPath(), partialKeys }));
                if (isDebugEnabled) {
                    logger.debug(partialKeys.detailString());
                }
                if (runtimeException == null) {
                    // if received exception from server first, ignore local exception
                    if (removeAllOp.isBridgeOperation()) {
                        if (partialKeys.getFailure() instanceof CancelException) {
                            runtimeException = (RuntimeException) partialKeys.getFailure();
                        } else if (partialKeys.getFailure() instanceof LowMemoryException) {
                            // fix for #43589
                            throw partialKeys.getFailure();
                        } else {
                            runtimeException = new PutAllPartialResultException(partialKeys);
                            if (isDebugEnabled) {
                                logger.debug("basicRemoveAll: {}", partialKeys.detailString());
                            }
                        }
                    } else {
                        throw partialKeys.getFailure();
                    }
                }
            }
        } catch (LowMemoryException lme) {
            throw lme;
        } catch (RuntimeException ex) {
            runtimeException = ex;
        } catch (Exception ex) {
            runtimeException = new RuntimeException(ex);
        } finally {
            removeAllOp.getBaseEvent().release();
            removeAllOp.freeOffHeapResources();
        }
        getDataView().postRemoveAll(removeAllOp, succeeded, this);
    } finally {
        unlockRVVForBulkOp();
    }
    if (runtimeException != null) {
        throw runtimeException;
    }
    return succeeded;
}
Also used : VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) PutAllPartialResult(org.apache.geode.internal.cache.PutAllPartialResultException.PutAllPartialResult) Endpoint(org.apache.geode.cache.client.internal.Endpoint) TimeoutException(org.apache.geode.cache.TimeoutException) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InternalGemFireException(org.apache.geode.InternalGemFireException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) ExecutionException(java.util.concurrent.ExecutionException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) EntryExistsException(org.apache.geode.cache.EntryExistsException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) StatisticsDisabledException(org.apache.geode.cache.StatisticsDisabledException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) FailedSynchronizationException(org.apache.geode.cache.FailedSynchronizationException) NoSuchElementException(java.util.NoSuchElementException) QueryException(org.apache.geode.cache.query.QueryException) RedundancyAlreadyMetException(org.apache.geode.internal.cache.partitioned.RedundancyAlreadyMetException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) LowMemoryException(org.apache.geode.cache.LowMemoryException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) SystemException(javax.transaction.SystemException) SubscriptionNotEnabledException(org.apache.geode.cache.client.SubscriptionNotEnabledException) RegionExistsException(org.apache.geode.cache.RegionExistsException) RegionReinitializedException(org.apache.geode.cache.RegionReinitializedException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IndexMaintenanceException(org.apache.geode.cache.query.IndexMaintenanceException) TransactionException(org.apache.geode.cache.TransactionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) RollbackException(javax.transaction.RollbackException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) MultiIndexCreationException(org.apache.geode.cache.query.MultiIndexCreationException) DeltaSerializationException(org.apache.geode.DeltaSerializationException) LRUEntry(org.apache.geode.internal.cache.lru.LRUEntry) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) TransactionException(org.apache.geode.cache.TransactionException) Iterator(java.util.Iterator) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) StoredObject(org.apache.geode.internal.offheap.StoredObject) CancelException(org.apache.geode.CancelException) Map(java.util.Map) IndexMap(org.apache.geode.internal.cache.persistence.query.IndexMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashMap(java.util.HashMap) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Example 12 with TransactionException

use of org.apache.geode.cache.TransactionException in project geode by apache.

the class PartitionedRegionFunctionExecutor method validateExecution.

@Override
public void validateExecution(Function function, Set targetMembers) {
    InternalCache cache = pr.getGemFireCache();
    if (cache != null && cache.getTxManager().getTXState() != null) {
        if (targetMembers.size() > 1) {
            throw new TransactionException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_ON_MORE_THAN_ONE_NODE.toLocalizedString());
        } else {
            assert targetMembers.size() == 1;
            DistributedMember funcTarget = (DistributedMember) targetMembers.iterator().next();
            DistributedMember target = cache.getTxManager().getTXState().getTarget();
            if (target == null) {
                cache.getTxManager().getTXState().setTarget(funcTarget);
            } else if (!target.equals(funcTarget)) {
                throw new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_EXECUTION_NOT_COLOCATED_0_1.toLocalizedString(target, funcTarget));
            }
        }
    }
    if (function.optimizeForWrite() && cache.getInternalResourceManager().getHeapMonitor().containsHeapCriticalMembers(targetMembers) && !MemoryThresholds.isLowMemoryExceptionDisabled()) {
        Set<InternalDistributedMember> hcm = cache.getResourceAdvisor().adviseCritialMembers();
        Set<DistributedMember> sm = SetUtils.intersection(hcm, targetMembers);
        throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_FOR_0_FUNCEXEC_MEMBERS_1.toLocalizedString(new Object[] { function.getId(), sm }), sm);
    }
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Example 13 with TransactionException

use of org.apache.geode.cache.TransactionException in project geode by apache.

the class BaseCommand method execute.

@Override
public void execute(Message clientMessage, ServerConnection serverConnection) {
    // Read the request and update the statistics
    long start = DistributionStats.getStatTime();
    if (EntryLogger.isEnabled() && serverConnection != null) {
        EntryLogger.setSource(serverConnection.getMembershipID(), "c2s");
    }
    boolean shouldMasquerade = shouldMasqueradeForTx(clientMessage, serverConnection);
    try {
        if (shouldMasquerade) {
            InternalCache cache = serverConnection.getCache();
            InternalDistributedMember member = (InternalDistributedMember) serverConnection.getProxyID().getDistributedMember();
            TXManagerImpl txMgr = cache.getTxManager();
            TXStateProxy tx = null;
            try {
                tx = txMgr.masqueradeAs(clientMessage, member, false);
                cmdExecute(clientMessage, serverConnection, start);
                tx.updateProxyServer(txMgr.getMemberId());
            } finally {
                txMgr.unmasquerade(tx);
            }
        } else {
            cmdExecute(clientMessage, serverConnection, start);
        }
    } catch (TransactionException | CopyException | SerializationException | CacheWriterException | CacheLoaderException | GemFireSecurityException | PartitionOfflineException | MessageTooLargeException e) {
        handleExceptionNoDisconnect(clientMessage, serverConnection, e);
    } catch (EOFException eof) {
        BaseCommand.handleEOFException(clientMessage, serverConnection, eof);
    } catch (InterruptedIOException e) {
        // Solaris only
        BaseCommand.handleInterruptedIOException(serverConnection, e);
    } catch (IOException e) {
        BaseCommand.handleIOException(clientMessage, serverConnection, e);
    } catch (DistributedSystemDisconnectedException e) {
        BaseCommand.handleShutdownException(clientMessage, serverConnection, e);
    } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // now, so don't let this thread continue.
        throw err;
    } catch (Throwable e) {
        BaseCommand.handleThrowable(clientMessage, serverConnection, e);
    } finally {
        EntryLogger.clearSource();
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) CopyException(org.apache.geode.CopyException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) SerializationException(org.apache.geode.SerializationException) InternalCache(org.apache.geode.internal.cache.InternalCache) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) TransactionException(org.apache.geode.cache.TransactionException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) EOFException(java.io.EOFException) CacheWriterException(org.apache.geode.cache.CacheWriterException)

Example 14 with TransactionException

use of org.apache.geode.cache.TransactionException in project geode by apache.

the class LocalRegion method basicPutAll.

// TODO: refactor basicPutAll
public VersionedObjectList basicPutAll(final Map<?, ?> map, final DistributedPutAllOperation putAllOp, final Map<Object, VersionTag> retryVersions) {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    final EntryEventImpl event = putAllOp.getBaseEvent();
    EventID eventId = event.getEventId();
    if (eventId == null && generateEventID()) {
        // We need to "reserve" the eventIds for the entries in map here
        event.reserveNewEventId(this.cache.getDistributedSystem(), map.size());
        eventId = event.getEventId();
    }
    verifyPutAllMap(map);
    VersionedObjectList proxyResult = null;
    boolean partialResult = false;
    RuntimeException runtimeException = null;
    if (hasServerProxy()) {
        // send message to bridge server
        if (isTX()) {
            TXStateProxyImpl txState = (TXStateProxyImpl) this.cache.getTxManager().getTXState();
            txState.getRealDeal(null, this);
        }
        try {
            proxyResult = getServerProxy().putAll(map, eventId, !event.isGenerateCallbacks(), event.getCallbackArgument());
            if (isDebugEnabled) {
                logger.debug("PutAll received response from server: {}", proxyResult);
            }
        } catch (PutAllPartialResultException e) {
            // adjust the map to only add succeeded entries, then apply the adjustedMap
            proxyResult = e.getSucceededKeysAndVersions();
            partialResult = true;
            if (isDebugEnabled) {
                logger.debug("putAll in client encountered a PutAllPartialResultException:{}{}. Adjusted keys are: {}", e.getMessage(), getLineSeparator(), proxyResult.getKeys());
            }
            Throwable txException = e.getFailure();
            while (txException != null) {
                if (txException instanceof TransactionException) {
                    runtimeException = (RuntimeException) txException;
                    break;
                }
                txException = txException.getCause();
            }
            if (runtimeException == null) {
                // for cache close
                runtimeException = getCancelCriterion().generateCancelledException(e.getFailure());
                if (runtimeException == null) {
                    runtimeException = new ServerOperationException(LocalizedStrings.Region_PutAll_Applied_PartialKeys_At_Server_0.toLocalizedString(getFullPath()), e.getFailure());
                }
            }
        }
    }
    final VersionedObjectList succeeded = new VersionedObjectList(map.size(), true, this.concurrencyChecksEnabled);
    // if this is a transactional putAll, we will not have version information as it is only
    // generated at commit
    // so treat transactional putAll as if the server is not versioned
    final boolean serverIsVersioned = proxyResult != null && proxyResult.regionIsVersioned() && !isTX() && this.dataPolicy != DataPolicy.EMPTY;
    if (!serverIsVersioned && !partialResult) {
        // we don't need server information if it isn't versioned or if the region is empty
        proxyResult = null;
    }
    lockRVVForBulkOp();
    try {
        try {
            int size = proxyResult == null ? map.size() : proxyResult.size();
            if (isDebugEnabled) {
                logger.debug("size of put result is {} maps is {} proxyResult is {}", size, map, proxyResult);
            }
            final PutAllPartialResult partialKeys = new PutAllPartialResult(size);
            final Iterator iterator;
            final boolean isVersionedResults;
            if (proxyResult != null) {
                iterator = proxyResult.iterator();
                isVersionedResults = true;
            } else {
                iterator = map.entrySet().iterator();
                isVersionedResults = false;
            }
            // TODO: refactor this mess
            Runnable task = new Runnable() {

                @Override
                public void run() {
                    int offset = 0;
                    VersionTagHolder tagHolder = new VersionTagHolder();
                    while (iterator.hasNext()) {
                        stopper.checkCancelInProgress(null);
                        Map.Entry mapEntry = (Map.Entry) iterator.next();
                        Object key = mapEntry.getKey();
                        VersionTag versionTag = null;
                        tagHolder.setVersionTag(null);
                        final Object value;
                        boolean overwritten = false;
                        if (isVersionedResults) {
                            versionTag = ((VersionedObjectList.Entry) mapEntry).getVersionTag();
                            value = map.get(key);
                            if (isDebugEnabled) {
                                logger.debug("putAll key {} -> {} version={}", key, value, versionTag);
                            }
                            if (versionTag == null && serverIsVersioned && concurrencyChecksEnabled && dataPolicy.withStorage()) {
                                // entry since we don't know what its state should be (but the server should)
                                if (isDebugEnabled) {
                                    logger.debug("server returned no version information for {}", key);
                                }
                                localDestroyNoCallbacks(key);
                                // to be consistent we need to fetch the current entry
                                get(key, event.getCallbackArgument(), false, null);
                                overwritten = true;
                            }
                        } else {
                            value = mapEntry.getValue();
                            if (isDebugEnabled) {
                                logger.debug("putAll {} -> {}", key, value);
                            }
                        }
                        try {
                            if (serverIsVersioned) {
                                if (isDebugEnabled) {
                                    logger.debug("associating version tag with {} version={}", key, versionTag);
                                }
                                // If we have received a version tag from a server, add it to the event
                                tagHolder.setVersionTag(versionTag);
                                tagHolder.setFromServer(true);
                            } else if (retryVersions != null && retryVersions.containsKey(key)) {
                                // If this is a retried event, and we have a version tag for the retry,
                                // add it to the event.
                                tagHolder.setVersionTag(retryVersions.get(key));
                            }
                            if (!overwritten) {
                                basicEntryPutAll(key, value, putAllOp, offset, tagHolder);
                            }
                            // now we must check again since the cache may have closed during
                            // distribution (causing this process to not receive and queue the
                            // event for clients
                            stopper.checkCancelInProgress(null);
                            succeeded.addKeyAndVersion(key, tagHolder.getVersionTag());
                        } catch (Exception ex) {
                            if (isDebugEnabled) {
                                logger.debug("PutAll operation encountered exception for key {}", key, ex);
                            }
                            partialKeys.saveFailedKey(key, ex);
                        }
                        offset++;
                    }
                }
            };
            syncBulkOp(task, eventId);
            if (partialKeys.hasFailure()) {
                // Bug 51725: Now succeeded contains an order key list, may be missing the version tags.
                // Save reference of succeeded into partialKeys. The succeeded may be modified by
                // postPutAll() to fill in the version tags.
                partialKeys.setSucceededKeysAndVersions(succeeded);
                logger.info(LocalizedMessage.create(LocalizedStrings.Region_PutAll_Applied_PartialKeys_0_1, new Object[] { getFullPath(), partialKeys }));
                if (isDebugEnabled) {
                    logger.debug(partialKeys.detailString());
                }
                if (runtimeException == null) {
                    // if received exception from server first, ignore local exception
                    if (putAllOp.isBridgeOperation()) {
                        if (partialKeys.getFailure() instanceof CancelException) {
                            runtimeException = (RuntimeException) partialKeys.getFailure();
                        } else if (partialKeys.getFailure() instanceof LowMemoryException) {
                            // fix for #43589
                            throw partialKeys.getFailure();
                        } else {
                            runtimeException = new PutAllPartialResultException(partialKeys);
                            if (isDebugEnabled) {
                                logger.debug("basicPutAll:" + partialKeys.detailString());
                            }
                        }
                    } else {
                        throw partialKeys.getFailure();
                    }
                }
            }
        } catch (LowMemoryException lme) {
            throw lme;
        } catch (RuntimeException ex) {
            runtimeException = ex;
        } catch (Exception ex) {
            runtimeException = new RuntimeException(ex);
        } finally {
            putAllOp.getBaseEvent().release();
            putAllOp.freeOffHeapResources();
        }
        getDataView().postPutAll(putAllOp, succeeded, this);
    } finally {
        unlockRVVForBulkOp();
    }
    if (runtimeException != null) {
        throw runtimeException;
    }
    return succeeded;
}
Also used : VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) PutAllPartialResult(org.apache.geode.internal.cache.PutAllPartialResultException.PutAllPartialResult) Endpoint(org.apache.geode.cache.client.internal.Endpoint) TimeoutException(org.apache.geode.cache.TimeoutException) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InternalGemFireException(org.apache.geode.InternalGemFireException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) ExecutionException(java.util.concurrent.ExecutionException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) EntryExistsException(org.apache.geode.cache.EntryExistsException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) StatisticsDisabledException(org.apache.geode.cache.StatisticsDisabledException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) FailedSynchronizationException(org.apache.geode.cache.FailedSynchronizationException) NoSuchElementException(java.util.NoSuchElementException) QueryException(org.apache.geode.cache.query.QueryException) RedundancyAlreadyMetException(org.apache.geode.internal.cache.partitioned.RedundancyAlreadyMetException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) LowMemoryException(org.apache.geode.cache.LowMemoryException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) SystemException(javax.transaction.SystemException) SubscriptionNotEnabledException(org.apache.geode.cache.client.SubscriptionNotEnabledException) RegionExistsException(org.apache.geode.cache.RegionExistsException) RegionReinitializedException(org.apache.geode.cache.RegionReinitializedException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IndexMaintenanceException(org.apache.geode.cache.query.IndexMaintenanceException) TransactionException(org.apache.geode.cache.TransactionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) RollbackException(javax.transaction.RollbackException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) MultiIndexCreationException(org.apache.geode.cache.query.MultiIndexCreationException) DeltaSerializationException(org.apache.geode.DeltaSerializationException) LRUEntry(org.apache.geode.internal.cache.lru.LRUEntry) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) TransactionException(org.apache.geode.cache.TransactionException) Iterator(java.util.Iterator) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) StoredObject(org.apache.geode.internal.offheap.StoredObject) CancelException(org.apache.geode.CancelException) Map(java.util.Map) IndexMap(org.apache.geode.internal.cache.persistence.query.IndexMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashMap(java.util.HashMap) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Example 15 with TransactionException

use of org.apache.geode.cache.TransactionException in project geode by apache.

the class MultiRegionFunctionExecutor method validateExecution.

@Override
public void validateExecution(Function function, Set targetMembers) {
    InternalCache cache = null;
    for (Region r : regions) {
        cache = (InternalCache) r.getCache();
        break;
    }
    if (cache != null && cache.getTxManager().getTXState() != null) {
        if (targetMembers.size() > 1) {
            throw new TransactionException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_ON_MORE_THAN_ONE_NODE.toLocalizedString());
        } else {
            assert targetMembers.size() == 1;
            DistributedMember funcTarget = (DistributedMember) targetMembers.iterator().next();
            DistributedMember target = cache.getTxManager().getTXState().getTarget();
            if (target == null) {
                cache.getTxManager().getTXState().setTarget(funcTarget);
            } else if (!target.equals(funcTarget)) {
                throw new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_EXECUTION_NOT_COLOCATED_0_1.toLocalizedString(target, funcTarget));
            }
        }
    }
    if (function.optimizeForWrite() && cache.getInternalResourceManager().getHeapMonitor().containsHeapCriticalMembers(targetMembers) && !MemoryThresholds.isLowMemoryExceptionDisabled()) {
        Set<InternalDistributedMember> hcm = cache.getResourceAdvisor().adviseCritialMembers();
        Set<DistributedMember> sm = SetUtils.intersection(hcm, targetMembers);
        throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_FOR_0_FUNCEXEC_MEMBERS_1.toLocalizedString(function.getId(), sm), sm);
    }
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Aggregations

TransactionException (org.apache.geode.cache.TransactionException)31 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)12 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)11 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)9 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)9 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)9 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)9 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)7 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)7 LowMemoryException (org.apache.geode.cache.LowMemoryException)6 DistributedMember (org.apache.geode.distributed.DistributedMember)6 InternalCache (org.apache.geode.internal.cache.InternalCache)6 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)5 CacheWriterException (org.apache.geode.cache.CacheWriterException)5 UnsupportedOperationInTransactionException (org.apache.geode.cache.UnsupportedOperationInTransactionException)5 IOException (java.io.IOException)4 RollbackException (javax.transaction.RollbackException)4 CancelException (org.apache.geode.CancelException)4 CacheClosedException (org.apache.geode.cache.CacheClosedException)4 CommitConflictException (org.apache.geode.cache.CommitConflictException)4