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;
}
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();
}
}
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();
}
}
}
}
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);
}
}
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;
}
}
Aggregations