Search in sources :

Example 6 with InternalGemFireException

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

the class AbstractDistributionConfig method getAttributeObject.

public Object getAttributeObject(String attName) {
    checkAttributeName(attName);
    // special case:
    if (attName.equalsIgnoreCase(LOG_LEVEL)) {
        return LogWriterImpl.levelToString(this.getLogLevel());
    }
    if (attName.equalsIgnoreCase(SECURITY_LOG_LEVEL)) {
        return LogWriterImpl.levelToString(this.getSecurityLogLevel());
    }
    Method getter = getters.get(attName);
    if (getter == null) {
        if (attName.startsWith(SECURITY_PREFIX)) {
            return this.getSecurity(attName);
        }
        throw new InternalGemFireException(LocalizedStrings.AbstractDistributionConfig_UNHANDLED_ATTRIBUTE_NAME_0.toLocalizedString(attName));
    }
    try {
        return getter.invoke(this);
    } 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.getName(), e);
        }
    }
}
Also used : 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 7 with InternalGemFireException

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

the class AbstractDistributionConfig method checkAttribute.

protected Object checkAttribute(String attName, Object value) {
    // valid one.
    if (!isAttributeModifiable(attName)) {
        throw new UnmodifiableException(_getUnmodifiableMsg(attName));
    }
    ConfigAttribute attribute = attributes.get(attName);
    if (attribute == null) {
        // checking needed
        return value;
    }
    // for integer attribute, do the range check.
    if (attribute.type().equals(Integer.class)) {
        Integer intValue = (Integer) value;
        minMaxCheck(attName, intValue, attribute.min(), attribute.max());
    }
    Method checker = checkers.get(attName);
    if (checker == null) {
        return value;
    }
    // if specific checker exists for this attribute, call that with the value
    try {
        return checker.invoke(this, value);
    } 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 " + checker.getName() + " with value " + value);
        }
    }
}
Also used : UnmodifiableException(org.apache.geode.UnmodifiableException) 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 8 with InternalGemFireException

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

the class DistributionMessage method schedule.

/**
   * Schedule this message's process() method in a thread determined by getExecutor()
   */
protected void schedule(final DistributionManager dm) {
    boolean inlineProcess = DistributionManager.INLINE_PROCESS && getProcessorType() == DistributionManager.SERIAL_EXECUTOR && !isPreciousThread();
    boolean forceInline = this.acker != null || getInlineProcess() || Connection.isDominoThread();
    if (inlineProcess && !forceInline && isSharedReceiver()) {
        // do it inline.
        if (mayAddToMultipleSerialGateways(dm)) {
            inlineProcess = false;
        }
    }
    inlineProcess |= forceInline;
    if (inlineProcess) {
        dm.getStats().incNumSerialThreads(1);
        try {
            scheduleAction(dm);
        } finally {
            dm.getStats().incNumSerialThreads(-1);
        }
    } else {
        // not inline
        try {
            getExecutor(dm).execute(new SizeableRunnable(this.getBytesRead()) {

                public void run() {
                    scheduleAction(dm);
                }

                @Override
                public String toString() {
                    return "Processing {" + DistributionMessage.this.toString() + "}";
                }
            });
        } catch (RejectedExecutionException ex) {
            if (!dm.shutdownInProgress()) {
                // fix for bug 32395
                logger.warn(LocalizedMessage.create(LocalizedStrings.DistributionMessage_0__SCHEDULE_REJECTED, this.toString()), ex);
            }
        } catch (VirtualMachineError err) {
            SystemFailure.initiateFailure(err);
            // now, so don't let this thread continue.
            throw err;
        } catch (Throwable t) {
            // Whenever you catch Error or Throwable, you must also
            // catch VirtualMachineError (see above). However, there is
            // _still_ a possibility that you are dealing with a cascading
            // error condition, so you also need to check to see if the JVM
            // is still usable:
            SystemFailure.checkFailure();
            logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributionMessage_UNCAUGHT_EXCEPTION_PROCESSING__0, this), t);
            // I don't believe this ever happens (DJP May 2007)
            throw new InternalGemFireException(LocalizedStrings.DistributionMessage_UNEXPECTED_ERROR_SCHEDULING_MESSAGE.toLocalizedString(), t);
        }
    }
// not inline
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 9 with InternalGemFireException

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

the class DistributionManager method startThreads.

/**
   * Need to do this outside the constructor so that the child constructor can finish.
   */
protected void startThreads() {
    // fix for bug 33362
    this.system.setDM(this);
    if (this.memberEventThread != null)
        this.memberEventThread.start();
    try {
        // And the distinguished guests today are...
        NetView v = membershipManager.getView();
        logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_INITIAL_MEMBERSHIPMANAGER_VIEW___0, printView(v)));
        // Add them all to our view
        Iterator<InternalDistributedMember> it = v.getMembers().iterator();
        while (it.hasNext()) {
            addNewMember(it.next());
        }
        // Figure out who the elder is...
        // ShutdownException could be thrown here
        selectElder();
    } catch (Exception ex) {
        throw new InternalGemFireException(LocalizedStrings.DistributionManager_COULD_NOT_PROCESS_INITIAL_VIEW.toLocalizedString(), ex);
    }
    try {
        getWaitingThreadPool().execute(new Runnable() {

            public void run() {
                // call in background since it might need to send a reply
                // and we are not ready to send messages until startup is finished
                isStartupThread.set(Boolean.TRUE);
                readyForMessages();
            }
        });
    } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // now, so don't let this thread continue.
        throw err;
    } catch (Throwable t) {
        // Whenever you catch Error or Throwable, you must also
        // catch VirtualMachineError (see above). However, there is
        // _still_ a possibility that you are dealing with a cascading
        // error condition, so you also need to check to see if the JVM
        // is still usable:
        SystemFailure.checkFailure();
        logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributionManager_UNCAUGHT_EXCEPTION_CALLING_READYFORMESSAGES), t);
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InternalGemFireException(org.apache.geode.InternalGemFireException) NetView(org.apache.geode.distributed.internal.membership.NetView) IncompatibleSystemException(org.apache.geode.IncompatibleSystemException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CancelException(org.apache.geode.CancelException) InternalGemFireException(org.apache.geode.InternalGemFireException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) ForcedDisconnectException(org.apache.geode.ForcedDisconnectException) SystemConnectException(org.apache.geode.SystemConnectException) NoSuchElementException(java.util.NoSuchElementException) NotSerializableException(java.io.NotSerializableException) UnknownHostException(java.net.UnknownHostException) ReenteredConnectException(org.apache.geode.internal.tcp.ReenteredConnectException) ToDataException(org.apache.geode.ToDataException)

Example 10 with InternalGemFireException

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

the class AbstractStringIdResourceBundle method readDataFile.

private Int2ObjectOpenHashMap readDataFile(InputStream is) {
    Int2ObjectOpenHashMap map = new Int2ObjectOpenHashMap();
    boolean complete = false;
    BufferedReader input = null;
    try {
        input = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        String line = null;
        while ((line = input.readLine()) != null) {
            int equalSign = line.indexOf('=');
            String idAsString = line.substring(0, equalSign - 1).trim();
            // The +2 is because we need to skip the "= ", we dont use trim because some messages want
            // leading whitespace
            String message = line.substring(equalSign + 2).replaceAll("\\\\n", "\n");
            try {
                int id = Integer.parseInt(idAsString);
                map.put(id, message);
            } catch (NumberFormatException nfe) {
                // unit tests should prevent this from happening in a customer situation
                throw new InternalGemFireException(nfe);
            }
            complete = true;
        }
    } catch (IOException ioe) {
    // @TODO log this exception
    } finally {
        if (!complete) {
            // something went wrong, clean up and revert back to English
            try {
                if (input != null) {
                    input.close();
                } else {
                    is.close();
                }
            } catch (IOException ignore) {
            }
            // set map back to null so we default to English
            map = null;
        }
    }
    return map;
}
Also used : Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) InputStreamReader(java.io.InputStreamReader) InternalGemFireException(org.apache.geode.InternalGemFireException) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

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