本文整理匯總了Java中org.apache.flink.configuration.Configuration.setBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.setBoolean方法的具體用法?Java Configuration.setBoolean怎麽用?Java Configuration.setBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.setBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateHeapSizeMB
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Test for {@link TaskManagerServices#calculateHeapSizeMB(long, Configuration)} with some
* manually calculated scenarios.
*/
@Test
public void calculateHeapSizeMB() throws Exception {
Configuration config = new Configuration();
config.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.1f);
config.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN, 64L << 20); // 64MB
config.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX, 1L << 30); // 1GB
config.setBoolean(TaskManagerOptions.MEMORY_OFF_HEAP, false);
assertEquals(900, TaskManagerServices.calculateHeapSizeMB(1000, config));
config.setBoolean(TaskManagerOptions.MEMORY_OFF_HEAP, false);
config.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.2f);
assertEquals(800, TaskManagerServices.calculateHeapSizeMB(1000, config));
config.setBoolean(TaskManagerOptions.MEMORY_OFF_HEAP, true);
config.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.1f);
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 10); // 10MB
assertEquals(890, TaskManagerServices.calculateHeapSizeMB(1000, config));
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, -1); // use fraction of given memory
config.setFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION, 0.1f); // 10%
assertEquals(810, TaskManagerServices.calculateHeapSizeMB(1000, config));
}
示例2: testCreateSSLServerContextWithMultiProtocols
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Tests if SSL Server Context creation fails with bad SSL configuration.
*/
@Test
public void testCreateSSLServerContextWithMultiProtocols() {
Configuration serverConfig = new Configuration();
serverConfig.setBoolean(SecurityOptions.SSL_ENABLED, true);
serverConfig.setString(SecurityOptions.SSL_KEYSTORE, "src/test/resources/local127.keystore");
serverConfig.setString(SecurityOptions.SSL_KEYSTORE_PASSWORD, "password");
serverConfig.setString(SecurityOptions.SSL_KEY_PASSWORD, "password");
serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1,TLSv1.2");
try {
SSLContext serverContext = SSLUtils.createSSLServerContext(serverConfig);
Assert.fail("SSL server context created even with multiple protocols set ");
} catch (Exception e) {
// Exception here is valid
}
}
示例3: setup
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@BeforeClass
public static void setup() {
try {
Configuration config = new Configuration();
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 4L);
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TMS);
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, NUM_SLOTS_PER_TM);
config.setInteger(QueryableStateOptions.CLIENT_NETWORK_THREADS, 1);
config.setBoolean(QueryableStateOptions.SERVER_ENABLE, true);
config.setInteger(QueryableStateOptions.SERVER_NETWORK_THREADS, 1);
cluster = new TestingCluster(config, false);
cluster.start(true);
testActorSystem = AkkaUtils.createDefaultActorSystem();
// verify that we are not in HA mode
Assert.assertTrue(cluster.haMode() == HighAvailabilityMode.NONE);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例4: setup
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@BeforeClass
public static void setup() {
try {
Configuration config = new Configuration();
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 4L);
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TMS);
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, NUM_SLOTS_PER_TM);
config.setInteger(QueryableStateOptions.CLIENT_NETWORK_THREADS, 1);
config.setBoolean(QueryableStateOptions.SERVER_ENABLE, true);
config.setInteger(QueryableStateOptions.SERVER_NETWORK_THREADS, 1);
cluster = new TestingCluster(config, false);
cluster.start(true);
testActorSystem = AkkaUtils.createDefaultActorSystem();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例5: testCreateSSLClientContextMisconfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Tests if SSL Client Context creation fails with bad SSL configuration.
*/
@Test
public void testCreateSSLClientContextMisconfiguration() {
Configuration clientConfig = new Configuration();
clientConfig.setBoolean(SecurityOptions.SSL_ENABLED, true);
clientConfig.setString(SecurityOptions.SSL_TRUSTSTORE, "src/test/resources/local127.truststore");
clientConfig.setString(SecurityOptions.SSL_TRUSTSTORE_PASSWORD, "badpassword");
try {
SSLContext clientContext = SSLUtils.createSSLClientContext(clientConfig);
Assert.fail("SSL client context created even with bad SSL configuration ");
} catch (Exception e) {
// Exception here is valid
}
}
示例6: writeParametersToConfig
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Override
public void writeParametersToConfig(Configuration config) {
for (int i = 0; i < this.positions.length; i++) {
if (this.positions[i] < 0) {
throw new IllegalArgumentException("The key position " + i + " is invalid: " + this.positions[i]);
}
if (this.types[i] == null || !Value.class.isAssignableFrom(this.types[i])) {
throw new IllegalArgumentException("The key type " + i + " is null or not implenting the interface " +
Value.class.getName() + ".");
}
}
// write the config
config.setInteger(NUM_KEYS, this.positions.length);
for (int i = 0; i < this.positions.length; i++) {
config.setInteger(KEY_POS_PREFIX + i, this.positions[i]);
config.setString(KEY_CLASS_PREFIX + i, this.types[i].getName());
config.setBoolean(KEY_SORT_DIRECTION_PREFIX + i, this.sortDirections[i]);
}
}
示例7: setup
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static void setup(int proxyPortRangeStart, int serverPortRangeStart) {
try {
Configuration config = new Configuration();
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 4L);
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TMS);
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, NUM_SLOTS_PER_TM);
config.setInteger(QueryableStateOptions.CLIENT_NETWORK_THREADS, 1);
config.setBoolean(QueryableStateOptions.SERVER_ENABLE, true);
config.setInteger(QueryableStateOptions.SERVER_NETWORK_THREADS, 1);
config.setString(QueryableStateOptions.PROXY_PORT_RANGE, proxyPortRangeStart + "-" + (proxyPortRangeStart + NUM_TMS));
config.setString(QueryableStateOptions.SERVER_PORT_RANGE, serverPortRangeStart + "-" + (serverPortRangeStart + NUM_TMS));
cluster = new TestingCluster(config, false);
cluster.start(true);
client = new QueryableStateClient("localhost", proxyPortRangeStart);
// verify that we are not in HA mode
Assert.assertTrue(cluster.haMode() == HighAvailabilityMode.NONE);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例8: testCreateSSLServerContext
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Tests if SSL Server Context is created given a valid SSL configuration.
*/
@Test
public void testCreateSSLServerContext() throws Exception {
Configuration serverConfig = new Configuration();
serverConfig.setBoolean(SecurityOptions.SSL_ENABLED, true);
serverConfig.setString(SecurityOptions.SSL_KEYSTORE, "src/test/resources/local127.keystore");
serverConfig.setString(SecurityOptions.SSL_KEYSTORE_PASSWORD, "password");
serverConfig.setString(SecurityOptions.SSL_KEY_PASSWORD, "password");
SSLContext serverContext = SSLUtils.createSSLServerContext(serverConfig);
Assert.assertNotNull(serverContext);
}
示例9: testLoadMemoryStateWithParameters
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Validates loading a memory state backend with additional parameters from the cluster configuration.
*/
@Test
public void testLoadMemoryStateWithParameters() throws Exception {
final String checkpointDir = new Path(tmp.newFolder().toURI()).toString();
final String savepointDir = new Path(tmp.newFolder().toURI()).toString();
final Path expectedCheckpointPath = new Path(checkpointDir);
final Path expectedSavepointPath = new Path(savepointDir);
final boolean async = !CheckpointingOptions.ASYNC_SNAPSHOTS.defaultValue();
// we configure with the explicit string (rather than AbstractStateBackend#X_STATE_BACKEND_NAME)
// to guard against config-breaking changes of the name
final Configuration config1 = new Configuration();
config1.setString(backendKey, "jobmanager");
config1.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
config1.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
config1.setBoolean(CheckpointingOptions.ASYNC_SNAPSHOTS, async);
final Configuration config2 = new Configuration();
config2.setString(backendKey, MemoryStateBackendFactory.class.getName());
config2.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
config2.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
config2.setBoolean(CheckpointingOptions.ASYNC_SNAPSHOTS, async);
MemoryStateBackend backend1 = (MemoryStateBackend)
StateBackendLoader.loadStateBackendFromConfig(config1, cl, null);
MemoryStateBackend backend2 = (MemoryStateBackend)
StateBackendLoader.loadStateBackendFromConfig(config2, cl, null);
assertNotNull(backend1);
assertNotNull(backend2);
assertEquals(expectedCheckpointPath, backend1.getCheckpointPath());
assertEquals(expectedCheckpointPath, backend2.getCheckpointPath());
assertEquals(expectedSavepointPath, backend1.getSavepointPath());
assertEquals(expectedSavepointPath, backend2.getSavepointPath());
assertEquals(async, backend1.isUsingAsynchronousSnapshots());
assertEquals(async, backend2.isUsingAsynchronousSnapshots());
}
示例10: testCreateSSLServerContextWithSSLDisabled
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Tests if SSL Server Context is not created if SSL is disabled.
*/
@Test
public void testCreateSSLServerContextWithSSLDisabled() throws Exception {
Configuration serverConfig = new Configuration();
serverConfig.setBoolean(SecurityOptions.SSL_ENABLED, false);
SSLContext serverContext = SSLUtils.createSSLServerContext(serverConfig);
Assert.assertNull(serverContext);
}
示例11: startCluster
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static LocalFlinkMiniCluster startCluster(
Configuration config,
boolean singleActorSystem) throws Exception {
logDir = File.createTempFile("TestBaseUtils-logdir", null);
Assert.assertTrue("Unable to delete temp file", logDir.delete());
Assert.assertTrue("Unable to create temp directory", logDir.mkdir());
Path logFile = Files.createFile(new File(logDir, "jobmanager.log").toPath());
Files.createFile(new File(logDir, "jobmanager.out").toPath());
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, TASK_MANAGER_MEMORY_SIZE);
config.setBoolean(ConfigConstants.FILESYSTEM_DEFAULT_OVERWRITE_KEY, true);
config.setString(AkkaOptions.ASK_TIMEOUT, DEFAULT_AKKA_ASK_TIMEOUT + "s");
config.setString(AkkaOptions.STARTUP_TIMEOUT, DEFAULT_AKKA_STARTUP_TIMEOUT);
config.setInteger(WebOptions.PORT, 8081);
config.setString(WebOptions.LOG_PATH, logFile.toString());
config.setString(ConfigConstants.TASK_MANAGER_LOG_PATH_KEY, logFile.toString());
LocalFlinkMiniCluster cluster = new LocalFlinkMiniCluster(config, singleActorSystem);
cluster.start();
return cluster;
}
示例12: startCluster
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Before
public void startCluster() throws Exception {
verifyJvmOptions();
Configuration config = new Configuration();
config.setBoolean(ConfigConstants.FILESYSTEM_DEFAULT_OVERWRITE_KEY, true);
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 2);
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, 4);
config.setString(AkkaOptions.ASK_TIMEOUT, TestingUtils.DEFAULT_AKKA_ASK_TIMEOUT());
config.setInteger(TaskManagerOptions.MEMORY_SEGMENT_SIZE, 4096);
config.setInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS, 2048);
this.executor = new LocalFlinkMiniCluster(config, false);
this.executor.start();
}
示例13: setup
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@BeforeClass
public static void setup() {
try {
zkServer = new TestingServer();
temporaryFolder = new TemporaryFolder();
temporaryFolder.create();
Configuration config = new Configuration();
config.setInteger(ConfigConstants.LOCAL_NUMBER_JOB_MANAGER, NUM_JMS);
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TMS);
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, NUM_SLOTS_PER_TM);
config.setBoolean(QueryableStateOptions.SERVER_ENABLE, true);
config.setInteger(QueryableStateOptions.CLIENT_NETWORK_THREADS, 2);
config.setInteger(QueryableStateOptions.SERVER_NETWORK_THREADS, 2);
config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().toString());
config.setString(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM, zkServer.getConnectString());
config.setString(HighAvailabilityOptions.HA_MODE, "zookeeper");
cluster = new TestingCluster(config, false);
cluster.start();
testActorSystem = AkkaUtils.createDefaultActorSystem();
// verify that we are in HA mode
Assert.assertTrue(cluster.haMode() == HighAvailabilityMode.ZOOKEEPER);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例14: testConfigureMemoryStateBackend
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Validates taking the application-defined memory state backend and adding additional
* parameters from the cluster configuration.
*/
@Test
public void testConfigureMemoryStateBackend() throws Exception {
final String checkpointDir = new Path(tmp.newFolder().toURI()).toString();
final String savepointDir = new Path(tmp.newFolder().toURI()).toString();
final Path expectedCheckpointPath = new Path(checkpointDir);
final Path expectedSavepointPath = new Path(savepointDir);
final int maxSize = 100;
final boolean async = !CheckpointingOptions.ASYNC_SNAPSHOTS.defaultValue();
final MemoryStateBackend backend = new MemoryStateBackend(maxSize, async);
final Configuration config = new Configuration();
config.setString(backendKey, "filesystem"); // check that this is not accidentally picked up
config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
config.setBoolean(CheckpointingOptions.ASYNC_SNAPSHOTS, !async);
StateBackend loadedBackend = StateBackendLoader.fromApplicationOrConfigOrDefault(backend, config, cl, null);
assertTrue(loadedBackend instanceof MemoryStateBackend);
final MemoryStateBackend memBackend = (MemoryStateBackend) loadedBackend;
assertEquals(expectedCheckpointPath, memBackend.getCheckpointPath());
assertEquals(expectedSavepointPath, memBackend.getSavepointPath());
assertEquals(maxSize, memBackend.getMaxStateSize());
assertEquals(async, memBackend.isUsingAsynchronousSnapshots());
}
示例15: testTotalMemoryDoesNotExceedContainerMemoryOffHeap
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* This tests that when using on-heap memory the sum of on and off heap memory does not exceed the container
* maximum.
*/
@Test
public void testTotalMemoryDoesNotExceedContainerMemoryOffHeap() {
Configuration conf = new Configuration();
conf.setBoolean(MEMORY_OFF_HEAP, true);
ContaineredTaskManagerParameters params =
ContaineredTaskManagerParameters.create(conf, CONTAINER_MEMORY, 1);
assertTrue(params.taskManagerDirectMemoryLimitMB() > 0L);
assertTrue(params.taskManagerHeapSizeMB() +
params.taskManagerDirectMemoryLimitMB() <= CONTAINER_MEMORY);
}