Search in sources :

Example 16 with PrimaryBucketException

use of org.apache.geode.internal.cache.PrimaryBucketException in project geode by apache.

the class PartitionedTXRegionStub method findObject.

public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object value, boolean peferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent) {
    Object retVal = null;
    final Object key = keyInfo.getKey();
    final Object callbackArgument = keyInfo.getCallbackArg();
    PartitionedRegion pr = (PartitionedRegion) region;
    try {
        retVal = pr.getRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), key, callbackArgument, peferCD, requestingClient, clientEvent, false);
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        if (isBucketNotFoundException(e)) {
            RuntimeException re = getTransactionException(keyInfo, e);
            re.initCause(e);
            throw re;
        }
        waitToRetry();
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e);
        throw re;
    }
    trackBucketForTx(keyInfo);
    return retVal;
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException)

Example 17 with PrimaryBucketException

use of org.apache.geode.internal.cache.PrimaryBucketException in project geode by apache.

the class PartitionedTXRegionStub method invalidateExistingEntry.

public void invalidateExistingEntry(EntryEventImpl event, boolean invokeCallbacks, boolean forceNewEntry) {
    PartitionedRegion pr = (PartitionedRegion) event.getLocalRegion();
    try {
        pr.invalidateRemotely(state.getTarget(), event.getKeyInfo().getBucketId(), event);
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        RuntimeException re;
        if (isBucketNotFoundException(e)) {
            re = new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString());
        } else {
            re = new TransactionDataNodeHasDepartedException(LocalizedStrings.PartitionedRegion_TRANSACTION_DATA_NODE_0_HAS_DEPARTED_TO_PROCEED_ROLLBACK_THIS_TRANSACTION_AND_BEGIN_A_NEW_ONE.toLocalizedString(state.getTarget()));
        }
        re.initCause(e);
        waitToRetry();
        throw re;
    }
    trackBucketForTx(event.getKeyInfo());
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 18 with PrimaryBucketException

use of org.apache.geode.internal.cache.PrimaryBucketException in project geode by apache.

the class LuceneEventListener method process.

protected boolean process(final List<AsyncEvent> events) {
    // Try to get a PDX instance if possible, rather than a deserialized object
    DefaultQuery.setPdxReadSerialized(true);
    Set<IndexRepository> affectedRepos = new HashSet<IndexRepository>();
    try {
        for (AsyncEvent event : events) {
            Region region = event.getRegion();
            Object key = event.getKey();
            Object callbackArgument = event.getCallbackArgument();
            IndexRepository repository = repositoryManager.getRepository(region, key, callbackArgument);
            Object value = getValue(region.getEntry(key));
            if (value != null) {
                repository.update(key, value);
            } else {
                repository.delete(key);
            }
            affectedRepos.add(repository);
        }
        for (IndexRepository repo : affectedRepos) {
            repo.commit();
        }
        return true;
    } catch (BucketNotFoundException | RegionDestroyedException | PrimaryBucketException e) {
        logger.debug("Bucket not found while saving to lucene index: " + e.getMessage(), e);
        return false;
    } catch (CacheClosedException e) {
        logger.debug("Unable to save to lucene index, cache has been closed", e);
        return false;
    } catch (AlreadyClosedException e) {
        logger.debug("Unable to commit, the lucene index is already closed", e);
        return false;
    } catch (IOException e) {
        throw new InternalGemFireError("Unable to save to lucene index", e);
    } finally {
        DefaultQuery.setPdxReadSerialized(false);
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) CacheClosedException(org.apache.geode.cache.CacheClosedException) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) IOException(java.io.IOException) AsyncEvent(org.apache.geode.cache.asyncqueue.AsyncEvent) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) IndexRepository(org.apache.geode.cache.lucene.internal.repository.IndexRepository) Region(org.apache.geode.cache.Region) BucketNotFoundException(org.apache.geode.internal.cache.BucketNotFoundException) HashSet(java.util.HashSet) InternalGemFireError(org.apache.geode.InternalGemFireError)

Aggregations

PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)18 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)11 TransactionException (org.apache.geode.cache.TransactionException)8 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)7 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)6 ReplyException (org.apache.geode.distributed.internal.ReplyException)6 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)6 TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)5 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 EntryEventImpl (org.apache.geode.internal.cache.EntryEventImpl)4 InternalGemFireError (org.apache.geode.InternalGemFireError)3 CacheClosedException (org.apache.geode.cache.CacheClosedException)3 Region (org.apache.geode.cache.Region)3 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)3 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)3 DataLocationException (org.apache.geode.internal.cache.DataLocationException)3 Released (org.apache.geode.internal.offheap.annotations.Released)3 IOException (java.io.IOException)2 CacheWriterException (org.apache.geode.cache.CacheWriterException)2 RegionFunctionContext (org.apache.geode.cache.execute.RegionFunctionContext)2