Search in sources :

Example 1 with LinkedList

use of java.util.LinkedList in project che by eclipse.

the class LifecycleModule method doGet.

private Method[] doGet(Class<?> type, Class<? extends Annotation> annotationType) {
    final List<Method> allMethods = getAllMethods(type);
    final LinkedList<Method> methods = new LinkedList<>();
    final Set<String> methodNames = new HashSet<>();
    for (Method method : allMethods) {
        if (method.isAnnotationPresent(annotationType) && method.getParameterTypes().length == 0 && method.getReturnType() == void.class && methodNames.add(method.getName())) {
            method.setAccessible(true);
            methods.addFirst(method);
        }
    }
    return methods.toArray(new Method[methods.size()]);
}
Also used : Method(java.lang.reflect.Method) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 2 with LinkedList

use of java.util.LinkedList in project elastic-job by dangdangdotcom.

the class JobEventRdbSearch method getJobStatusTraceEvents.

private List<JobStatusTraceEvent> getJobStatusTraceEvents(final Condition condition) {
    List<JobStatusTraceEvent> result = new LinkedList<>();
    try (Connection conn = dataSource.getConnection();
        PreparedStatement preparedStatement = createDataPreparedStatement(conn, TABLE_JOB_STATUS_TRACE_LOG, FIELDS_JOB_STATUS_TRACE_LOG, condition);
        ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
            JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(resultSet.getString(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4), resultSet.getString(5), Source.valueOf(resultSet.getString(6)), ExecutionType.valueOf(resultSet.getString(7)), resultSet.getString(8), State.valueOf(resultSet.getString(9)), resultSet.getString(10), new Date(resultSet.getTimestamp(11).getTime()));
            result.add(jobStatusTraceEvent);
        }
    } catch (final SQLException ex) {
        // TODO 记录失败直接输出日志,未来可考虑配置化
        log.error("Fetch JobStatusTraceEvent from DB error:", ex);
    }
    return result;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) JobStatusTraceEvent(com.dangdang.ddframe.job.event.type.JobStatusTraceEvent) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 3 with LinkedList

use of java.util.LinkedList in project elastic-job by dangdangdotcom.

the class StatisticRdbRepository method findJobRunningStatistics.

/**
     * 获取运行中的任务统计数据集合.
     * 
     * @param from 统计开始时间
     * @return 运行中的任务统计数据集合
     */
public List<JobRunningStatistics> findJobRunningStatistics(final Date from) {
    List<JobRunningStatistics> result = new LinkedList<>();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s WHERE statistics_time >= '%s' order by id ASC", TABLE_JOB_RUNNING_STATISTICS, formatter.format(from));
    try (Connection conn = dataSource.getConnection();
        PreparedStatement preparedStatement = conn.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
            JobRunningStatistics jobRunningStatistics = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime()));
            result.add(jobRunningStatistics);
        }
    } catch (final SQLException ex) {
        // TODO 记录失败直接输出日志,未来可考虑配置化
        log.error("Fetch jobRunningStatistics from DB error:", ex);
    }
    return result;
}
Also used : SQLException(java.sql.SQLException) JobRunningStatistics(com.dangdang.ddframe.job.statistics.type.job.JobRunningStatistics) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleDateFormat(java.text.SimpleDateFormat) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 4 with LinkedList

use of java.util.LinkedList in project elastic-job by dangdangdotcom.

the class StatisticRdbRepository method findTaskResultStatistics.

/**
     * 获取任务运行结果统计数据集合.
     * 
     * @param from 统计开始时间
     * @param statisticInterval 统计时间间隔
     * @return 任务运行结果统计数据集合
     */
public List<TaskResultStatistics> findTaskResultStatistics(final Date from, final StatisticInterval statisticInterval) {
    List<TaskResultStatistics> result = new LinkedList<>();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String sql = String.format("SELECT id, success_count, failed_count, statistics_time, creation_time FROM %s WHERE statistics_time >= '%s' order by id ASC", TABLE_TASK_RESULT_STATISTICS + "_" + statisticInterval, formatter.format(from));
    try (Connection conn = dataSource.getConnection();
        PreparedStatement preparedStatement = conn.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
            TaskResultStatistics taskResultStatistics = new TaskResultStatistics(resultSet.getLong(1), resultSet.getInt(2), resultSet.getInt(3), statisticInterval, new Date(resultSet.getTimestamp(4).getTime()), new Date(resultSet.getTimestamp(5).getTime()));
            result.add(taskResultStatistics);
        }
    } catch (final SQLException ex) {
        // TODO 记录失败直接输出日志,未来可考虑配置化
        log.error("Fetch taskResultStatistics from DB error:", ex);
    }
    return result;
}
Also used : TaskResultStatistics(com.dangdang.ddframe.job.statistics.type.task.TaskResultStatistics) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleDateFormat(java.text.SimpleDateFormat) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 5 with LinkedList

use of java.util.LinkedList in project elastic-job by dangdangdotcom.

the class JobEventRdbSearch method getJobExecutionEvents.

private List<JobExecutionEvent> getJobExecutionEvents(final Condition condition) {
    List<JobExecutionEvent> result = new LinkedList<>();
    try (Connection conn = dataSource.getConnection();
        PreparedStatement preparedStatement = createDataPreparedStatement(conn, TABLE_JOB_EXECUTION_LOG, FIELDS_JOB_EXECUTION_LOG, condition);
        ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
            JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(resultSet.getString(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4), resultSet.getString(5), JobExecutionEvent.ExecutionSource.valueOf(resultSet.getString(6)), Integer.valueOf(resultSet.getString(7)), new Date(resultSet.getTimestamp(8).getTime()), resultSet.getTimestamp(9) == null ? null : new Date(resultSet.getTimestamp(9).getTime()), resultSet.getBoolean(10), new JobExecutionEventThrowable(null, resultSet.getString(11)));
            result.add(jobExecutionEvent);
        }
    } catch (final SQLException ex) {
        // TODO 记录失败直接输出日志,未来可考虑配置化
        log.error("Fetch JobExecutionEvent from DB error:", ex);
    }
    return result;
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) JobExecutionEventThrowable(com.dangdang.ddframe.job.event.type.JobExecutionEventThrowable) LinkedList(java.util.LinkedList) Date(java.util.Date)

Aggregations

LinkedList (java.util.LinkedList)10851 Test (org.junit.Test)1544 List (java.util.List)1517 HashMap (java.util.HashMap)1413 ArrayList (java.util.ArrayList)1368 Map (java.util.Map)915 IOException (java.io.IOException)823 File (java.io.File)721 HashSet (java.util.HashSet)632 LinkedHashMap (java.util.LinkedHashMap)390 GenericValue (org.apache.ofbiz.entity.GenericValue)296 Iterator (java.util.Iterator)281 Set (java.util.Set)274 Date (java.util.Date)249 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)232 Collection (java.util.Collection)208 Collectors (java.util.stream.Collectors)162 Delegator (org.apache.ofbiz.entity.Delegator)162 Locale (java.util.Locale)159 URL (java.net.URL)158