org.apache.flink.util.ConfigurationException Java Examples

The following examples show how to use org.apache.flink.util.ConfigurationException. 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: SlotManagerConfiguration.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static SlotManagerConfiguration fromConfiguration(Configuration configuration) throws ConfigurationException {
	final String strTimeout = configuration.getString(AkkaOptions.ASK_TIMEOUT);
	final Time rpcTimeout;

	try {
		rpcTimeout = Time.milliseconds(Duration.apply(strTimeout).toMillis());
	} catch (NumberFormatException e) {
		throw new ConfigurationException("Could not parse the resource manager's timeout " +
			"value " + AkkaOptions.ASK_TIMEOUT + '.', e);
	}

	final Time slotRequestTimeout = getSlotRequestTimeout(configuration);
	final Time taskManagerTimeout = Time.milliseconds(
			configuration.getLong(ResourceManagerOptions.TASK_MANAGER_TIMEOUT));

	boolean waitResultConsumedBeforeRelease =
		configuration.getBoolean(ResourceManagerOptions.TASK_MANAGER_RELEASE_WHEN_RESULT_CONSUMED);

	return new SlotManagerConfiguration(rpcTimeout, slotRequestTimeout, taskManagerTimeout, waitResultConsumedBeforeRelease);
}
 
Example #2
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
		@Override
		public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
		sendRequest(
			final String targetAddress,
			final int targetPort,
			final M messageHeaders,
			final U messageParameters,
			final R request,
			final Collection<FileUpload> files) throws IOException {
			if (failHttpRequest.test(messageHeaders, messageParameters, request)) {
				return FutureUtils.completedExceptionally(new IOException("expected"));
			} else {
				return super.sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, files);
			}
		}
	};
}
 
Example #3
Source File: RestServerEndpointConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasicMapping() throws ConfigurationException {
	Configuration originalConfig = new Configuration();
	originalConfig.setString(RestOptions.ADDRESS, ADDRESS);
	originalConfig.setString(RestOptions.BIND_ADDRESS, BIND_ADDRESS);
	originalConfig.setString(RestOptions.BIND_PORT, BIND_PORT);
	originalConfig.setInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH, CONTENT_LENGTH);
	originalConfig.setString(WebOptions.TMP_DIR, temporaryFolder.getRoot().getAbsolutePath());

	final RestServerEndpointConfiguration result = RestServerEndpointConfiguration.fromConfiguration(originalConfig);
	Assert.assertEquals(ADDRESS, result.getRestAddress());
	Assert.assertEquals(BIND_ADDRESS, result.getRestBindAddress());
	Assert.assertEquals(BIND_PORT, result.getRestBindPortRange());
	Assert.assertEquals(CONTENT_LENGTH, result.getMaxContentLength());
	Assert.assertThat(
		result.getUploadDir().toAbsolutePath().toString(),
		containsString(temporaryFolder.getRoot().getAbsolutePath()));
}
 
Example #4
Source File: HighAvailabilityServicesUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the JobManager's hostname and port extracted from the given
 * {@link Configuration}.
 *
 * @param configuration Configuration to extract the JobManager's address from
 * @return The JobManager's hostname and port
 * @throws ConfigurationException if the JobManager's address cannot be extracted from the configuration
 */
public static Tuple2<String, Integer> getJobManagerAddress(Configuration configuration) throws ConfigurationException {

	final String hostname = configuration.getString(JobManagerOptions.ADDRESS);
	final int port = configuration.getInteger(JobManagerOptions.PORT);

	if (hostname == null) {
		throw new ConfigurationException("Config parameter '" + JobManagerOptions.ADDRESS +
			"' is missing (hostname/address of JobManager to connect to).");
	}

	if (port <= 0 || port >= 65536) {
		throw new ConfigurationException("Invalid value for '" + JobManagerOptions.PORT +
			"' (port of the JobManager actor system) : " + port +
			".  it must be greater than 0 and less than 65536.");
	}

	return Tuple2.of(hostname, port);
}
 
Example #5
Source File: RestClientConfiguration.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a new {@link RestClientConfiguration} from the given {@link Configuration}.
 *
 * @param config configuration from which the REST client endpoint configuration should be created from
 * @return REST client endpoint configuration
 * @throws ConfigurationException if SSL was configured incorrectly
 */

public static RestClientConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	Preconditions.checkNotNull(config);

	final SSLHandlerFactory sslHandlerFactory;
	if (SSLUtils.isRestSSLEnabled(config)) {
		try {
			sslHandlerFactory = SSLUtils.createRestClientSSLEngineFactory(config);
		} catch (Exception e) {
			throw new ConfigurationException("Failed to initialize SSLContext for the REST client", e);
		}
	} else {
		sslHandlerFactory = null;
	}

	final long connectionTimeout = config.getLong(RestOptions.CONNECTION_TIMEOUT);

	final long idlenessTimeout = config.getLong(RestOptions.IDLENESS_TIMEOUT);

	int maxContentLength = config.getInteger(RestOptions.CLIENT_MAX_CONTENT_LENGTH);

	return new RestClientConfiguration(sslHandlerFactory, connectionTimeout, idlenessTimeout, maxContentLength);
}
 
Example #6
Source File: ResourceManagerRuntimeServicesConfiguration.java    From flink with Apache License 2.0 6 votes vote down vote up
public static ResourceManagerRuntimeServicesConfiguration fromConfiguration(
		Configuration configuration,
		WorkerResourceSpecFactory defaultWorkerResourceSpecFactory) throws ConfigurationException {

	final String strJobTimeout = configuration.getString(ResourceManagerOptions.JOB_TIMEOUT);
	final Time jobTimeout;

	try {
		jobTimeout = Time.milliseconds(TimeUtils.parseDuration(strJobTimeout).toMillis());
	} catch (IllegalArgumentException e) {
		throw new ConfigurationException("Could not parse the resource manager's job timeout " +
			"value " + ResourceManagerOptions.JOB_TIMEOUT + '.', e);
	}

	final WorkerResourceSpec defaultWorkerResourceSpec = defaultWorkerResourceSpecFactory.createDefaultWorkerResourceSpec(configuration);
	final SlotManagerConfiguration slotManagerConfiguration =
		SlotManagerConfiguration.fromConfiguration(configuration, defaultWorkerResourceSpec);

	return new ResourceManagerRuntimeServicesConfiguration(jobTimeout, slotManagerConfiguration);
}
 
Example #7
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
		@Override
		public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
		sendRequest(
			final String targetAddress,
			final int targetPort,
			final M messageHeaders,
			final U messageParameters,
			final R request,
			final Collection<FileUpload> files) throws IOException {
			if (failHttpRequest.test(messageHeaders, messageParameters, request)) {
				return FutureUtils.completedExceptionally(new IOException("expected"));
			} else {
				return super.sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, files);
			}
		}
	};
}
 
Example #8
Source File: RestServerEndpointConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasicMapping() throws ConfigurationException {
	Configuration originalConfig = new Configuration();
	originalConfig.setString(RestOptions.ADDRESS, ADDRESS);
	originalConfig.setString(RestOptions.BIND_ADDRESS, BIND_ADDRESS);
	originalConfig.setString(RestOptions.BIND_PORT, BIND_PORT);
	originalConfig.setInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH, CONTENT_LENGTH);
	originalConfig.setString(WebOptions.TMP_DIR, temporaryFolder.getRoot().getAbsolutePath());

	final RestServerEndpointConfiguration result = RestServerEndpointConfiguration.fromConfiguration(originalConfig);
	Assert.assertEquals(ADDRESS, result.getRestAddress());
	Assert.assertEquals(BIND_ADDRESS, result.getRestBindAddress());
	Assert.assertEquals(BIND_PORT, result.getRestBindPortRange());
	Assert.assertEquals(CONTENT_LENGTH, result.getMaxContentLength());
	Assert.assertThat(
		result.getUploadDir().toAbsolutePath().toString(),
		containsString(temporaryFolder.getRoot().getAbsolutePath()));
}
 
Example #9
Source File: HighAvailabilityServicesUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the JobManager's hostname and port extracted from the given
 * {@link Configuration}.
 *
 * @param configuration Configuration to extract the JobManager's address from
 * @return The JobManager's hostname and port
 * @throws ConfigurationException if the JobManager's address cannot be extracted from the configuration
 */
public static Tuple2<String, Integer> getJobManagerAddress(Configuration configuration) throws ConfigurationException {

	final String hostname = configuration.getString(JobManagerOptions.ADDRESS);
	final int port = configuration.getInteger(JobManagerOptions.PORT);

	if (hostname == null) {
		throw new ConfigurationException("Config parameter '" + JobManagerOptions.ADDRESS +
			"' is missing (hostname/address of JobManager to connect to).");
	}

	if (port <= 0 || port >= 65536) {
		throw new ConfigurationException("Invalid value for '" + JobManagerOptions.PORT +
			"' (port of the JobManager actor system) : " + port +
			".  it must be greater than 0 and less than 65536.");
	}

	return Tuple2.of(hostname, port);
}
 
Example #10
Source File: StandaloneUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link StandaloneLeaderRetrievalService} form the given configuration and the
 * JobManager name. The host and port for the remote Akka URL are retrieved from the provided
 * configuration. Instead of using the standard JobManager Akka name, the provided one is used
 * for the remote Akka URL.
 *
 * @param configuration Configuration instance containing hte host and port information
 * @param resolveInitialHostName If true, resolves the hostname of the StandaloneLeaderRetrievalService
 * @param jobManagerName Name of the JobManager actor
 * @return StandaloneLeaderRetrievalService
 * @throws ConfigurationException if the job manager address cannot be retrieved from the configuration
 * @throws UnknownHostException if the job manager address cannot be resolved
 */
public static StandaloneLeaderRetrievalService createLeaderRetrievalService(
		Configuration configuration,
		boolean resolveInitialHostName,
		String jobManagerName)
	throws ConfigurationException, UnknownHostException {
	Tuple2<String, Integer> hostnamePort = HighAvailabilityServicesUtils.getJobManagerAddress(configuration);

	String jobManagerAkkaUrl = AkkaRpcServiceUtils.getRpcUrl(
		hostnamePort.f0,
		hostnamePort.f1,
		jobManagerName != null ? jobManagerName : JobMaster.JOB_MANAGER_NAME,
		resolveInitialHostName ? AddressResolution.TRY_ADDRESS_RESOLUTION : AddressResolution.NO_ADDRESS_RESOLUTION,
		configuration);

	return new StandaloneLeaderRetrievalService(jobManagerAkkaUrl);
}
 
Example #11
Source File: RestClientConfiguration.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a new {@link RestClientConfiguration} from the given {@link Configuration}.
 *
 * @param config configuration from which the REST client endpoint configuration should be created from
 * @return REST client endpoint configuration
 * @throws ConfigurationException if SSL was configured incorrectly
 */

public static RestClientConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	Preconditions.checkNotNull(config);

	final SSLHandlerFactory sslHandlerFactory;
	if (SSLUtils.isRestSSLEnabled(config)) {
		try {
			sslHandlerFactory = SSLUtils.createRestClientSSLEngineFactory(config);
		} catch (Exception e) {
			throw new ConfigurationException("Failed to initialize SSLContext for the REST client", e);
		}
	} else {
		sslHandlerFactory = null;
	}

	final long connectionTimeout = config.getLong(RestOptions.CONNECTION_TIMEOUT);

	final long idlenessTimeout = config.getLong(RestOptions.IDLENESS_TIMEOUT);

	int maxContentLength = config.getInteger(RestOptions.CLIENT_MAX_CONTENT_LENGTH);

	return new RestClientConfiguration(sslHandlerFactory, connectionTimeout, idlenessTimeout, maxContentLength);
}
 
Example #12
Source File: SlotManagerConfiguration.java    From flink with Apache License 2.0 6 votes vote down vote up
public static SlotManagerConfiguration fromConfiguration(Configuration configuration) throws ConfigurationException {
	final String strTimeout = configuration.getString(AkkaOptions.ASK_TIMEOUT);
	final Time rpcTimeout;

	try {
		rpcTimeout = Time.milliseconds(Duration.apply(strTimeout).toMillis());
	} catch (NumberFormatException e) {
		throw new ConfigurationException("Could not parse the resource manager's timeout " +
			"value " + AkkaOptions.ASK_TIMEOUT + '.', e);
	}

	final Time slotRequestTimeout = getSlotRequestTimeout(configuration);
	final Time taskManagerTimeout = Time.milliseconds(
			configuration.getLong(ResourceManagerOptions.TASK_MANAGER_TIMEOUT));

	boolean waitResultConsumedBeforeRelease =
		configuration.getBoolean(ResourceManagerOptions.TASK_MANAGER_RELEASE_WHEN_RESULT_CONSUMED);

	return new SlotManagerConfiguration(rpcTimeout, slotRequestTimeout, taskManagerTimeout, waitResultConsumedBeforeRelease);
}
 
Example #13
Source File: ResourceManagerRuntimeServicesConfiguration.java    From flink with Apache License 2.0 6 votes vote down vote up
public static ResourceManagerRuntimeServicesConfiguration fromConfiguration(Configuration configuration) throws ConfigurationException {

		final String strJobTimeout = configuration.getString(ResourceManagerOptions.JOB_TIMEOUT);
		final Time jobTimeout;

		try {
			jobTimeout = Time.milliseconds(Duration.apply(strJobTimeout).toMillis());
		} catch (NumberFormatException e) {
			throw new ConfigurationException("Could not parse the resource manager's job timeout " +
				"value " + ResourceManagerOptions.JOB_TIMEOUT + '.', e);
		}

		final SlotManagerConfiguration slotManagerConfiguration = SlotManagerConfiguration.fromConfiguration(configuration);

		return new ResourceManagerRuntimeServicesConfiguration(jobTimeout, slotManagerConfiguration);
	}
 
Example #14
Source File: RestClientConfiguration.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a new {@link RestClientConfiguration} from the given {@link Configuration}.
 *
 * @param config configuration from which the REST client endpoint configuration should be created from
 * @return REST client endpoint configuration
 * @throws ConfigurationException if SSL was configured incorrectly
 */

public static RestClientConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	Preconditions.checkNotNull(config);

	final SSLHandlerFactory sslHandlerFactory;
	if (SSLUtils.isRestSSLEnabled(config)) {
		try {
			sslHandlerFactory = SSLUtils.createRestClientSSLEngineFactory(config);
		} catch (Exception e) {
			throw new ConfigurationException("Failed to initialize SSLContext for the REST client", e);
		}
	} else {
		sslHandlerFactory = null;
	}

	final long connectionTimeout = config.getLong(RestOptions.CONNECTION_TIMEOUT);

	final long idlenessTimeout = config.getLong(RestOptions.IDLENESS_TIMEOUT);

	int maxContentLength = config.getInteger(RestOptions.CLIENT_MAX_CONTENT_LENGTH);

	return new RestClientConfiguration(sslHandlerFactory, connectionTimeout, idlenessTimeout, maxContentLength);
}
 
Example #15
Source File: StandaloneUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link StandaloneLeaderRetrievalService} form the given configuration and the
 * JobManager name. The host and port for the remote Akka URL are retrieved from the provided
 * configuration. Instead of using the standard JobManager Akka name, the provided one is used
 * for the remote Akka URL.
 *
 * @param configuration Configuration instance containing hte host and port information
 * @param resolveInitialHostName If true, resolves the hostname of the StandaloneLeaderRetrievalService
 * @param jobManagerName Name of the JobManager actor
 * @return StandaloneLeaderRetrievalService
 * @throws ConfigurationException if the job manager address cannot be retrieved from the configuration
 * @throws UnknownHostException if the job manager address cannot be resolved
 */
public static StandaloneLeaderRetrievalService createLeaderRetrievalService(
		Configuration configuration,
		boolean resolveInitialHostName,
		String jobManagerName)
	throws ConfigurationException, UnknownHostException {
	Tuple2<String, Integer> hostnamePort = HighAvailabilityServicesUtils.getJobManagerAddress(configuration);

	String jobManagerAkkaUrl = AkkaRpcServiceUtils.getRpcUrl(
		hostnamePort.f0,
		hostnamePort.f1,
		jobManagerName != null ? jobManagerName : JobMaster.JOB_MANAGER_NAME,
		resolveInitialHostName ? AddressResolution.TRY_ADDRESS_RESOLUTION : AddressResolution.NO_ADDRESS_RESOLUTION,
		configuration);

	return new StandaloneLeaderRetrievalService(jobManagerAkkaUrl);
}
 
Example #16
Source File: HighAvailabilityServicesUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the JobManager's hostname and port extracted from the given
 * {@link Configuration}.
 *
 * @param configuration Configuration to extract the JobManager's address from
 * @return The JobManager's hostname and port
 * @throws ConfigurationException if the JobManager's address cannot be extracted from the configuration
 */
public static Tuple2<String, Integer> getJobManagerAddress(Configuration configuration) throws ConfigurationException {

	final String hostname = configuration.getString(JobManagerOptions.ADDRESS);
	final int port = configuration.getInteger(JobManagerOptions.PORT);

	if (hostname == null) {
		throw new ConfigurationException("Config parameter '" + JobManagerOptions.ADDRESS +
			"' is missing (hostname/address of JobManager to connect to).");
	}

	if (port <= 0 || port >= 65536) {
		throw new ConfigurationException("Invalid value for '" + JobManagerOptions.PORT +
			"' (port of the JobManager actor system) : " + port +
			".  it must be greater than 0 and less than 65536.");
	}

	return Tuple2.of(hostname, port);
}
 
Example #17
Source File: RestServerEndpointConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasicMapping() throws ConfigurationException {
	Configuration originalConfig = new Configuration();
	originalConfig.setString(RestOptions.ADDRESS, ADDRESS);
	originalConfig.setString(RestOptions.BIND_ADDRESS, BIND_ADDRESS);
	originalConfig.setString(RestOptions.BIND_PORT, BIND_PORT);
	originalConfig.setInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH, CONTENT_LENGTH);
	originalConfig.setString(WebOptions.TMP_DIR, temporaryFolder.getRoot().getAbsolutePath());

	final RestServerEndpointConfiguration result = RestServerEndpointConfiguration.fromConfiguration(originalConfig);
	Assert.assertEquals(ADDRESS, result.getRestAddress());
	Assert.assertEquals(BIND_ADDRESS, result.getRestBindAddress());
	Assert.assertEquals(BIND_PORT, result.getRestBindPortRange());
	Assert.assertEquals(CONTENT_LENGTH, result.getMaxContentLength());
	Assert.assertThat(
		result.getUploadDir().toAbsolutePath().toString(),
		containsString(temporaryFolder.getRoot().getAbsolutePath()));
}
 
Example #18
Source File: RestClusterClientTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
		@Override
		public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
		sendRequest(
			final String targetAddress,
			final int targetPort,
			final M messageHeaders,
			final U messageParameters,
			final R request,
			final Collection<FileUpload> files) throws IOException {
			if (failHttpRequest.test(messageHeaders, messageParameters, request)) {
				return FutureUtils.completedExceptionally(new IOException("expected"));
			} else {
				return super.sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, files);
			}
		}
	};
}
 
Example #19
Source File: ResourceManagerRuntimeServicesConfiguration.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static ResourceManagerRuntimeServicesConfiguration fromConfiguration(Configuration configuration) throws ConfigurationException {

		final String strJobTimeout = configuration.getString(ResourceManagerOptions.JOB_TIMEOUT);
		final Time jobTimeout;

		try {
			jobTimeout = Time.milliseconds(Duration.apply(strJobTimeout).toMillis());
		} catch (NumberFormatException e) {
			throw new ConfigurationException("Could not parse the resource manager's job timeout " +
				"value " + ResourceManagerOptions.JOB_TIMEOUT + '.', e);
		}

		final SlotManagerConfiguration slotManagerConfiguration = SlotManagerConfiguration.fromConfiguration(configuration);

		return new ResourceManagerRuntimeServicesConfiguration(jobTimeout, slotManagerConfiguration);
	}
 
Example #20
Source File: RestClusterClientConfiguration.java    From flink with Apache License 2.0 5 votes vote down vote up
public static RestClusterClientConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	RestClientConfiguration restClientConfiguration = RestClientConfiguration.fromConfiguration(config);

	final long awaitLeaderTimeout = config.getLong(RestOptions.AWAIT_LEADER_TIMEOUT);
	final int retryMaxAttempts = config.getInteger(RestOptions.RETRY_MAX_ATTEMPTS);
	final long retryDelay = config.getLong(RestOptions.RETRY_DELAY);

	return new RestClusterClientConfiguration(restClientConfiguration, awaitLeaderTimeout, retryMaxAttempts, retryDelay);
}
 
Example #21
Source File: LeaderRetrievalServiceHostnameResolutionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnresolvableHostname1() throws UnknownHostException, ConfigurationException {
	Configuration config = new Configuration();

	config.setString(JobManagerOptions.ADDRESS, nonExistingHostname);
	config.setInteger(JobManagerOptions.PORT, 17234);

	StandaloneUtils.createLeaderRetrievalService(
		config,
		false,
		JobMaster.JOB_MANAGER_NAME);
}
 
Example #22
Source File: RestClusterClientConfiguration.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static RestClusterClientConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	RestClientConfiguration restClientConfiguration = RestClientConfiguration.fromConfiguration(config);

	final long awaitLeaderTimeout = config.getLong(RestOptions.AWAIT_LEADER_TIMEOUT);
	final int retryMaxAttempts = config.getInteger(RestOptions.RETRY_MAX_ATTEMPTS);
	final long retryDelay = config.getLong(RestOptions.RETRY_DELAY);

	return new RestClusterClientConfiguration(restClientConfiguration, awaitLeaderTimeout, retryMaxAttempts, retryDelay);
}
 
Example #23
Source File: RestClusterClientConfiguration.java    From flink with Apache License 2.0 5 votes vote down vote up
public static RestClusterClientConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	RestClientConfiguration restClientConfiguration = RestClientConfiguration.fromConfiguration(config);

	final long awaitLeaderTimeout = config.getLong(RestOptions.AWAIT_LEADER_TIMEOUT);
	final int retryMaxAttempts = config.getInteger(RestOptions.RETRY_MAX_ATTEMPTS);
	final long retryDelay = config.getLong(RestOptions.RETRY_DELAY);

	return new RestClusterClientConfiguration(restClientConfiguration, awaitLeaderTimeout, retryMaxAttempts, retryDelay);
}
 
Example #24
Source File: LeaderRetrievalServiceHostnameResolutionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnresolvableHostname1() throws UnknownHostException, ConfigurationException {
	Configuration config = new Configuration();

	config.setString(JobManagerOptions.ADDRESS, nonExistingHostname);
	config.setInteger(JobManagerOptions.PORT, 17234);

	StandaloneUtils.createLeaderRetrievalService(
		config,
		false,
		JobMaster.JOB_MANAGER_NAME);
}
 
Example #25
Source File: SlotManagerConfiguration.java    From flink with Apache License 2.0 5 votes vote down vote up
public static SlotManagerConfiguration fromConfiguration(
		Configuration configuration,
		WorkerResourceSpec defaultWorkerResourceSpec) throws ConfigurationException {

	final Time rpcTimeout;
	try {
		rpcTimeout = AkkaUtils.getTimeoutAsTime(configuration);
	} catch (IllegalArgumentException e) {
		throw new ConfigurationException("Could not parse the resource manager's timeout " +
			"value " + AkkaOptions.ASK_TIMEOUT + '.', e);
	}

	final Time slotRequestTimeout = getSlotRequestTimeout(configuration);
	final Time taskManagerTimeout = Time.milliseconds(
			configuration.getLong(ResourceManagerOptions.TASK_MANAGER_TIMEOUT));

	boolean waitResultConsumedBeforeRelease =
		configuration.getBoolean(ResourceManagerOptions.TASK_MANAGER_RELEASE_WHEN_RESULT_CONSUMED);

	boolean evenlySpreadOutSlots = configuration.getBoolean(ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY);
	final SlotMatchingStrategy slotMatchingStrategy = evenlySpreadOutSlots ?
		LeastUtilizationSlotMatchingStrategy.INSTANCE : AnyMatchingSlotMatchingStrategy.INSTANCE;

	int numSlotsPerWorker = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS);

	int maxSlotNum = configuration.getInteger(ResourceManagerOptions.MAX_SLOT_NUM);

	return new SlotManagerConfiguration(
		rpcTimeout,
		slotRequestTimeout,
		taskManagerTimeout,
		waitResultConsumedBeforeRelease,
		slotMatchingStrategy,
		defaultWorkerResourceSpec,
		numSlotsPerWorker,
		maxSlotNum);
}
 
Example #26
Source File: ResourceManagerFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
private ResourceManagerRuntimeServices createResourceManagerRuntimeServices(
		Configuration configuration,
		RpcService rpcService,
		HighAvailabilityServices highAvailabilityServices,
		SlotManagerMetricGroup slotManagerMetricGroup) throws ConfigurationException {

	return ResourceManagerRuntimeServices.fromConfiguration(
		createResourceManagerRuntimeServicesConfiguration(configuration),
		highAvailabilityServices,
		rpcService.getScheduledExecutor(),
		slotManagerMetricGroup);
}
 
Example #27
Source File: RestClientMultipartTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupClient() throws ConfigurationException {
	restClient = new RestClient(RestClientConfiguration.fromConfiguration(new Configuration()), TestingUtils.defaultExecutor());
}
 
Example #28
Source File: RestServerEndpointConfiguration.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Creates and returns a new {@link RestServerEndpointConfiguration} from the given {@link Configuration}.
 *
 * @param config configuration from which the REST server endpoint configuration should be created from
 * @return REST server endpoint configuration
 * @throws ConfigurationException if SSL was configured incorrectly
 */
public static RestServerEndpointConfiguration fromConfiguration(Configuration config) throws ConfigurationException {
	Preconditions.checkNotNull(config);

	final String restAddress = Preconditions.checkNotNull(config.getString(RestOptions.ADDRESS),
		"%s must be set",
		RestOptions.ADDRESS.key());

	final String restBindAddress = config.getString(RestOptions.BIND_ADDRESS);
	final String portRangeDefinition = config.getString(RestOptions.BIND_PORT);

	final SSLHandlerFactory sslHandlerFactory;
	if (SSLUtils.isRestSSLEnabled(config)) {
		try {
			sslHandlerFactory = SSLUtils.createRestServerSSLEngineFactory(config);
		} catch (Exception e) {
			throw new ConfigurationException("Failed to initialize SSLEngineFactory for REST server endpoint.", e);
		}
	} else {
		sslHandlerFactory = null;
	}

	final Path uploadDir = Paths.get(
		config.getString(WebOptions.UPLOAD_DIR,	config.getString(WebOptions.TMP_DIR)),
		"flink-web-upload");

	final int maxContentLength = config.getInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH);

	final Map<String, String> responseHeaders = Collections.singletonMap(
		HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,
		config.getString(WebOptions.ACCESS_CONTROL_ALLOW_ORIGIN));

	return new RestServerEndpointConfiguration(
		restAddress,
		restBindAddress,
		portRangeDefinition,
		sslHandlerFactory,
		uploadDir,
		maxContentLength,
		responseHeaders);
}
 
Example #29
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUp() throws ConfigurationException {
	restServerEndpointConfiguration = RestServerEndpointConfiguration.fromConfiguration(REST_CONFIG);
	executor = Executors.newSingleThreadExecutor(new ExecutorThreadFactory(RestClusterClientSavepointTriggerTest.class.getSimpleName()));
}
 
Example #30
Source File: BatchFineGrainedRecoveryITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(
		RestClientConfiguration.fromConfiguration(new UnmodifiableConfiguration(new Configuration())),
		executorService);
}