use of org.apache.geode.InternalGemFireError in project geode by apache.
the class Assert method throwError.
private static void throwError(Object message) {
if (debug) {
System.out.flush();
System.err.println("Assertion failure: " + message);
try {
throw new Exception(LocalizedStrings.Assert_GET_STACK_TRACE.toLocalizedString());
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println();
System.out.flush();
System.err.println("Waiting for debugger to attach");
System.err.flush();
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
}
} else {
InternalGemFireError ex = null;
if (message != null) {
ex = new InternalGemFireError(message);
} else {
ex = new InternalGemFireError();
}
// }
throw ex;
}
}
use of org.apache.geode.InternalGemFireError in project geode by apache.
the class LocalRegion method createOQLIndexes.
void createOQLIndexes(InternalRegionArguments internalRegionArgs, boolean recoverFromDisk) {
if (internalRegionArgs == null || internalRegionArgs.getIndexes() == null || internalRegionArgs.getIndexes().isEmpty()) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("LocalRegion.createOQLIndexes on region {}", this.getFullPath());
}
long start = getCachePerfStats().startIndexInitialization();
List oqlIndexes = internalRegionArgs.getIndexes();
if (this.indexManager == null) {
this.indexManager = IndexUtils.getIndexManager(this, true);
}
DiskRegion dr = this.getDiskRegion();
boolean isOverflowToDisk = false;
if (dr != null) {
isOverflowToDisk = dr.isOverflowEnabled();
if (recoverFromDisk && !isOverflowToDisk) {
// Refer bug #44119
// For disk regions, index creation should wait for async value creation to complete before
// it starts its iteration
// In case of disk overflow regions the waitForAsyncRecovery is done in populateOQLIndexes
// method via getBestIterator()
dr.waitForAsyncRecovery();
}
}
Set<Index> indexes = new HashSet<Index>();
Set<Index> prIndexes = new HashSet<>();
int initLevel = 0;
try {
// Release the initialization latch for index creation.
initLevel = LocalRegion.setThreadInitLevelRequirement(ANY_INIT);
for (Object o : oqlIndexes) {
IndexCreationData icd = (IndexCreationData) o;
try {
if (icd.getPartitionedIndex() != null) {
ExecutionContext externalContext = new ExecutionContext(null, this.cache);
if (internalRegionArgs.getPartitionedRegion() != null) {
externalContext.setBucketRegion(internalRegionArgs.getPartitionedRegion(), (BucketRegion) this);
}
if (logger.isDebugEnabled()) {
logger.debug("IndexManager Index creation process for {}", icd.getIndexName());
}
// load entries during initialization only for non overflow regions
indexes.add(this.indexManager.createIndex(icd.getIndexName(), icd.getIndexType(), icd.getIndexExpression(), icd.getIndexFromClause(), icd.getIndexImportString(), externalContext, icd.getPartitionedIndex(), !isOverflowToDisk));
prIndexes.add(icd.getPartitionedIndex());
} else {
if (logger.isDebugEnabled()) {
logger.debug("QueryService Index creation process for {}" + icd.getIndexName());
}
DefaultQueryService qs = (DefaultQueryService) getGemFireCache().getLocalQueryService();
String fromClause = icd.getIndexType() == IndexType.FUNCTIONAL || icd.getIndexType() == IndexType.HASH ? icd.getIndexFromClause() : this.getFullPath();
// load entries during initialization only for non overflow regions
indexes.add(qs.createIndex(icd.getIndexName(), icd.getIndexType(), icd.getIndexExpression(), fromClause, icd.getIndexImportString(), !isOverflowToDisk));
}
} catch (Exception ex) {
logger.info("Failed to create index {} on region {} with exception: {}", icd.getIndexName(), this.getFullPath(), ex);
// exception.
if (internalRegionArgs.getDeclarativeIndexCreation()) {
throw new InternalGemFireError(LocalizedStrings.GemFireCache_INDEX_CREATION_EXCEPTION_1.toLocalizedString(icd.getIndexName(), this.getFullPath()), ex);
}
}
}
} finally {
// Reset the initialization lock.
LocalRegion.setThreadInitLevelRequirement(initLevel);
}
// Load data into OQL indexes in case of disk recovery and disk overflow
if (isOverflowToDisk) {
if (recoverFromDisk) {
populateOQLIndexes(indexes);
} else {
// Empty indexes are created for overflow regions but not populated at this stage
// since this is not recovery.
// Setting the populate flag to true so that the indexes can apply updates.
this.indexManager.setPopulateFlagForIndexes(indexes);
}
// due to bug #52096, the pr index populate flags were not being set
// we should revisit and clean up the index creation code paths
this.indexManager.setPopulateFlagForIndexes(prIndexes);
}
getCachePerfStats().endIndexInitialization(start);
}
use of org.apache.geode.InternalGemFireError in project geode by apache.
the class LocalRegion method nonTxnFindObject.
/**
* optimized to only allow one thread to do a search/load, other threads wait on a future
*
* @param isCreate true if call found no entry; false if updating an existing entry
* @param localValue the value retrieved from the region for this object.
* @param disableCopyOnRead if true then do not make a copy
* @param preferCD true if the preferred result form is CachedDeserializable
* @param clientEvent the client event, if any
* @param returnTombstones whether to return tombstones
*/
@Retained
Object nonTxnFindObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object localValue, boolean disableCopyOnRead, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean returnTombstones) throws TimeoutException, CacheLoaderException {
@Retained Object result = null;
FutureResult thisFuture = new FutureResult(this.stopper);
Future otherFuture = (Future) this.getFutures.putIfAbsent(keyInfo.getKey(), thisFuture);
// only one thread can get their future into the map for this key at a time
if (otherFuture != null) {
try {
Object[] valueAndVersion = (Object[]) otherFuture.get();
if (valueAndVersion != null) {
result = valueAndVersion[0];
if (clientEvent != null) {
clientEvent.setVersionTag((VersionTag) valueAndVersion[1]);
}
if (!preferCD && result instanceof CachedDeserializable) {
CachedDeserializable cd = (CachedDeserializable) result;
// fix for bug 43023
if (!disableCopyOnRead && isCopyOnRead()) {
result = cd.getDeserializedWritableCopy(null, null);
} else {
result = cd.getDeserializedForReading();
}
} else if (!disableCopyOnRead) {
result = conditionalCopy(result);
}
// what was a miss is now a hit
if (isCreate) {
RegionEntry regionEntry = basicGetEntry(keyInfo.getKey());
updateStatsForGet(regionEntry, true);
}
return result;
}
// if value == null, try our own search/load
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
// TODO check a CancelCriterion here?
return null;
} catch (ExecutionException e) {
// NOTE: this was creating InternalGemFireError and initCause with itself
throw new InternalGemFireError(LocalizedStrings.LocalRegion_UNEXPECTED_EXCEPTION.toLocalizedString(), e);
}
}
// condition where the future was just removed by another thread
try {
boolean partitioned = this.getDataPolicy().withPartitioning();
if (!partitioned) {
localValue = getDeserializedValue(null, keyInfo, isCreate, disableCopyOnRead, preferCD, clientEvent, false, false);
// stats have now been updated
if (localValue != null && !Token.isInvalid(localValue)) {
result = localValue;
return result;
}
isCreate = localValue == null;
result = findObjectInSystem(keyInfo, isCreate, null, generateCallbacks, localValue, disableCopyOnRead, preferCD, requestingClient, clientEvent, returnTombstones);
} else {
// For PRs we don't want to deserialize the value and we can't use findObjectInSystem
// because it can invoke code that is transactional.
result = getSharedDataView().findObject(keyInfo, this, isCreate, generateCallbacks, localValue, disableCopyOnRead, preferCD, requestingClient, clientEvent, returnTombstones);
}
if (result == null && localValue != null) {
if (localValue != Token.TOMBSTONE || returnTombstones) {
result = localValue;
}
}
// findObjectInSystem does not call conditionalCopy
} finally {
if (result != null) {
VersionTag tag = clientEvent == null ? null : clientEvent.getVersionTag();
thisFuture.set(new Object[] { result, tag });
} else {
thisFuture.set(null);
}
this.getFutures.remove(keyInfo.getKey());
}
if (!disableCopyOnRead) {
result = conditionalCopy(result);
}
return result;
}
use of org.apache.geode.InternalGemFireError in project geode by apache.
the class RegisterInterestTracker method getRegionToInterestsMap.
/**
* Return keys of interest for a given region. The keys in this Map are the full names of the
* regions. The values are instances of RegionInterestEntry.
*
* @param interestType the type to return
* @return the map
*/
public ConcurrentMap getRegionToInterestsMap(int interestType, boolean isDurable, boolean receiveUpdatesAsInvalidates) {
FailoverInterestList fil = this.fils[getInterestLookupIndex(isDurable, receiveUpdatesAsInvalidates)];
ConcurrentMap mapOfInterest = null;
switch(interestType) {
case InterestType.KEY:
mapOfInterest = fil.keysOfInterest;
break;
case InterestType.REGULAR_EXPRESSION:
mapOfInterest = fil.regexOfInterest;
break;
case InterestType.FILTER_CLASS:
mapOfInterest = fil.filtersOfInterest;
break;
case InterestType.CQ:
mapOfInterest = fil.cqsOfInterest;
break;
case InterestType.OQL_QUERY:
mapOfInterest = fil.queriesOfInterest;
break;
default:
throw new InternalGemFireError("Unknown interestType");
}
return mapOfInterest;
}
use of org.apache.geode.InternalGemFireError in project geode by apache.
the class LonerDistributionManager method generateMemberId.
// private static final int CHARS_32KB = 16384;
private InternalDistributedMember generateMemberId() {
InternalDistributedMember result = null;
String host;
try {
// create string of the current millisecond clock time
StringBuffer sb = new StringBuffer();
// use low four bytes for backward compatibility
long time = System.currentTimeMillis() & 0xffffffffL;
for (int i = 0; i < 4; i++) {
String hex = Integer.toHexString((int) (time & 0xff));
if (hex.length() < 2) {
sb.append('0');
}
sb.append(hex);
time = time / 0x100;
}
String uniqueString = sb.toString();
String name = this.system.getName();
InetAddress hostAddr = SocketCreator.getLocalHost();
host = SocketCreator.use_client_host_name ? hostAddr.getCanonicalHostName() : hostAddr.getHostAddress();
DistributionConfig config = system.getConfig();
DurableClientAttributes dac = null;
if (config.getDurableClientId() != null) {
dac = new DurableClientAttributes(config.getDurableClientId(), config.getDurableClientTimeout());
}
result = new InternalDistributedMember(host, lonerPort, name, uniqueString, DistributionManager.LONER_DM_TYPE, MemberAttributes.parseGroups(config.getRoles(), config.getGroups()), dac);
} catch (UnknownHostException ex) {
throw new InternalGemFireError(LocalizedStrings.LonerDistributionManager_CANNOT_RESOLVE_LOCAL_HOST_NAME_TO_AN_IP_ADDRESS.toLocalizedString());
}
return result;
}
Aggregations