Search in sources :

Example 51 with MILLISECONDS

use of java.util.concurrent.TimeUnit.MILLISECONDS in project presto by prestodb.

the class QueryPreprocessor method preprocessQueryInternal.

private static String preprocessQueryInternal(Optional<String> catalog, Optional<String> schema, String query, List<String> preprocessorCommand, Duration timeout) throws QueryPreprocessorException {
    // execute the process in a child thread so we can better handle interruption and timeouts
    AtomicReference<Process> processReference = new AtomicReference<>();
    Future<String> task = executeInNewThread("Query preprocessor", () -> {
        String result;
        int exitCode;
        Future<String> readStderr;
        try {
            ProcessBuilder processBuilder = new ProcessBuilder(preprocessorCommand);
            processBuilder.environment().put(ENV_PRESTO_CATALOG, catalog.orElse(""));
            processBuilder.environment().put(ENV_PRESTO_SCHEMA, schema.orElse(""));
            Process process = processBuilder.start();
            processReference.set(process);
            Future<?> writeOutput = null;
            try {
                // write query to process standard out
                writeOutput = executeInNewThread("Query preprocessor output", () -> {
                    try (OutputStream outputStream = process.getOutputStream()) {
                        outputStream.write(query.getBytes(UTF_8));
                    }
                    return null;
                });
                // read stderr
                readStderr = executeInNewThread("Query preprocessor read stderr", () -> {
                    StringBuilder builder = new StringBuilder();
                    try (InputStream inputStream = process.getErrorStream()) {
                        CharStreams.copy(new InputStreamReader(inputStream, UTF_8), builder);
                    } catch (IOException | RuntimeException ignored) {
                    }
                    return builder.toString();
                });
                // read response
                try (InputStream inputStream = process.getInputStream()) {
                    result = CharStreams.toString(new InputStreamReader(inputStream, UTF_8));
                }
                // verify output was written successfully
                try {
                    writeOutput.get();
                } catch (ExecutionException e) {
                    throw e.getCause();
                }
                // wait for process to finish
                exitCode = process.waitFor();
            } finally {
                process.destroyForcibly();
                if (writeOutput != null) {
                    writeOutput.cancel(true);
                }
            }
        } catch (QueryPreprocessorException e) {
            throw e;
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new QueryPreprocessorException("Interrupted while preprocessing query");
        } catch (Throwable e) {
            throw new QueryPreprocessorException("Error preprocessing query: " + e.getMessage(), e);
        }
        // check we got a valid exit code
        if (exitCode != 0) {
            Optional<String> errorMessage = tryGetFutureValue(readStderr, 100, MILLISECONDS).flatMap(value -> Optional.ofNullable(emptyToNull(value.trim())));
            throw new QueryPreprocessorException("Query preprocessor exited " + exitCode + errorMessage.map(message1 -> "\n===\n" + message1 + "\n===").orElse(""));
        }
        return result;
    });
    try {
        return task.get(timeout.toMillis(), MILLISECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new QueryPreprocessorException("Interrupted while preprocessing query");
    } catch (ExecutionException e) {
        Throwable cause = e.getCause();
        propagateIfPossible(cause, QueryPreprocessorException.class);
        throw new QueryPreprocessorException("Error preprocessing query: " + cause.getMessage(), cause);
    } catch (TimeoutException e) {
        throw new QueryPreprocessorException("Timed out waiting for query preprocessor after " + timeout);
    } finally {
        Process process = processReference.get();
        if (process != null) {
            process.destroyForcibly();
        }
        task.cancel(true);
    }
}
Also used : SignalHandler(sun.misc.SignalHandler) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) FutureTask(java.util.concurrent.FutureTask) TimeoutException(java.util.concurrent.TimeoutException) Callable(java.util.concurrent.Callable) AtomicReference(java.util.concurrent.atomic.AtomicReference) Duration(io.airlift.units.Duration) Strings(com.google.common.base.Strings) Future(java.util.concurrent.Future) Throwables.propagateIfPossible(com.google.common.base.Throwables.propagateIfPossible) ImmutableList(com.google.common.collect.ImmutableList) CharStreams(com.google.common.io.CharStreams) Signal(sun.misc.Signal) REAL_TERMINAL(com.facebook.presto.cli.ConsolePrinter.REAL_TERMINAL) OutputStream(java.io.OutputStream) UTF_8(java.nio.charset.StandardCharsets.UTF_8) IOException(java.io.IOException) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) InputStreamReader(java.io.InputStreamReader) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) MoreFutures.tryGetFutureValue(com.facebook.airlift.concurrent.MoreFutures.tryGetFutureValue) Strings.emptyToNull(com.google.common.base.Strings.emptyToNull) Optional(java.util.Optional) SECONDS(java.util.concurrent.TimeUnit.SECONDS) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) AtomicReference(java.util.concurrent.atomic.AtomicReference) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 52 with MILLISECONDS

use of java.util.concurrent.TimeUnit.MILLISECONDS in project presto by prestodb.

the class TestHiveRecoverableExecution method testRecoverableGroupedExecution.

private void testRecoverableGroupedExecution(DistributedQueryRunner queryRunner, int writerConcurrency, boolean optimizedPartitionUpdateSerializationEnabled, List<String> preQueries, @Language("SQL") String queryWithoutFailure, @Language("SQL") String queryWithFailure, int expectedUpdateCount, List<String> postQueries) throws Exception {
    waitUntilAllNodesAreHealthy(queryRunner, new Duration(10, SECONDS));
    Session recoverableSession = createRecoverableSession(writerConcurrency, optimizedPartitionUpdateSerializationEnabled);
    for (@Language("SQL") String postQuery : postQueries) {
        queryRunner.execute(recoverableSession, postQuery);
    }
    try {
        for (@Language("SQL") String preQuery : preQueries) {
            queryRunner.execute(recoverableSession, preQuery);
        }
        // test no failure case
        Stopwatch noRecoveryStopwatch = Stopwatch.createStarted();
        assertEquals(queryRunner.execute(recoverableSession, queryWithoutFailure).getUpdateCount(), OptionalLong.of(expectedUpdateCount));
        log.info("Query with no recovery took %sms", noRecoveryStopwatch.elapsed(MILLISECONDS));
        // cancel all queries and tasks to make sure we are dealing only with a single running query
        cancelAllQueries(queryRunner);
        cancelAllTasks(queryRunner);
        // test failure case
        Stopwatch recoveryStopwatch = Stopwatch.createStarted();
        ListenableFuture<MaterializedResult> result = executor.submit(() -> queryRunner.execute(recoverableSession, queryWithFailure));
        List<TestingPrestoServer> workers = queryRunner.getServers().stream().filter(server -> !server.isCoordinator()).collect(toList());
        shuffle(workers);
        TestingPrestoServer worker1 = workers.get(0);
        // kill worker1 right away, to make sure recoverable execution works in cases when the task hasn't been yet submitted
        worker1.stopResponding();
        // kill worker2 only after the task has been scheduled
        TestingPrestoServer worker2 = workers.get(1);
        sleep(1000);
        worker2.stopResponding();
        assertEquals(result.get(1000, SECONDS).getUpdateCount(), OptionalLong.of(expectedUpdateCount));
        log.info("Query with recovery took %sms", recoveryStopwatch.elapsed(MILLISECONDS));
    } finally {
        queryRunner.getServers().forEach(TestingPrestoServer::startResponding);
        cancelAllQueries(queryRunner);
        cancelAllTasks(queryRunner);
        for (@Language("SQL") String postQuery : postQueries) {
            queryRunner.execute(recoverableSession, postQuery);
        }
    }
}
Also used : Collections.shuffle(java.util.Collections.shuffle) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Duration(io.airlift.units.Duration) RECOVERABLE_GROUPED_EXECUTION(com.facebook.presto.SystemSessionProperties.RECOVERABLE_GROUPED_EXECUTION) Thread.sleep(java.lang.Thread.sleep) TASK_WRITER_COUNT(com.facebook.presto.SystemSessionProperties.TASK_WRITER_COUNT) EXCHANGE_MATERIALIZATION_STRATEGY(com.facebook.presto.SystemSessionProperties.EXCHANGE_MATERIALIZATION_STRATEGY) TASK_PARTITIONED_WRITER_COUNT(com.facebook.presto.SystemSessionProperties.TASK_PARTITIONED_WRITER_COUNT) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) String.format(java.lang.String.format) List(java.util.List) HASH_PARTITION_COUNT(com.facebook.presto.SystemSessionProperties.HASH_PARTITION_COUNT) CONCURRENT_LIFESPANS_PER_NODE(com.facebook.presto.SystemSessionProperties.CONCURRENT_LIFESPANS_PER_NODE) Optional(java.util.Optional) VIRTUAL_BUCKET_COUNT(com.facebook.presto.hive.HiveSessionProperties.VIRTUAL_BUCKET_COUNT) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) Logger(com.facebook.airlift.log.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DataProvider(org.testng.annotations.DataProvider) TPCH_BUCKETED_SCHEMA(com.facebook.presto.hive.HiveQueryRunner.TPCH_BUCKETED_SCHEMA) Stopwatch(com.google.common.base.Stopwatch) PARTITIONING_PROVIDER_CATALOG(com.facebook.presto.SystemSessionProperties.PARTITIONING_PROVIDER_CATALOG) ALL(com.facebook.presto.spi.security.SelectedRole.Type.ALL) ORDERS(io.airlift.tpch.TpchTable.ORDERS) Assert.assertEquals(org.testng.Assert.assertEquals) ROLE(com.facebook.presto.spi.security.SelectedRole.Type.ROLE) OptionalLong(java.util.OptionalLong) OPTIMIZED_PARTITION_UPDATE_SERIALIZATION_ENABLED(com.facebook.presto.hive.HiveSessionProperties.OPTIMIZED_PARTITION_UPDATE_SERIALIZATION_ENABLED) ImmutableList(com.google.common.collect.ImmutableList) Identity(com.facebook.presto.spi.security.Identity) GROUPED_EXECUTION(com.facebook.presto.SystemSessionProperties.GROUPED_EXECUTION) AfterClass(org.testng.annotations.AfterClass) SelectedRole(com.facebook.presto.spi.security.SelectedRole) HIVE_CATALOG(com.facebook.presto.hive.HiveQueryRunner.HIVE_CATALOG) Language(org.intellij.lang.annotations.Language) Session(com.facebook.presto.Session) MAX_STAGE_RETRIES(com.facebook.presto.SystemSessionProperties.MAX_STAGE_RETRIES) TestingSession.testSessionBuilder(com.facebook.presto.testing.TestingSession.testSessionBuilder) AllNodes(com.facebook.presto.metadata.AllNodes) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Collectors.toList(java.util.stream.Collectors.toList) Executors.newCachedThreadPool(java.util.concurrent.Executors.newCachedThreadPool) COLOCATED_JOIN(com.facebook.presto.SystemSessionProperties.COLOCATED_JOIN) REDISTRIBUTE_WRITES(com.facebook.presto.SystemSessionProperties.REDISTRIBUTE_WRITES) SECONDS(java.util.concurrent.TimeUnit.SECONDS) SCALE_WRITERS(com.facebook.presto.SystemSessionProperties.SCALE_WRITERS) Language(org.intellij.lang.annotations.Language) Stopwatch(com.google.common.base.Stopwatch) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Duration(io.airlift.units.Duration) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Session(com.facebook.presto.Session)

Example 53 with MILLISECONDS

use of java.util.concurrent.TimeUnit.MILLISECONDS in project presto by prestodb.

the class TestResourceManagerClusterStatusSender method setup.

@BeforeTest
public void setup() {
    resourceManagerClient = new TestingResourceManagerClient();
    InMemoryNodeManager nodeManager = new InMemoryNodeManager();
    nodeManager.addNode(CONNECTOR_ID, new InternalNode("identifier", URI.create("http://localhost:80/identifier"), OptionalInt.of(1), "1", false, true));
    sender = new ResourceManagerClusterStatusSender((addressSelectionContext, headers) -> resourceManagerClient, nodeManager, () -> NODE_STATUS, newSingleThreadScheduledExecutor(), new ResourceManagerConfig().setNodeHeartbeatInterval(new Duration(HEARTBEAT_INTERVAL, MILLISECONDS)).setQueryHeartbeatInterval(new Duration(HEARTBEAT_INTERVAL, MILLISECONDS)));
}
Also used : NodeStatus(com.facebook.presto.server.NodeStatus) ImmutableMap(com.google.common.collect.ImmutableMap) MockManagedQueryExecution(com.facebook.presto.execution.MockManagedQueryExecution) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) Test(org.testng.annotations.Test) NodeVersion(com.facebook.presto.client.NodeVersion) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) OptionalInt(java.util.OptionalInt) MemoryInfo(com.facebook.presto.memory.MemoryInfo) String.format(java.lang.String.format) Duration(io.airlift.units.Duration) AfterTest(org.testng.annotations.AfterTest) InternalNode(com.facebook.presto.metadata.InternalNode) DataSize(io.airlift.units.DataSize) BeforeTest(org.testng.annotations.BeforeTest) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) Assert.assertTrue(org.testng.Assert.assertTrue) URI(java.net.URI) ConnectorId(com.facebook.presto.spi.ConnectorId) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Duration(io.airlift.units.Duration) InternalNode(com.facebook.presto.metadata.InternalNode) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) BeforeTest(org.testng.annotations.BeforeTest)

Example 54 with MILLISECONDS

use of java.util.concurrent.TimeUnit.MILLISECONDS in project presto by prestodb.

the class StorageModule method createStripeMetadataSourceFactory.

@Singleton
@Provides
public StripeMetadataSourceFactory createStripeMetadataSourceFactory(OrcCacheConfig orcCacheConfig, MBeanExporter exporter) {
    StripeMetadataSource stripeMetadataSource = new StorageStripeMetadataSource();
    if (orcCacheConfig.isStripeMetadataCacheEnabled()) {
        Cache<StripeId, Slice> footerCache = CacheBuilder.newBuilder().maximumWeight(orcCacheConfig.getStripeFooterCacheSize().toBytes()).weigher((id, footer) -> ((Slice) footer).length()).expireAfterAccess(orcCacheConfig.getStripeFooterCacheTtlSinceLastAccess().toMillis(), TimeUnit.MILLISECONDS).recordStats().build();
        Cache<StripeStreamId, Slice> streamCache = CacheBuilder.newBuilder().maximumWeight(orcCacheConfig.getStripeStreamCacheSize().toBytes()).weigher((id, stream) -> ((Slice) stream).length()).expireAfterAccess(orcCacheConfig.getStripeStreamCacheTtlSinceLastAccess().toMillis(), TimeUnit.MILLISECONDS).recordStats().build();
        CacheStatsMBean footerCacheStatsMBean = new CacheStatsMBean(footerCache);
        CacheStatsMBean streamCacheStatsMBean = new CacheStatsMBean(streamCache);
        exporter.export(generatedNameOf(CacheStatsMBean.class, connectorId + "_StripeFooter"), footerCacheStatsMBean);
        exporter.export(generatedNameOf(CacheStatsMBean.class, connectorId + "_StripeStream"), streamCacheStatsMBean);
        Optional<Cache<StripeStreamId, List<RowGroupIndex>>> rowGroupIndexCache = Optional.empty();
        if (orcCacheConfig.isRowGroupIndexCacheEnabled()) {
            rowGroupIndexCache = Optional.of(CacheBuilder.newBuilder().maximumWeight(orcCacheConfig.getRowGroupIndexCacheSize().toBytes()).weigher((id, rowGroupIndices) -> toIntExact(((List<RowGroupIndex>) rowGroupIndices).stream().mapToLong(RowGroupIndex::getRetainedSizeInBytes).sum())).expireAfterAccess(orcCacheConfig.getStripeStreamCacheTtlSinceLastAccess().toMillis(), MILLISECONDS).recordStats().build());
            CacheStatsMBean rowGroupIndexCacheStatsMBean = new CacheStatsMBean(rowGroupIndexCache.get());
            exporter.export(generatedNameOf(CacheStatsMBean.class, connectorId + "_StripeStreamRowGroupIndex"), rowGroupIndexCacheStatsMBean);
        }
        stripeMetadataSource = new CachingStripeMetadataSource(stripeMetadataSource, footerCache, streamCache, rowGroupIndexCache);
    }
    StripeMetadataSourceFactory factory = StripeMetadataSourceFactory.of(stripeMetadataSource);
    if (orcCacheConfig.isDwrfStripeCacheEnabled()) {
        factory = new DwrfAwareStripeMetadataSourceFactory(factory);
    }
    return factory;
}
Also used : StripeMetadataSource(com.facebook.presto.orc.StripeMetadataSource) CachingStripeMetadataSource(com.facebook.presto.orc.CachingStripeMetadataSource) StorageStripeMetadataSource(com.facebook.presto.orc.StorageStripeMetadataSource) Module(com.google.inject.Module) CacheStatsMBean(com.facebook.presto.hive.CacheStatsMBean) StripeMetadataSource(com.facebook.presto.orc.StripeMetadataSource) ShardOrganizer(com.facebook.presto.raptor.storage.organization.ShardOrganizer) StripeId(com.facebook.presto.orc.StripeReader.StripeId) OrcCacheConfig(com.facebook.presto.orc.cache.OrcCacheConfig) RowGroupIndex(com.facebook.presto.orc.metadata.RowGroupIndex) ExportBinder.newExporter(org.weakref.jmx.guice.ExportBinder.newExporter) CachingOrcFileTailSource(com.facebook.presto.orc.cache.CachingOrcFileTailSource) ShardManager(com.facebook.presto.raptor.metadata.ShardManager) DatabaseShardRecorder(com.facebook.presto.raptor.metadata.DatabaseShardRecorder) StripeMetadataSourceFactory(com.facebook.presto.orc.StripeMetadataSourceFactory) StripeStreamId(com.facebook.presto.orc.StripeReader.StripeStreamId) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Ticker(com.google.common.base.Ticker) DwrfAwareStripeMetadataSourceFactory(com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory) List(java.util.List) CachingStripeMetadataSource(com.facebook.presto.orc.CachingStripeMetadataSource) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) BackupManager(com.facebook.presto.raptor.backup.BackupManager) AssignmentLimiter(com.facebook.presto.raptor.metadata.AssignmentLimiter) ShardCleanerConfig(com.facebook.presto.raptor.metadata.ShardCleanerConfig) Slice(io.airlift.slice.Slice) MetadataConfig(com.facebook.presto.raptor.metadata.MetadataConfig) Singleton(javax.inject.Singleton) ShardCompactor(com.facebook.presto.raptor.storage.organization.ShardCompactor) Binder(com.google.inject.Binder) OrcFileTail(com.facebook.presto.orc.metadata.OrcFileTail) Objects.requireNonNull(java.util.Objects.requireNonNull) ShardCompactionManager(com.facebook.presto.raptor.storage.organization.ShardCompactionManager) Math.toIntExact(java.lang.Math.toIntExact) OrcFileTailSource(com.facebook.presto.orc.cache.OrcFileTailSource) OrcDataSourceId(com.facebook.presto.orc.OrcDataSourceId) ObjectNames.generatedNameOf(org.weakref.jmx.ObjectNames.generatedNameOf) StorageStripeMetadataSource(com.facebook.presto.orc.StorageStripeMetadataSource) ShardCleaner(com.facebook.presto.raptor.metadata.ShardCleaner) OrganizationJobFactory(com.facebook.presto.raptor.storage.organization.OrganizationJobFactory) Scopes(com.google.inject.Scopes) ShardOrganizationManager(com.facebook.presto.raptor.storage.organization.ShardOrganizationManager) ShardRecorder(com.facebook.presto.raptor.metadata.ShardRecorder) TimeUnit(java.util.concurrent.TimeUnit) StorageOrcFileTailSource(com.facebook.presto.orc.cache.StorageOrcFileTailSource) Provides(com.google.inject.Provides) DatabaseShardManager(com.facebook.presto.raptor.metadata.DatabaseShardManager) ConfigBinder.configBinder(com.facebook.airlift.configuration.ConfigBinder.configBinder) JobFactory(com.facebook.presto.raptor.storage.organization.JobFactory) TemporalFunction(com.facebook.presto.raptor.storage.organization.TemporalFunction) Cache(com.google.common.cache.Cache) MBeanExporter(org.weakref.jmx.MBeanExporter) StripeStreamId(com.facebook.presto.orc.StripeReader.StripeStreamId) StripeMetadataSourceFactory(com.facebook.presto.orc.StripeMetadataSourceFactory) DwrfAwareStripeMetadataSourceFactory(com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory) CachingStripeMetadataSource(com.facebook.presto.orc.CachingStripeMetadataSource) StripeId(com.facebook.presto.orc.StripeReader.StripeId) RowGroupIndex(com.facebook.presto.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) DwrfAwareStripeMetadataSourceFactory(com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory) CacheStatsMBean(com.facebook.presto.hive.CacheStatsMBean) StorageStripeMetadataSource(com.facebook.presto.orc.StorageStripeMetadataSource) Cache(com.google.common.cache.Cache) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 55 with MILLISECONDS

use of java.util.concurrent.TimeUnit.MILLISECONDS in project mule by mulesoft.

the class ServerNotificationsTestCase method testCustomNotifications.

@Test
public void testCustomNotifications() throws Exception {
    final CountDownLatch latch = new CountDownLatch(2);
    getNotificationListenerRegistry().registerListener((DummyNotificationListener) notification -> {
        if (new IntegerAction(EVENT_RECEIVED).equals(notification.getAction())) {
            customNotificationCount.incrementAndGet();
            assertEquals("hello", ((EventObject) notification).getSource());
            latch.countDown();
        }
    });
    getNotificationDispatcher().dispatch(new DummyNotification("hello", EVENT_RECEIVED));
    getNotificationDispatcher().dispatch(new DummyNotification("hello", EVENT_RECEIVED));
    // Wait for the notifcation event to be fired as they are queued
    latch.await(2000, MILLISECONDS);
    assertEquals(2, customNotificationCount.get());
}
Also used : EVENT_RECEIVED(org.mule.runtime.core.api.context.notification.ServerNotificationsTestCase.DummyNotification.EVENT_RECEIVED) CustomNotificationListener(org.mule.runtime.api.notification.CustomNotificationListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Callable(java.util.concurrent.Callable) EventObject(java.util.EventObject) Mockito.doThrow(org.mockito.Mockito.doThrow) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Notification(org.mule.runtime.api.notification.Notification) MuleContext(org.mule.runtime.core.api.MuleContext) Scheduler(org.mule.runtime.api.scheduler.Scheduler) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CONTEXT_STOPPED(org.mule.runtime.core.api.context.notification.MuleContextNotification.CONTEXT_STOPPED) RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Mockito.when(org.mockito.Mockito.when) CustomNotification(org.mule.runtime.api.notification.CustomNotification) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) NotificationListenerRegistry(org.mule.runtime.api.notification.NotificationListenerRegistry) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito.never(org.mockito.Mockito.never) IntegerAction(org.mule.runtime.api.notification.IntegerAction) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) Assert.assertFalse(org.junit.Assert.assertFalse) NotificationDispatcher(org.mule.runtime.api.notification.NotificationDispatcher) NotificationListener(org.mule.runtime.api.notification.NotificationListener) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) IntegerAction(org.mule.runtime.api.notification.IntegerAction) CountDownLatch(java.util.concurrent.CountDownLatch) EventObject(java.util.EventObject) Test(org.junit.Test)

Aggregations

MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)56 List (java.util.List)35 Test (org.junit.Test)27 CountDownLatch (java.util.concurrent.CountDownLatch)22 ArrayList (java.util.ArrayList)20 Arrays (java.util.Arrays)15 Optional (java.util.Optional)15 SECONDS (java.util.concurrent.TimeUnit.SECONDS)15 Future (java.util.concurrent.Future)14 Before (org.junit.Before)13 Duration (io.airlift.units.Duration)11 Map (java.util.Map)11 ExecutorService (java.util.concurrent.ExecutorService)8 Context (android.content.Context)7 Math.toIntExact (java.lang.Math.toIntExact)7 TimeUnit (java.util.concurrent.TimeUnit)7 Rule (org.junit.Rule)7 Threads.daemonThreadsNamed (com.facebook.airlift.concurrent.Threads.daemonThreadsNamed)6 Cache (com.google.common.cache.Cache)6 CacheBuilder (com.google.common.cache.CacheBuilder)6