Search in sources :

Example 51 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 52 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class Dhcpd method onStart.

/**
     * <p>onStart</p>
     */
@Override
protected void onStart() {
    boolean relayMode = false;
    LOG.debug("start: DHCP client daemon starting...");
    // Only allow start to be called once.
    if (m_worker != null && m_worker.isAlive()) {
        throw new IllegalStateException("The server is already running");
    }
    // Unless the worker has died, then stop and continue
    if (m_worker != null) {
        stop();
    }
    // the client list
    m_clients = Collections.synchronizedList(new LinkedList<Client>());
    // load the dhcpd configuration
    DhcpdConfigFactory dFactory = null;
    try {
        DhcpdConfigFactory.reload();
        dFactory = DhcpdConfigFactory.getInstance();
    } catch (Exception ex) {
        LOG.error("Failed to load dhcpd configuration", ex);
        throw new UndeclaredThrowableException(ex);
    }
    //
    try {
        LOG.debug("start: listening on TCP port {} for incoming client requests.", dFactory.getPort());
        m_server = new ServerSocket(dFactory.getPort(), 0, InetAddressUtils.addr("127.0.0.1"));
    } catch (IOException ex) {
        if (ex instanceof java.net.BindException) {
            LOG.error("Failed to listen on DHCP port, perhaps something else is already listening?", ex);
            LOG.error("Failed to listen on DHCP port, perhaps something else is already listening?", ex);
        } else {
            LOG.error("Failed to initialize DHCP socket", ex);
        }
        throw new UndeclaredThrowableException(ex);
    }
    // see if we have a valid relay address
    String myIpStr = DhcpdConfigFactory.getInstance().getMyIpAddress();
    LOG.debug("Checking string \"{}\" to see if we have an IP address", myIpStr);
    if (myIpStr != null && !myIpStr.equals("") && !myIpStr.equalsIgnoreCase("broadcast")) {
        try {
            InetAddressUtils.toIpAddrBytes(myIpStr);
            relayMode = true;
        } catch (IllegalArgumentException e) {
            LOG.warn("Invalid format for IP address: {}", myIpStr);
        }
    }
    LOG.debug("Setting relay mode {}", relayMode);
    // open the receiver socket(s)
    if (!relayMode || (dFactory.getExtendedMode() != null && dFactory.getExtendedMode().equalsIgnoreCase("true"))) {
        try {
            LOG.debug("start: starting receiver thread for port 68");
            m_listener = new Receiver(m_clients);
            m_listener.start();
        } catch (IOException ex) {
            try {
                m_server.close();
            } catch (IOException ex1) {
            }
            throw new UndeclaredThrowableException(ex);
        }
    }
    if (relayMode) {
        try {
            LOG.debug("start: starting receiver thread for port 67");
            m_listener2 = new Receiver2(m_clients);
            m_listener2.start();
        } catch (IOException ex) {
            try {
                m_server.close();
            } catch (IOException ex1) {
            }
            throw new UndeclaredThrowableException(ex);
        }
    }
    m_worker = new Thread(this, getName());
    m_worker.start();
}
Also used : DhcpdConfigFactory(org.opennms.netmgt.config.dhcpd.DhcpdConfigFactory) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException) InterruptedIOException(java.io.InterruptedIOException) LinkedList(java.util.LinkedList) IOException(java.io.IOException) InterruptedIOException(java.io.InterruptedIOException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Example 53 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class AvailabilityReportFullIT method testBuiltClassicReport.

@Test
@Ignore("Don't run this test (which has less coverage than the next) until I figure out why we're holding onto the previous test's dataSource.")
public void testBuiltClassicReport() {
    try {
        classicAvailabilityCalculator.setPeriodEndDate(m_calendar.getTime());
        classicAvailabilityCalculator.setLogoURL("wahtever");
        classicAvailabilityCalculator.setReportFormat("PDF");
        classicAvailabilityCalculator.setMonthFormat("classic");
        classicAvailabilityCalculator.setCategoryName("Network Interfaces");
        classicAvailabilityCalculator.calculate();
        Report report = classicAvailabilityCalculator.getReport();
        Assert.assertNotNull("report", report);
        Assert.assertNotNull("report categories", report.getCategories());
        Categories categories = report.getCategories();
        Assert.assertEquals("category count", 1, categories.getCategoryCount());
        Category category = categories.getCategory(0);
        // basic test
        Assert.assertEquals("category node count", Integer.valueOf(2), category.getNodeCount());
        Assert.assertEquals("category ip address count", Integer.valueOf(3), category.getIpaddrCount());
        Assert.assertEquals("category service count", Integer.valueOf(3), category.getServiceCount());
        Section section = getSectionByName(category, "LastMonthsDailyAvailability");
        Assert.assertNull("section calendar table", section.getCalendarTable());
        Created created = report.getCreated();
        Assert.assertNotNull("report created period", created.getPeriod());
    } catch (Throwable e) {
        throw new UndeclaredThrowableException(e);
    }
}
Also used : UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 54 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class AvailabilityReportIT method buildReport.

/*
    private int numRowsWithValue(Section section, String title, String data){

        int rowMatched = 0;
        boolean titlematch;
        boolean datamatch;

        ClassicTable table = section.getClassicTable();
        Rows rows = table.getRows();
        Row[] row = rows.getRow();
        for(int j= 0; j < row.length; j++) {
            Value[] value = row[j].getValue();
            titlematch = false;
            datamatch = false;
            for(int k= 0; k < value.length; k++){
                if (value[k].getType().equals("title") &&
                        value[k].getContent().equals(title))
                    titlematch = true;	
                if (value[k].getType().equals("data") &&
                        value[k].getContent().equals(data))
                    datamatch = true;
                if (datamatch && titlematch)
                    rowMatched++;
            }	
        }			
        return rowMatched; 
    }
    */
private Report buildReport(Calendar calendar, String calFormat) {
    Report report = new Report();
    report.setLogo("wherever");
    ViewInfo viewInfo = new ViewInfo();
    report.setViewInfo(viewInfo);
    report.setCategories(m_categories);
    // AvailabilityData availData = null;
    try {
        /* it seems we just initialize this to make sure it works
             * availData =
             */
        AvailabilityData reportSource = new AvailabilityData();
        reportSource.setAvailabilityDataService(new LegacyAvailabilityDataService());
        reportSource.fillReport("Network Interfaces", report, "HTML", calFormat, "4", "18", "2005");
    } catch (Throwable e) {
        throw new UndeclaredThrowableException(e);
    }
    return report;
}
Also used : LegacyAvailabilityDataService(org.opennms.reporting.availability.svclayer.LegacyAvailabilityDataService) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Example 55 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project Activiti by Activiti.

the class JtaTransactionInterceptor method execute.

public <T> T execute(CommandConfig config, Command<T> command) {
    LOGGER.debug("Running command with propagation {}", config.getTransactionPropagation());
    if (config.getTransactionPropagation() == TransactionPropagation.NOT_SUPPORTED) {
        return next.execute(config, command);
    }
    boolean requiresNew = config.getTransactionPropagation() == TransactionPropagation.REQUIRES_NEW;
    Transaction oldTx = null;
    try {
        boolean existing = isExisting();
        boolean isNew = !existing || requiresNew;
        if (existing && requiresNew) {
            oldTx = doSuspend();
        }
        if (isNew) {
            doBegin();
        }
        T result;
        try {
            result = next.execute(config, command);
        } catch (RuntimeException ex) {
            doRollback(isNew, ex);
            throw ex;
        } catch (Error err) {
            doRollback(isNew, err);
            throw err;
        } catch (Exception ex) {
            doRollback(isNew, ex);
            throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception");
        }
        if (isNew) {
            doCommit();
        }
        return result;
    } finally {
        doResume(oldTx);
    }
}
Also used : Transaction(javax.transaction.Transaction) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HeuristicRollbackException(javax.transaction.HeuristicRollbackException) InvalidTransactionException(javax.transaction.InvalidTransactionException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException) RollbackException(javax.transaction.RollbackException) HeuristicMixedException(javax.transaction.HeuristicMixedException)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)121 IOException (java.io.IOException)36 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)14 Test (org.junit.Test)12 BufferedReader (java.io.BufferedReader)10 InputStreamReader (java.io.InputStreamReader)10 ServerSocket (java.net.ServerSocket)10 Socket (java.net.Socket)9 PollStatus (org.opennms.netmgt.poller.PollStatus)9 HashMap (java.util.HashMap)8 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)7 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)7 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)7 Method (java.lang.reflect.Method)6 AccessControlException (java.security.AccessControlException)6 SQLException (java.sql.SQLException)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)6