Search in sources :

Example 31 with InternalGemFireError

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;
    }
}
Also used : InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 32 with InternalGemFireError

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);
}
Also used : Index(org.apache.geode.cache.query.Index) Endpoint(org.apache.geode.cache.client.internal.Endpoint) TimeoutException(org.apache.geode.cache.TimeoutException) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InternalGemFireException(org.apache.geode.InternalGemFireException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) ExecutionException(java.util.concurrent.ExecutionException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) EntryExistsException(org.apache.geode.cache.EntryExistsException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) StatisticsDisabledException(org.apache.geode.cache.StatisticsDisabledException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) FailedSynchronizationException(org.apache.geode.cache.FailedSynchronizationException) NoSuchElementException(java.util.NoSuchElementException) QueryException(org.apache.geode.cache.query.QueryException) RedundancyAlreadyMetException(org.apache.geode.internal.cache.partitioned.RedundancyAlreadyMetException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) LowMemoryException(org.apache.geode.cache.LowMemoryException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) SystemException(javax.transaction.SystemException) SubscriptionNotEnabledException(org.apache.geode.cache.client.SubscriptionNotEnabledException) RegionExistsException(org.apache.geode.cache.RegionExistsException) RegionReinitializedException(org.apache.geode.cache.RegionReinitializedException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IndexMaintenanceException(org.apache.geode.cache.query.IndexMaintenanceException) TransactionException(org.apache.geode.cache.TransactionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) RollbackException(javax.transaction.RollbackException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) MultiIndexCreationException(org.apache.geode.cache.query.MultiIndexCreationException) DeltaSerializationException(org.apache.geode.DeltaSerializationException) IndexCreationData(org.apache.geode.cache.query.internal.index.IndexCreationData) ExecutionContext(org.apache.geode.cache.query.internal.ExecutionContext) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) ArrayList(java.util.ArrayList) List(java.util.List) StoredObject(org.apache.geode.internal.offheap.StoredObject) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) HashSet(java.util.HashSet) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 33 with InternalGemFireError

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;
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) FutureResult(org.apache.geode.internal.util.concurrent.FutureResult) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) Future(java.util.concurrent.Future) StoredObject(org.apache.geode.internal.offheap.StoredObject) ExecutionException(java.util.concurrent.ExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) InternalGemFireError(org.apache.geode.InternalGemFireError) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 34 with InternalGemFireError

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;
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 35 with InternalGemFireError

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;
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) UnknownHostException(java.net.UnknownHostException) InetAddress(java.net.InetAddress) DurableClientAttributes(org.apache.geode.distributed.DurableClientAttributes) InternalGemFireError(org.apache.geode.InternalGemFireError)

Aggregations

InternalGemFireError (org.apache.geode.InternalGemFireError)38 IOException (java.io.IOException)8 HashMap (java.util.HashMap)5 Map (java.util.Map)5 TXStateProxy (org.apache.geode.internal.cache.TXStateProxy)5 HashSet (java.util.HashSet)4 ExecutionException (java.util.concurrent.ExecutionException)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 Set (java.util.Set)3 Future (java.util.concurrent.Future)3 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)3 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)3 InternalRegionArguments (org.apache.geode.internal.cache.InternalRegionArguments)3 Part (org.apache.geode.internal.cache.tier.sockets.Part)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2