本文整理匯總了Java中org.apache.flink.configuration.Configuration.setFloat方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.setFloat方法的具體用法?Java Configuration.setFloat怎麽用?Java Configuration.setFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.setFloat方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: hasNewNetworkBufConfMixed
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Verifies that {@link TaskManagerServicesConfiguration#hasNewNetworkBufConf(Configuration)}
* returns the correct result for mixed old/new configurations.
*/
@SuppressWarnings("deprecation")
@Test
public void hasNewNetworkBufConfMixed() throws Exception {
Configuration config = new Configuration();
assertTrue(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config));
config.setInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS, 1);
assertFalse(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config));
// old + 1 new parameter = new:
Configuration config1 = config.clone();
config1.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.1f);
assertTrue(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config1));
config1 = config.clone();
config1.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN, 1024);
assertTrue(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config1));
config1 = config.clone();
config1.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX, 1024);
assertTrue(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config1));
}
示例3: calculateNetworkBufMixed
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Test for {@link TaskManagerServices#calculateNetworkBufferMemory(long, Configuration)} using mixed
* old/new configurations.
*/
@SuppressWarnings("deprecation")
@Test
public void calculateNetworkBufMixed() throws Exception {
Configuration config = new Configuration();
config.setInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS, 1);
final Float defaultFrac = TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION.defaultValue();
final Long defaultMin = TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN.defaultValue();
final Long defaultMax = TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX.defaultValue();
// old + 1 new parameter = new:
Configuration config1 = config.clone();
config1.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.1f);
assertEquals(enforceBounds((long) (0.1f * (10L << 20)), defaultMin, defaultMax),
TaskManagerServices.calculateNetworkBufferMemory((64L << 20 + 1), config1));
assertEquals(enforceBounds((long) (0.1f * (10L << 30)), defaultMin, defaultMax),
TaskManagerServices.calculateNetworkBufferMemory((10L << 30), config1));
config1 = config.clone();
long newMin = TaskManagerOptions.MEMORY_SEGMENT_SIZE.defaultValue(); // smallest value possible
config1.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN, newMin);
assertEquals(enforceBounds((long) (defaultFrac * (10L << 20)), newMin, defaultMax),
TaskManagerServices.calculateNetworkBufferMemory((10L << 20), config1));
assertEquals(enforceBounds((long) (defaultFrac * (10L << 30)), newMin, defaultMax),
TaskManagerServices.calculateNetworkBufferMemory((10L << 30), config1));
config1 = config.clone();
long newMax = Math.max(64L << 20 + 1, TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN.defaultValue());
config1.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX, newMax);
assertEquals(enforceBounds((long) (defaultFrac * (10L << 20)), defaultMin, newMax),
TaskManagerServices.calculateNetworkBufferMemory((64L << 20 + 1), config1));
assertEquals(enforceBounds((long) (defaultFrac * (10L << 30)), defaultMin, newMax),
TaskManagerServices.calculateNetworkBufferMemory((10L << 30), config1));
assertTrue(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config1));
// old + any new parameter = new:
calculateNetworkBufNew(config);
}
示例4: getConfig
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Returns a flink configuration object with the given values.
*
* @param javaMemMB
* total JVM memory to use (in megabytes)
* @param useOffHeap
* whether to use off-heap memory (<tt>true</tt>) or not (<tt>false</tt>)
* @param netBufMemFrac
* fraction of JVM memory to use for network buffers
* @param netBufMemMin
* minimum memory size for network buffers (in bytes)
* @param netBufMemMax
* maximum memory size for network buffers (in bytes)
* @param managedMemSizeMB
* amount of managed memory (in megabytes)
* @param managedMemFrac
* fraction of free memory to use for managed memory (if <tt>managedMemSizeMB</tt> is
* <tt>-1</tt>)
*
* @return flink configuration
*/
private static Configuration getConfig(
final int javaMemMB, final boolean useOffHeap, final float netBufMemFrac,
final long netBufMemMin, final long netBufMemMax, final int managedMemSizeMB,
final float managedMemFrac) {
Configuration config = new Configuration();
config.setLong(KEY_TASKM_MEM_SIZE, javaMemMB);
config.setBoolean(TaskManagerOptions.MEMORY_OFF_HEAP, useOffHeap);
config.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, netBufMemFrac);
config.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN, netBufMemMin);
config.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX, netBufMemMax);
config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, managedMemSizeMB);
config.setFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION, managedMemFrac);
return config;
}