Search in sources :

Example 1 with TempMode

use of org.apache.flink.optimizer.dag.TempMode in project flink by apache.

the class JobGraphGenerator method addLocalInfoFromChannelToConfig.

private void addLocalInfoFromChannelToConfig(Channel channel, TaskConfig config, int inputNum, boolean isBroadcastChannel) {
    // serializer
    if (isBroadcastChannel) {
        config.setBroadcastInputSerializer(channel.getSerializer(), inputNum);
        if (channel.getLocalStrategy() != LocalStrategy.NONE || (channel.getTempMode() != null && channel.getTempMode() != TempMode.NONE)) {
            throw new CompilerException("Found local strategy or temp mode on a broadcast variable channel.");
        } else {
            return;
        }
    } else {
        config.setInputSerializer(channel.getSerializer(), inputNum);
    }
    // local strategy
    if (channel.getLocalStrategy() != LocalStrategy.NONE) {
        config.setInputLocalStrategy(inputNum, channel.getLocalStrategy());
        if (channel.getLocalStrategyComparator() != null) {
            config.setInputComparator(channel.getLocalStrategyComparator(), inputNum);
        }
    }
    assignLocalStrategyResources(channel, config, inputNum);
    // materialization / caching
    if (channel.getTempMode() != null) {
        final TempMode tm = channel.getTempMode();
        boolean needsMemory = false;
        // Don't add a pipeline breaker if the data exchange is already blocking, EXCEPT the channel is within an iteration.
        if (tm.breaksPipeline() && (channel.isOnDynamicPath() || channel.getDataExchangeMode() != DataExchangeMode.BATCH)) {
            config.setInputAsynchronouslyMaterialized(inputNum, true);
            needsMemory = true;
        }
        if (tm.isCached()) {
            config.setInputCached(inputNum, true);
            needsMemory = true;
        }
        if (needsMemory) {
            // sanity check
            if (tm == TempMode.NONE || channel.getRelativeTempMemory() <= 0) {
                throw new CompilerException("Bug in compiler: Inconsistent description of input materialization.");
            }
            config.setRelativeInputMaterializationMemory(inputNum, channel.getRelativeTempMemory());
        }
    }
}
Also used : TempMode(org.apache.flink.optimizer.dag.TempMode) CompilerException(org.apache.flink.optimizer.CompilerException)

Aggregations

CompilerException (org.apache.flink.optimizer.CompilerException)1 TempMode (org.apache.flink.optimizer.dag.TempMode)1