Search in sources :

Example 51 with VisibleForTesting

use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.

the class SsgNetworkMemoryCalculationUtils method getMaxInputChannelNumsForDynamicGraph.

@VisibleForTesting
static Map<IntermediateDataSetID, Integer> getMaxInputChannelNumsForDynamicGraph(ExecutionJobVertex ejv) {
    Map<IntermediateDataSetID, Integer> ret = new HashMap<>();
    for (ExecutionVertex vertex : ejv.getTaskVertices()) {
        for (ConsumedPartitionGroup partitionGroup : vertex.getAllConsumedPartitionGroups()) {
            IntermediateResultPartition resultPartition = ejv.getGraph().getResultPartitionOrThrow((partitionGroup.getFirst()));
            SubpartitionIndexRange subpartitionIndexRange = TaskDeploymentDescriptorFactory.computeConsumedSubpartitionRange(resultPartition, vertex.getParallelSubtaskIndex());
            ret.merge(partitionGroup.getIntermediateDataSetID(), subpartitionIndexRange.size() * partitionGroup.size(), Integer::max);
        }
    }
    return ret;
}
Also used : ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup) IntermediateResultPartition(org.apache.flink.runtime.executiongraph.IntermediateResultPartition) HashMap(java.util.HashMap) IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID) SubpartitionIndexRange(org.apache.flink.runtime.deployment.SubpartitionIndexRange) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting)

Example 52 with VisibleForTesting

use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.

the class SqlClient method startClient.

@VisibleForTesting
protected static void startClient(String[] args, Supplier<Terminal> terminalFactory) {
    final String mode;
    final String[] modeArgs;
    if (args.length < 1 || args[0].startsWith("-")) {
        // mode is not specified, use the default `embedded` mode
        mode = MODE_EMBEDDED;
        modeArgs = args;
    } else {
        // mode is specified, extract the mode value and reaming args
        mode = args[0];
        // remove mode
        modeArgs = Arrays.copyOfRange(args, 1, args.length);
    }
    switch(mode) {
        case MODE_EMBEDDED:
            final CliOptions options = CliOptionsParser.parseEmbeddedModeClient(modeArgs);
            if (options.isPrintHelp()) {
                CliOptionsParser.printHelpEmbeddedModeClient();
            } else {
                try {
                    final SqlClient client = new SqlClient(true, options, terminalFactory);
                    client.start();
                } catch (SqlClientException e) {
                    // make space in terminal
                    System.out.println();
                    System.out.println();
                    LOG.error("SQL Client must stop.", e);
                    throw e;
                } catch (Throwable t) {
                    // make space in terminal
                    System.out.println();
                    System.out.println();
                    LOG.error("SQL Client must stop. Unexpected exception. This is a bug. Please consider filing an issue.", t);
                    throw new SqlClientException("Unexpected exception. This is a bug. Please consider filing an issue.", t);
                }
            }
            break;
        case MODE_GATEWAY:
            throw new SqlClientException("Gateway mode is not supported yet.");
        default:
            CliOptionsParser.printHelpClient();
    }
}
Also used : CliOptions(org.apache.flink.table.client.cli.CliOptions) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting)

Example 53 with VisibleForTesting

use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.

the class CreditBasedPartitionRequestClientHandler method notifyAllChannelsOfErrorAndClose.

@VisibleForTesting
void notifyAllChannelsOfErrorAndClose(Throwable cause) {
    if (channelError.compareAndSet(null, cause)) {
        try {
            for (RemoteInputChannel inputChannel : inputChannels.values()) {
                inputChannel.onError(cause);
            }
        } catch (Throwable t) {
            // We can only swallow the Exception at this point. :(
            LOG.warn("An Exception was thrown during error notification of a remote input channel.", t);
        } finally {
            inputChannels.clear();
            clientOutboundMessages.clear();
            if (ctx != null) {
                ctx.close();
            }
        }
    }
}
Also used : RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting)

Example 54 with VisibleForTesting

use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.

the class SSLUtils method getSSLProvider.

@VisibleForTesting
static SslProvider getSSLProvider(final Configuration config) {
    checkNotNull(config, "config must not be null");
    String providerString = config.getString(SecurityOptions.SSL_PROVIDER);
    if (providerString.equalsIgnoreCase("OPENSSL")) {
        if (OpenSsl.isAvailable()) {
            return OPENSSL;
        } else {
            throw new IllegalConfigurationException("openSSL not available", OpenSsl.unavailabilityCause());
        }
    } else if (providerString.equalsIgnoreCase("JDK")) {
        return JDK;
    } else {
        throw new IllegalConfigurationException("Unknown SSL provider: %s", providerString);
    }
}
Also used : IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting)

Example 55 with VisibleForTesting

use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.

the class SSLUtils method createRestSSLContext.

/**
 * Creates an SSL context for clients against the external REST endpoint.
 */
@Nullable
@VisibleForTesting
public static SSLContext createRestSSLContext(Configuration config, boolean clientMode) throws Exception {
    ClientAuth clientAuth = SecurityOptions.isRestSSLAuthenticationEnabled(config) ? ClientAuth.REQUIRE : ClientAuth.NONE;
    JdkSslContext nettySSLContext = (JdkSslContext) createRestNettySSLContext(config, clientMode, clientAuth, JDK);
    if (nettySSLContext != null) {
        return nettySSLContext.context();
    } else {
        return null;
    }
}
Also used : JdkSslContext(org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext) ClientAuth(org.apache.flink.shaded.netty4.io.netty.handler.ssl.ClientAuth) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting) Nullable(javax.annotation.Nullable)

Aggregations

VisibleForTesting (org.apache.flink.annotation.VisibleForTesting)64 HashMap (java.util.HashMap)11 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 Configuration (org.apache.flink.configuration.Configuration)7 Map (java.util.Map)6 File (java.io.File)5 URI (java.net.URI)4 List (java.util.List)4 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)4 Field (java.lang.reflect.Field)3 Set (java.util.Set)3 Nullable (javax.annotation.Nullable)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 Path (java.nio.file.Path)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Matcher (java.util.regex.Matcher)2 MetricGroup (org.apache.flink.metrics.MetricGroup)2 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)2