Search in sources :

Example 21 with TransactionDataNotColocatedException

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

the class DistributedTXRegionStub method postPutAll.

public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, LocalRegion region) {
    try {
        RemotePutAllMessage.PutAllResponse response = RemotePutAllMessage.send(state.getTarget(), putallOp.getBaseEvent(), putallOp.getPutAllEntryData(), putallOp.getPutAllEntryData().length, true, DistributionManager.PARTITIONED_REGION_EXECUTOR, false);
        response.waitForCacheException();
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
}
Also used : RemotePutAllMessage(org.apache.geode.internal.cache.RemotePutAllMessage) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 22 with TransactionDataNotColocatedException

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

the class DistributedTXRegionStub method postRemoveAll.

@Override
public void postRemoveAll(DistributedRemoveAllOperation op, VersionedObjectList successfulOps, LocalRegion region) {
    try {
        RemoteRemoveAllMessage.RemoveAllResponse response = RemoteRemoveAllMessage.send(state.getTarget(), op.getBaseEvent(), op.getRemoveAllEntryData(), op.getRemoveAllEntryData().length, true, DistributionManager.PARTITIONED_REGION_EXECUTOR, false);
        response.waitForCacheException();
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
}
Also used : RemoteRemoveAllMessage(org.apache.geode.internal.cache.RemoteRemoveAllMessage) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 23 with TransactionDataNotColocatedException

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

the class DistributedTXRegionStub method invalidateExistingEntry.

public void invalidateExistingEntry(EntryEventImpl event, boolean invokeCallbacks, boolean forceNewEntry) {
    try {
        RemoteOperationResponse response = RemoteInvalidateMessage.send(state.getTarget(), event.getRegion(), event, DistributionManager.PARTITIONED_REGION_EXECUTOR, true, false);
        response.waitForCacheException();
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) RemoteOperationResponse(org.apache.geode.internal.cache.RemoteOperationMessage.RemoteOperationResponse) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 24 with TransactionDataNotColocatedException

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

the class RemoteRemoveAllMessage method distribute.

/*
   * this is similar to send() but it selects an initialized replicate that is used to proxy the
   * message
   * 
   */
public static boolean distribute(EntryEventImpl event, RemoveAllEntryData[] data, int dataCount) {
    boolean successful = false;
    DistributedRegion r = (DistributedRegion) event.getRegion();
    Collection replicates = r.getCacheDistributionAdvisor().adviseInitializedReplicates();
    if (replicates.isEmpty()) {
        return false;
    }
    if (replicates.size() > 1) {
        ArrayList l = new ArrayList(replicates);
        Collections.shuffle(l);
        replicates = l;
    }
    int attempts = 0;
    for (Iterator<InternalDistributedMember> it = replicates.iterator(); it.hasNext(); ) {
        InternalDistributedMember replicate = it.next();
        try {
            attempts++;
            final boolean posDup = (attempts > 1);
            RemoveAllResponse response = send(replicate, event, data, dataCount, false, DistributionManager.SERIAL_EXECUTOR, posDup);
            response.waitForCacheException();
            VersionedObjectList result = response.getResponse();
            // Set successful version tags in RemoveAllEntryData.
            List successfulKeys = result.getKeys();
            List<VersionTag> versions = result.getVersionTags();
            for (RemoveAllEntryData removeAllEntry : data) {
                Object key = removeAllEntry.getKey();
                if (successfulKeys.contains(key)) {
                    int index = successfulKeys.indexOf(key);
                    removeAllEntry.versionTag = versions.get(index);
                }
            }
            return true;
        } catch (TransactionDataNotColocatedException enfe) {
            throw enfe;
        } catch (CancelException e) {
            event.getRegion().getCancelCriterion().checkCancelInProgress(e);
        } catch (CacheException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("RemoteRemoveAllMessage caught CacheException during distribution", e);
            }
            // not a cancel-exception, so don't complain any more about it
            successful = true;
        } catch (RemoteOperationException e) {
            if (logger.isTraceEnabled(LogMarker.DM)) {
                logger.trace(LogMarker.DM, "RemoteRemoveAllMessage caught an unexpected exception during distribution", e);
            }
        }
    }
    return successful;
}
Also used : CacheException(org.apache.geode.cache.CacheException) ArrayList(java.util.ArrayList) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) Collection(java.util.Collection) EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) ArrayList(java.util.ArrayList) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) List(java.util.List) CancelException(org.apache.geode.CancelException)

Example 25 with TransactionDataNotColocatedException

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

the class RemoteInvalidateMessage method distribute.

public static boolean distribute(EntryEventImpl event, boolean onlyPersistent) {
    boolean successful = false;
    DistributedRegion r = (DistributedRegion) event.getRegion();
    Collection replicates = onlyPersistent ? r.getCacheDistributionAdvisor().adviseInitializedPersistentMembers().keySet() : r.getCacheDistributionAdvisor().adviseInitializedReplicates();
    if (replicates.isEmpty()) {
        return false;
    }
    if (replicates.size() > 1) {
        ArrayList l = new ArrayList(replicates);
        Collections.shuffle(l);
        replicates = l;
    }
    int attempts = 0;
    for (Iterator<InternalDistributedMember> it = replicates.iterator(); it.hasNext(); ) {
        InternalDistributedMember replicate = it.next();
        try {
            attempts++;
            final boolean posDup = (attempts > 1);
            InvalidateResponse processor = send(replicate, event.getRegion(), event, DistributionManager.SERIAL_EXECUTOR, false, posDup);
            processor.waitForCacheException();
            VersionTag versionTag = processor.getVersionTag();
            if (versionTag != null) {
                event.setVersionTag(versionTag);
                if (event.getRegion().getVersionVector() != null) {
                    event.getRegion().getVersionVector().recordVersion(versionTag.getMemberID(), versionTag);
                }
            }
            event.setInhibitDistribution(true);
            return true;
        } catch (TransactionDataNotColocatedException enfe) {
            throw enfe;
        } catch (CancelException e) {
            event.getRegion().getCancelCriterion().checkCancelInProgress(e);
        } catch (EntryNotFoundException e) {
            throw new EntryNotFoundException("" + event.getKey());
        } catch (CacheException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("RemoteDestroyMessage caught CacheException during distribution", e);
            }
            // not a cancel-exception, so don't complain any more about it
            successful = true;
        } catch (RemoteOperationException e) {
            if (logger.isTraceEnabled(LogMarker.DM)) {
                logger.trace(LogMarker.DM, "RemoteDestroyMessage caught an unexpected exception during distribution", e);
            }
        }
    }
    return successful;
}
Also used : CacheException(org.apache.geode.cache.CacheException) ArrayList(java.util.ArrayList) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) DiskVersionTag(org.apache.geode.internal.cache.versions.DiskVersionTag) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) Collection(java.util.Collection) CancelException(org.apache.geode.CancelException)

Aggregations

TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)27 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)13 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)11 CacheException (org.apache.geode.cache.CacheException)10 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)10 TransactionException (org.apache.geode.cache.TransactionException)10 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)9 ArrayList (java.util.ArrayList)8 CustId (org.apache.geode.internal.cache.execute.data.CustId)7 CommitConflictException (org.apache.geode.cache.CommitConflictException)6 Region (org.apache.geode.cache.Region)6 TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)6 RemoteOperationException (org.apache.geode.internal.cache.RemoteOperationException)6 Customer (org.apache.geode.internal.cache.execute.data.Customer)6 Collection (java.util.Collection)5 CancelException (org.apache.geode.CancelException)5 UnsupportedOperationInTransactionException (org.apache.geode.cache.UnsupportedOperationInTransactionException)5 NamingException (javax.naming.NamingException)4 RollbackException (javax.transaction.RollbackException)4 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)4