Package com.asakusafw.vocabulary.bulkloader

Examples of com.asakusafw.vocabulary.bulkloader.BulkLoadImporterDescription


    }

    private Location getImporterDestination(InputDescription input) {
        assert input != null;
        if (isCacheEnabled(input)) {
            BulkLoadImporterDescription desc = extract(input);
            return computeCacheDirectory(desc.calculateCacheId(), desc.getTargetName(), desc.getTableName());
        } else {
            String name = normalize(input.getName());
            return getEnvironment()
                .getPrologueLocation(MODULE_NAME)
                .append(name);
View Full Code Here


        return script;
    }

    private ImportTable convert(InputDescription input) {
        assert input != null;
        BulkLoadImporterDescription desc = extract(input);
        LockType lockType;
        LockedOperation lockedOperation;
        switch (desc.getLockType()) {
        case CHECK:
            lockType = LockType.UNLOCKED;
            lockedOperation = LockedOperation.ERROR;
            break;
        case ROW:
            lockType = LockType.ROW;
            lockedOperation = LockedOperation.ERROR;
            break;
        case ROW_OR_SKIP:
            lockType = LockType.ROW;
            lockedOperation = LockedOperation.SKIP;
            break;
        case TABLE:
            lockType = LockType.TABLE;
            lockedOperation = LockedOperation.ERROR;
            break;
        case UNUSED:
            lockType = LockType.UNLOCKED;
            lockedOperation = LockedOperation.FORCE;
            break;
        default:
            throw new AssertionError(desc.getLockType());
        }
        return new ImportTable(
                desc.getModelType(),
                desc.getTableName(),
                desc.getColumnNames(),
                desc.getWhere(),
                desc.isCacheEnabled() ? desc.calculateCacheId() : null,
                lockType,
                lockedOperation,
                getImporterDestination(input));
    }
View Full Code Here

    public ExternalIoCommandProvider createCommandProvider(IoContext context) {
        String primary = null;
        Map<String, IoContextBuilder> targets = new TreeMap<String, IoContextBuilder>();
        Map<String, IoContextBuilder> caches = new TreeMap<String, IoContextBuilder>();
        for (Input input : context.getInputs()) {
            BulkLoadImporterDescription desc = extract(input.getDescription());
            String target = desc.getTargetName();
            if (desc.getMode() == Mode.PRIMARY) {
                assert primary == null || primary.equals(target);
                primary = target;
            }
            add(targets, target, input);
            if (isCacheEnabled(input.getDescription())) {
                add(caches, target, input);
            }
        }
        for (Output output : context.getOutputs()) {
            BulkLoadExporterDescription desc = extract(output.getDescription());
            String target = desc.getTargetName();
            assert primary == null || primary.equals(target);
            primary = target;
            add(targets, target, output);
        }
        return new CommandProvider(
View Full Code Here

    private boolean checkImports(List<InputDescription> inputs) {
        assert inputs != null;
        boolean valid = true;
        for (InputDescription input : inputs) {
            BulkLoadImporterDescription desc = extract(input);
            boolean cacheEnabled = desc.isCacheEnabled();
            if (cacheEnabled) {
                if (ThunderGateCacheSupport.class.isAssignableFrom(desc.getModelType()) == false) {
                    getEnvironment().error(
                            "\"{0}\"のデータモデル型はキャッシュをサポートしていません: {1}",
                            desc.getClass().getName(),
                            desc.getModelType().getName());
                    valid = false;
                }
                if (desc.getWhere() != null && desc.getWhere().trim().isEmpty() == false) {
                    getEnvironment().error(
                            "\"{0}\"は検索条件を指定しているためキャッシュを利用できません: {1}",
                            desc.getClass().getName(),
                            desc.getWhere());
                    valid = false;
                }
                if (desc.getLockType() == BulkLoadImporterDescription.LockType.ROW
                        || desc.getLockType() == BulkLoadImporterDescription.LockType.ROW_OR_SKIP) {
                    getEnvironment().error(
                            "\"{0}\"に指定されたロック方法ではキャッシュを利用できません: {1}",
                            desc.getClass().getName(),
                            desc.getLockType());
                    valid = false;
                }
                if (desc.getDataSize() == DataSize.TINY || desc.getDataSize() == DataSize.SMALL) {
                    getEnvironment().error(
                            "\"{0}\"に指定されたデータサイズではキャッシュを利用できません: {1}",
                            desc.getClass().getName(),
                            desc.getDataSize());
                    valid = false;
                }
            }
        }
        return valid;
View Full Code Here

        assert inputs != null;
        assert outputs != null;
        Set<String> primaryTargets = Sets.create();
        Set<String> secondaryTargets = Sets.create();
        for (InputDescription description : inputs) {
            BulkLoadImporterDescription desc = extract(description);
            if (desc.getMode() == Mode.PRIMARY) {
                primaryTargets.add(desc.getTargetName());
            } else {
                secondaryTargets.add(desc.getTargetName());
                if (desc.getLockType() != BulkLoadImporterDescription.LockType.UNUSED) {
                    getEnvironment().error(
                            "補助インポーターはロックを指定できません: {0}",
                            desc.getClass().getName());
                    return false;
                }
            }
        }
        if (primaryTargets.size() >= 2) {
            getEnvironment().error(
                    "ジョブフロー内で複数のインポーターを起動できません。{1}を利用してください: {0}",
                    primaryTargets,
                    SecondaryImporterDescription.class.getSimpleName());
            return false;
        }

        for (String primary : primaryTargets) {
            if (secondaryTargets.contains(primary)) {
                LOG.warn("補助インポーターの指定がある{}は通常のインポーターでロードされます", primary);
            }
        }

        Set<String> exportTargets = Sets.create();
        for (OutputDescription description : outputs) {
            BulkLoadExporterDescription desc = extract(description);
            exportTargets.add(desc.getTargetName());
        }
        if (exportTargets.size() >= 2) {
            getEnvironment().error(
                    "ジョブフロー内で複数のエクスポーターを起動できません: {0}",
                    primaryTargets);
View Full Code Here

TOP

Related Classes of com.asakusafw.vocabulary.bulkloader.BulkLoadImporterDescription

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.