Search in sources :

Example 16 with IllegalConfigurationException

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

the class YarnClusterDescriptorTest method testFailIfTaskSlotsHigherThanMaxVcores.

@Test
public void testFailIfTaskSlotsHigherThanMaxVcores() {
    YarnClusterDescriptor clusterDescriptor = new YarnClusterDescriptor();
    clusterDescriptor.setLocalJarPath(new Path(flinkJar.getPath()));
    clusterDescriptor.setFlinkConfiguration(new Configuration());
    clusterDescriptor.setConfigurationDirectory(temporaryFolder.getRoot().getAbsolutePath());
    clusterDescriptor.setConfigurationFilePath(new Path(flinkConf.getPath()));
    // configure slots too high
    clusterDescriptor.setTaskManagerSlots(Integer.MAX_VALUE);
    try {
        clusterDescriptor.deploy();
        fail("The deploy call should have failed.");
    } catch (RuntimeException e) {
        // we expect the cause to be an IllegalConfigurationException
        if (!(e.getCause() instanceof IllegalConfigurationException)) {
            throw e;
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.flink.configuration.Configuration) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) Test(org.junit.Test)

Example 17 with IllegalConfigurationException

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

the class YarnPreConfiguredMasterHaServicesTest method testMissingRmConfiguration.

@Test
public void testMissingRmConfiguration() throws Exception {
    final Configuration flinkConfig = new Configuration();
    // missing resource manager address
    try {
        new YarnPreConfiguredMasterNonHaServices(flinkConfig, hadoopConfig);
        fail();
    } catch (IllegalConfigurationException e) {
    // expected
    }
    flinkConfig.setString(YarnConfigOptions.APP_MASTER_RPC_ADDRESS, "localhost");
    // missing resource manager port
    try {
        new YarnPreConfiguredMasterNonHaServices(flinkConfig, hadoopConfig);
        fail();
    } catch (IllegalConfigurationException e) {
    // expected
    }
    flinkConfig.setInteger(YarnConfigOptions.APP_MASTER_RPC_PORT, 1427);
    // now everything is good ;-)
    new YarnPreConfiguredMasterNonHaServices(flinkConfig, hadoopConfig).closeAndCleanupAllData();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) Test(org.junit.Test)

Example 18 with IllegalConfigurationException

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

the class JobManagerServices method fromConfiguration.

// ------------------------------------------------------------------------
//  Creating the components from a configuration 
// ------------------------------------------------------------------------
public static JobManagerServices fromConfiguration(Configuration config, HighAvailabilityServices haServices) throws Exception {
    final BlobServer blobServer = new BlobServer(config, haServices);
    final long cleanupInterval = config.getLong(ConfigConstants.LIBRARY_CACHE_MANAGER_CLEANUP_INTERVAL, ConfigConstants.DEFAULT_LIBRARY_CACHE_MANAGER_CLEANUP_INTERVAL) * 1000;
    final BlobLibraryCacheManager libraryCacheManager = new BlobLibraryCacheManager(blobServer, cleanupInterval);
    final FiniteDuration timeout;
    try {
        timeout = AkkaUtils.getTimeout(config);
    } catch (NumberFormatException e) {
        throw new IllegalConfigurationException(AkkaUtils.formatDurationParingErrorMessage());
    }
    final ScheduledExecutorService futureExecutor = Executors.newScheduledThreadPool(Hardware.getNumberCPUCores(), new ExecutorThreadFactory("jobmanager-future"));
    return new JobManagerServices(futureExecutor, libraryCacheManager, RestartStrategyFactory.createRestartStrategyFactory(config), Time.of(timeout.length(), timeout.unit()));
}
Also used : ExecutorThreadFactory(org.apache.flink.runtime.util.ExecutorThreadFactory) BlobLibraryCacheManager(org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) FiniteDuration(scala.concurrent.duration.FiniteDuration) BlobServer(org.apache.flink.runtime.blob.BlobServer)

Example 19 with IllegalConfigurationException

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

the class ZooKeeperUtils method startCuratorFramework.

/**
	 * Starts a {@link CuratorFramework} instance and connects it to the given ZooKeeper
	 * quorum.
	 *
	 * @param configuration {@link Configuration} object containing the configuration values
	 * @return {@link CuratorFramework} instance
	 */
public static CuratorFramework startCuratorFramework(Configuration configuration) {
    Preconditions.checkNotNull(configuration, "configuration");
    String zkQuorum = configuration.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
    if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
        throw new RuntimeException("No valid ZooKeeper quorum has been specified. " + "You can specify the quorum via the configuration key '" + HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM.key() + "'.");
    }
    int sessionTimeout = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_SESSION_TIMEOUT);
    int connectionTimeout = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_CONNECTION_TIMEOUT);
    int retryWait = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_RETRY_WAIT);
    int maxRetryAttempts = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_MAX_RETRY_ATTEMPTS);
    String root = configuration.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_ROOT);
    String namespace = configuration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
    boolean disableSaslClient = configuration.getBoolean(ConfigConstants.ZOOKEEPER_SASL_DISABLE, ConfigConstants.DEFAULT_ZOOKEEPER_SASL_DISABLE);
    ACLProvider aclProvider;
    ZkClientACLMode aclMode = ZkClientACLMode.fromConfig(configuration);
    if (disableSaslClient && aclMode == ZkClientACLMode.CREATOR) {
        String errorMessage = "Cannot set ACL role to " + aclMode + "  since SASL authentication is " + "disabled through the " + ConfigConstants.ZOOKEEPER_SASL_DISABLE + " property";
        LOG.warn(errorMessage);
        throw new IllegalConfigurationException(errorMessage);
    }
    if (aclMode == ZkClientACLMode.CREATOR) {
        LOG.info("Enforcing creator for ZK connections");
        aclProvider = new SecureAclProvider();
    } else {
        LOG.info("Enforcing default ACL for ZK connections");
        aclProvider = new DefaultACLProvider();
    }
    String rootWithNamespace = generateZookeeperPath(root, namespace);
    LOG.info("Using '{}' as Zookeeper namespace.", rootWithNamespace);
    CuratorFramework cf = CuratorFrameworkFactory.builder().connectString(zkQuorum).sessionTimeoutMs(sessionTimeout).connectionTimeoutMs(connectionTimeout).retryPolicy(new ExponentialBackoffRetry(retryWait, maxRetryAttempts)).namespace(rootWithNamespace.startsWith("/") ? rootWithNamespace.substring(1) : rootWithNamespace).aclProvider(aclProvider).build();
    cf.start();
    return cf;
}
Also used : ACLProvider(org.apache.curator.framework.api.ACLProvider) DefaultACLProvider(org.apache.curator.framework.imps.DefaultACLProvider) CuratorFramework(org.apache.curator.framework.CuratorFramework) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) DefaultACLProvider(org.apache.curator.framework.imps.DefaultACLProvider) CompletedCheckpoint(org.apache.flink.runtime.checkpoint.CompletedCheckpoint)

Example 20 with IllegalConfigurationException

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

the class FlinkZooKeeperQuorumPeer method writeMyIdToDataDir.

/**
	 * Write 'myid' file to the 'dataDir' in the given ZooKeeper configuration.
	 *
	 * <blockquote>
	 * Every machine that is part of the ZooKeeper ensemble should know about every other machine in
	 * the ensemble. You accomplish this with the series of lines of the form
	 * server.id=host:port:port. The parameters host and port are straightforward. You attribute the
	 * server id to each machine by creating a file named myid, one for each server, which resides
	 * in that server's data directory, as specified by the configuration file parameter dataDir.
	 * </blockquote>
	 *
	 * @param zkProps ZooKeeper configuration.
	 * @param id      The ID of this {@link QuorumPeer}.
	 * @throws IllegalConfigurationException Thrown, if 'dataDir' property not set in given
	 *                                       ZooKeeper properties.
	 * @throws IOException                   Thrown, if 'dataDir' does not exist and cannot be
	 *                                       created.
	 * @see <a href="http://zookeeper.apache.org/doc/r3.4.6/zookeeperAdmin.html">
	 * ZooKeeper Administrator's Guide</a>
	 */
private static void writeMyIdToDataDir(Properties zkProps, int id) throws IOException {
    // Check dataDir and create if necessary
    if (zkProps.getProperty("dataDir") == null) {
        throw new IllegalConfigurationException("No dataDir configured.");
    }
    File dataDir = new File(zkProps.getProperty("dataDir"));
    if (!dataDir.isDirectory() && !dataDir.mkdirs()) {
        throw new IOException("Cannot create dataDir '" + dataDir + "'.");
    }
    dataDir.deleteOnExit();
    LOG.info("Writing {} to myid file in 'dataDir'.", id);
    // while the PrintWriter swallows errors
    try (FileWriter writer = new FileWriter(new File(dataDir, "myid"))) {
        writer.write(String.valueOf(id));
    }
}
Also used : FileWriter(java.io.FileWriter) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) IOException(java.io.IOException) File(java.io.File)

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