Java Code Examples for org.apache.flink.runtime.net.SSLUtils#isInternalSSLEnabled()

The following examples show how to use org.apache.flink.runtime.net.SSLUtils#isInternalSSLEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AkkaRpcServiceUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param hostname The hostname or address where the target RPC service is listening.
 * @param port The port where the target RPC service is listening.
 * @param endpointName The name of the RPC endpoint.
 * @param addressResolution Whether to try address resolution of the given hostname or not.
 *                          This allows to fail fast in case that the hostname cannot be resolved.
 * @param config The configuration from which to deduce further settings.
 *
 * @return The RPC URL of the specified RPC endpoint.
 */
public static String getRpcUrl(
	String hostname,
	int port,
	String endpointName,
	HighAvailabilityServicesUtils.AddressResolution addressResolution,
	Configuration config) throws UnknownHostException {

	checkNotNull(config, "config is null");

	final boolean sslEnabled = config.getBoolean(AkkaOptions.SSL_ENABLED) &&
			SSLUtils.isInternalSSLEnabled(config);

	return getRpcUrl(
		hostname,
		port,
		endpointName,
		addressResolution,
		sslEnabled ? AkkaProtocol.SSL_TCP : AkkaProtocol.TCP);
}
 
Example 2
Source File: AkkaRpcServiceUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param hostname The hostname or address where the target RPC service is listening.
 * @param port The port where the target RPC service is listening.
 * @param endpointName The name of the RPC endpoint.
 * @param addressResolution Whether to try address resolution of the given hostname or not.
 *                          This allows to fail fast in case that the hostname cannot be resolved.
 * @param config The configuration from which to deduce further settings.
 *
 * @return The RPC URL of the specified RPC endpoint.
 */
public static String getRpcUrl(
	String hostname,
	int port,
	String endpointName,
	HighAvailabilityServicesUtils.AddressResolution addressResolution,
	Configuration config) throws UnknownHostException {

	checkNotNull(config, "config is null");

	final boolean sslEnabled = config.getBoolean(AkkaOptions.SSL_ENABLED) &&
			SSLUtils.isInternalSSLEnabled(config);

	return getRpcUrl(
		hostname,
		port,
		endpointName,
		addressResolution,
		sslEnabled ? AkkaProtocol.SSL_TCP : AkkaProtocol.TCP);
}
 
Example 3
Source File: AkkaRpcServiceUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param hostname The hostname or address where the target RPC service is listening.
 * @param port The port where the target RPC service is listening.
 * @param endpointName The name of the RPC endpoint.
 * @param addressResolution Whether to try address resolution of the given hostname or not.
 *                          This allows to fail fast in case that the hostname cannot be resolved.
 * @param config The configuration from which to deduce further settings.
 *
 * @return The RPC URL of the specified RPC endpoint.
 */
public static String getRpcUrl(
	String hostname,
	int port,
	String endpointName,
	HighAvailabilityServicesUtils.AddressResolution addressResolution,
	Configuration config) throws UnknownHostException {

	checkNotNull(config, "config is null");

	final boolean sslEnabled = config.getBoolean(AkkaOptions.SSL_ENABLED) &&
			SSLUtils.isInternalSSLEnabled(config);

	return getRpcUrl(
		hostname,
		port,
		endpointName,
		addressResolution,
		sslEnabled ? AkkaProtocol.SSL_TCP : AkkaProtocol.TCP);
}
 
Example 4
Source File: BlobServer.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Instantiates a new BLOB server and binds it to a free network port.
 *
 * @param config Configuration to be used to instantiate the BlobServer
 * @param blobStore BlobStore to store blobs persistently
 *
 * @throws IOException
 * 		thrown if the BLOB server cannot bind to a free network port or if the
 * 		(local or distributed) file storage cannot be created or is not usable
 */
public BlobServer(Configuration config, BlobStore blobStore) throws IOException {
	this.blobServiceConfiguration = checkNotNull(config);
	this.blobStore = checkNotNull(blobStore);
	this.readWriteLock = new ReentrantReadWriteLock();

	// configure and create the storage directory
	this.storageDir = BlobUtils.initLocalStorageDirectory(config);
	LOG.info("Created BLOB server storage directory {}", storageDir);

	// configure the maximum number of concurrent connections
	final int maxConnections = config.getInteger(BlobServerOptions.FETCH_CONCURRENT);
	if (maxConnections >= 1) {
		this.maxConnections = maxConnections;
	}
	else {
		LOG.warn("Invalid value for maximum connections in BLOB server: {}. Using default value of {}",
				maxConnections, BlobServerOptions.FETCH_CONCURRENT.defaultValue());
		this.maxConnections = BlobServerOptions.FETCH_CONCURRENT.defaultValue();
	}

	// configure the backlog of connections
	int backlog = config.getInteger(BlobServerOptions.FETCH_BACKLOG);
	if (backlog < 1) {
		LOG.warn("Invalid value for BLOB connection backlog: {}. Using default value of {}",
				backlog, BlobServerOptions.FETCH_BACKLOG.defaultValue());
		backlog = BlobServerOptions.FETCH_BACKLOG.defaultValue();
	}

	// Initializing the clean up task
	this.cleanupTimer = new Timer(true);

	this.cleanupInterval = config.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
	this.cleanupTimer
		.schedule(new TransientBlobCleanupTask(blobExpiryTimes, readWriteLock.writeLock(),
			storageDir, LOG), cleanupInterval, cleanupInterval);

	this.shutdownHook = ShutdownHookUtil.addShutdownHook(this, getClass().getSimpleName(), LOG);

	//  ----------------------- start the server -------------------

	final String serverPortRange = config.getString(BlobServerOptions.PORT);
	final Iterator<Integer> ports = NetUtils.getPortRangeFromString(serverPortRange);

	final ServerSocketFactory socketFactory;
	if (SSLUtils.isInternalSSLEnabled(config) && config.getBoolean(BlobServerOptions.SSL_ENABLED)) {
		try {
			socketFactory = SSLUtils.createSSLServerSocketFactory(config);
		}
		catch (Exception e) {
			throw new IOException("Failed to initialize SSL for the blob server", e);
		}
	}
	else {
		socketFactory = ServerSocketFactory.getDefault();
	}

	final int finalBacklog = backlog;
	this.serverSocket = NetUtils.createSocketFromPorts(ports,
			(port) -> socketFactory.createServerSocket(port, finalBacklog));

	if (serverSocket == null) {
		throw new IOException("Unable to open BLOB Server in specified port range: " + serverPortRange);
	}

	// start the server thread
	setName("BLOB Server listener at " + getPort());
	setDaemon(true);

	if (LOG.isInfoEnabled()) {
		LOG.info("Started BLOB server at {}:{} - max concurrent requests: {} - max backlog: {}",
				serverSocket.getInetAddress().getHostAddress(), getPort(), maxConnections, backlog);
	}
}
 
Example 5
Source File: NettyConfig.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public boolean getSSLEnabled() {
	return config.getBoolean(TaskManagerOptions.DATA_SSL_ENABLED)
		&& SSLUtils.isInternalSSLEnabled(config);
}
 
Example 6
Source File: BlobServer.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Instantiates a new BLOB server and binds it to a free network port.
 *
 * @param config Configuration to be used to instantiate the BlobServer
 * @param blobStore BlobStore to store blobs persistently
 *
 * @throws IOException
 * 		thrown if the BLOB server cannot bind to a free network port or if the
 * 		(local or distributed) file storage cannot be created or is not usable
 */
public BlobServer(Configuration config, BlobStore blobStore) throws IOException {
	this.blobServiceConfiguration = checkNotNull(config);
	this.blobStore = checkNotNull(blobStore);
	this.readWriteLock = new ReentrantReadWriteLock();

	// configure and create the storage directory
	this.storageDir = BlobUtils.initLocalStorageDirectory(config);
	LOG.info("Created BLOB server storage directory {}", storageDir);

	// configure the maximum number of concurrent connections
	final int maxConnections = config.getInteger(BlobServerOptions.FETCH_CONCURRENT);
	if (maxConnections >= 1) {
		this.maxConnections = maxConnections;
	}
	else {
		LOG.warn("Invalid value for maximum connections in BLOB server: {}. Using default value of {}",
				maxConnections, BlobServerOptions.FETCH_CONCURRENT.defaultValue());
		this.maxConnections = BlobServerOptions.FETCH_CONCURRENT.defaultValue();
	}

	// configure the backlog of connections
	int backlog = config.getInteger(BlobServerOptions.FETCH_BACKLOG);
	if (backlog < 1) {
		LOG.warn("Invalid value for BLOB connection backlog: {}. Using default value of {}",
				backlog, BlobServerOptions.FETCH_BACKLOG.defaultValue());
		backlog = BlobServerOptions.FETCH_BACKLOG.defaultValue();
	}

	// Initializing the clean up task
	this.cleanupTimer = new Timer(true);

	this.cleanupInterval = config.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
	this.cleanupTimer
		.schedule(new TransientBlobCleanupTask(blobExpiryTimes, readWriteLock.writeLock(),
			storageDir, LOG), cleanupInterval, cleanupInterval);

	this.shutdownHook = ShutdownHookUtil.addShutdownHook(this, getClass().getSimpleName(), LOG);

	//  ----------------------- start the server -------------------

	final String serverPortRange = config.getString(BlobServerOptions.PORT);
	final Iterator<Integer> ports = NetUtils.getPortRangeFromString(serverPortRange);

	final ServerSocketFactory socketFactory;
	if (SSLUtils.isInternalSSLEnabled(config) && config.getBoolean(BlobServerOptions.SSL_ENABLED)) {
		try {
			socketFactory = SSLUtils.createSSLServerSocketFactory(config);
		}
		catch (Exception e) {
			throw new IOException("Failed to initialize SSL for the blob server", e);
		}
	}
	else {
		socketFactory = ServerSocketFactory.getDefault();
	}

	final int finalBacklog = backlog;
	this.serverSocket = NetUtils.createSocketFromPorts(ports,
			(port) -> socketFactory.createServerSocket(port, finalBacklog));

	if (serverSocket == null) {
		throw new IOException("Unable to open BLOB Server in specified port range: " + serverPortRange);
	}

	// start the server thread
	setName("BLOB Server listener at " + getPort());
	setDaemon(true);

	if (LOG.isInfoEnabled()) {
		LOG.info("Started BLOB server at {}:{} - max concurrent requests: {} - max backlog: {}",
				serverSocket.getInetAddress().getHostAddress(), getPort(), maxConnections, backlog);
	}
}
 
Example 7
Source File: NettyConfig.java    From flink with Apache License 2.0 4 votes vote down vote up
public boolean getSSLEnabled() {
	return config.getBoolean(NettyShuffleEnvironmentOptions.DATA_SSL_ENABLED)
		&& SSLUtils.isInternalSSLEnabled(config);
}
 
Example 8
Source File: BlobServer.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Instantiates a new BLOB server and binds it to a free network port.
 *
 * @param config Configuration to be used to instantiate the BlobServer
 * @param blobStore BlobStore to store blobs persistently
 *
 * @throws IOException
 * 		thrown if the BLOB server cannot bind to a free network port or if the
 * 		(local or distributed) file storage cannot be created or is not usable
 */
public BlobServer(Configuration config, BlobStore blobStore) throws IOException {
	this.blobServiceConfiguration = checkNotNull(config);
	this.blobStore = checkNotNull(blobStore);
	this.readWriteLock = new ReentrantReadWriteLock();

	// configure and create the storage directory
	this.storageDir = BlobUtils.initLocalStorageDirectory(config);
	LOG.info("Created BLOB server storage directory {}", storageDir);

	// configure the maximum number of concurrent connections
	final int maxConnections = config.getInteger(BlobServerOptions.FETCH_CONCURRENT);
	if (maxConnections >= 1) {
		this.maxConnections = maxConnections;
	}
	else {
		LOG.warn("Invalid value for maximum connections in BLOB server: {}. Using default value of {}",
				maxConnections, BlobServerOptions.FETCH_CONCURRENT.defaultValue());
		this.maxConnections = BlobServerOptions.FETCH_CONCURRENT.defaultValue();
	}

	// configure the backlog of connections
	int backlog = config.getInteger(BlobServerOptions.FETCH_BACKLOG);
	if (backlog < 1) {
		LOG.warn("Invalid value for BLOB connection backlog: {}. Using default value of {}",
				backlog, BlobServerOptions.FETCH_BACKLOG.defaultValue());
		backlog = BlobServerOptions.FETCH_BACKLOG.defaultValue();
	}

	// Initializing the clean up task
	this.cleanupTimer = new Timer(true);

	this.cleanupInterval = config.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
	this.cleanupTimer
		.schedule(new TransientBlobCleanupTask(blobExpiryTimes, readWriteLock.writeLock(),
			storageDir, LOG), cleanupInterval, cleanupInterval);

	this.shutdownHook = ShutdownHookUtil.addShutdownHook(this, getClass().getSimpleName(), LOG);

	//  ----------------------- start the server -------------------

	final String serverPortRange = config.getString(BlobServerOptions.PORT);
	final Iterator<Integer> ports = NetUtils.getPortRangeFromString(serverPortRange);

	final ServerSocketFactory socketFactory;
	if (SSLUtils.isInternalSSLEnabled(config) && config.getBoolean(BlobServerOptions.SSL_ENABLED)) {
		try {
			socketFactory = SSLUtils.createSSLServerSocketFactory(config);
		}
		catch (Exception e) {
			throw new IOException("Failed to initialize SSL for the blob server", e);
		}
	}
	else {
		socketFactory = ServerSocketFactory.getDefault();
	}

	final int finalBacklog = backlog;
	final String bindHost = config.getOptional(JobManagerOptions.BIND_HOST).orElseGet(NetUtils::getWildcardIPAddress);

	this.serverSocket = NetUtils.createSocketFromPorts(ports,
			(port) -> socketFactory.createServerSocket(port, finalBacklog, InetAddress.getByName(bindHost)));

	if (serverSocket == null) {
		throw new IOException("Unable to open BLOB Server in specified port range: " + serverPortRange);
	}

	// start the server thread
	setName("BLOB Server listener at " + getPort());
	setDaemon(true);

	if (LOG.isInfoEnabled()) {
		LOG.info("Started BLOB server at {}:{} - max concurrent requests: {} - max backlog: {}",
				serverSocket.getInetAddress().getHostAddress(), getPort(), maxConnections, backlog);
	}
}
 
Example 9
Source File: NettyConfig.java    From flink with Apache License 2.0 4 votes vote down vote up
public boolean getSSLEnabled() {
	return config.getBoolean(NettyShuffleEnvironmentOptions.DATA_SSL_ENABLED)
		&& SSLUtils.isInternalSSLEnabled(config);
}