Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService.submit()


                                   fileName,
                                   consistencyFix,
                                   consistencyFixWorkers,
                                   badKeyQOut);
        }
        badKeyReaderService.submit(bkr);

        // Wait for file to be processed.
        try {
            allBadKeysReadLatch.await();
View Full Code Here


        // Set up bad key writer
        BlockingQueue<BadKeyStatus> bq = new ArrayBlockingQueue<BadKeyStatus>(5);
        ExecutorService badKeyWriterService = Executors.newSingleThreadExecutor();

        BadKeyWriter badKeyWriter = new BadKeyWriter(fileName, bq);
        badKeyWriterService.submit(badKeyWriter);

        // Enqueue stuff for bad key writer to write
        try {
            for(int i = 0; i < 100; ++i) {
                BadKey badKey = new BadKey(Integer.toHexString(i), Integer.toHexString(i) + "\n");
View Full Code Here

                                                                                                    .setSocketTimeout(timeoutSecs,
                                                                                                                      TimeUnit.SECONDS)
                                                                                                    .setMaxThreads(numThreads)
                                                                                                    .setSelectors(numSelectors));
            for(int i = 0; i < numThreads; i++) {
                executor.submit(new Runnable() {

                    public void run() {
                        for(int j = 0; j < count; j++) {
                            try {
                                String clusterXml = factory.bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
View Full Code Here

        final AtomicBoolean isRunning = new AtomicBoolean(true);
        ExecutorService threadPool = Executors.newFixedThreadPool(ec2FailureDetectorTestConfig.testThreads + 1);

        // 1. Create a bunch of threads that just hit the stores repeatedly.
        for(int i = 0; i < ec2FailureDetectorTestConfig.testThreads; i++) {
            threadPool.submit(new Runnable() {

                public void run() {
                    while(isRunning.get())
                        test(store, 100);
                }
View Full Code Here

            });
        }

        // 2. Create a thread that randomly brings a single node offline and
        // then up again, waiting some period of time in between.
        threadPool.submit(new Runnable() {

            public void run() {
                try {
                    Random random = new Random();
View Full Code Here

            List<Future<Object>> results = new ArrayList<Future<Object>>(increment);
            long startTime = System.currentTimeMillis();
            final int fi = i;
            for(int j = 0; j < increment; j++) {
                final int fj = j;
                results.add(service.submit(new Callable<Object>() {

                    public Object call() throws Exception {
                        upsert(conn,
                               Integer.toString(fi * increment + fj),
                               Integer.toString(fi * increment + fj));
View Full Code Here

            System.out.println("write: " + (writeTimes[i] / (double) increment));
            results.clear();

            startTime = System.currentTimeMillis();
            for(int j = 0; j < increment; j++) {
                results.add(service.submit(new Callable<Object>() {

                    public Object call() throws Exception {
                        return select(conn, Integer.toString(rand.nextInt((fi + 1) * increment)));
                    }
                }));
View Full Code Here

        ExecutorService runner = Executors.newFixedThreadPool(numClients);
        long start = System.nanoTime();

        try {
            for(int i = 0; i < numClients; i++) {
                runner.submit(new Runnable() {

                    public void run() {

                        for(int i = 0; i < numKeys; i++) {
                            ByteArray key = new ByteArray(("test-key-" + i).getBytes());
View Full Code Here

        final byte[] keyBytes = "foo".getBytes();
        final byte[] valueBytes = "bar".getBytes();
        store.put(new ByteArray(keyBytes), new Versioned<byte[]>(valueBytes), null);

        for(int i = 0; i < 10; i++) {
            executor.submit(new Runnable() {

                public void run() {
                    try {
                        for(int j = 0; j < 1000 && !returnedEmpty.get(); j++) {
                            List<Versioned<byte[]>> vals = store.get(new ByteArray(keyBytes), null);
View Full Code Here

        final ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(NUMBER_PARALLEL_THREADS);
        try {
            final Collection<Future<Integer>> futures = new ArrayList<Future<Integer>>();

            for (int index = 1; index <= NUMBER_OF_REQUESTS; index++) {
                futures.add(newFixedThreadPool.submit(new SpanThread()));
            }

            for (final Future<Integer> future : futures) {
                assertEquals(Integer.valueOf(2), future.get());
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.