Search in sources :

Example 6 with IllegalConfigurationException

use of org.apache.flink.configuration.IllegalConfigurationException in project flink by apache.

the class CliFrontend method retrieveClient.

/**
	 * Updates the associated configuration with the given command line options
	 *
	 * @param options Command line options
	 */
protected ClusterClient retrieveClient(CommandLineOptions options) {
    CustomCommandLine customCLI = getActiveCustomCommandLine(options.getCommandLine());
    try {
        ClusterClient client = customCLI.retrieveCluster(options.getCommandLine(), config);
        logAndSysout("Using address " + client.getJobManagerAddress() + " to connect to JobManager.");
        return client;
    } catch (Exception e) {
        LOG.error("Couldn't retrieve {} cluster.", customCLI.getId(), e);
        throw new IllegalConfigurationException("Couldn't retrieve client for cluster", e);
    }
}
Also used : CustomCommandLine(org.apache.flink.client.cli.CustomCommandLine) ClusterClient(org.apache.flink.client.program.ClusterClient) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) ProgramMissingJobException(org.apache.flink.client.program.ProgramMissingJobException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) ProgramParametrizationException(org.apache.flink.client.program.ProgramParametrizationException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) CliArgsException(org.apache.flink.client.cli.CliArgsException) IOException(java.io.IOException)

Example 7 with IllegalConfigurationException

use of org.apache.flink.configuration.IllegalConfigurationException in project flink by apache.

the class RocksDBStateBackendFactory method createFromConfig.

@Override
public RocksDBStateBackend createFromConfig(Configuration config) throws IllegalConfigurationException, IOException {
    final String checkpointDirURI = config.getString(CHECKPOINT_DIRECTORY_URI_CONF_KEY, null);
    final String rocksdbLocalPath = config.getString(ROCKSDB_CHECKPOINT_DIRECTORY_URI_CONF_KEY, null);
    if (checkpointDirURI == null) {
        throw new IllegalConfigurationException("Cannot create the RocksDB state backend: The configuration does not specify the " + "checkpoint directory '" + CHECKPOINT_DIRECTORY_URI_CONF_KEY + '\'');
    }
    try {
        Path path = new Path(checkpointDirURI);
        RocksDBStateBackend backend = new RocksDBStateBackend(path.toUri());
        if (rocksdbLocalPath != null) {
            String[] directories = rocksdbLocalPath.split(",|" + File.pathSeparator);
            backend.setDbStoragePaths(directories);
        }
        LOG.info("State backend is set to RocksDB (configured DB storage paths {}, checkpoints to filesystem {} ) ", backend.getDbStoragePaths(), path);
        return backend;
    } catch (IllegalArgumentException e) {
        throw new IllegalConfigurationException("Cannot initialize RocksDB State Backend with URI '" + checkpointDirURI + '.', e);
    }
}
Also used : Path(org.apache.flink.core.fs.Path) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException)

Example 8 with IllegalConfigurationException

use of org.apache.flink.configuration.IllegalConfigurationException in project flink by apache.

the class CliFrontend method createClient.

/**
	 * Creates a {@link ClusterClient} object from the given command line options and other parameters.
	 * @param options Command line options
	 * @param program The program for which to create the client.
	 * @throws Exception
	 */
protected ClusterClient createClient(CommandLineOptions options, PackagedProgram program) throws Exception {
    // Get the custom command-line (e.g. Standalone/Yarn/Mesos)
    CustomCommandLine<?> activeCommandLine = getActiveCustomCommandLine(options.getCommandLine());
    ClusterClient client;
    try {
        client = activeCommandLine.retrieveCluster(options.getCommandLine(), config);
        logAndSysout("Cluster configuration: " + client.getClusterIdentifier());
    } catch (UnsupportedOperationException e) {
        try {
            String applicationName = "Flink Application: " + program.getMainClassName();
            client = activeCommandLine.createCluster(applicationName, options.getCommandLine(), config, program.getAllLibraries());
            logAndSysout("Cluster started: " + client.getClusterIdentifier());
        } catch (UnsupportedOperationException e2) {
            throw new IllegalConfigurationException("The JobManager address is neither provided at the command-line, " + "nor configured in flink-conf.yaml.");
        }
    }
    // Avoid resolving the JobManager Gateway here to prevent blocking until we invoke the user's program.
    final InetSocketAddress jobManagerAddress = client.getJobManagerAddress();
    logAndSysout("Using address " + jobManagerAddress.getHostString() + ":" + jobManagerAddress.getPort() + " to connect to JobManager.");
    logAndSysout("JobManager web interface address " + client.getWebInterfaceURL());
    return client;
}
Also used : ClusterClient(org.apache.flink.client.program.ClusterClient) InetSocketAddress(java.net.InetSocketAddress) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException)

Example 9 with IllegalConfigurationException

use of org.apache.flink.configuration.IllegalConfigurationException in project flink by apache.

the class MesosTaskManagerParameters method create.

/**
	 * Create the Mesos TaskManager parameters.
	 * @param flinkConfig the TM configuration.
     */
public static MesosTaskManagerParameters create(Configuration flinkConfig) {
    // parse the common parameters
    ContaineredTaskManagerParameters containeredParameters = ContaineredTaskManagerParameters.create(flinkConfig, flinkConfig.getInteger(MESOS_RM_TASKS_MEMORY_MB), flinkConfig.getInteger(MESOS_RM_TASKS_SLOTS));
    double cpus = flinkConfig.getDouble(MESOS_RM_TASKS_CPUS);
    if (cpus <= 0.0) {
        cpus = Math.max(containeredParameters.numSlots(), 1.0);
    }
    // parse the containerization parameters
    String imageName = flinkConfig.getString(MESOS_RM_CONTAINER_IMAGE_NAME);
    ContainerType containerType;
    String containerTypeString = flinkConfig.getString(MESOS_RM_CONTAINER_TYPE);
    switch(containerTypeString) {
        case MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS:
            containerType = ContainerType.MESOS;
            break;
        case MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER:
            containerType = ContainerType.DOCKER;
            if (imageName == null || imageName.length() == 0) {
                throw new IllegalConfigurationException(MESOS_RM_CONTAINER_IMAGE_NAME.key() + " must be specified for docker container type");
            }
            break;
        default:
            throw new IllegalConfigurationException("invalid container type: " + containerTypeString);
    }
    return new MesosTaskManagerParameters(cpus, containerType, Option.apply(imageName), containeredParameters);
}
Also used : IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) ContaineredTaskManagerParameters(org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameters)

Example 10 with IllegalConfigurationException

use of org.apache.flink.configuration.IllegalConfigurationException in project flink by apache.

the class TaskManagerConfigurationTest method testActorSystemPortConfig.

@Test
public void testActorSystemPortConfig() {
    try {
        // config with pre-configured hostname to speed up tests (no interface selection)
        Configuration config = new Configuration();
        config.setString(ConfigConstants.TASK_MANAGER_HOSTNAME_KEY, "localhost");
        config.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, "localhost");
        config.setInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, 7891);
        // auto port
        assertEquals(0, TaskManager.selectNetworkInterfaceAndPort(config)._2());
        // pre-defined port
        final int testPort = 22551;
        config.setInteger(ConfigConstants.TASK_MANAGER_IPC_PORT_KEY, testPort);
        assertEquals(testPort, TaskManager.selectNetworkInterfaceAndPort(config)._2());
        // invalid port
        try {
            config.setInteger(ConfigConstants.TASK_MANAGER_IPC_PORT_KEY, -1);
            TaskManager.selectNetworkInterfaceAndPort(config);
            fail("should fail with an exception");
        } catch (IllegalConfigurationException e) {
        // bam!
        }
        // invalid port
        try {
            config.setInteger(ConfigConstants.TASK_MANAGER_IPC_PORT_KEY, 100000);
            TaskManager.selectNetworkInterfaceAndPort(config);
            fail("should fail with an exception");
        } catch (IllegalConfigurationException e) {
        // bam!
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) GlobalConfiguration(org.apache.flink.configuration.GlobalConfiguration) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)20 IOException (java.io.IOException)9 Configuration (org.apache.flink.configuration.Configuration)5 Test (org.junit.Test)5 Path (org.apache.flink.core.fs.Path)3 File (java.io.File)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClusterClient (org.apache.flink.client.program.ClusterClient)2 HighAvailabilityMode (org.apache.flink.runtime.jobmanager.HighAvailabilityMode)2 Path (org.apache.hadoop.fs.Path)2 FiniteDuration (scala.concurrent.duration.FiniteDuration)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BindException (java.net.BindException)1 InetSocketAddress (java.net.InetSocketAddress)1