Package com.asakusafw.runtime.util.cache

Examples of com.asakusafw.runtime.util.cache.FileCacheRepository


            Path repositoryPath = computeRepositoryPath();
            File temporary = computeTemporaryDirectory();
            int threads = Math.max(configuration.getInt(KEY_MAX_THREADS, DEFAULT_MAX_THREADS), MINIMUM_MAX_THREADS);
            int retryCount = configuration.getInt(KEY_CACHE_RETRY_COUNT, DEFAULT_CACHE_RETRY_COUNT);
            long retryInterval = configuration.getLong(KEY_CACHE_RETRY_INTERVAL, DEFAULT_CACHE_RETRY_INTERVAL);
            FileCacheRepository unit = new HadoopFileCacheRepository(
                    configuration,
                    repositoryPath,
                    new LocalFileLockProvider<Path>(new File(temporary, PATH_LOCK_DIRECTORY)),
                    new ConstantRetryStrategy(retryCount, retryInterval));
            ExecutorService executor = Executors.newFixedThreadPool(threads, DAEMON_THREAD_FACTORY);
View Full Code Here


        final Path path = path(source);
        File cacheRepo = folder.newFolder();
        Configuration configuration = new ConfigurationProvider().newInstance();
        LockProvider<Path> locks = new LocalFileLockProvider<Path>(folder.newFolder());
        RetryStrategy retrier = new ConstantRetryStrategy(30, 100, 200);
        final FileCacheRepository cache = new HadoopFileCacheRepository(configuration, path(cacheRepo), locks, retrier);

        List<Future<Path>> futures = new ArrayList<Future<Path>>();
        int count = 10;
        final CountDownLatch latch = new CountDownLatch(count);
        ExecutorService executor = Executors.newFixedThreadPool(count);
        try {
            for (int i = 0; i < count; i++) {
                final String label = String.format("thread-%d", i);
                futures.add(executor.submit(new Callable<Path>() {
                    @Override
                    public Path call() throws Exception {
                        LOG.info("Wait: resolve @" + label);
                        latch.countDown();
                        if (latch.await(5, TimeUnit.SECONDS) == false) {
                            throw new TimeoutException();
                        }
                        LOG.info("Start: resolve @" + label);
                        Path result = cache.resolve(path);

                        LOG.info("Finish: resolve @" + label);
                        return result;
                    }
                }));
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.util.cache.FileCacheRepository

Copyright © 2018 www.massapicom. 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.