use of org.apache.flink.util.ConfigurationException in project flink by apache.
the class ResourceManagerRuntimeServicesConfiguration method fromConfiguration.
// ---------------------------- Static methods ----------------------------------
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);
final boolean enableFineGrainedResourceManagement = ClusterOptions.isFineGrainedResourceManagementEnabled(configuration);
return new ResourceManagerRuntimeServicesConfiguration(jobTimeout, slotManagerConfiguration, enableFineGrainedResourceManagement);
}
use of org.apache.flink.util.ConfigurationException in project flink by apache.
the class RestClientConfiguration method fromConfiguration.
/**
* 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 (SecurityOptions.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);
}
use of org.apache.flink.util.ConfigurationException in project flink by apache.
the class FlinkYarnSessionCli method encodeFilesToShipToCluster.
private void encodeFilesToShipToCluster(final Configuration configuration, final CommandLine cmd) throws ConfigurationException {
checkNotNull(cmd);
checkNotNull(configuration);
if (cmd.hasOption(shipPath.getOpt())) {
String[] shipFiles = cmd.getOptionValues(this.shipPath.getOpt());
for (String path : shipFiles) {
final File shipFile = new File(path);
if (!shipFile.exists()) {
throw new ConfigurationException("Ship file " + path + " does not exist");
}
}
ConfigUtils.encodeArrayToConfig(configuration, YarnConfigOptions.SHIP_FILES, shipFiles, f -> f);
}
}
use of org.apache.flink.util.ConfigurationException in project flink by apache.
the class FlinkYarnSessionCliTest method testMissingShipFiles.
@Test
public void testMissingShipFiles() throws Exception {
File tmpFile = tmp.newFile();
final String[] args = new String[] { "run", "--yarnship", tmpFile.toString(), "--yarnship", "missing.file" };
final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli();
final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(args, false);
try {
flinkYarnSessionCli.toConfiguration(commandLine);
fail("Expected error for missing file");
} catch (ConfigurationException ce) {
assertEquals("Ship file missing.file does not exist", ce.getMessage());
}
}
use of org.apache.flink.util.ConfigurationException in project flink by apache.
the class LocalStandaloneFlinkResource method startCluster.
@Override
public ClusterController startCluster(int numTaskManagers) throws IOException {
distribution.setTaskExecutorHosts(Collections.nCopies(numTaskManagers, "localhost"));
distribution.startFlinkCluster();
try (final RestClient restClient = new RestClient(new Configuration(), Executors.directExecutor())) {
for (int retryAttempt = 0; retryAttempt < 30; retryAttempt++) {
final CompletableFuture<TaskManagersInfo> localhost = restClient.sendRequest("localhost", 8081, TaskManagersHeaders.getInstance(), EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance());
try {
final TaskManagersInfo taskManagersInfo = localhost.get(1, TimeUnit.SECONDS);
final int numRunningTaskManagers = taskManagersInfo.getTaskManagerInfos().size();
if (numRunningTaskManagers == numTaskManagers) {
return new StandaloneClusterController(distribution);
} else {
LOG.info("Waiting for task managers to come up. {}/{} are currently running.", numRunningTaskManagers, numTaskManagers);
}
} catch (InterruptedException e) {
LOG.info("Waiting for dispatcher REST endpoint to come up...");
Thread.currentThread().interrupt();
} catch (TimeoutException | ExecutionException e) {
// ExecutionExceptions may occur if leader election is still going on
LOG.info("Waiting for dispatcher REST endpoint to come up...");
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
} catch (ConfigurationException e) {
throw new RuntimeException("Could not create RestClient.", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
throw new RuntimeException("Cluster did not start in expected time-frame.");
}
Aggregations