private double getAvgCPU(final String url, final Long ts, Connection con) { double r = 0; PreparedStatement cmd = null; ResultSet rs = null; try { cmd = con.prepareStatement("select avg(percentcpu) from rawdatamachineprocess where uri=? and utcdatetime > ?"); cmd.setString(1, url); cmd.setLong(2, System.currentTimeMillis() - ts); rs = cmd.executeQuery(); if (rs.next()) { r = rs.getLong(1); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } return r; }
private void RecordDependency(String url, String action, String url0, String action0, Connection con) { PreparedStatement cmd=null; try { cmd = con.prepareStatement("INSERT INTO dependencies(sourceurl, sourcesoapaction, destintationurl, destinationsoapaction) VALUES (?, ?, ?, ?);"); cmd.setString(1, url); cmd.setString(2, action); cmd.setString(3, url0); cmd.setString(4, action0); cmd.executeUpdate(); } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(cmd); } }
private long getMaxQueueDepth(final String url, final Long ts, Connection con) { long r = 0; PreparedStatement cmd = null; ResultSet rs = null; try { cmd = con.prepareStatement("select max(queuedepth) from brokerhistory where host=? and utcdatetime > ?"); cmd.setString(1, url); cmd.setLong(2, System.currentTimeMillis() - ts); rs = cmd.executeQuery(); if (rs.next()) { r = rs.getLong(1); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } return r; }
private long getMessagesOut(String url, Long ts, Connection con) { long r = 0; PreparedStatement cmd = null; ResultSet rs = null; try { cmd = con.prepareStatement("select avg(messagecount) from brokerhistory where host=? and utcdatetime > ?"); cmd.setString(1, url); cmd.setLong(2, System.currentTimeMillis() - ts); rs = cmd.executeQuery(); if (rs.next()) { r = rs.getLong(1); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } return r; }
private long getMessagesDropped(final String url, final Long ts, Connection con) { long r = 0; PreparedStatement cmd = null; ResultSet rs = null; try { cmd = con.prepareStatement("select avg(messagedropcount) from brokerhistory where host=? and utcdatetime > ?"); cmd.setString(1, url); cmd.setLong(2, System.currentTimeMillis() - ts); rs = cmd.executeQuery(); if (rs.next()) { r = rs.getLong(1); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } return r; } private void doWorkBrokers(Connection ConfigCon, Connection PerfCon, List<Long> periods) throws Exception {
private long getAvgMem(final String url, final Long ts, Connection con) { Double r = Double.valueOf(0); PreparedStatement cmd = null; ResultSet rs = null; try { cmd = con.prepareStatement("select avg(memoryused) from rawdatamachineprocess where uri=? and utcdatetime > ?"); cmd.setString(1, url); cmd.setLong(2, System.currentTimeMillis() - ts); rs = cmd.executeQuery(); if (rs.next()) { r = rs.getDouble(1); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } return r.longValue(); }
private long getAvgFile(final String url, final Long ts, Connection con) { Double r = Double.valueOf(0); PreparedStatement cmd = null; ResultSet rs = null; try { cmd = con.prepareStatement("select avg(openfiles) from rawdatamachineprocess where uri=? and utcdatetime > ?"); cmd.setString(1, url); cmd.setLong(2, System.currentTimeMillis() - ts); rs = cmd.executeQuery(); if (rs.next()) { r = rs.getDouble(1); } } catch (Exception ex) { log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(rs); DBUtils.safeClose(cmd); } return r.longValue(); }
private void updateLastRanAt(ReportDefinition get) { Connection con = Utility.getPerformanceDBConnection(); PreparedStatement cmd = null; try { cmd = con.prepareStatement("update arsjobs set lastranat=? where jobid=?"); cmd.setLong(1, System.currentTimeMillis()); cmd.setString(2, get.getJobId()); cmd.executeUpdate(); } catch (Exception ex) { log.log(Level.WARN, null, ex); } finally { DBUtils.safeClose(cmd); DBUtils.safeClose(con); } } }
/** * returns all of the mail settings, use from nonpooled connections, * connections loaded from properties file in common * * @return */ @Deprecated public static Properties LoadSLAPropertiesNotPooled() { Connection con = Utility.getConfigurationDB_NONPOOLED_Connection(); Properties p = loadSLAProperties(con); DBUtils.safeClose(con); return p; }
/** * returns all of the mail settings, use from pooled connections with jndi * * @return */ public static Properties LoadSLAPropertiesPooled() { Connection con = Utility.getConfigurationDBConnection(); Properties p = loadSLAProperties(con); DBUtils.safeClose(con); return p; }
@Deprecated public static InternetAddress[] GetAllfgsmsAdminsEmailAddressNotPooled() { SetupBundle(); Connection con = Utility.getConfigurationDB_NONPOOLED_Connection(); InternetAddress[] sp = getAllfgsmsAdminsEmailAddress(con); DBUtils.safeClose(con); return sp; }
@Override public void run() { UUID random = UUID.randomUUID(); MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME, 0, myUrl, "machine/process", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", ""); Connection ConfigCon = Utility.getConfigurationDBConnection(); Connection PerfCon = Utility.getPerformanceDBConnection(); try { doWorkBrokers(ConfigCon, PerfCon, periods); MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap()); } catch (Exception ex) { MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap()); } finally { DBUtils.safeClose(PerfCon); DBUtils.safeClose(ConfigCon); } }
@Override public void run() { UUID random = UUID.randomUUID(); MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME, 0, myUrl, "machine/process", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", ""); Connection ConfigCon = Utility.getConfigurationDBConnection(); Connection PerfCon = Utility.getPerformanceDBConnection(); try { doWorkMachinesProcesses(ConfigCon, PerfCon, periods); MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap()); } catch (Exception ex) { MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap()); } finally { DBUtils.safeClose(PerfCon); DBUtils.safeClose(ConfigCon); } }
@Override public void run() { UUID random = UUID.randomUUID(); MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME, 0, myUrl, "status", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", ""); Connection ConfigCon = Utility.getConfigurationDBConnection(); Connection PerfCon = Utility.getPerformanceDBConnection(); try { doWorkForStatusItemsOnly(ConfigCon, PerfCon, periods); MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap()); } catch (Exception ex) { MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap()); log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(PerfCon); DBUtils.safeClose(ConfigCon); } }
@Override public void run() { UUID random = UUID.randomUUID(); MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME + " for " + uri, 0, myUrl, "transactional", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", ""); Connection ConfigCon = Utility.getConfigurationDBConnection(); Connection PerfCon = Utility.getPerformanceDBConnection(); try { doWorkTransactional(ConfigCon, PerfCon, periods, uri); MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap()); } catch (Exception ex) { MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap()); log.log(Level.ERROR, null, ex); } finally { DBUtils.safeClose(PerfCon); DBUtils.safeClose(ConfigCon); } }
/** * used by qpid agents * * @param uRI * @return */ @Deprecated public static ServicePolicy LoadPolicyNotPooled(String uRI) { SetupBundle(); Connection con = Utility.getConfigurationDB_NONPOOLED_Connection(); ServicePolicy sp = loadPolicy(con, uRI); DBUtils.safeClose(con); return sp; }
/** * Returns a list of user's email addresses that are subscribed to a * specific SLA with email actions * * @param guid * @return */ @Deprecated public static InternetAddress[] GetSubscribersNotPooled(String guid) { SetupBundle(); Connection con = Utility.getConfigurationDB_NONPOOLED_Connection(); InternetAddress[] sp = getSubscribers(con, guid); DBUtils.safeClose(con); return sp; }
public static InternetAddress[] GetAllfgsmsAdminsEmailAddressPooled() { SetupBundle(); Connection con = Utility.getConfigurationDBConnection(); InternetAddress[] sp = getAllfgsmsAdminsEmailAddress(con); DBUtils.safeClose(con); return sp; }
/** * Returns a list of user's email addresses that are subscribed to a * specific SLA with email actions * * @param guid * @return */ public static InternetAddress[] GetSubscribersPooled(String guid) { SetupBundle(); Connection con = Utility.getConfigurationDBConnection(); InternetAddress[] sp = getSubscribers(con, guid); DBUtils.safeClose(con); return sp; }
/** * used by NT SLA for web services * * @return */ public static List<ServicePolicy> LoadServicePoliciesNotPooled() { Connection con = Utility.getConfigurationDB_NONPOOLED_Connection(); SetupBundle(); List<ServicePolicy> r = null; try { r = loadServicePolicies(con); } catch (Exception ex) { log.log(Level.ERROR, bundle.getString("ErrorLoadingPolicy"), ex); } finally { DBUtils.safeClose(con); } if (r == null) { r = new ArrayList<ServicePolicy>(); } return r; }