/** * Resume a paused query */ public void resume() { queryContext.getExecutionControls().unpauseAll(); }
/** * Method that injects an IOException with a site description of THROWS_IOEXCEPTION. * * @throws IOException */ public void throwsIOException() throws IOException { // ... code ... // simulated IOException injector.injectChecked(context.getExecutionControls(), THROWS_IOEXCEPTION, IOException.class); // ... code ... } }
/** * Method that injects an unchecked exception with the given site description. * * @param desc the injection site description */ public void descPassthroughMethod(final String desc) { // ... code ... // simulated unchecked exception injector.injectUnchecked(context.getExecutionControls(), desc); // ... code ... }
/** * Method that pauses. * * @return how long the method paused in milliseconds */ public long pauses() { // ... code ... latch.countDown(); final long startTime = System.currentTimeMillis(); // simulated pause injector.injectPause(context.getExecutionControls(), PAUSES, logger); final long endTime = System.currentTimeMillis(); // ... code ... return (endTime - startTime); } }
@Override public void run() { latch.awaitUninterruptibly(); try { Thread.sleep(millis); } catch (final InterruptedException ex) { this.ex.value = ex; } context.getExecutionControls().unpauseAll(); } }
/** * Method that initializes and waits for "count" number of count down (from those many threads) */ public long initAndWait() throws InterruptedException { // ... code ... injector.getLatch(context.getExecutionControls(), LATCH_NAME).initialize(count); // ... code ... latch.countDown(); // trigger threads spawn final long startTime = System.currentTimeMillis(); // simulated wait for "count" threads to count down on the same latch injector.getLatch(context.getExecutionControls(), LATCH_NAME).await(); final long endTime = System.currentTimeMillis(); // ... code ... return (endTime - startTime); }
public void countDown() { // ... code ... injector.getLatch(context.getExecutionControls(), LATCH_NAME).countDown(); // ... code ... } }
protected QueryContext mockQueryContext(SabotContext dbContext) throws Exception { final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(dbContext.getOptionManager()).build(); final SessionOptionManager sessionOptions = (SessionOptionManager) userSession.getOptions(); final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions); final ExecutionControls executionControls = new ExecutionControls(queryOptions, NodeEndpoint.getDefaultInstance()); final OperatorTable table = new OperatorTable(FUNCTIONS()); final LogicalPlanPersistence lp = dbContext.getLpPersistence(); final CatalogService registry = dbContext.getCatalogService(); final QueryContext context = Mockito.mock(QueryContext.class); when(context.getSession()).thenReturn(userSession); when(context.getLpPersistence()).thenReturn(lp); when(context.getCatalogService()).thenReturn(registry); when(context.getFunctionRegistry()).thenReturn(FUNCTIONS()); when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build()); when(context.getCurrentEndpoint()).thenReturn(NodeEndpoint.getDefaultInstance()); when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(NodeEndpoint.getDefaultInstance())); when(context.getPlannerSettings()).thenReturn(new PlannerSettings(dbContext.getConfig(), queryOptions, dbContext.getClusterResourceInformation())); when(context.getOptions()).thenReturn(queryOptions); when(context.getConfig()).thenReturn(DEFAULT_SABOT_CONFIG); when(context.getOperatorTable()).thenReturn(table); when(context.getAllocator()).thenReturn(allocator); when(context.getExecutionControls()).thenReturn(executionControls); when(context.getMaterializationProvider()).thenReturn(Mockito.mock(MaterializationDescriptorProvider.class)); return context; }
injector.injectPause(queryContext.getExecutionControls(), "foreman-cleanup", logger);
injector.injectChecked(queryContext.getExecutionControls(), "run-try-beginning", ForemanException.class); injector.injectChecked(queryContext.getExecutionControls(), "run-try-end", ForemanException.class); } catch (ResourceUnavailableException e) {
public CommandRunner<?> toCommand() throws ForemanException { injector.injectChecked(context.getExecutionControls(), "run-try-beginning", ForemanException.class); switch(request.getType()){ case GET_CATALOGS:
context.getScanResult()); injector.injectChecked(context.getExecutionControls(), "sql-parsing", ForemanSetupException.class); final DremioCatalogReader reader = parser.getCatalogReader(); final Catalog catalog = context.getCatalog();