Search in sources :

Example 26 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class PeerTypeRegistration method getExistingIdForEnum.

/** Should be called holding the dlock */
private EnumId getExistingIdForEnum(EnumInfo ei) {
    TXStateProxy currentState = suspendTX();
    int totalEnumIdInDS = 0;
    try {
        EnumId result = null;
        for (Map.Entry<Object, Object> entry : getIdToType().entrySet()) {
            Object v = entry.getValue();
            Object k = entry.getKey();
            if (k instanceof EnumId) {
                EnumId id = (EnumId) k;
                EnumInfo info = (EnumInfo) v;
                enumToId.put(info, id);
                int tmpDsId = PLACE_HOLDER_FOR_DS_ID & id.intValue();
                if (tmpDsId == this.dsId) {
                    totalEnumIdInDS++;
                }
                if (ei.equals(info)) {
                    result = id;
                }
            } else {
                typeToId.put((PdxType) v, (Integer) k);
            }
        }
        if (totalEnumIdInDS == this.maxTypeId) {
            throw new InternalGemFireError("Used up all of the PDX enum ids for this distributed system. The maximum number of PDX types is " + this.maxTypeId);
        }
        return result;
    } finally {
        resumeTX(currentState);
    }
}
Also used : TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) HashMap(java.util.HashMap) CopyOnWriteHashMap(org.apache.geode.internal.util.concurrent.CopyOnWriteHashMap) Map(java.util.Map) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 27 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class LuceneEventListenerJUnitTest method shouldThrowAndCaptureIOException.

@Test
public void shouldThrowAndCaptureIOException() throws BucketNotFoundException {
    RepositoryManager manager = Mockito.mock(RepositoryManager.class);
    Mockito.when(manager.getRepository(any(), any(), any())).thenThrow(IOException.class);
    AtomicReference<Throwable> lastException = new AtomicReference<>();
    LuceneEventListener.setExceptionObserver(lastException::set);
    LuceneEventListener listener = new LuceneEventListener(manager);
    AsyncEvent event = Mockito.mock(AsyncEvent.class);
    try {
        listener.processEvents(Arrays.asList(new AsyncEvent[] { event }));
        fail("should have thrown an exception");
    } catch (InternalGemFireError expected) {
        assertEquals(expected, lastException.get());
    }
}
Also used : RepositoryManager(org.apache.geode.cache.lucene.internal.repository.RepositoryManager) AtomicReference(java.util.concurrent.atomic.AtomicReference) AsyncEvent(org.apache.geode.cache.asyncqueue.AsyncEvent) InternalGemFireError(org.apache.geode.InternalGemFireError) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 28 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class GemFireCacheImpl method shutDownAll.

public void shutDownAll() {
    if (LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER) {
        try {
            CacheObserverHolder.getInstance().beforeShutdownAll();
        } finally {
            LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
        }
    }
    if (!this.isShutDownAll.compareAndSet(false, true)) {
        // it's already doing shutdown by another thread
        try {
            this.shutDownAllFinished.await();
        } catch (InterruptedException ignore) {
            logger.debug("Shutdown all interrupted while waiting for another thread to do the shutDownAll");
            Thread.currentThread().interrupt();
        }
        return;
    }
    synchronized (GemFireCacheImpl.class) {
        try {
            boolean testIGE = Boolean.getBoolean("TestInternalGemFireError");
            if (testIGE) {
                throw new InternalGemFireError(LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString());
            }
            // bug 44031 requires multithread shutDownAll should be grouped
            // by root region. However, shutDownAllDuringRecovery.conf test revealed that
            // we have to close colocated child regions first.
            // Now check all the PR, if anyone has colocate-with attribute, sort all the
            // PRs by colocation relationship and close them sequentially, otherwise still
            // group them by root region.
            SortedMap<String, Map<String, PartitionedRegion>> prTrees = getPRTrees();
            if (prTrees.size() > 1 && shutdownAllPoolSize != 1) {
                ExecutorService es = getShutdownAllExecutorService(prTrees.size());
                for (final Map<String, PartitionedRegion> prSubMap : prTrees.values()) {
                    es.execute(() -> {
                        ConnectionTable.threadWantsSharedResources();
                        shutdownSubTreeGracefully(prSubMap);
                    });
                }
                // for each root
                es.shutdown();
                try {
                    es.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);
                } catch (InterruptedException ignore) {
                    logger.debug("Shutdown all interrupted while waiting for PRs to be shutdown gracefully.");
                }
            } else {
                for (final Map<String, PartitionedRegion> prSubMap : prTrees.values()) {
                    shutdownSubTreeGracefully(prSubMap);
                }
            }
            close("Shut down all members", null, false, true);
        } finally {
            this.shutDownAllFinished.countDown();
        }
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 29 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class FilterProfile method unregisterClientInterest.

/**
   * Unregisters a client's interest
   *
   * @param inputClientID The identity of the client that is losing interest
   * @param interest The key in which to unregister interest
   * @param interestType the type of uninterest
   * @return the keys unregistered, which may be null
   */
public Set unregisterClientInterest(Object inputClientID, Object interest, int interestType) {
    Long clientID;
    if (inputClientID instanceof Long) {
        clientID = (Long) inputClientID;
    } else {
        // read
        Map<Object, Long> cids = clientMap.realIDs;
        clientID = cids.get(inputClientID);
        if (clientID == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("region profile unable to find '{}' for unregistration.  Probably means there is no durable queue.", inputClientID);
            }
            return null;
        }
    }
    Set keysUnregistered = new HashSet();
    operationType opType = null;
    synchronized (this.interestListLock) {
        switch(interestType) {
            case InterestType.KEY:
                {
                    opType = operationType.UNREGISTER_KEY;
                    unregisterClientKeys(inputClientID, interest, clientID, keysUnregistered);
                    break;
                }
            case InterestType.REGULAR_EXPRESSION:
                {
                    opType = operationType.UNREGISTER_PATTERN;
                    unregisterClientPattern(interest, clientID, keysUnregistered);
                    break;
                }
            case InterestType.FILTER_CLASS:
                {
                    opType = operationType.UNREGISTER_FILTER;
                    unregisterClientFilterClass(interest, clientID);
                    break;
                }
            default:
                throw new InternalGemFireError(LocalizedStrings.CacheClientProxy_BAD_INTEREST_TYPE.toLocalizedString());
        }
        if (this.region != null && this.isLocalProfile) {
            sendProfileOperation(clientID, opType, interest, false);
        }
    }
    // synchronized
    return keysUnregistered;
}
Also used : Set(java.util.Set) CopyOnWriteHashSet(org.apache.geode.internal.CopyOnWriteHashSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) CopyOnWriteHashSet(org.apache.geode.internal.CopyOnWriteHashSet) HashSet(java.util.HashSet) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 30 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class ConfigurationResponse method describeConfig.

public String describeConfig() {
    StringBuffer sb = new StringBuffer();
    if (requestedConfiguration.isEmpty()) {
        sb.append("Received an empty shared configuration");
    } else {
        Set<Entry<String, Configuration>> entries = requestedConfiguration.entrySet();
        Iterator<Entry<String, Configuration>> iter = entries.iterator();
        while (iter.hasNext()) {
            Entry<String, Configuration> entry = iter.next();
            String configType = entry.getKey();
            Configuration config = entry.getValue();
            if (config != null) {
                sb.append("\n***************************************************************");
                sb.append("\nConfiguration for  '" + configType + "'");
                sb.append("\n\nJar files to deployed");
                Set<String> jarNames = config.getJarNames();
                Iterator<String> jarIter = jarNames.iterator();
                int jarCounter = 0;
                while (jarIter.hasNext()) {
                    sb.append("\n" + ++jarCounter + "." + jarIter.next());
                }
                try {
                    String cacheXmlContent = config.getCacheXmlContent();
                    if (StringUtils.isNotBlank(cacheXmlContent)) {
                        sb.append("\n" + XmlUtils.prettyXml(cacheXmlContent));
                    }
                } catch (IOException | TransformerFactoryConfigurationError | TransformerException | SAXException | ParserConfigurationException e) {
                    throw new InternalGemFireError(e);
                }
            }
        }
    }
    return sb.toString();
}
Also used : TransformerFactoryConfigurationError(javax.xml.transform.TransformerFactoryConfigurationError) Configuration(org.apache.geode.management.internal.configuration.domain.Configuration) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) Entry(java.util.Map.Entry) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) TransformerException(javax.xml.transform.TransformerException) 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