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