diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index d8aabd8..8e88955 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -4818,6 +4818,8 @@ new TimeValidator(TimeUnit.SECONDS), "While scheduled queries are in flight; " + "a background update happens periodically to report the actual state of the query"), + HIVE_SCHEDULED_QUERIES_CREATE_AS_ENABLED("hive.scheduled.queries.create.as.enabled", true, + "This option sets the default behaviour of newly created scheduled queries."), HIVE_SECURITY_AUTHORIZATION_SCHEDULED_QUERIES_SUPPORTED("hive.security.authorization.scheduled.queries.supported", false, "Enable this if the configured authorizer is able to handle scheduled query related calls."), diff --git itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java index 698ded2..26c4937 100644 --- itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java +++ itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java @@ -1375,7 +1375,7 @@ @Override - public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException{ + public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException, MetaException { return objectStore.markScheduledExecutionsTimedOut(timeoutSecs); } } diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/ScheduledQueryAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/ScheduledQueryAnalyzer.java index 2deb1b7..66394a3 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/ScheduledQueryAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/ScheduledQueryAnalyzer.java @@ -86,7 +86,7 @@ private ScheduledQuery buildEmptySchq() { ScheduledQuery ret = new ScheduledQuery(); - ret.setEnabled(true); + ret.setEnabled(conf.getBoolVar(ConfVars.HIVE_SCHEDULED_QUERIES_CREATE_AS_ENABLED)); ret.setUser(getUserName()); return ret; } @@ -184,7 +184,8 @@ String currentUser = getUserName(); if (!Objects.equal(currentUser, schq.getUser())) { throw new HiveAccessControlException( - "authorization of scheduled queries is not enabled - only owners may change scheduled queries"); + "Authorization of scheduled queries is not enabled - only owners may change scheduled queries (currentUser: " + + currentUser + ", owner: " + schq.getUser() + ")"); } } else { HiveOperationType opType = toHiveOpType(type); diff --git ql/src/java/org/apache/hadoop/hive/ql/scheduled/ScheduledQueryExecutionService.java ql/src/java/org/apache/hadoop/hive/ql/scheduled/ScheduledQueryExecutionService.java index 813f3af..9b9b291 100644 --- ql/src/java/org/apache/hadoop/hive/ql/scheduled/ScheduledQueryExecutionService.java +++ ql/src/java/org/apache/hadoop/hive/ql/scheduled/ScheduledQueryExecutionService.java @@ -64,7 +64,7 @@ } static boolean isTerminalState(QueryState state) { - return state == QueryState.FINISHED || state == QueryState.ERRORED; + return state == QueryState.FINISHED || state == QueryState.FAILED; } class ScheduledQueryExecutor implements Runnable { @@ -125,7 +125,7 @@ } } catch (Throwable t) { info.setErrorMessage(getErrorStringForException(t)); - info.setState(QueryState.ERRORED); + info.setState(QueryState.FAILED); } finally { if (state != null) { try { diff --git ql/src/test/org/apache/hadoop/hive/ql/schq/TestScheduledQueryService.java ql/src/test/org/apache/hadoop/hive/ql/schq/TestScheduledQueryService.java index 4fe3dd2..9a7b423 100644 --- ql/src/test/org/apache/hadoop/hive/ql/schq/TestScheduledQueryService.java +++ ql/src/test/org/apache/hadoop/hive/ql/schq/TestScheduledQueryService.java @@ -129,7 +129,7 @@ public void scheduledQueryProgress(ScheduledQueryProgressInfo info) { System.out.printf("%d, state: %s, error: %s", info.getScheduledExecutionId(), info.getState(), info.getErrorMessage()); - if (info.getState() == QueryState.FINISHED || info.getState() == QueryState.ERRORED) { + if (info.getState() == QueryState.FINISHED || info.getState() == QueryState.FAILED) { // Query is done, notify any waiters synchronized (notifier) { notifier.notifyAll(); diff --git standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/QueryState.java standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/QueryState.java index 9a6e7bf..67d63e9 100644 --- standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/QueryState.java +++ standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/QueryState.java @@ -14,7 +14,7 @@ public enum QueryState implements org.apache.thrift.TEnum { INITED(0), EXECUTING(1), - ERRORED(2), + FAILED(2), FINISHED(3), TIMED_OUT(4); @@ -42,7 +42,7 @@ case 1: return EXECUTING; case 2: - return ERRORED; + return FAILED; case 3: return FINISHED; case 4: diff --git standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php index 093ad4b..e8556dc 100644 --- standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php +++ standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php @@ -295,13 +295,13 @@ final class QueryState { const INITED = 0; const EXECUTING = 1; - const ERRORED = 2; + const FAILED = 2; const FINISHED = 3; const TIMED_OUT = 4; static public $__names = array( 0 => 'INITED', 1 => 'EXECUTING', - 2 => 'ERRORED', + 2 => 'FAILED', 3 => 'FINISHED', 4 => 'TIMED_OUT', ); diff --git standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py index 0dcca59..b05e61e 100644 --- standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py +++ standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py @@ -446,14 +446,14 @@ class QueryState: INITED = 0 EXECUTING = 1 - ERRORED = 2 + FAILED = 2 FINISHED = 3 TIMED_OUT = 4 _VALUES_TO_NAMES = { 0: "INITED", 1: "EXECUTING", - 2: "ERRORED", + 2: "FAILED", 3: "FINISHED", 4: "TIMED_OUT", } @@ -461,7 +461,7 @@ _NAMES_TO_VALUES = { "INITED": 0, "EXECUTING": 1, - "ERRORED": 2, + "FAILED": 2, "FINISHED": 3, "TIMED_OUT": 4, } diff --git standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb index 8d7c32a..868cf69 100644 --- standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb +++ standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb @@ -211,11 +211,11 @@ module QueryState INITED = 0 EXECUTING = 1 - ERRORED = 2 + FAILED = 2 FINISHED = 3 TIMED_OUT = 4 - VALUE_MAP = {0 => "INITED", 1 => "EXECUTING", 2 => "ERRORED", 3 => "FINISHED", 4 => "TIMED_OUT"} - VALID_VALUES = Set.new([INITED, EXECUTING, ERRORED, FINISHED, TIMED_OUT]).freeze + VALUE_MAP = {0 => "INITED", 1 => "EXECUTING", 2 => "FAILED", 3 => "FINISHED", 4 => "TIMED_OUT"} + VALID_VALUES = Set.new([INITED, EXECUTING, FAILED, FINISHED, TIMED_OUT]).freeze end module PartitionFilterMode diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java index 38417be..bc87e8f 100644 --- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java +++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java @@ -760,19 +760,21 @@ 86400, TimeUnit.SECONDS, "Maximum duration for query producing a materialization. After this time, transaction" + "entries that are not relevant for materializations can be removed from invalidation cache."), - RUNTIME_STATS_CLEAN_FREQUENCY("runtime.stats.clean.frequency", "hive.metastore.runtime.stats.clean.frequency", 3600, + RUNTIME_STATS_CLEAN_FREQUENCY("metastore.runtime.stats.clean.frequency", "hive.metastore.runtime.stats.clean.frequency", 3600, TimeUnit.SECONDS, "Frequency at which timer task runs to remove outdated runtime stat entries."), - RUNTIME_STATS_MAX_AGE("runtime.stats.max.age", "hive.metastore.runtime.stats.max.age", 86400 * 3, TimeUnit.SECONDS, + RUNTIME_STATS_MAX_AGE("metastore.runtime.stats.max.age", "hive.metastore.runtime.stats.max.age", 86400 * 3, TimeUnit.SECONDS, "Stat entries which are older than this are removed."), - SCHEDULED_QUERIES_EXECUTION_PROGRESS_TIMEOUT("scheduled.queries.execution.timeout", + SCHEDULED_QUERIES_ENABLED("metastore.scheduled.queries.enabled", "hive.metastore.scheduled.queries.enabled", true, + "Wheter scheduled query metastore requests be processed"), + SCHEDULED_QUERIES_EXECUTION_PROGRESS_TIMEOUT("metastore.scheduled.queries.execution.timeout", "hive.metastore.scheduled.queries.progress.timeout", 120, TimeUnit.SECONDS, "If a scheduled query is not making progress for this amount of time it will be considered TIMED_OUT"), - SCHEDULED_QUERIES_EXECUTION_MAINT_TASK_FREQUENCY("scheduled.queries.execution.maint.task.frequency", + SCHEDULED_QUERIES_EXECUTION_MAINT_TASK_FREQUENCY("metastore.scheduled.queries.execution.maint.task.frequency", "hive.metastore.scheduled.queries.execution.clean.frequency", 60, TimeUnit.SECONDS, "Interval of scheduled query maintenance task. Which removes executions above max age;" + "and marks executions as timed out if the condition is met"), - SCHEDULED_QUERIES_EXECUTION_MAX_AGE("scheduled.queries.execution.max.age", + SCHEDULED_QUERIES_EXECUTION_MAX_AGE("metastore.scheduled.queries.execution.max.age", "hive.metastore.scheduled.queries.execution.max.age", 30 * 86400, TimeUnit.SECONDS, "Maximal age of a scheduled query execution entry before it is removed."), diff --git standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift index 72ccdd1..61a94fe 100644 --- standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift +++ standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift @@ -1806,7 +1806,7 @@ enum QueryState { INITED, EXECUTING, - ERRORED, + FAILED, FINISHED, TIMED_OUT, } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index a1592cd..a3186f7 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -12643,7 +12643,8 @@ } @Override - public ScheduledQueryPollResponse scheduledQueryPoll(ScheduledQueryPollRequest request) { + public ScheduledQueryPollResponse scheduledQueryPoll(ScheduledQueryPollRequest request) throws MetaException { + ensureScheduledQueriesEnabled(); String namespace = request.getClusterNamespace(); boolean commited = false; ScheduledQueryPollResponse ret = new ScheduledQueryPollResponse(); @@ -12691,7 +12692,8 @@ } @Override - public void scheduledQueryProgress(ScheduledQueryProgressInfo info) throws InvalidOperationException { + public void scheduledQueryProgress(ScheduledQueryProgressInfo info) throws InvalidOperationException, MetaException { + ensureScheduledQueriesEnabled(); boolean commited = false; try { openTransaction(); @@ -12712,7 +12714,7 @@ case EXECUTING: execution.setLastUpdateTime((int) (System.currentTimeMillis() / 1000)); break; - case ERRORED: + case FAILED: case FINISHED: case TIMED_OUT: execution.setEndTime((int) (System.currentTimeMillis() / 1000)); @@ -12730,6 +12732,13 @@ } } + private void ensureScheduledQueriesEnabled() throws MetaException { + if (!MetastoreConf.getBoolVar(conf, ConfVars.SCHEDULED_QUERIES_ENABLED)) { + throw new MetaException( + "Scheduled query request processing is disabled via " + ConfVars.SCHEDULED_QUERIES_ENABLED.getVarname()); + } + } + private boolean validateStateChange(QueryState from, QueryState to) { switch (from) { case INITED: @@ -12737,7 +12746,7 @@ case EXECUTING: return to == QueryState.FINISHED || to == QueryState.EXECUTING - || to == QueryState.ERRORED; + || to == QueryState.FAILED; default: return false; } @@ -12769,6 +12778,7 @@ @Override public void scheduledQueryMaintenance(ScheduledQueryMaintenanceRequest request) throws MetaException, NoSuchObjectException, AlreadyExistsException, InvalidInputException { + ensureScheduledQueriesEnabled(); switch (request.getType()) { case CREATE: scheduledQueryInsert(request.getScheduledQuery()); @@ -12913,7 +12923,7 @@ } @Override - public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException { + public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException, MetaException { if (timeoutSecs < 0) { LOG.debug("scheduled executions - time_out mark is disabled"); return 0; diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java index 4975b88..09850c5 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java @@ -1820,5 +1820,5 @@ int deleteScheduledExecutions(int maxRetainSecs); - int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException; + int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException, MetaException; } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ScheduledQueryExecutionsMaintTask.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ScheduledQueryExecutionsMaintTask.java index 2585fe9..d678d01 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ScheduledQueryExecutionsMaintTask.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ScheduledQueryExecutionsMaintTask.java @@ -22,6 +22,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,6 +53,9 @@ @Override public void run() { try { + if (!MetastoreConf.getBoolVar(conf, ConfVars.SCHEDULED_QUERIES_ENABLED)) { + return; + } RawStore ms = HiveMetaStore.HMSHandler.getMSForConf(conf); int timeoutSecs = (int) MetastoreConf.getTimeVar(conf, diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java index d36b3f0..c96c755 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java @@ -2890,7 +2890,7 @@ } @Override - public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException{ + public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException, MetaException { return rawStore.markScheduledExecutionsTimedOut(timeoutSecs); } } diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java index 4e144fc..6a6ba5f 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java @@ -1298,7 +1298,7 @@ } @Override - public ScheduledQueryPollResponse scheduledQueryPoll(ScheduledQueryPollRequest request) { + public ScheduledQueryPollResponse scheduledQueryPoll(ScheduledQueryPollRequest request) throws MetaException { return objectStore.scheduledQueryPoll(request); } @@ -1309,7 +1309,7 @@ } @Override - public void scheduledQueryProgress(ScheduledQueryProgressInfo info) throws InvalidOperationException { + public void scheduledQueryProgress(ScheduledQueryProgressInfo info) throws InvalidOperationException, MetaException { objectStore.scheduledQueryProgress(info); } @@ -1324,7 +1324,7 @@ } @Override - public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException{ + public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException, MetaException { return objectStore.markScheduledExecutionsTimedOut(timeoutSecs); } } diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java index d3313f7..d84cc04 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java @@ -39,6 +39,7 @@ import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; import org.apache.hadoop.hive.metastore.api.InvalidInputException; +import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.QueryState; import org.apache.hadoop.hive.metastore.api.ScheduledQuery; @@ -48,20 +49,25 @@ import org.apache.hadoop.hive.metastore.api.ScheduledQueryPollRequest; import org.apache.hadoop.hive.metastore.api.ScheduledQueryPollResponse; import org.apache.hadoop.hive.metastore.api.ScheduledQueryProgressInfo; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.hadoop.hive.metastore.model.MScheduledExecution; import org.apache.thrift.TException; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.mockito.Matchers; /** * Tests handling of scheduled queries related calls to the metastore. * - * Checks wether expected state changes are being done to the HMS database. + * Checks whether expected state changes are being done to the HMS database. */ @RunWith(Parameterized.class) @Category(MetastoreUnitTest.class) @@ -69,6 +75,9 @@ private final AbstractMetaStoreService metaStore; private IMetaStoreClient client; + @Rule + public ExpectedException thrown = ExpectedException.none(); + public TestMetastoreScheduledQueries(String name, AbstractMetaStoreService metaStore) throws Exception { metaStore.getConf().set("scheduled.queries.progress.timeout", "3"); this.metaStore = metaStore; @@ -329,13 +338,13 @@ Thread.sleep(1000); info = new ScheduledQueryProgressInfo( - pollResult.getExecutionId(), QueryState.ERRORED, "executor-query-id"); + pollResult.getExecutionId(), QueryState.FAILED, "executor-query-id"); // info.set client.scheduledQueryProgress(info); try (PersistenceManager pm = PersistenceManagerProvider.getPersistenceManager()) { MScheduledExecution q = pm.getObjectById(MScheduledExecution.class, pollResult.getExecutionId()); - assertEquals(QueryState.ERRORED, q.getState()); + assertEquals(QueryState.FAILED, q.getState()); assertEquals("executor-query-id", q.getExecutorQueryId()); assertNull(q.getLastUpdateTime()); assertTrue(q.getEndTime() <= getEpochSeconds()); @@ -411,6 +420,48 @@ } } + @Test + public void testDisabledMaintenance() throws MetaException, TException { + try { + MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, false); + ObjectStore objStore = new ObjectStore(); + objStore.setConf(metaStore.getConf()); + thrown.expect(MetaException.class); + thrown.expectMessage(Matchers.contains(ConfVars.SCHEDULED_QUERIES_ENABLED.getVarname())); + objStore.scheduledQueryMaintenance(new ScheduledQueryMaintenanceRequest()); + } finally { + MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, true); + } + } + + @Test + public void testDisabledPoll() throws MetaException, TException { + try { + MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, false); + ObjectStore objStore = new ObjectStore(); + objStore.setConf(metaStore.getConf()); + thrown.expect(MetaException.class); + thrown.expectMessage(Matchers.contains(ConfVars.SCHEDULED_QUERIES_ENABLED.getVarname())); + objStore.scheduledQueryPoll(new ScheduledQueryPollRequest()); + } finally { + MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, true); + } + } + + @Test //(expected = MetaException.class) + public void testDisabledProgress() throws MetaException, TException { + try { + MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, false); + ObjectStore objStore = new ObjectStore(); + objStore.setConf(metaStore.getConf()); + thrown.expect(MetaException.class); + thrown.expectMessage(Matchers.contains(ConfVars.SCHEDULED_QUERIES_ENABLED.getVarname())); + objStore.scheduledQueryProgress(new ScheduledQueryProgressInfo()); + } finally { + MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, true); + } + } + private int getEpochSeconds() { return (int) (System.currentTimeMillis() / 1000); }