Search in sources :

Example 1 with ForceReattemptException

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

the class DefaultQueryService method createIndex.

public Index createIndex(String indexName, IndexType indexType, String indexedExpression, String fromClause, String imports, boolean loadEntries, Region region) throws IndexNameConflictException, IndexExistsException, RegionNotFoundException {
    if (pool != null) {
        throw new UnsupportedOperationException("Index creation on the server is not supported from the client.");
    }
    PartitionedIndex parIndex = null;
    if (region == null) {
        region = getRegionFromPath(imports, fromClause);
    }
    RegionAttributes ra = region.getAttributes();
    // if its a pr the create index on all of the local buckets.
    if (((LocalRegion) region).memoryThresholdReached.get() && !MemoryThresholds.isLowMemoryExceptionDisabled()) {
        LocalRegion lr = (LocalRegion) region;
        throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_FOR_INDEX.toLocalizedString(region.getName()), lr.getMemoryThresholdReachedMembers());
    }
    if (region instanceof PartitionedRegion) {
        try {
            parIndex = (PartitionedIndex) ((PartitionedRegion) region).createIndex(false, indexType, indexName, indexedExpression, fromClause, imports, loadEntries);
        } catch (ForceReattemptException ex) {
            region.getCache().getLoggerI18n().info(LocalizedStrings.DefaultQueryService_EXCEPTION_WHILE_CREATING_INDEX_ON_PR_DEFAULT_QUERY_PROCESSOR, ex);
        } catch (IndexCreationException exx) {
            region.getCache().getLoggerI18n().info(LocalizedStrings.DefaultQueryService_EXCEPTION_WHILE_CREATING_INDEX_ON_PR_DEFAULT_QUERY_PROCESSOR, exx);
        }
        return parIndex;
    } else {
        IndexManager indexManager = IndexUtils.getIndexManager(region, true);
        Index index = indexManager.createIndex(indexName, indexType, indexedExpression, fromClause, imports, null, null, loadEntries);
        return index;
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) RegionAttributes(org.apache.geode.cache.RegionAttributes) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Example 2 with ForceReattemptException

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

the class DefaultQueryService method removeIndex.

public void removeIndex(Index index) {
    if (pool != null) {
        throw new UnsupportedOperationException("Index Operation is not supported on the Server Region.");
    }
    Region region = index.getRegion();
    if (region instanceof PartitionedRegion) {
        try {
            ((PartitionedRegion) region).removeIndex(index, false);
        } catch (ForceReattemptException ex) {
            logger.info(LocalizedMessage.create(LocalizedStrings.DefaultQueryService_EXCEPTION_REMOVING_INDEX___0), ex);
        }
        return;
    }
    // get write lock for indexes in replicated region
    // for PR lock will be taken in PartitionRegion.removeIndex
    ((AbstractIndex) index).acquireIndexWriteLockForRemove();
    try {
        IndexManager indexManager = ((LocalRegion) index.getRegion()).getIndexManager();
        indexManager.removeIndex(index);
    } finally {
        ((AbstractIndex) index).releaseIndexWriteLockForRemove();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 3 with ForceReattemptException

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

the class PRUpdateEntryVersionMessage method send.

public static UpdateEntryVersionResponse send(InternalDistributedMember recipient, PartitionedRegion r, EntryEventImpl event) throws ForceReattemptException {
    Set recipients = Collections.singleton(recipient);
    UpdateEntryVersionResponse p = new UpdateEntryVersionResponse(r.getSystem(), recipient, event.getKey());
    PRUpdateEntryVersionMessage m = new PRUpdateEntryVersionMessage(recipients, r.getPRId(), p, event);
    Set failures = r.getDistributionManager().putOutgoing(m);
    if (failures != null && failures.size() > 0) {
        throw new ForceReattemptException(LocalizedStrings.UpdateEntryVersionMessage_FAILED_SENDING_0.toLocalizedString(m));
    }
    return p;
}
Also used : Set(java.util.Set) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException)

Example 4 with ForceReattemptException

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

the class PartitionMessage method process.

/**
   * Upon receipt of the message, both process the message and send an acknowledgement, not
   * necessarily in that order. Note: Any hang in this message may cause a distributed deadlock for
   * those threads waiting for an acknowledgement.
   * 
   * @throws PartitionedRegionException if the region does not exist (typically, if it has been
   *         destroyed)
   */
@Override
public void process(final DistributionManager dm) {
    Throwable thr = null;
    boolean sendReply = true;
    PartitionedRegion pr = null;
    long startTime = 0;
    EntryLogger.setSource(getSender(), "PR");
    try {
        if (checkCacheClosing(dm) || checkDSClosing(dm)) {
            thr = new CacheClosedException(LocalizedStrings.PartitionMessage_REMOTE_CACHE_IS_CLOSED_0.toLocalizedString(dm.getId()));
            return;
        }
        pr = getPartitionedRegion();
        if (pr == null && failIfRegionMissing()) {
            // if the distributed system is disconnecting, don't send a reply saying
            // the partitioned region can't be found (bug 36585)
            thr = new ForceReattemptException(LocalizedStrings.PartitionMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1.toLocalizedString(dm.getDistributionManagerId(), regionId));
            // reply sent in finally block below
            return;
        }
        if (pr != null) {
            startTime = getStartPartitionMessageProcessingTime(pr);
        }
        thr = UNHANDLED_EXCEPTION;
        InternalCache cache = getInternalCache();
        if (cache == null) {
            throw new ForceReattemptException(LocalizedStrings.PartitionMessage_REMOTE_CACHE_IS_CLOSED_0.toLocalizedString());
        }
        TXManagerImpl txMgr = getTXManagerImpl(cache);
        TXStateProxy tx = txMgr.masqueradeAs(this);
        if (tx == null) {
            sendReply = operateOnPartitionedRegion(dm, pr, startTime);
        } else {
            try {
                if (txMgr.isClosed()) {
                    // NO DISTRIBUTED MESSAGING CAN BE DONE HERE!
                    sendReply = false;
                } else if (tx.isInProgress()) {
                    sendReply = operateOnPartitionedRegion(dm, pr, startTime);
                    tx.updateProxyServer(this.getSender());
                }
            } finally {
                txMgr.unmasquerade(tx);
            }
        }
        thr = null;
    } catch (ForceReattemptException fre) {
        thr = fre;
    } catch (DataLocationException fre) {
        thr = new ForceReattemptException(fre.getMessage(), fre);
    } catch (DistributedSystemDisconnectedException se) {
        // bug 37026: this is too noisy...
        // throw new CacheClosedException("remote system shutting down");
        // thr = se; cache is closed, no point trying to send a reply
        thr = null;
        sendReply = false;
        if (logger.isDebugEnabled()) {
            logger.debug("shutdown caught, abandoning message: {}", se.getMessage(), se);
        }
    } catch (RegionDestroyedException | RegionNotFoundException rde) {
        // [bruce] RDE does not always mean that the sender's region is also
        // destroyed, so we must send back an exception. If the sender's
        // region is also destroyed, who cares if we send it an exception
        // if (pr != null && pr.isClosed) {
        thr = new ForceReattemptException(LocalizedStrings.PartitionMessage_REGION_IS_DESTROYED_IN_0.toLocalizedString(dm.getDistributionManagerId()), rde);
    // }
    } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // now, so don't let this thread continue.
        throw err;
    } catch (Throwable t) {
        // Whenever you catch Error or Throwable, you must also
        // catch VirtualMachineError (see above). However, there is
        // _still_ a possibility that you are dealing with a cascading
        // error condition, so you also need to check to see if the JVM
        // is still usable:
        SystemFailure.checkFailure();
        // log the exception at fine level if there is no reply to the message
        thr = null;
        if (sendReply) {
            if (!checkDSClosing(dm)) {
                thr = t;
            } else {
                // don't pass arbitrary runtime exceptions and errors back if this
                // cache/vm is closing
                thr = new ForceReattemptException(LocalizedStrings.PartitionMessage_DISTRIBUTED_SYSTEM_IS_DISCONNECTING.toLocalizedString());
            }
        }
        if (logger.isTraceEnabled(LogMarker.DM) && t instanceof RuntimeException) {
            logger.trace(LogMarker.DM, "Exception caught while processing message: {}", t.getMessage(), t);
        }
    } finally {
        if (sendReply) {
            ReplyException rex = null;
            if (thr != null) {
                // don't transmit the exception if this message was to a listener
                // and this listener is shutting down
                boolean excludeException = this.notificationOnly && ((thr instanceof CancelException) || (thr instanceof ForceReattemptException));
                if (!excludeException) {
                    rex = new ReplyException(thr);
                }
            }
            // Send the reply if the operateOnPartitionedRegion returned true
            sendReply(getSender(), this.processorId, dm, rex, pr, startTime);
            EntryLogger.clearSource();
        }
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) DataLocationException(org.apache.geode.internal.cache.DataLocationException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) InternalCache(org.apache.geode.internal.cache.InternalCache) CacheClosedException(org.apache.geode.cache.CacheClosedException) ReplyException(org.apache.geode.distributed.internal.ReplyException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) CancelException(org.apache.geode.CancelException)

Example 5 with ForceReattemptException

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

the class PutMessage method send.

/**
   * Sends a PartitionedRegion {@link org.apache.geode.cache.Region#put(Object, Object)} message to
   * the recipient
   * 
   * @param recipient the member to which the put message is sent
   * @param r the PartitionedRegion for which the put was performed
   * @param event the event prompting this message
   * @param ifNew whether a new entry must be created
   * @param ifOld whether an old entry must be updated (no creates)
   * @return the processor used to await acknowledgement that the update was sent, or null to
   *         indicate that no acknowledgement will be sent
   * @throws ForceReattemptException if the peer is no longer available
   */
public static PartitionResponse send(DistributedMember recipient, PartitionedRegion r, EntryEventImpl event, final long lastModified, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue) throws ForceReattemptException {
    // Assert.assertTrue(recipient != null, "PutMessage NULL recipient"); recipient can be null for
    // event notifications
    Set recipients = Collections.singleton(recipient);
    PutResponse processor = new PutResponse(r.getSystem(), recipients, event.getKey());
    PutMessage m = new PutMessage(recipients, false, r.getPRId(), processor, event, lastModified, ifNew, ifOld, expectedOldValue, requireOldValue);
    m.setInternalDs(r.getSystem());
    m.setSendDelta(true);
    m.setTransactionDistributed(r.getCache().getTxManager().isDistributed());
    processor.setPutMessage(m);
    Set failures = r.getDistributionManager().putOutgoing(m);
    if (failures != null && failures.size() > 0) {
        throw new ForceReattemptException(LocalizedStrings.PutMessage_FAILED_SENDING_0.toLocalizedString(m));
    }
    return processor;
}
Also used : Set(java.util.Set) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) RemotePutMessage(org.apache.geode.internal.cache.RemotePutMessage)

Aggregations

ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)62 Set (java.util.Set)21 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)13 FunctionException (org.apache.geode.cache.execute.FunctionException)12 ReplyException (org.apache.geode.distributed.internal.ReplyException)11 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)11 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)9 TransactionException (org.apache.geode.cache.TransactionException)8 HashSet (java.util.HashSet)7 CacheException (org.apache.geode.cache.CacheException)7 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)7 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)6 CacheClosedException (org.apache.geode.cache.CacheClosedException)5 TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)5 Host (org.apache.geode.test.dunit.Host)5 VM (org.apache.geode.test.dunit.VM)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 Test (org.junit.Test)5 LinkedList (java.util.LinkedList)4 List (java.util.List)4