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);
}
}
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());
}
}
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();
}
}
}
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;
}
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();
}
Aggregations