use of org.apache.geode.InternalGemFireException in project geode by apache.
the class DistributedCacheTestCase method setUpDistributedCacheTestCase.
/**
* Creates the {@link Cache} and root region in each remote VM and, if createLocalCache, in this
* VM.
*/
private final void setUpDistributedCacheTestCase(boolean createLocalCache) throws Exception {
if (createLocalCache) {
try {
remoteCreateCache();
assertTrue(cache != null);
} catch (Exception ex) {
String s = "While creating cache in this VM";
throw new InternalGemFireException(s, ex);
}
} else {
// make sure we have a connected DistributedSystem
this.getSystem();
}
for (int h = 0; h < Host.getHostCount(); h++) {
Host host = Host.getHost(h);
for (int v = 0; v < host.getVMCount(); v++) {
VM vm = host.getVM(v);
vm.invoke(() -> this.remoteCreateCache());
}
}
}
use of org.apache.geode.InternalGemFireException 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");
}
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class AbstractLRURegionMap method evictEntry.
/**
* Evicts the given entry from the cache. Returns the total number of bytes evicted. 1. For action
* local destroy, returns size(key + value) 2. For action evict to disk, returns size(value)
*
* @return number of bytes evicted, zero if no eviction took place
*/
protected int evictEntry(LRUEntry entry, LRUStatistics stats) throws RegionClearedException {
EvictionAction action = _getCCHelper().getEvictionAction();
LocalRegion region = _getOwner();
if (action.isLocalDestroy()) {
int size = entry.getEntrySize();
if (region.evictDestroy(entry)) {
return size;
} else {
return 0;
}
} else if (action.isOverflowToDisk()) {
Assert.assertTrue(entry instanceof DiskEntry);
int change = 0;
synchronized (entry) {
if (entry.isInUseByTransaction()) {
entry.unsetEvicted();
if (logger.isTraceEnabled(LogMarker.LRU)) {
logger.trace(LogMarker.LRU, "No eviction of transactional entry for key={}", entry.getKey());
}
return 0;
}
// Do the following check while synchronized to fix bug 31761
Token entryVal = entry.getValueAsToken();
if (entryVal == null) {
if (logger.isTraceEnabled(LogMarker.LRU)) {
logger.trace(LogMarker.LRU, "no need to evict already evicted key={}", entry.getKey());
}
return 0;
}
if (Token.isInvalidOrRemoved(entryVal)) {
// and the destroyed token needs to stay in memory
if (logger.isTraceEnabled(LogMarker.LRU)) {
logger.trace(LogMarker.LRU, "no need to evict {} token for key={}", entryVal, entry.getKey());
}
return 0;
}
entry.setEvicted();
change = DiskEntry.Helper.overflowToDisk((DiskEntry) entry, region, _getCCHelper());
}
boolean result = change < 0;
if (result) {
if (_getOwner() instanceof BucketRegion) {
BucketRegion bucketRegion = (BucketRegion) _getOwner();
bucketRegion.updateCounter(change);
// if(bucketRegion.getBucketAdvisor().isPrimary()){
stats.updateCounter(change);
// }
} else {
stats.updateCounter(change);
}
} else {
if (logger.isTraceEnabled(LogMarker.LRU)) {
logger.trace(LogMarker.LRU, "no need to evict token for key={} because moving its value to disk resulted in a net change of {} bytes.", entry.getKey(), change);
}
}
return change * -1;
} else {
throw new InternalGemFireException(LocalizedStrings.AbstractLRURegionMap_UNKNOWN_EVICTION_ACTION_0.toLocalizedString(action));
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class EventID method getMembershipId.
/**
* Convert a ClientProxyMembershipID distribted member ID array into one usable by EventIDs
*
* @param client the client's ID
* @return a byte array that may be used in EventID formation
*/
public static byte[] getMembershipId(ClientProxyMembershipID client) {
try {
HeapDataOutputStream hdos = new HeapDataOutputStream(256, Version.CURRENT);
((InternalDistributedMember) client.getDistributedMember()).writeEssentialData(hdos);
return hdos.toByteArray();
} catch (IOException ioe) {
throw new InternalGemFireException(LocalizedStrings.ClientProxyMembershipID_UNABLE_TO_SERIALIZE_IDENTITY.toLocalizedString(), ioe);
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class SingleHopClientExecutor method submitAllHA.
static boolean submitAllHA(List callableTasks, LocalRegion region, boolean isHA, ResultCollector rc, Set<String> failedNodes) {
ClientMetadataService cms = region.getCache().getClientMetadataService();
boolean reexecute = false;
if (callableTasks != null && !callableTasks.isEmpty()) {
List futures = null;
try {
futures = execService.invokeAll(callableTasks);
} catch (RejectedExecutionException rejectedExecutionEx) {
throw rejectedExecutionEx;
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
}
if (futures != null) {
GemFireException functionExecutionException = null;
Iterator futureItr = futures.iterator();
Iterator taskItr = callableTasks.iterator();
final boolean isDebugEnabled = logger.isDebugEnabled();
while (futureItr.hasNext() && !execService.isShutdown() && !execService.isTerminated()) {
Future fut = (Future) futureItr.next();
SingleHopOperationCallable task = (SingleHopOperationCallable) taskItr.next();
ServerLocation server = task.getServer();
try {
fut.get();
if (isDebugEnabled) {
logger.debug("ExecuteRegionFunctionSingleHopOp#got result from {}", server);
}
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
} catch (ExecutionException ee) {
if (ee.getCause() instanceof InternalFunctionInvocationTargetException) {
if (isDebugEnabled) {
logger.debug("ExecuteRegionFunctionSingleHopOp#ExecutionException.InternalFunctionInvocationTargetException : Caused by :{}", ee.getCause());
}
try {
cms = region.getCache().getClientMetadataService();
} catch (CacheClosedException e) {
return false;
}
cms.removeBucketServerLocation(server);
cms.scheduleGetPRMetaData(region, false);
reexecute = true;
failedNodes.addAll(((InternalFunctionInvocationTargetException) ee.getCause()).getFailedNodeSet());
// Clear the results only if isHA so that partial results can be returned.
if (isHA) {
rc.clearResults();
} else {
if (ee.getCause().getCause() != null) {
functionExecutionException = new FunctionInvocationTargetException(ee.getCause().getCause());
} else {
functionExecutionException = new FunctionInvocationTargetException(new BucketMovedException(LocalizedStrings.FunctionService_BUCKET_MIGRATED_TO_ANOTHER_NODE.toLocalizedString()));
}
}
} else if (ee.getCause() instanceof FunctionException) {
if (isDebugEnabled) {
logger.debug("ExecuteRegionFunctionSingleHopOp#ExecutionException.FunctionException : Caused by :{}", ee.getCause());
}
FunctionException fe = (FunctionException) ee.getCause();
if (isHA) {
throw fe;
} else {
functionExecutionException = fe;
}
} else if (ee.getCause() instanceof ServerOperationException) {
if (isDebugEnabled) {
logger.debug("ExecuteRegionFunctionSingleHopOp#ExecutionException.ServerOperationException : Caused by :{}", ee.getCause());
}
ServerOperationException soe = (ServerOperationException) ee.getCause();
if (isHA) {
throw soe;
} else {
functionExecutionException = soe;
}
} else if (ee.getCause() instanceof ServerConnectivityException) {
if (isDebugEnabled) {
logger.debug("ExecuteRegionFunctionSingleHopOp#ExecutionException.ServerConnectivityException : Caused by :{} The failed server is: {}", ee.getCause(), server);
}
try {
cms = region.getCache().getClientMetadataService();
} catch (CacheClosedException e) {
return false;
}
cms.removeBucketServerLocation(server);
cms.scheduleGetPRMetaData(region, false);
// Clear the results only if isHA so that partial results can be returned.
if (isHA) {
reexecute = true;
rc.clearResults();
} else {
functionExecutionException = (ServerConnectivityException) ee.getCause();
}
} else {
throw executionThrowable(ee.getCause());
}
}
}
if (functionExecutionException != null) {
throw functionExecutionException;
}
}
}
return reexecute;
}
Aggregations