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