Search in sources :

Example 61 with UndeclaredThrowableException

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;
}
Also used : UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Example 62 with UndeclaredThrowableException

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();
}
Also used : UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ActiondConfigFactory(org.opennms.netmgt.config.ActiondConfigFactory)

Example 63 with UndeclaredThrowableException

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;
}
Also used : TException(org.apache.thrift.TException) PrivilegedActionException(java.security.PrivilegedActionException) TTransportException(org.apache.thrift.transport.TTransportException) NoReconnect(org.apache.hadoop.hive.metastore.annotation.NoReconnect) Annotation(java.lang.annotation.Annotation) InvocationTargetException(java.lang.reflect.InvocationTargetException) TApplicationException(org.apache.thrift.TApplicationException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) TProtocolException(org.apache.thrift.protocol.TProtocolException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 64 with UndeclaredThrowableException

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();
    }
}
Also used : TestHeader(org.apache.header_test.TestHeader) Holder(javax.xml.ws.Holder) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPHeaderService(org.apache.header_test.SOAPHeaderService) TestHeader2Response(org.apache.header_test.types.TestHeader2Response) TestHeader2(org.apache.header_test.types.TestHeader2) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 65 with UndeclaredThrowableException

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();
    }
}
Also used : SOAPRPCHeaderService(org.apache.header_test.rpc.SOAPRPCHeaderService) QName(javax.xml.namespace.QName) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HeaderMessage(org.apache.header_test.rpc.types.HeaderMessage) TestRPCHeader(org.apache.header_test.rpc.TestRPCHeader) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)180 Test (org.junit.Test)66 IOException (java.io.IOException)37 URL (java.net.URL)25 Greeter (org.apache.hello_world_soap_http.Greeter)21 SOAPService (org.apache.hello_world_soap_http.SOAPService)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)14 Endpoint (javax.xml.ws.Endpoint)12 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)11 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)11 BufferedReader (java.io.BufferedReader)10 InputStreamReader (java.io.InputStreamReader)10 ServerSocket (java.net.ServerSocket)10 QName (javax.xml.namespace.QName)10 BindingProvider (javax.xml.ws.BindingProvider)10 Greeter (org.apache.cxf.greeter_control.Greeter)10 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 Socket (java.net.Socket)9 PollStatus (org.opennms.netmgt.poller.PollStatus)9