private boolean getDbStatus() { try { return this.dbOperator.query("SELECT 1", rs -> true); } catch (final SQLException e) { log.error("DB Error", e); } return false; }
@Override public Collection<TriggerInstance> getRunning() { try { //todo chengren311: // 1. add index for the execution_dependencies table to accelerate selection. return this.dbOperator.query(SELECT_ALL_RUNNING_EXECUTIONS, new TriggerInstanceHandler (SORT_MODE.SORT_ON_START_TIME_ASC)); } catch (final SQLException ex) { handleSQLException(ex); } return Collections.emptyList(); }
public int fetchNumExecutableNodes(final int projectId, final String jobId) throws ExecutorManagerException { final IntHandler intHandler = new IntHandler(); try { return this.dbOperator.query(IntHandler.NUM_JOB_EXECUTIONS, intHandler, projectId, jobId); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching num executions", e); } }
List<Executor> fetchActiveExecutors() throws ExecutorManagerException { try { return this.dbOperator .query(FetchExecutorHandler.FETCH_ACTIVE_EXECUTORS, new FetchExecutorHandler()); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching active executors", e); } }
List<ExecutableFlow> fetchFlowHistory(final int projectId, final String flowId, final int skip, final int num) throws ExecutorManagerException { try { return this.dbOperator.query(FetchExecutableFlows.FETCH_EXECUTABLE_FLOW_HISTORY, new FetchExecutableFlows(), projectId, flowId, skip, num); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching flow history", e); } }
public List<Pair<ExecutionReference, ExecutableFlow>> fetchQueuedFlows() throws ExecutorManagerException { try { return this.dbOperator.query(FetchQueuedExecutableFlows.FETCH_QUEUED_EXECUTABLE_FLOW, new FetchQueuedExecutableFlows()); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching active flows", e); } }
List<Executor> fetchAllExecutors() throws ExecutorManagerException { try { return this.dbOperator .query(FetchExecutorHandler.FETCH_ALL_EXECUTORS, new FetchExecutorHandler()); } catch (final Exception e) { throw new ExecutorManagerException("Error fetching executors", e); } }
LogData fetchLogs(final int execId, final String name, final int attempt, final int startByte, final int length) throws ExecutorManagerException { final FetchLogsHandler handler = new FetchLogsHandler(startByte, length + startByte); try { return this.dbOperator.query(FetchLogsHandler.FETCH_LOGS, handler, execId, name, attempt, startByte, startByte + length); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching logs " + execId + " : " + name, e); } }
public int fetchNumExecutableFlows(final int projectId, final String flowId) throws ExecutorManagerException { final IntHandler intHandler = new IntHandler(); try { return this.dbOperator.query(IntHandler.NUM_FLOW_EXECUTIONS, intHandler, projectId, flowId); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching num executions", e); } }
public int fetchNumExecutableFlows() throws ExecutorManagerException { try { return this.dbOperator.query(IntHandler.NUM_EXECUTIONS, new IntHandler()); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching num executions", e); } }
List<ExecutableFlow> fetchFlowHistory(final int skip, final int num) throws ExecutorManagerException { try { return this.dbOperator.query(FetchExecutableFlows.FETCH_ALL_EXECUTABLE_FLOW_HISTORY, new FetchExecutableFlows(), skip, num); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching flow History", e); } }
public Props fetchExecutionJobInputProps(final int execId, final String jobId) throws ExecutorManagerException { try { final Pair<Props, Props> props = this.dbOperator.query( FetchExecutableJobPropsHandler.FETCH_INPUT_PARAM_EXECUTABLE_NODE, new FetchExecutableJobPropsHandler(), execId, jobId); return props.getFirst(); } catch (final SQLException e) { throw new ExecutorManagerException("Error querying job params " + execId + " " + jobId, e); } }
@Override public int getLatestProjectVersion(final Project project) throws ProjectManagerException { final IntHandler handler = new IntHandler(); try { return this.dbOperator.query(IntHandler.SELECT_LATEST_VERSION, handler, project.getId()); } catch (final SQLException e) { logger.error(e); throw new ProjectManagerException( "Error marking project " + project.getName() + " as inactive", e); } }
@Test(expected = SQLException.class) public void testTypoSqlStatement() throws Exception { System.out.println("testTypoSqlStatement"); this.dbOperator.query("sele * from blah where ? = ?", this.handler, "id", 2); }
public Props fetchExecutionJobOutputProps(final int execId, final String jobId) throws ExecutorManagerException { try { final Pair<Props, Props> props = this.dbOperator.query( FetchExecutableJobPropsHandler.FETCH_OUTPUT_PARAM_EXECUTABLE_NODE, new FetchExecutableJobPropsHandler(), execId, jobId); return props.getFirst(); } catch (final SQLException e) { throw new ExecutorManagerException("Error querying job params " + execId + " " + jobId, e); } }
List<ExecutableFlow> fetchFlowHistory(final int projectId, final String flowId, final int skip, final int num, final Status status) throws ExecutorManagerException { try { return this.dbOperator.query(FetchExecutableFlows.FETCH_EXECUTABLE_FLOW_BY_STATUS, new FetchExecutableFlows(), projectId, flowId, status.getNumVal(), skip, num); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching active flows", e); } }
List<ExecutableFlow> fetchRecentlyFinishedFlows(final Duration maxAge) throws ExecutorManagerException { try { return this.dbOperator.query(FetchRecentlyFinishedFlows.FETCH_RECENTLY_FINISHED_FLOW, new FetchRecentlyFinishedFlows(), System.currentTimeMillis() - maxAge.toMillis(), Status.SUCCEEDED.getNumVal(), Status.KILLED.getNumVal(), Status.FAILED.getNumVal()); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching recently finished flows", e); } }
public List<ExecutorLogEvent> getExecutorEvents(final Executor executor, final int num, final int offset) throws ExecutorManagerException { try { return this.dbOperator.query(ExecutorLogsResultHandler.SELECT_EXECUTOR_EVENTS_ORDER, new ExecutorLogsResultHandler(), executor.getId(), num, offset); } catch (final SQLException e) { throw new ExecutorManagerException( "Failed to fetch events for executor id : " + executor.getId(), e); } }
@Before public void setUp() throws Exception { this.databaseOperator = mock(DatabaseOperator.class); this.storage = mock(Storage.class); when(this.databaseOperator.query( eq(StorageCleaner.SQL_FETCH_PVR), anyObject(), eq(TEST_PROJECT_ID))) .thenReturn(Arrays.asList("14/14-9.zip", "14/14-8.zip", "14/14-7.zip")); when(this.storage.delete("14/14-8.zip")).thenReturn(true); when(this.storage.delete("14/14-7.zip")).thenReturn(false); when(this.databaseOperator.update(any(), anyVararg())).thenReturn(1); }
@Test public void testInvalidQuery() throws Exception { final int res = this.dbOperator.query("select * from blah where ? = ?", this.handler, "id", 3); Assert.assertEquals(0, res); }