Search in sources :

Example 6 with Bucket

use of org.apache.geode.internal.cache.partitioned.Bucket in project geode by apache.

the class PrepareNewPersistentMemberMessage method process.

@Override
protected void process(DistributionManager dm) {
    // Set thread local flag to allow entrance through initialization Latch
    int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT);
    PersistentMemberState state = null;
    PersistentMemberID myId = null;
    ReplyException exception = null;
    try {
        // get the region from the path, but do NOT wait on initialization,
        // otherwise we could have a distributed deadlock
        Cache cache = CacheFactory.getInstance(dm.getSystem());
        Region region = cache.getRegion(this.regionPath);
        PersistenceAdvisor persistenceAdvisor = null;
        if (region instanceof DistributedRegion) {
            persistenceAdvisor = ((DistributedRegion) region).getPersistenceAdvisor();
        } else if (region == null) {
            Bucket proxy = PartitionedRegionHelper.getProxyBucketRegion(GemFireCacheImpl.getInstance(), this.regionPath, false);
            if (proxy != null) {
                persistenceAdvisor = proxy.getPersistenceAdvisor();
            }
        }
        if (persistenceAdvisor != null) {
            persistenceAdvisor.prepareNewMember(getSender(), oldId, newId);
        }
    } catch (RegionDestroyedException e) {
        logger.debug("<RegionDestroyed> {}", this);
    } catch (CancelException e) {
        logger.debug("<CancelException> {}", this);
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (Throwable t) {
        SystemFailure.checkFailure();
        exception = new ReplyException(t);
    } finally {
        LocalRegion.setThreadInitLevelRequirement(oldLevel);
        ReplyMessage replyMsg = new ReplyMessage();
        replyMsg.setRecipient(getSender());
        replyMsg.setProcessorId(processorId);
        if (exception != null) {
            replyMsg.setException(exception);
        }
        dm.putOutgoing(replyMsg);
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) ReplyException(org.apache.geode.distributed.internal.ReplyException) ReplyMessage(org.apache.geode.distributed.internal.ReplyMessage) Bucket(org.apache.geode.internal.cache.partitioned.Bucket) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Region(org.apache.geode.cache.Region) CancelException(org.apache.geode.CancelException) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Cache(org.apache.geode.cache.Cache)

Example 7 with Bucket

use of org.apache.geode.internal.cache.partitioned.Bucket in project geode by apache.

the class RemovePersistentMemberMessage method process.

@Override
protected void process(DistributionManager dm) {
    // Set thread local flag to allow entrance through initialization Latch
    int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT);
    PersistentMemberState state = null;
    PersistentMemberID myId = null;
    ReplyException exception = null;
    try {
        // get the region from the path, but do NOT wait on initialization,
        // otherwise we could have a distributed deadlock
        Cache cache = CacheFactory.getInstance(dm.getSystem());
        Region region = cache.getRegion(this.regionPath);
        PersistenceAdvisor persistenceAdvisor = null;
        if (region instanceof DistributedRegion) {
            persistenceAdvisor = ((DistributedRegion) region).getPersistenceAdvisor();
        } else if (region == null) {
            Bucket proxy = PartitionedRegionHelper.getProxyBucketRegion(GemFireCacheImpl.getInstance(), this.regionPath, false);
            if (proxy != null) {
                persistenceAdvisor = proxy.getPersistenceAdvisor();
            }
        }
        if (persistenceAdvisor != null) {
            if (id != null) {
                persistenceAdvisor.removeMember(id);
            }
            if (initializingId != null) {
                persistenceAdvisor.removeMember(initializingId);
            }
        }
    } catch (RegionDestroyedException e) {
        logger.debug("<RegionDestroyed> {}", this);
    } catch (CancelException e) {
        logger.debug("<CancelException> {}", this);
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (Throwable t) {
        SystemFailure.checkFailure();
        exception = new ReplyException(t);
    } finally {
        LocalRegion.setThreadInitLevelRequirement(oldLevel);
        ReplyMessage replyMsg = new ReplyMessage();
        replyMsg.setRecipient(getSender());
        replyMsg.setProcessorId(processorId);
        if (exception != null) {
            replyMsg.setException(exception);
        }
        dm.putOutgoing(replyMsg);
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) ReplyException(org.apache.geode.distributed.internal.ReplyException) ReplyMessage(org.apache.geode.distributed.internal.ReplyMessage) Bucket(org.apache.geode.internal.cache.partitioned.Bucket) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Region(org.apache.geode.cache.Region) CancelException(org.apache.geode.CancelException) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Cache(org.apache.geode.cache.Cache)

Example 8 with Bucket

use of org.apache.geode.internal.cache.partitioned.Bucket in project geode by apache.

the class AbstractIndex method query.

@Override
public void query(Object key, int operator, Collection results, @Retained CompiledValue iterOp, RuntimeIterator indpndntItr, ExecutionContext context, List projAttrib, SelectResults intermediateResults, boolean isIntersection) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException {
    // get a read lock when doing a lookup
    if (context.getBucketList() != null && this.region instanceof BucketRegion) {
        PartitionedRegion pr = ((Bucket) region).getPartitionedRegion();
        long start = updateIndexUseStats();
        try {
            for (Object bucketId : context.getBucketList()) {
                AbstractIndex bucketIndex = PartitionedIndex.getBucketIndex(pr, this.indexName, (Integer) bucketId);
                if (bucketIndex == null) {
                    continue;
                }
                bucketIndex.lockedQuery(key, operator, results, iterOp, indpndntItr, context, projAttrib, intermediateResults, isIntersection);
            }
        } finally {
            updateIndexUseEndStats(start);
        }
    } else {
        long start = updateIndexUseStats();
        try {
            lockedQuery(key, operator, results, iterOp, indpndntItr, context, projAttrib, intermediateResults, isIntersection);
        } finally {
            updateIndexUseEndStats(start);
        }
    }
}
Also used : BucketRegion(org.apache.geode.internal.cache.BucketRegion) Bucket(org.apache.geode.internal.cache.partitioned.Bucket) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Example 9 with Bucket

use of org.apache.geode.internal.cache.partitioned.Bucket in project geode by apache.

the class AbstractIndex method query.

@Override
public void query(Collection results, Set keysToRemove, ExecutionContext context) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException {
    Iterator iterator = keysToRemove.iterator();
    Object temp = iterator.next();
    iterator.remove();
    if (context.getBucketList() != null && this.region instanceof BucketRegion) {
        long start = updateIndexUseStats();
        try {
            PartitionedRegion partitionedRegion = ((Bucket) this.region).getPartitionedRegion();
            for (Object bucketId : context.getBucketList()) {
                AbstractIndex bucketIndex = PartitionedIndex.getBucketIndex(partitionedRegion, this.indexName, (Integer) bucketId);
                if (bucketIndex == null) {
                    continue;
                }
                bucketIndex.lockedQuery(temp, OQLLexerTokenTypes.TOK_NE, results, iterator.hasNext() ? keysToRemove : null, context);
            }
        } finally {
            updateIndexUseEndStats(start);
        }
    } else {
        long start = updateIndexUseStats();
        try {
            lockedQuery(temp, OQLLexerTokenTypes.TOK_NE, results, iterator.hasNext() ? keysToRemove : null, context);
        } finally {
            updateIndexUseEndStats(start);
        }
    }
}
Also used : BucketRegion(org.apache.geode.internal.cache.BucketRegion) Bucket(org.apache.geode.internal.cache.partitioned.Bucket) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RuntimeIterator(org.apache.geode.cache.query.internal.RuntimeIterator) CloseableIterator(org.apache.geode.internal.cache.persistence.query.CloseableIterator) Iterator(java.util.Iterator)

Example 10 with Bucket

use of org.apache.geode.internal.cache.partitioned.Bucket in project geode by apache.

the class AbstractIndex method query.

@Override
public void query(Object lowerBoundKey, int lowerBoundOperator, Object upperBoundKey, int upperBoundOperator, Collection results, Set keysToRemove, ExecutionContext context) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException {
    if (context.getBucketList() != null) {
        if (this.region instanceof BucketRegion) {
            PartitionedRegion partitionedRegion = ((Bucket) this.region).getPartitionedRegion();
            long start = updateIndexUseStats();
            try {
                for (Object bucketId : context.getBucketList()) {
                    AbstractIndex bucketIndex = PartitionedIndex.getBucketIndex(partitionedRegion, this.indexName, (Integer) bucketId);
                    if (bucketIndex == null) {
                        continue;
                    }
                    bucketIndex.lockedQuery(lowerBoundKey, lowerBoundOperator, upperBoundKey, upperBoundOperator, results, keysToRemove, context);
                }
            } finally {
                updateIndexUseEndStats(start);
            }
        }
    } else {
        long start = updateIndexUseStats();
        try {
            lockedQuery(lowerBoundKey, lowerBoundOperator, upperBoundKey, upperBoundOperator, results, keysToRemove, context);
        } finally {
            updateIndexUseEndStats(start);
        }
    }
}
Also used : BucketRegion(org.apache.geode.internal.cache.BucketRegion) Bucket(org.apache.geode.internal.cache.partitioned.Bucket) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Aggregations

Bucket (org.apache.geode.internal.cache.partitioned.Bucket)22 BucketRegion (org.apache.geode.internal.cache.BucketRegion)11 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)11 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)9 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)7 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)6 Test (org.junit.Test)6 CancelException (org.apache.geode.CancelException)5 Cache (org.apache.geode.cache.Cache)4 Region (org.apache.geode.cache.Region)4 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)4 ReplyException (org.apache.geode.distributed.internal.ReplyException)4 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)4 LocalRegion (org.apache.geode.internal.cache.LocalRegion)4 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)4 ReplyMessage (org.apache.geode.distributed.internal.ReplyMessage)3 RemoveBucketResponse (org.apache.geode.internal.cache.partitioned.RemoveBucketMessage.RemoveBucketResponse)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1