use of org.apache.geode.InternalGemFireException in project geode by apache.
the class PartitionedRegion method fetchEntries.
/**
* Fetches entries from local and remote nodes and appends these to register-interest response.
*/
public void fetchEntries(String regex, VersionedObjectList values, ServerConnection servConn) throws IOException {
int retryAttempts = calcRetry();
RetryTimeKeeper retryTime = null;
HashSet<Integer> failures = new HashSet<Integer>(getRegionAdvisor().getBucketSet());
HashMap<InternalDistributedMember, HashSet<Integer>> nodeToBuckets = new HashMap<InternalDistributedMember, HashSet<Integer>>();
while (--retryAttempts >= 0 && !failures.isEmpty()) {
nodeToBuckets.clear();
updateNodeToBucketMap(nodeToBuckets, failures);
failures.clear();
HashSet<Integer> localBuckets = nodeToBuckets.remove(getMyId());
if (localBuckets != null && !localBuckets.isEmpty()) {
for (Integer id : localBuckets) {
Set keys = fetchAllLocalKeys(id, failures, regex);
if (!keys.isEmpty()) {
BaseCommand.appendNewRegisterInterestResponseChunkFromLocal(this, values, regex != null ? regex : "ALL_KEYS", keys, servConn);
}
}
}
// Add failed buckets to nodeToBuckets map so that these will be tried on
// remote nodes.
updateNodeToBucketMap(nodeToBuckets, failures);
failures.clear();
// Handle old nodes for Rolling Upgrade support
Set<Integer> ret = handleOldNodes(nodeToBuckets, values, servConn);
if (!ret.isEmpty()) {
failures.addAll(ret);
updateNodeToBucketMap(nodeToBuckets, failures);
failures.clear();
}
localBuckets = nodeToBuckets.remove(getMyId());
if (localBuckets != null && !localBuckets.isEmpty()) {
failures.addAll(localBuckets);
// updateNodeToBucketMap(nodeToBuckets, failures);
// failures.clear();
}
fetchAllRemoteEntries(nodeToBuckets, failures, regex, values, servConn);
if (!failures.isEmpty()) {
if (retryTime == null) {
retryTime = new RetryTimeKeeper(this.retryTimeout);
}
if (!waitForFetchRemoteEntriesRetry(retryTime)) {
break;
}
}
}
if (!failures.isEmpty()) {
throw new InternalGemFireException("Failed to fetch entries from " + failures.size() + " buckets of region " + getName() + " for register interest.");
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class DistributionConfigImpl method validateSSLEnabledComponentsConfiguration.
private void validateSSLEnabledComponentsConfiguration() {
Object value = null;
try {
Method method = getters.get(ConfigurationProperties.SSL_ENABLED_COMPONENTS);
if (method != null) {
value = method.invoke(this, new Object[] {});
}
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new InternalGemFireException("error invoking getter for property" + ConfigurationProperties.SSL_ENABLED_COMPONENTS);
}
}
SecurableCommunicationChannel[] sslEnabledComponents = (SecurableCommunicationChannel[]) value;
for (SecurableCommunicationChannel securableCommunicationChannel : sslEnabledComponents) {
if (!isAliasCorrectlyConfiguredForComponents(securableCommunicationChannel)) {
throw new IllegalArgumentException(LocalizedStrings.AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_INVALID_ALIAS_OPTIONS.toLocalizedString());
}
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class DistributionConfigImpl method validateConfigurationProperties.
/**
* Here we will validate the correctness of the set properties as per the CheckAttributeChecker
* annotations defined in #AbstractDistributionConfig
*
* @param props
*/
private void validateConfigurationProperties(final HashMap props) {
for (Object o : props.keySet()) {
String propertyName = (String) o;
Object value = null;
try {
Method method = getters.get(propertyName);
if (method != null) {
value = method.invoke(this, new Object[] {});
}
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new InternalGemFireException("error invoking getter for property" + propertyName);
}
}
checkAttribute(propertyName, value);
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class AbstractDistributionConfig method setAttributeObject.
public void setAttributeObject(String attName, Object attValue, ConfigSource source) {
// TODO: the setters is already checking the parameter type, do we still need to do this?
Class validValueClass = getAttributeType(attName);
if (attValue != null) {
// null is a "valid" value for any class
if (!validValueClass.isInstance(attValue)) {
throw new InvalidValueException(LocalizedStrings.AbstractDistributionConfig_0_VALUE_1_MUST_BE_OF_TYPE_2.toLocalizedString(new Object[] { attName, attValue, validValueClass.getName() }));
}
}
if (attName.startsWith(USERDEFINED_PREFIX_NAME)) {
// Do nothing its user defined property.
return;
}
// accepts int
if (attName.equalsIgnoreCase(LOG_LEVEL) || attName.equalsIgnoreCase(SECURITY_LOG_LEVEL)) {
if (attValue instanceof String) {
attValue = LogLevel.getLogWriterLevel((String) attValue);
}
}
if (attName.startsWith(SECURITY_PREFIX)) {
this.setSecurity(attName, attValue.toString());
}
if (attName.startsWith(SSL_SYSTEM_PROPS_NAME) || attName.startsWith(SYS_PROP_NAME)) {
this.setSSLProperty(attName, attValue.toString());
}
Method setter = setters.get(attName);
if (setter == null) {
// return
if (attName.startsWith(SECURITY_PREFIX) || attName.startsWith(SSL_SYSTEM_PROPS_NAME) || attName.startsWith(SYS_PROP_NAME)) {
getAttSourceMap().put(attName, source);
return;
}
throw new InternalGemFireException(LocalizedStrings.AbstractDistributionConfig_UNHANDLED_ATTRIBUTE_NAME_0.toLocalizedString(attName));
}
Class[] pTypes = setter.getParameterTypes();
if (pTypes.length != 1) {
throw new InternalGemFireException("the attribute setter must have one and only one parametter");
}
checkAttribute(attName, attValue);
try {
setter.invoke(this, attValue);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new InternalGemFireException("error invoking " + setter.getName() + " with " + attValue, e);
}
}
getAttSourceMap().put(attName, source);
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class ConcurrentSerialGatewaySenderEventProcessor method stopProcessing.
@Override
public void stopProcessing() {
if (!this.isAlive()) {
return;
}
setIsStopped(true);
final LoggingThreadGroup loggingThreadGroup = LoggingThreadGroup.createThreadGroup("ConcurrentSerialGatewaySenderEventProcessor Logger Group", logger);
ThreadFactory threadFactory = new ThreadFactory() {
public Thread newThread(final Runnable task) {
final Thread thread = new Thread(loggingThreadGroup, task, "ConcurrentSerialGatewaySenderEventProcessor Stopper Thread");
thread.setDaemon(true);
return thread;
}
};
List<SenderStopperCallable> stopperCallables = new ArrayList<SenderStopperCallable>();
for (SerialGatewaySenderEventProcessor serialProcessor : this.processors) {
stopperCallables.add(new SenderStopperCallable(serialProcessor));
}
ExecutorService stopperService = Executors.newFixedThreadPool(processors.size(), threadFactory);
try {
List<Future<Boolean>> futures = stopperService.invokeAll(stopperCallables);
for (Future<Boolean> f : futures) {
try {
boolean b = f.get();
if (logger.isDebugEnabled()) {
logger.debug("ConcurrentSerialGatewaySenderEventProcessor: {} stopped dispatching: {}", (b ? "Successfully" : "Unsuccesfully"), this);
}
} catch (ExecutionException e) {
// we don't expect any exception but if caught then eat it and log
// warning
logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_0_CAUGHT_EXCEPTION_WHILE_STOPPING_1, new Object[] { sender, e.getCause() }));
}
}
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
} catch (RejectedExecutionException rejectedExecutionEx) {
throw rejectedExecutionEx;
}
// shutdown the stopperService. This will release all the stopper threads
stopperService.shutdown();
closeProcessor();
if (logger.isDebugEnabled()) {
logger.debug("ConcurrentSerialGatewaySenderEventProcessor: Stopped dispatching: {}", this);
}
}
Aggregations