use of org.apache.geode.cache.TimeoutException in project geode by apache.
the class LocalRegion method localDestroyNoCallbacks.
/**
* WARNING: this method is overridden in subclasses.
*/
protected void localDestroyNoCallbacks(Object key) {
if (logger.isDebugEnabled()) {
logger.debug("localDestroyNoCallbacks key={}", key);
}
checkReadiness();
validateKey(key);
@Released EntryEventImpl event = EntryEventImpl.create(this, Operation.LOCAL_DESTROY, key, false, getMyId(), false, /* generateCallbacks */
true);
try {
// expectedOldValue
basicDestroy(event, false, null);
} catch (CacheWriterException e) {
// cache writer not called
throw new Error(LocalizedStrings.LocalRegion_CACHE_WRITER_SHOULD_NOT_HAVE_BEEN_CALLED_FOR_LOCALDESTROY.toLocalizedString(), e);
} catch (TimeoutException e) {
// no distributed lock
throw new Error(LocalizedStrings.LocalRegion_NO_DISTRIBUTED_LOCK_SHOULD_HAVE_BEEN_ATTEMPTED_FOR_LOCALDESTROY.toLocalizedString(), e);
} catch (EntryNotFoundException ignore) {
// not a problem
} finally {
event.release();
}
}
use of org.apache.geode.cache.TimeoutException in project geode by apache.
the class SearchLoadAndWriteProcessor method waitForObject2.
private synchronized void waitForObject2(final int timeoutMs) throws TimeoutException {
if (this.requestInProgress) {
try {
final DM dm = this.region.getCache().getInternalDistributedSystem().getDistributionManager();
long waitTimeMs = timeoutMs;
final long endTime = System.currentTimeMillis() + waitTimeMs;
for (; ; ) {
if (!this.requestInProgress) {
return;
}
if (waitTimeMs <= 0) {
throw new TimeoutException(LocalizedStrings.SearchLoadAndWriteProcessor_TIMED_OUT_WHILE_DOING_NETSEARCHNETLOADNETWRITE_PROCESSORID_0_KEY_IS_1.toLocalizedString(new Object[] { this.processorId, this.key }));
}
boolean interrupted = Thread.interrupted();
int lastNS = this.lastNotifySpot;
try {
{
boolean done = (lastNS != 0);
while (!done && waitTimeMs > 0) {
this.region.getCancelCriterion().checkCancelInProgress(null);
interrupted = Thread.interrupted() || interrupted;
long wt = Math.min(RETRY_TIME, waitTimeMs);
// spurious wakeup ok
wait(wt);
lastNS = this.lastNotifySpot;
done = (lastNS != 0);
if (!done) {
// calc remaing wait time to fix bug 37196
waitTimeMs = endTime - System.currentTimeMillis();
}
}
// while
if (done) {
this.lastNotifySpot = 0;
}
}
if (this.requestInProgress && !this.selectedNodeDead) {
// added the test of "!this.selectedNodeDead" for bug 37196
StringBuilder sb = new StringBuilder(200);
sb.append("processorId=").append(this.processorId);
sb.append(" Key is ").append(this.key);
sb.append(" searchTimeoutMs ").append(timeoutMs);
if (waitTimeMs > 0) {
sb.append(" msRemaining=").append(waitTimeMs);
}
if (lastNS != 0) {
sb.append(" lastNotifySpot=").append(lastNS);
}
throw new TimeoutException(LocalizedStrings.SearchLoadAndWriteProcessor_TIMEOUT_DURING_NETSEARCHNETLOADNETWRITE_DETAILS_0.toLocalizedString(sb));
}
return;
} catch (InterruptedException ignore) {
interrupted = true;
region.getCancelCriterion().checkCancelInProgress(null);
// keep waiting until we are done
waitTimeMs = endTime - System.currentTimeMillis();
// continue
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
// for
} finally {
computeRemainingTimeout();
}
}
// requestInProgress
}
use of org.apache.geode.cache.TimeoutException in project geode by apache.
the class SearchLoadAndWriteProcessor method load.
private void load(EntryEventImpl event) throws CacheLoaderException, TimeoutException {
Object obj = null;
RegionAttributes attrs = this.region.getAttributes();
Scope scope = attrs.getScope();
CacheLoader loader = ((AbstractRegion) region).basicGetLoader();
Assert.assertTrue(scope.isDistributed());
if ((loader != null) && (!scope.isGlobal())) {
obj = doLocalLoad(loader, false);
event.setNewValue(obj);
Assert.assertTrue(obj != Token.INVALID && obj != Token.LOCAL_INVALID);
return;
}
if (scope.isGlobal()) {
Assert.assertTrue(this.lock == null);
Set loadCandidatesSet = advisor.adviseNetLoad();
if ((loader == null) && (loadCandidatesSet.isEmpty())) {
// no one has a data Loader. No point getting a lock
return;
}
this.lock = region.getDistributedLock(this.key);
boolean locked = false;
try {
final CancelCriterion stopper = region.getCancelCriterion();
for (; ; ) {
stopper.checkCancelInProgress(null);
boolean interrupted = Thread.interrupted();
try {
locked = this.lock.tryLock(region.getCache().getLockTimeout(), TimeUnit.SECONDS);
if (!locked) {
throw new TimeoutException(LocalizedStrings.SearchLoadAndWriteProcessor_TIMED_OUT_LOCKING_0_BEFORE_LOAD.toLocalizedString(key));
}
break;
} catch (InterruptedException ignore) {
interrupted = true;
region.getCancelCriterion().checkCancelInProgress(null);
// continue;
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
// for
if (loader == null) {
this.localLoad = false;
if (scope.isDistributed()) {
this.isSerialized = false;
obj = doNetLoad();
Assert.assertTrue(obj != Token.INVALID && obj != Token.LOCAL_INVALID);
if (this.isSerialized && obj != null) {
event.setSerializedNewValue((byte[]) obj);
} else {
event.setNewValue(obj);
}
}
} else {
obj = doLocalLoad(loader, false);
Assert.assertTrue(obj != Token.INVALID && obj != Token.LOCAL_INVALID);
event.setNewValue(obj);
}
return;
} finally {
// called on this processor
if (!locked)
this.lock = null;
}
}
if (scope.isDistributed()) {
// long start = System.currentTimeMillis();
obj = doNetLoad();
if (this.isSerialized && obj != null) {
event.setSerializedNewValue((byte[]) obj);
} else {
Assert.assertTrue(obj != Token.INVALID && obj != Token.LOCAL_INVALID);
event.setNewValue(obj);
}
// long end = System.currentTimeMillis();
}
}
use of org.apache.geode.cache.TimeoutException in project geode by apache.
the class HARegionQueue method peek.
public Object peek() throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
Conflatable object = null;
Long next = null;
while (true) {
try {
next = (Long) this.getNextAvailableIDFromList();
if (next == null) {
break;
}
} catch (TimeoutException ignore) {
throw new InterruptedException();
}
object = (Conflatable) this.region.get(next);
if (object != null) {
// peeked a object, so add the correponding counter to thread-context
object = (object instanceof HAEventWrapper) ? (Conflatable) this.haContainer.get(object) : object;
if (object != null) {
// Is it possible for object to be null...when?
List peekedEvents;
if ((peekedEvents = (List) HARegionQueue.peekedEventsContext.get()) != null) {
peekedEvents.add(next);
} else {
peekedEvents = new LinkedList();
peekedEvents.add(next);
HARegionQueue.peekedEventsContext.set(peekedEvents);
}
this.storePeekedID(next);
break;
}
}
}
// since size is zero, return null
if (logger.isTraceEnabled()) {
logger.trace("HARegionQueue::peek: Returning object from head = {}", object);
}
return object;
}
use of org.apache.geode.cache.TimeoutException in project geode by apache.
the class ReplyProcessor21 method timeout.
/**
* process a wait-timeout. Usually suspectThem would be used in the first timeout, followed by a
* subsequent use of disconnectThem
*
* @param suspectThem whether to ask the membership manager to suspect the unresponsive members
* @param severeAlert whether to ask the membership manager to disconnect the unresponseive
* members
*/
private void timeout(boolean suspectThem, boolean severeAlert) {
if (!this.processTimeout())
return;
Set activeMembers = getDistributionManagerIds();
// an alert that will show up in the console
long timeout = getAckWaitThreshold();
final Object[] msgArgs = new Object[] { Long.valueOf(timeout + (severeAlert ? getSevereAlertThreshold() : 0)), this, getDistributionManager().getId(), activeMembers };
final StringId msg = LocalizedStrings.ReplyProcessor21_0_SEC_HAVE_ELAPSED_WHILE_WAITING_FOR_REPLIES_1_ON_2_WHOSE_CURRENT_MEMBERSHIP_LIST_IS_3;
if (severeAlert) {
logger.fatal(LocalizedMessage.create(msg, msgArgs));
} else {
logger.warn(LocalizedMessage.create(msg, msgArgs));
}
msgArgs[3] = "(omitted)";
Breadcrumbs.setProblem(msg, msgArgs);
// Increment the stat
getDistributionManager().getStats().incReplyTimeouts();
final Set suspectMembers;
if (suspectThem || severeAlert) {
suspectMembers = new HashSet();
} else {
suspectMembers = null;
}
synchronized (this.members) {
for (int i = 0; i < this.members.length; i++) {
if (this.members[i] != null) {
if (!activeMembers.contains(this.members[i])) {
logger.warn(LocalizedMessage.create(LocalizedStrings.ReplyProcessor21_VIEW_NO_LONGER_HAS_0_AS_AN_ACTIVE_MEMBER_SO_WE_WILL_NO_LONGER_WAIT_FOR_IT, this.members[i]));
memberDeparted(this.members[i], false);
} else {
if (suspectMembers != null) {
suspectMembers.add(this.members[i]);
}
}
}
}
}
if (THROW_EXCEPTION_ON_TIMEOUT) {
// init the cause to be a TimeoutException so catchers can determine cause
TimeoutException cause = new TimeoutException(LocalizedStrings.TIMED_OUT_WAITING_FOR_ACKS.toLocalizedString());
throw new InternalGemFireException(LocalizedStrings.ReplyProcessor21_0_SEC_HAVE_ELAPSED_WHILE_WAITING_FOR_REPLIES_1_ON_2_WHOSE_CURRENT_MEMBERSHIP_LIST_IS_3.toLocalizedString(msgArgs), cause);
} else if (suspectThem) {
if (suspectMembers != null && suspectMembers.size() > 0) {
getDistributionManager().getMembershipManager().suspectMembers(suspectMembers, "Failed to respond within ack-wait-threshold");
}
}
}
Aggregations