Java Code Examples for org.apache.phoenix.schema.PTable#TaskType
The following examples show how to use
org.apache.phoenix.schema.PTable#TaskType .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Task.java From phoenix with Apache License 2.0 | 6 votes |
public static void addTask(PhoenixConnection conn, PTable.TaskType taskType, String tenantId, String schemaName, String tableName, String taskStatus, String data, Integer priority, Timestamp startTs, Timestamp endTs, boolean accessCheckEnabled) throws IOException { PreparedStatement stmt; try { stmt = conn.prepareStatement("UPSERT INTO " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME + " ( " + PhoenixDatabaseMetaData.TASK_TYPE + ", " + PhoenixDatabaseMetaData.TENANT_ID + ", " + PhoenixDatabaseMetaData.TABLE_SCHEM + ", " + PhoenixDatabaseMetaData.TABLE_NAME + ", " + PhoenixDatabaseMetaData.TASK_STATUS + ", " + PhoenixDatabaseMetaData.TASK_PRIORITY + ", " + PhoenixDatabaseMetaData.TASK_TS + ", " + PhoenixDatabaseMetaData.TASK_END_TS + ", " + PhoenixDatabaseMetaData.TASK_DATA + " ) VALUES(?,?,?,?,?,?,?,?,?)"); stmt = setValuesToAddTaskPS(stmt, taskType, tenantId, schemaName, tableName, taskStatus, data, priority, startTs, endTs); } catch (SQLException e) { throw new IOException(e); } mutateSystemTaskTable(conn, stmt, accessCheckEnabled); }
Example 2
Source File: Task.java From phoenix with Apache License 2.0 | 6 votes |
public static void deleteTask(PhoenixConnection conn, PTable.TaskType taskType, Timestamp ts, String tenantId, String schemaName, String tableName, boolean accessCheckEnabled) throws IOException { PreparedStatement stmt = null; try { stmt = conn.prepareStatement("DELETE FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME + " WHERE " + PhoenixDatabaseMetaData.TASK_TYPE + " = ? AND " + PhoenixDatabaseMetaData.TASK_TS + " = ? AND " + PhoenixDatabaseMetaData.TENANT_ID + (tenantId == null ? " IS NULL " : " = '" + tenantId + "'") + " AND " + PhoenixDatabaseMetaData.TABLE_SCHEM + (schemaName == null ? " IS NULL " : " = '" + schemaName + "'") + " AND " + PhoenixDatabaseMetaData.TABLE_NAME + " = ?"); stmt.setByte(1, taskType.getSerializedValue()); stmt.setTimestamp(2, ts); stmt.setString(3, tableName); } catch (SQLException e) { throw new IOException(e); } mutateSystemTaskTable(conn, stmt, accessCheckEnabled); }
Example 3
Source File: IndexRebuildTaskIT.java From phoenix with Apache License 2.0 | 6 votes |
public static void waitForTaskState(Connection conn, PTable.TaskType taskType, String expectedTableName, PTable.TaskStatus expectedTaskStatus) throws InterruptedException, SQLException { int maxTries = 200, nTries = 0; String taskStatus = ""; String taskData = ""; do { Thread.sleep(2000); ResultSet rs = conn.createStatement().executeQuery("SELECT * " + " FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME + " WHERE " + PhoenixDatabaseMetaData.TABLE_NAME + "='" + expectedTableName + "' AND " + PhoenixDatabaseMetaData.TASK_TYPE + " = " + taskType.getSerializedValue()); while (rs.next()) { taskStatus = rs.getString(PhoenixDatabaseMetaData.TASK_STATUS); taskData = rs.getString(PhoenixDatabaseMetaData.TASK_DATA); boolean matchesExpected = (expectedTaskStatus.toString().equals(taskStatus)); if (matchesExpected) { return; } } } while (++nTries < maxTries); fail(String.format("Ran out of time waiting for current task state %s to become %s. TaskData: %s", taskStatus, expectedTaskStatus, taskData)); }
Example 4
Source File: DropTableWithViewsIT.java From phoenix with Apache License 2.0 | 5 votes |
public static void assertTaskColumns(Connection conn, String expectedStatus, PTable.TaskType taskType, String expectedTableName, String expectedTenantId, String expectedSchema, Timestamp expectedTs, String expectedIndexName) throws SQLException { ResultSet rs = conn.createStatement().executeQuery("SELECT * " + " FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME + " WHERE " + PhoenixDatabaseMetaData.TASK_TYPE + " = " + taskType.getSerializedValue()); assertTrue(rs.next()); String taskStatus = rs.getString(PhoenixDatabaseMetaData.TASK_STATUS); assertEquals(expectedStatus, taskStatus); if (expectedTableName != null) { String tableName = rs.getString(PhoenixDatabaseMetaData.TABLE_NAME); assertEquals(expectedTableName, tableName); } if (expectedTenantId != null) { String tenantId = rs.getString(PhoenixDatabaseMetaData.TENANT_ID); assertEquals(expectedTenantId, tenantId); } if (expectedSchema != null) { String schema = rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM); assertEquals(expectedSchema, schema); } if (expectedTs != null) { Timestamp ts = rs.getTimestamp(PhoenixDatabaseMetaData.TASK_TS); assertEquals(expectedTs, ts); } if (expectedIndexName != null) { String data = rs.getString(PhoenixDatabaseMetaData.TASK_DATA); assertEquals(true, data.contains("\"IndexName\":\"" + expectedIndexName)); } }
Example 5
Source File: Task.java From phoenix with Apache License 2.0 | 4 votes |
public static List<TaskRecord> queryTaskTable(Connection connection, Timestamp ts, String schema, String tableName, PTable.TaskType taskType, String tenantId, String indexName) throws SQLException { String taskQuery = "SELECT " + PhoenixDatabaseMetaData.TASK_TS + ", " + PhoenixDatabaseMetaData.TENANT_ID + ", " + PhoenixDatabaseMetaData.TABLE_SCHEM + ", " + PhoenixDatabaseMetaData.TABLE_NAME + ", " + PhoenixDatabaseMetaData.TASK_STATUS + ", " + PhoenixDatabaseMetaData.TASK_TYPE + ", " + PhoenixDatabaseMetaData.TASK_PRIORITY + ", " + PhoenixDatabaseMetaData.TASK_DATA + " FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME; taskQuery += " WHERE " + PhoenixDatabaseMetaData.TABLE_NAME + " ='" + tableName + "' AND " + PhoenixDatabaseMetaData.TASK_TYPE + "=" + taskType.getSerializedValue(); if (!Strings.isNullOrEmpty(tenantId)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TENANT_ID + "='" + tenantId + "' "; } if (!Strings.isNullOrEmpty(schema)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TABLE_SCHEM + "='" + schema + "' "; } if (!Strings.isNullOrEmpty(indexName)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TASK_DATA + " LIKE '%" + indexName + "%'"; } List<TaskRecord> taskRecords = populateTasks(connection, taskQuery); List<TaskRecord> result = new ArrayList<TaskRecord>(); if (ts != null) { // Adding TASK_TS to the where clause did not work. It returns empty when directly querying with the timestamp. for (TaskRecord tr : taskRecords) { if (tr.getTimeStamp().equals(ts)) { result.add(tr); } } } else { result = taskRecords; } return result; }
Example 6
Source File: Task.java From phoenix with Apache License 2.0 | 4 votes |
public PTable.TaskType getTaskType() { return taskType; }
Example 7
Source File: Task.java From phoenix with Apache License 2.0 | 4 votes |
public void setTaskType(PTable.TaskType taskType) { this.taskType = taskType; }