use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class OpenManageChassisDetector method isServiceDetected.
/**
* {@inheritDoc}
*
* Returns true if the protocol defined by this plugin is supported. If
* the protocol is not supported then a false value is returned to the
* caller. The qualifier map passed to the method is used by the plugin to
* return additional information by key-name. These key-value pairs can be
* added to service events if needed.
*/
@Override
public boolean isServiceDetected(final InetAddress address, final SnmpAgentConfig agentConfig) {
try {
configureAgentPTR(agentConfig);
configureAgentVersion(agentConfig);
// Get the OpenManage chassis status
String chassisStatus = getValue(agentConfig, CHASSIS_STATUS_OID, isHex());
// If no chassis status received, do not detect the protocol and quit
if (chassisStatus == null) {
LOG.warn("isServiceDetected: Cannot receive chassis status");
return false;
} else {
LOG.debug("isServiceDetected: OpenManageChassis: {}", chassisStatus);
}
// Validate chassis status, check status is somewhere between OTHER and NON_RECOVERABLE
if (Integer.parseInt(chassisStatus) >= DELL_STATUS.OTHER.value() && Integer.parseInt(chassisStatus) <= DELL_STATUS.NON_RECOVERABLE.value()) {
// OpenManage chassis status detected
LOG.debug("isServiceDetected: OpenManageChassis: is valid, protocol supported.");
return true;
}
} catch (Throwable t) {
throw new UndeclaredThrowableException(t);
}
return false;
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class Actiond method init.
/**
* <p>init</p>
*/
@Override
public void init() {
try {
ActiondConfigFactory.init();
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
ActiondConfigFactory actiondConfig = ActiondConfigFactory.getInstance();
org.opennms.netmgt.actiond.Actiond actiond = org.opennms.netmgt.actiond.Actiond.getInstance();
actiond.setActiondConfig(actiondConfig);
actiond.init();
}
use of java.lang.reflect.UndeclaredThrowableException in project hive by apache.
the class RetryingMetaStoreClient method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object ret;
int retriesMade = 0;
TException caughtException;
boolean allowReconnect = !method.isAnnotationPresent(NoReconnect.class);
boolean allowRetry = true;
Annotation[] directives = method.getDeclaredAnnotations();
if (directives != null) {
for (Annotation a : directives) {
if (a instanceof RetrySemantics.CannotRetry) {
allowRetry = false;
}
}
}
while (true) {
try {
reloginExpiringKeytabUser();
if (allowReconnect) {
if (retriesMade > 0 || hasConnectionLifeTimeReached(method)) {
if (this.ugi != null) {
// Perform reconnect with the proper user context
try {
LOG.info("RetryingMetaStoreClient trying reconnect as " + this.ugi);
this.ugi.doAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws MetaException {
base.reconnect();
return null;
}
});
} catch (UndeclaredThrowableException e) {
Throwable te = e.getCause();
if (te instanceof PrivilegedActionException) {
throw te.getCause();
} else {
throw te;
}
}
lastConnectionTime = System.currentTimeMillis();
} else {
LOG.warn("RetryingMetaStoreClient unable to reconnect. No UGI information.");
throw new MetaException("UGI information unavailable. Will not attempt a reconnect.");
}
}
}
if (metaCallTimeMap == null) {
ret = method.invoke(base, args);
} else {
// need to capture the timing
long startTime = System.currentTimeMillis();
ret = method.invoke(base, args);
long timeTaken = System.currentTimeMillis() - startTime;
addMethodTime(method, timeTaken);
}
break;
} catch (UndeclaredThrowableException e) {
throw e.getCause();
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof TApplicationException) {
TApplicationException tae = (TApplicationException) t;
switch(tae.getType()) {
case TApplicationException.UNSUPPORTED_CLIENT_TYPE:
case TApplicationException.UNKNOWN_METHOD:
case TApplicationException.WRONG_METHOD_NAME:
case TApplicationException.INVALID_PROTOCOL:
throw t;
default:
// TODO: most other options are probably unrecoverable... throw?
caughtException = tae;
}
} else if ((t instanceof TProtocolException) || (t instanceof TTransportException)) {
// TODO: most protocol exceptions are probably unrecoverable... throw?
caughtException = (TException) t;
} else if ((t instanceof MetaException) && t.getMessage().matches("(?s).*(JDO[a-zA-Z]*|TProtocol|TTransport)Exception.*") && !t.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
caughtException = (MetaException) t;
} else {
throw t;
}
} catch (MetaException e) {
if (e.getMessage().matches("(?s).*(IO|TTransport)Exception.*") && !e.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
caughtException = e;
} else {
throw e;
}
}
if (retriesMade >= retryLimit || base.isLocalMetaStore() || !allowRetry) {
throw caughtException;
}
retriesMade++;
LOG.warn("MetaStoreClient lost connection. Attempting to reconnect (" + retriesMade + " of " + retryLimit + ") after " + retryDelaySeconds + "s. " + method.getName(), caughtException);
Thread.sleep(retryDelaySeconds * 1000);
}
return ret;
}
use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.
the class HeaderClientServerTest method testOutHeader.
@Test
public void testOutHeader() throws Exception {
URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
assertNotNull(wsdl);
SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
assertNotNull(service);
TestHeader proxy = service.getPort(portName, TestHeader.class);
try {
TestHeader2 in = new TestHeader2();
String val = new String(TestHeader2Response.class.getSimpleName());
Holder<TestHeader2Response> out = new Holder<TestHeader2Response>();
Holder<TestHeader2Response> outHeader = new Holder<TestHeader2Response>();
for (int idx = 0; idx < 2; idx++) {
val += idx;
in.setRequestType(val);
proxy.testHeader2(in, out, outHeader);
assertEquals(val, out.value.getResponseType());
assertEquals(val, outHeader.value.getResponseType());
}
} catch (UndeclaredThrowableException ex) {
ex.printStackTrace();
throw (Exception) ex.getCause();
}
}
use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.
the class HeaderClientServerTest method testRPCInHeader.
@Test
public void testRPCInHeader() throws Exception {
URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
assertNotNull(wsdl);
SOAPRPCHeaderService service = new SOAPRPCHeaderService(wsdl, new QName("http://apache.org/header_test/rpc", "SOAPRPCHeaderService"));
assertNotNull(service);
TestRPCHeader proxy = service.getSoapRPCHeaderPort();
try {
HeaderMessage header = new HeaderMessage();
header.setHeaderVal("header");
for (int idx = 0; idx < 2; idx++) {
String returnVal = proxy.testHeader1(header, "part");
assertNotNull(returnVal);
assertEquals("part/header", returnVal);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
Aggregations