本文整理匯總了Java中org.apache.flink.configuration.Configuration.getLong方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.getLong方法的具體用法?Java Configuration.getLong怎麽用?Java Configuration.getLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.getLong方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromConfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static RestHandlerConfiguration fromConfiguration(Configuration configuration) {
final long refreshInterval = configuration.getLong(WebOptions.REFRESH_INTERVAL);
final int maxCheckpointStatisticCacheEntries = configuration.getInteger(WebOptions.CHECKPOINTS_HISTORY_SIZE);
final Time timeout = Time.milliseconds(configuration.getLong(WebOptions.TIMEOUT));
final String rootDir = "flink-web-" + UUID.randomUUID();
final File tmpDir = new File(configuration.getString(WebOptions.TMP_DIR), rootDir);
final Map<String, String> responseHeaders = Collections.singletonMap(
HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,
configuration.getString(WebOptions.ACCESS_CONTROL_ALLOW_ORIGIN));
return new RestHandlerConfiguration(
refreshInterval,
maxCheckpointStatisticCacheEntries,
timeout,
tmpDir,
responseHeaders);
}
示例2: TransientBlobCache
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Instantiates a new BLOB cache.
*
* @param serverAddress
* address of the {@link BlobServer} to use for fetching files from
* @param blobClientConfig
* global configuration
*
* @throws IOException
* thrown if the (local or distributed) file storage cannot be created or is not usable
*/
public TransientBlobCache(
final InetSocketAddress serverAddress,
final Configuration blobClientConfig) throws IOException {
super(serverAddress, blobClientConfig, new VoidBlobStore(),
LoggerFactory.getLogger(TransientBlobCache.class));
// Initializing the clean up task
this.cleanupTimer = new Timer(true);
this.cleanupInterval = blobClientConfig.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
this.cleanupTimer
.schedule(new TransientBlobCleanupTask(blobExpiryTimes, readWriteLock.writeLock(),
storageDir, log), cleanupInterval, cleanupInterval);
}
示例3: SummarizationJobParameters
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public SummarizationJobParameters(Configuration conf) {
System.out.println("Creating job parameters from configuration: " + conf);
timelyHostname = conf.getString("timelyHostname", null);
timelyTcpPort = conf.getInteger("timelyTcpPort", 4241);
timelyHttpsPort = conf.getInteger("timelyHttpsPort", 4242);
timelyWssPort = conf.getInteger("timelyWssPort", 4243);
doLogin = conf.getBoolean("doLogin", false);
timelyUsername = conf.getString("timelyUsername", null);
timelyPassword = conf.getString("timelyPassword", null);
keyStoreFile = conf.getString("keyStoreFile", null);
keyStoreType = conf.getString("keyStoreType", "JKS");
keyStorePass = conf.getString("keyStorePass", null);
trustStoreFile = conf.getString("trustStoreFile", null);
trustStoreType = conf.getString("trustStoreType", "JKS");
trustStorePass = conf.getString("trustStorePass", null);
hostVerificationEnabled = conf.getBoolean("hostVerificationEnabled", true);
bufferSize = conf.getInteger("bufferSize", 10485760);
String metricNames = conf.getString("metrics", null);
if (null != metricNames) {
metrics = metricNames.split(",");
} else {
metrics = null;
}
startTime = conf.getLong("startTime", 0L);
endTime = conf.getLong("endTime", 0L);
interval = conf.getString("interval", null);
intervalUnits = conf.getString("intervalUnits", null);
}
示例4: compareNetworkBufJavaVsScript
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Calculates the heap size via
* {@link TaskManagerServices#calculateHeapSizeMB(long, Configuration)} and the shell script
* and verifies that these are equal.
*
* @param config flink configuration
* @param tolerance tolerate values that are off by this factor (0.01 = 1%)
*/
private void compareNetworkBufJavaVsScript(final Configuration config, final float tolerance)
throws IOException {
final long totalJavaMemorySizeMB = config.getLong(KEY_TASKM_MEM_SIZE, 0L);
long javaNetworkBufMem = TaskManagerServices.calculateNetworkBufferMemory(totalJavaMemorySizeMB << 20, config);
String[] command = {"src/test/bin/calcTMNetBufMem.sh",
String.valueOf(totalJavaMemorySizeMB),
String.valueOf(config.getFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION)),
String.valueOf(config.getLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN)),
String.valueOf(config.getLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX))};
String scriptOutput = executeScript(command);
long absoluteTolerance = (long) (javaNetworkBufMem * tolerance);
if (absoluteTolerance < 1) {
assertEquals(
"Different network buffer memory sizes with configuration: " + config.toString(),
String.valueOf(javaNetworkBufMem), scriptOutput);
} else {
Long scriptNetworkBufMem = Long.valueOf(scriptOutput);
assertThat(
"Different network buffer memory sizes (Java: " + javaNetworkBufMem + ", Script: " + scriptNetworkBufMem +
") with configuration: " + config.toString(), scriptNetworkBufMem,
allOf(greaterThanOrEqualTo(javaNetworkBufMem - absoluteTolerance),
lessThanOrEqualTo(javaNetworkBufMem + absoluteTolerance)));
}
}
示例5: compareHeapSizeJavaVsScript
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Calculates the heap size via
* {@link TaskManagerServices#calculateHeapSizeMB(long, Configuration)} and the shell script
* and verifies that these are equal.
*
* @param config flink configuration
* @param tolerance tolerate values that are off by this factor (0.01 = 1%)
*/
private void compareHeapSizeJavaVsScript(final Configuration config, float tolerance)
throws IOException {
final long totalJavaMemorySizeMB = config.getLong(KEY_TASKM_MEM_SIZE, 0L);
long javaHeapSizeMB = TaskManagerServices.calculateHeapSizeMB(totalJavaMemorySizeMB, config);
String[] command = {"src/test/bin/calcTMHeapSizeMB.sh",
String.valueOf(totalJavaMemorySizeMB),
String.valueOf(config.getBoolean(TaskManagerOptions.MEMORY_OFF_HEAP)),
String.valueOf(config.getFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION)),
String.valueOf(config.getLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN)),
String.valueOf(config.getLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX)),
String.valueOf(config.getLong(TaskManagerOptions.MANAGED_MEMORY_SIZE)),
String.valueOf(config.getFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION))};
String scriptOutput = executeScript(command);
long absoluteTolerance = (long) (javaHeapSizeMB * tolerance);
if (absoluteTolerance < 1) {
assertEquals("Different heap sizes with configuration: " + config.toString(),
String.valueOf(javaHeapSizeMB), scriptOutput);
} else {
Long scriptHeapSizeMB = Long.valueOf(scriptOutput);
assertThat(
"Different heap sizes (Java: " + javaHeapSizeMB + ", Script: " + scriptHeapSizeMB +
") with configuration: " + config.toString(), scriptHeapSizeMB,
allOf(greaterThanOrEqualTo(javaHeapSizeMB - absoluteTolerance),
lessThanOrEqualTo(javaHeapSizeMB + absoluteTolerance)));
}
}
示例6: initDefaultsFromConfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Initialize defaults for input format. Needs to be a static method because it is configured for local
* cluster execution, see LocalFlinkMiniCluster.
* @param configuration The configuration to load defaults from
*/
private static void initDefaultsFromConfiguration(Configuration configuration) {
final long to = configuration.getLong(ConfigConstants.FS_STREAM_OPENING_TIMEOUT_KEY,
ConfigConstants.DEFAULT_FS_STREAM_OPENING_TIMEOUT);
if (to < 0) {
LOG.error("Invalid timeout value for filesystem stream opening: " + to + ". Using default value of " +
ConfigConstants.DEFAULT_FS_STREAM_OPENING_TIMEOUT);
DEFAULT_OPENING_TIMEOUT = ConfigConstants.DEFAULT_FS_STREAM_OPENING_TIMEOUT;
} else if (to == 0) {
DEFAULT_OPENING_TIMEOUT = 300000; // 5 minutes
} else {
DEFAULT_OPENING_TIMEOUT = to;
}
}
示例7: configure
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Override
public void configure(Configuration parameters) {
super.configure(parameters);
// read own parameters
this.blockSize = parameters.getLong(BLOCK_SIZE_PARAMETER_KEY, NATIVE_BLOCK_SIZE);
if (this.blockSize < 1 && this.blockSize != NATIVE_BLOCK_SIZE) {
throw new IllegalArgumentException("The block size parameter must be set and larger than 0.");
}
if (this.blockSize > Integer.MAX_VALUE) {
throw new UnsupportedOperationException("Currently only block size up to Integer.MAX_VALUE are supported");
}
}
示例8: fromConfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Creates an HeartbeatServices instance from a {@link Configuration}.
*
* @param configuration Configuration to be used for the HeartbeatServices creation
* @return An HeartbeatServices instance created from the given configuration
*/
public static HeartbeatServices fromConfiguration(Configuration configuration) {
long heartbeatInterval = configuration.getLong(HeartbeatManagerOptions.HEARTBEAT_INTERVAL);
long heartbeatTimeout = configuration.getLong(HeartbeatManagerOptions.HEARTBEAT_TIMEOUT);
return new HeartbeatServices(heartbeatInterval, heartbeatTimeout);
}
示例9: calculateHeapSizeMB
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Calculates the amount of heap memory to use (to set via <tt>-Xmx</tt> and <tt>-Xms</tt>)
* based on the total memory to use and the given configuration parameters.
*
* @param totalJavaMemorySizeMB
* overall available memory to use (heap and off-heap)
* @param config
* configuration object
*
* @return heap memory to use (in megabytes)
*/
public static long calculateHeapSizeMB(long totalJavaMemorySizeMB, Configuration config) {
Preconditions.checkArgument(totalJavaMemorySizeMB > 0);
// subtract the Java memory used for network buffers (always off-heap)
final long networkBufMB =
calculateNetworkBufferMemory(
totalJavaMemorySizeMB << 20, // megabytes to bytes
config) >> 20; // bytes to megabytes
final long remainingJavaMemorySizeMB = totalJavaMemorySizeMB - networkBufMB;
// split the available Java memory between heap and off-heap
final boolean useOffHeap = config.getBoolean(TaskManagerOptions.MEMORY_OFF_HEAP);
final long heapSizeMB;
if (useOffHeap) {
long offHeapSize = config.getLong(TaskManagerOptions.MANAGED_MEMORY_SIZE);
if (offHeapSize <= 0) {
// calculate off-heap section via fraction
double fraction = config.getFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION);
offHeapSize = (long) (fraction * remainingJavaMemorySizeMB);
}
TaskManagerServicesConfiguration
.checkConfigParameter(offHeapSize < remainingJavaMemorySizeMB, offHeapSize,
TaskManagerOptions.MANAGED_MEMORY_SIZE.key(),
"Managed memory size too large for " + networkBufMB +
" MB network buffer memory and a total of " + totalJavaMemorySizeMB +
" MB JVM memory");
heapSizeMB = remainingJavaMemorySizeMB - offHeapSize;
} else {
heapSizeMB = remainingJavaMemorySizeMB;
}
return heapSizeMB;
}
示例10: PermanentBlobCache
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Instantiates a new cache for permanent BLOBs which are also available in an HA store.
*
* @param serverAddress
* address of the {@link BlobServer} to use for fetching files from
* @param blobClientConfig
* global configuration
* @param blobView
* (distributed) HA blob store file system to retrieve files from first
*
* @throws IOException
* thrown if the (local or distributed) file storage cannot be created or is not usable
*/
public PermanentBlobCache(
final InetSocketAddress serverAddress,
final Configuration blobClientConfig,
final BlobView blobView) throws IOException {
super(serverAddress, blobClientConfig, blobView,
LoggerFactory.getLogger(PermanentBlobCache.class));
// Initializing the clean up task
this.cleanupTimer = new Timer(true);
this.cleanupInterval = blobClientConfig.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
this.cleanupTimer.schedule(new PermanentBlobCleanupTask(), cleanupInterval, cleanupInterval);
}
示例11: BlobCache
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Instantiates a new BLOB cache.
*
* @param serverAddress
* address of the {@link BlobServer} to use for fetching files from
* @param blobClientConfig
* global configuration
* @param blobView
* (distributed) blob store file system to retrieve files from first
*
* @throws IOException
* thrown if the (local or distributed) file storage cannot be created or is not usable
*/
public BlobCache(
final InetSocketAddress serverAddress,
final Configuration blobClientConfig,
final BlobView blobView) throws IOException {
this.serverAddress = checkNotNull(serverAddress);
this.blobClientConfig = checkNotNull(blobClientConfig);
this.blobView = checkNotNull(blobView, "blobStore");
// configure and create the storage directory
String storageDirectory = blobClientConfig.getString(BlobServerOptions.STORAGE_DIRECTORY);
this.storageDir = BlobUtils.initLocalStorageDirectory(storageDirectory);
LOG.info("Created BLOB cache storage directory " + storageDir);
// configure the number of fetch retries
final int fetchRetries = blobClientConfig.getInteger(BlobServerOptions.FETCH_RETRIES);
if (fetchRetries >= 0) {
this.numFetchRetries = fetchRetries;
}
else {
LOG.warn("Invalid value for {}. System will attempt no retires on failed fetches of BLOBs.",
BlobServerOptions.FETCH_RETRIES.key());
this.numFetchRetries = 0;
}
// Initializing the clean up task
this.cleanupTimer = new Timer(true);
cleanupInterval = blobClientConfig.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
this.cleanupTimer.schedule(this, cleanupInterval, cleanupInterval);
// Add shutdown hook to delete storage directory
shutdownHook = BlobUtils.addShutdownHook(this, LOG);
}
示例12: fromConfig
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Parses and returns the settings for connection limiting, for the file system with
* the given file system scheme.
*
* @param config The configuration to check.
* @param fsScheme The file system scheme.
*
* @return The parsed configuration, or null, if no connection limiting is configured.
*/
@Nullable
public static ConnectionLimitingSettings fromConfig(Configuration config, String fsScheme) {
checkNotNull(fsScheme, "fsScheme");
checkNotNull(config, "config");
final ConfigOption<Integer> totalLimitOption = CoreOptions.fileSystemConnectionLimit(fsScheme);
final ConfigOption<Integer> limitInOption = CoreOptions.fileSystemConnectionLimitIn(fsScheme);
final ConfigOption<Integer> limitOutOption = CoreOptions.fileSystemConnectionLimitOut(fsScheme);
final int totalLimit = config.getInteger(totalLimitOption);
final int limitIn = config.getInteger(limitInOption);
final int limitOut = config.getInteger(limitOutOption);
checkLimit(totalLimit, totalLimitOption);
checkLimit(limitIn, limitInOption);
checkLimit(limitOut, limitOutOption);
// create the settings only, if at least one limit is configured
if (totalLimit <= 0 && limitIn <= 0 && limitOut <= 0) {
// no limit configured
return null;
}
else {
final ConfigOption<Long> openTimeoutOption =
CoreOptions.fileSystemConnectionLimitTimeout(fsScheme);
final ConfigOption<Long> inactivityTimeoutOption =
CoreOptions.fileSystemConnectionLimitStreamInactivityTimeout(fsScheme);
final long openTimeout = config.getLong(openTimeoutOption);
final long inactivityTimeout = config.getLong(inactivityTimeoutOption);
checkTimeout(openTimeout, openTimeoutOption);
checkTimeout(inactivityTimeout, inactivityTimeoutOption);
return new ConnectionLimitingSettings(
totalLimit == -1 ? 0 : totalLimit,
limitIn == -1 ? 0 : limitIn,
limitOut == -1 ? 0 : limitOut,
openTimeout,
inactivityTimeout);
}
}
示例13: PythonReceiver
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public PythonReceiver(Configuration config, boolean usesByteArray) {
readAsByteArray = usesByteArray;
mappedFileSizeBytes = config.getLong(PythonOptions.MMAP_FILE_SIZE) << 10;
}
示例14: PythonSender
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
protected PythonSender(Configuration config) {
this.config = config;
mappedFileSizeBytes = config.getLong(PythonOptions.MMAP_FILE_SIZE) << 10;
}
示例15: calculateNetworkBufferMemory
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Calculates the amount of memory used for network buffers based on the total memory to use and
* the according configuration parameters.
*
* <p>The following configuration parameters are involved:
* <ul>
* <li>{@link TaskManagerOptions#NETWORK_BUFFERS_MEMORY_FRACTION},</li>
* <li>{@link TaskManagerOptions#NETWORK_BUFFERS_MEMORY_MIN},</li>
* <li>{@link TaskManagerOptions#NETWORK_BUFFERS_MEMORY_MAX}, and</li>
* <li>{@link TaskManagerOptions#NETWORK_NUM_BUFFERS} (fallback if the ones above do not exist)</li>
* </ul>.
*
* @param totalJavaMemorySize
* overall available memory to use (heap and off-heap, in bytes)
* @param config
* configuration object
*
* @return memory to use for network buffers (in bytes); at least one memory segment
*/
@SuppressWarnings("deprecation")
public static long calculateNetworkBufferMemory(long totalJavaMemorySize, Configuration config) {
Preconditions.checkArgument(totalJavaMemorySize > 0);
int segmentSize = config.getInteger(TaskManagerOptions.MEMORY_SEGMENT_SIZE);
final long networkBufBytes;
if (TaskManagerServicesConfiguration.hasNewNetworkBufConf(config)) {
// new configuration based on fractions of available memory with selectable min and max
float networkBufFraction = config.getFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION);
long networkBufMin = config.getLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN);
long networkBufMax = config.getLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX);
TaskManagerServicesConfiguration
.checkNetworkBufferConfig(segmentSize, networkBufFraction, networkBufMin, networkBufMax);
networkBufBytes = Math.min(networkBufMax, Math.max(networkBufMin,
(long) (networkBufFraction * totalJavaMemorySize)));
TaskManagerServicesConfiguration
.checkConfigParameter(networkBufBytes < totalJavaMemorySize,
"(" + networkBufFraction + ", " + networkBufMin + ", " + networkBufMax + ")",
"(" + TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION.key() + ", " +
TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN.key() + ", " +
TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX.key() + ")",
"Network buffer memory size too large: " + networkBufBytes + " >= " +
totalJavaMemorySize + " (total JVM memory size)");
TaskManagerServicesConfiguration
.checkConfigParameter(networkBufBytes >= segmentSize,
"(" + networkBufFraction + ", " + networkBufMin + ", " + networkBufMax + ")",
"(" + TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION.key() + ", " +
TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN.key() + ", " +
TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX.key() + ")",
"Network buffer memory size too small: " + networkBufBytes + " < " +
segmentSize + " (" + TaskManagerOptions.MEMORY_SEGMENT_SIZE.key() + ")");
} else {
// use old (deprecated) network buffers parameter
int numNetworkBuffers = config.getInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS);
networkBufBytes = (long) numNetworkBuffers * (long) segmentSize;
TaskManagerServicesConfiguration.checkNetworkConfigOld(numNetworkBuffers);
TaskManagerServicesConfiguration
.checkConfigParameter(networkBufBytes < totalJavaMemorySize,
networkBufBytes, TaskManagerOptions.NETWORK_NUM_BUFFERS.key(),
"Network buffer memory size too large: " + networkBufBytes + " >= " +
totalJavaMemorySize + " (total JVM memory size)");
TaskManagerServicesConfiguration
.checkConfigParameter(networkBufBytes >= segmentSize,
networkBufBytes, TaskManagerOptions.NETWORK_NUM_BUFFERS.key(),
"Network buffer memory size too small: " + networkBufBytes + " < " +
segmentSize + " (" + TaskManagerOptions.MEMORY_SEGMENT_SIZE.key() + ")");
}
return networkBufBytes;
}