Example usage for java.util.concurrent Executors newSingleThreadExecutor

List of usage examples for java.util.concurrent Executors newSingleThreadExecutor

Introduction

In this page you can find the example usage for java.util.concurrent Executors newSingleThreadExecutor.

Prototype

public static ExecutorService newSingleThreadExecutor() 

Source Link

Document

Creates an Executor that uses a single worker thread operating off an unbounded queue.

Usage

From source file:io.v.syncslides.lib.DeckImporter.java

public DeckImporter(ContentResolver contentResolver, DB db) {
    mExecutorService = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
    mContentResolver = contentResolver;
    mDB = db;
}

From source file:com.streamsets.pipeline.stage.destination.s3.TestAmazonS3Target.java

@BeforeClass
public static void setUpClass() throws IOException, InterruptedException {
    File dir = new File(new File("target", UUID.randomUUID().toString()), "fakes3_root").getAbsoluteFile();
    Assert.assertTrue(dir.mkdirs());/*from  w  w  w .j  ava  2  s . c o  m*/
    fakeS3Root = dir.getAbsolutePath();
    port = TestUtil.getFreePort();
    fakeS3 = new FakeS3(fakeS3Root, port);
    Assume.assumeTrue("Please install fakes3 in your system", fakeS3.fakes3Installed());
    //Start the fakes3 server
    executorService = Executors.newSingleThreadExecutor();
    executorService.submit(fakeS3);

    BasicAWSCredentials credentials = new BasicAWSCredentials("foo", "bar");
    s3client = new AmazonS3Client(credentials);
    s3client.setEndpoint("http://localhost:" + port);
    s3client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));

    TestUtil.createBucket(s3client, BUCKET_NAME);
}

From source file:ws.salient.aws.RecordProcessor.java

@Override
public void initialize(InitializationInput input) {
    AmazonClientProvider provider = new AmazonClientProvider();
    sessions = new Sessions(new AmazonS3Repository(provider.getAmazonS3()),
            new DynamoDBProfiles(provider.getDynamoDB(), provider.getAWSKMS(), json),
            new DynamoDBStore(provider.getDynamoDB(), provider.getAWSKMS(), json,
                    Executors.newSingleThreadExecutor()),
            Guice.createInjector(provider), Executors.newSingleThreadExecutor(), ForkJoinPool.commonPool());
}

From source file:io.joynr.messaging.bounceproxy.ControlledBounceProxyModule.java

@Provides
@Singleton
ExecutorService getExecutorService() {
    return Executors.newSingleThreadExecutor();
}

From source file:com.unicodecollective.amsterdam.TokenBucket.java

public void startFilling(FillRate fillRate) {
    checkNotNull(fillRate);//from w ww .j  a v  a 2 s.co  m
    checkState(bucketFillerExecutor == null, "Bucket filler has already been started for this token bucket.");
    bucketFillerExecutor = Executors.newSingleThreadExecutor();
    bucketFillerExecutor.execute(new BucketFiller(fillRate));
    filling = true;
}

From source file:com.clxcommunications.xms.PagedFetcherTest.java

private static PagedFetcher<Integer> mockedFetcher(final List<List<Integer>> pages) {
    final ExecutorService executor = Executors.newSingleThreadExecutor();

    return new PagedFetcher<Integer>() {

        @Override//from w  w w  .  j a v a  2 s  .  c  o  m
        Future<Page<Integer>> fetchAsync(final int page, FutureCallback<Page<Integer>> callback) {
            return executor.submit(mockedFetchCallable(pages, page));
        }

    };
}

From source file:com.examples.cloud.speech.AsyncRecognizeClient.java

public static ManagedChannel createChannel(String host, int port) throws IOException {
    GoogleCredentials creds = GoogleCredentials.getApplicationDefault();
    creds = creds.createScoped(OAUTH2_SCOPES);
    ManagedChannel channel = NettyChannelBuilder.forAddress(host, port).negotiationType(NegotiationType.TLS)
            .intercept(new ClientAuthInterceptor(creds, Executors.newSingleThreadExecutor())).build();

    return channel;
}

From source file:jp.co.brilliantservice.android.ric.command.SocketController.java

public SocketController(ProjectFile project, Activity context, String server) {
    super(project, null);
    this.context = context;
    this.exec = Executors.newSingleThreadExecutor();
    this.out = adapter;
    this.server = server;
}

From source file:com.mirth.connect.connectors.jdbc.DatabaseDispatcherTests.java

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    connection = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
    connection.setAutoCommit(true);// www .j a v  a 2  s.com

    // start a basic server
    Executors.newSingleThreadExecutor().execute(new Runnable() {
        @Override
        public void run() {
            server.run();
        }
    });

    while (ConfigurationController.getInstance().isEngineStarting()) {
        Thread.sleep(100);
    }
}

From source file:eu.scidipes.toolkits.pawebapp.preservation.PreservationJobImpl.java

/**
 * Creates a new preservation job and starts it in a single threaded {@link ExecutorService}
 * /* w ww. j ava  2 s. c o  m*/
 * @param formsBundle
 *            the formsBundle to preserve
 * @param registry
 *            the registry to preserve to
 * @param datasetRepo
 * @return the new job instance
 * @throws NullPointerException
 *             if any of the parameters are null
 */
public static PreservationJobImpl newInstance(final FormsBundle formsBundle, final Registry registry,
        final DataSetRepository datasetRepo) {

    notNull(formsBundle, "The formsBundle must not be null");
    notNull(registry, "The registry must not be null");
    notNull(datasetRepo, "The datasetRepo must not be null");

    final PreservationJobImpl job = new PreservationJobImpl(formsBundle, registry, datasetRepo);
    job.submitJobItems();
    Executors.newSingleThreadExecutor().execute(job);
    return job;
}