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);
}
}
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);
}
}
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;
}
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);
}
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());
}
}
Aggregations