Package com.asakusafw.runtime.directio

Examples of com.asakusafw.runtime.directio.DirectDataSourceRepository


                new Path(new File(temporary, "t1").toURI()));
        HadoopDataSourceProfile profile2 = new HadoopDataSourceProfile(
                conf, "t2", "c2",
                new Path(production2.toURI()),
                new Path(new File(temporary, "t2").toURI()));
        repo = new DirectDataSourceRepository(Arrays.asList(
                new MockProvider(profile1),
                new MockProvider(profile2)));

        editor = new DirectIoTransactionEditor(repo);
        editor.setConf(conf);
View Full Code Here


        LOG.debug("Creating test helper for Direct I/O (basePath={})", rootPath);
        this.variables = new VariableTable(RedefineStrategy.ERROR);
        variables.defineVariables(context.getArguments());
        String resolvedRootPath = resolve(rootPath);
        LOG.debug("Resolved base path: {} -> {}", rootPath, resolvedRootPath);
        DirectDataSourceRepository repo = getRepository();
        try {
            this.id = repo.getRelatedId(resolvedRootPath);
            this.dataSource = repo.getRelatedDataSource(resolvedRootPath);
        } catch (IOException e) {
            throw new IOException(MessageFormat.format(
                    "Failed to initialize Direct I/O for \"{0}\", please check configuration ({1})",
                    resolvedRootPath,
                    findExtraConfiguration()), e);
        } catch (InterruptedException e) {
            throw (IOException) new InterruptedIOException("interrupted").initCause(e);
        }
        this.fullPath = resolvedRootPath;
        this.containerPath = repo.getContainerPath(resolvedRootPath);
        this.basePath = repo.getComponentPath(resolvedRootPath);
        LOG.debug("Direct I/O Mapping: {} -> id={}", resolvedRootPath, id);
    }
View Full Code Here

        LOG.debug("Direct I/O Mapping: {} -> id={}", resolvedRootPath, id);
    }

    private synchronized DirectDataSourceRepository getRepository() {
        assert context != null;
        DirectDataSourceRepository cached = REPOSITORY_CACHE.get(context);
        if (cached != null) {
            return cached;
        }
        DirectDataSourceRepository repo = createRepository();
        REPOSITORY_CACHE.put(context, repo);
        return repo;
    }
View Full Code Here

        assert profiles != null;
        List<DirectDataSourceProvider> providers = new ArrayList<DirectDataSourceProvider>();
        for (DirectDataSourceProfile profile : profiles) {
            providers.add(createProvider(conf, profile));
        }
        return new DirectDataSourceRepository(providers);
    }
View Full Code Here

                log.debug(MessageFormat.format(
                        "Start setup directly output Mapper {0}@{1}",
                        getClass().getName(),
                        context.getTaskAttemptID()));
            }
            DirectDataSourceRepository repository = HadoopDataSourceUtil.loadRepository(context.getConfiguration());
            String arguments = context.getConfiguration().get(StageConstants.PROP_ASAKUSA_BATCH_ARGS, "");
            VariableTable variables = new VariableTable(VariableTable.RedefineStrategy.IGNORE);
            variables.defineVariables(arguments);

            String path = variables.parse(rawBasePath, false);
            String id = repository.getRelatedId(path);
            OutputAttemptContext outputContext = HadoopDataSourceUtil.createContext(context, id);
            DataFormat<? super T> format = ReflectionUtils.newInstance(dataFormatClass, context.getConfiguration());
            DirectDataSource datasource = repository.getRelatedDataSource(path);
            String basePath = repository.getComponentPath(path);
            String unresolvedResourcePath = rawResourcePath.replaceAll(
                    Pattern.quote("*"),
                    String.format("%04d", context.getTaskAttemptID().getTaskID().getId()));
            String resourcePath = variables.parse(unresolvedResourcePath);
            DataDefinition<? super T> definition = SimpleDataDefinition.newInstance(dataType, format);
View Full Code Here

                new Path(new File(temporary, "t1").toURI()));
        HadoopDataSourceProfile profile2 = new HadoopDataSourceProfile(
                conf, "t2", "c2",
                new Path(production2.toURI()),
                new Path(new File(temporary, "t2").toURI()));
        repo = new DirectDataSourceRepository(Arrays.asList(
                new MockProvider(profile1),
                new MockProvider(profile2)));

        testee = new DirectIoTransactionEditor(repo);
        testee.setConf(conf);
View Full Code Here

        if (LOG.isInfoEnabled()) {
            LOG.info(MessageFormat.format(
                    "Start computing splits for Direct I/O: input={0}",
                    inputList.size()));
        }
        DirectDataSourceRepository repo = getDataSourceRepository(context);
        List<InputSplit> results = new ArrayList<InputSplit>();
        Map<DirectInputGroup, List<InputPath>> patternGroups = extractInputList(context, repo, inputList);
        long totalSize = 0;
        for (Map.Entry<DirectInputGroup, List<InputPath>> entry : patternGroups.entrySet()) {
            DirectInputGroup group = entry.getKey();
            List<InputPath> paths = entry.getValue();
            DirectDataSource dataSource = repo.getRelatedDataSource(group.containerPath);
            DataFormat<?> format = ReflectionUtils.newInstance(group.formatClass, context.getConfiguration());
            DataDefinition<?> definition = SimpleDataDefinition.newInstance(group.dataType, format);
            for (InputPath path : paths) {
                List<DirectInputFragment> fragments = getFragments(repo, group, path, definition, dataSource);
                for (DirectInputFragment fragment : fragments) {
View Full Code Here

        assert context != null;
        assert containerPath != null;
        assert definition != null;
        assert counter != null;
        assert fragment != null;
        DirectDataSourceRepository repo = getDataSourceRepository(context);
        DirectDataSource ds = repo.getRelatedDataSource(containerPath);
        return ds.openInput(definition, fragment, counter);
    }
View Full Code Here

        return HadoopDataSourceUtil.loadRepository(context.getConfiguration());
    }

    @Override
    public void checkOutputSpecs(JobContext context) throws IOException, InterruptedException {
        DirectDataSourceRepository repo = getDataSourceRepository(context);
        List<OutputSpec> specs = getSpecs(context);
        for (OutputSpec spec : specs) {
            try {
                repo.getContainerPath(spec.basePath);
            } catch (IOException e) {
                throw new IOException(MessageFormat.format(
                        "There are no corresponded data sources for the base path: {0}",
                        spec.basePath), e);
            }
View Full Code Here

        }
    }

    private OutputCommitter createOutputCommitter(JobContext context) throws IOException {
        assert context != null;
        DirectDataSourceRepository repository = getDataSourceRepository(context);
        List<OutputSpec> specs = getSpecs(context);
        if (LOG.isDebugEnabled()) {
            LOG.debug(MessageFormat.format(
                    "Creating output commiter: {0}",
                    specs));
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.directio.DirectDataSourceRepository

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.