Search in sources :

Example 41 with InternalGemFireException

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.");
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashSet(java.util.HashSet) Set(java.util.Set) ResultsSet(org.apache.geode.cache.query.internal.ResultsSet) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) InternalGemFireException(org.apache.geode.InternalGemFireException) HashSet(java.util.HashSet)

Example 42 with InternalGemFireException

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());
        }
    }
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) Method(java.lang.reflect.Method) SecurableCommunicationChannel(org.apache.geode.internal.security.SecurableCommunicationChannel) GemFireIOException(org.apache.geode.GemFireIOException) GemFireConfigException(org.apache.geode.GemFireConfigException) InternalGemFireException(org.apache.geode.InternalGemFireException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 43 with InternalGemFireException

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);
    }
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) Method(java.lang.reflect.Method) GemFireIOException(org.apache.geode.GemFireIOException) GemFireConfigException(org.apache.geode.GemFireConfigException) InternalGemFireException(org.apache.geode.InternalGemFireException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 44 with InternalGemFireException

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);
}
Also used : InvalidValueException(org.apache.geode.InvalidValueException) InternalGemFireException(org.apache.geode.InternalGemFireException) Method(java.lang.reflect.Method) InvalidValueException(org.apache.geode.InvalidValueException) UnmodifiableException(org.apache.geode.UnmodifiableException) InternalGemFireException(org.apache.geode.InternalGemFireException) UnknownHostException(java.net.UnknownHostException)

Example 45 with InternalGemFireException

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);
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) InternalGemFireException(org.apache.geode.InternalGemFireException) ArrayList(java.util.ArrayList) LoggingThreadGroup(org.apache.geode.internal.logging.LoggingThreadGroup) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

InternalGemFireException (org.apache.geode.InternalGemFireException)46 IOException (java.io.IOException)12 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)8 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)8 ExecutionException (java.util.concurrent.ExecutionException)7 UnknownHostException (java.net.UnknownHostException)6 Future (java.util.concurrent.Future)6 Method (java.lang.reflect.Method)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 List (java.util.List)4 CancelException (org.apache.geode.CancelException)4 CacheException (org.apache.geode.cache.CacheException)4 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)4 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)4 NoSuchElementException (java.util.NoSuchElementException)3 Set (java.util.Set)3 ExecutorService (java.util.concurrent.ExecutorService)3