Search in sources :

Example 1 with ConfigurationException

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);
}
Also used : ConfigurationException(org.apache.flink.util.ConfigurationException) Time(org.apache.flink.api.common.time.Time) SlotManagerConfiguration(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManagerConfiguration)

Example 2 with ConfigurationException

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);
}
Also used : ConfigurationException(org.apache.flink.util.ConfigurationException) SSLHandlerFactory(org.apache.flink.runtime.io.network.netty.SSLHandlerFactory) ConfigurationException(org.apache.flink.util.ConfigurationException)

Example 3 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(org.apache.flink.util.ConfigurationException) File(java.io.File)

Example 4 with ConfigurationException

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());
    }
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) CommandLine(org.apache.commons.cli.CommandLine) ConfigurationException(org.apache.flink.util.ConfigurationException) File(java.io.File) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 5 with ConfigurationException

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.");
}
Also used : Configuration(org.apache.flink.configuration.Configuration) RestClient(org.apache.flink.runtime.rest.RestClient) ConfigurationException(org.apache.flink.util.ConfigurationException) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ConfigurationException(org.apache.flink.util.ConfigurationException) ExecutionException(java.util.concurrent.ExecutionException) TaskManagersInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagersInfo) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ConfigurationException (org.apache.flink.util.ConfigurationException)7 File (java.io.File)2 IOException (java.io.IOException)2 SSLHandlerFactory (org.apache.flink.runtime.io.network.netty.SSLHandlerFactory)2 BindException (java.net.BindException)1 InetSocketAddress (java.net.InetSocketAddress)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 CommandLine (org.apache.commons.cli.CommandLine)1 Time (org.apache.flink.api.common.time.Time)1 CustomCommandLine (org.apache.flink.client.cli.CustomCommandLine)1 Configuration (org.apache.flink.configuration.Configuration)1 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)1 InboundChannelHandlerFactory (org.apache.flink.runtime.io.network.netty.InboundChannelHandlerFactory)1 RedirectingSslHandler (org.apache.flink.runtime.net.RedirectingSslHandler)1 SlotManagerConfiguration (org.apache.flink.runtime.resourcemanager.slotmanager.SlotManagerConfiguration)1 RestClient (org.apache.flink.runtime.rest.RestClient)1