本文整理匯總了Java中org.apache.flink.configuration.Configuration.getInteger方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.getInteger方法的具體用法?Java Configuration.getInteger怎麽用?Java Configuration.getInteger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.getInteger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
if (!parseParameters(args))
return;
// set up execution environment
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Configuration config =
GlobalConfiguration.loadConfiguration();
int parallelism =
config.getInteger("parallelism.default", 0);
System.out.println("Paral: " + parallelism);
// get input data
DataSet<Long> input =
env.generateSequence(0, parallelism - 1);
DataSet<Long> slept = input.map(new Sleeper());
slept.count();
}
示例2: parseQueryableStateConfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Creates the {@link QueryableStateConfiguration} from the given Configuration.
*/
private static QueryableStateConfiguration parseQueryableStateConfiguration(Configuration config) {
final Iterator<Integer> proxyPorts = NetUtils.getPortRangeFromString(
config.getString(QueryableStateOptions.PROXY_PORT_RANGE,
QueryableStateOptions.PROXY_PORT_RANGE.defaultValue()));
final Iterator<Integer> serverPorts = NetUtils.getPortRangeFromString(
config.getString(QueryableStateOptions.SERVER_PORT_RANGE,
QueryableStateOptions.SERVER_PORT_RANGE.defaultValue()));
final int numProxyServerNetworkThreads = config.getInteger(QueryableStateOptions.PROXY_NETWORK_THREADS);
final int numProxyServerQueryThreads = config.getInteger(QueryableStateOptions.PROXY_ASYNC_QUERY_THREADS);
final int numStateServerNetworkThreads = config.getInteger(QueryableStateOptions.SERVER_NETWORK_THREADS);
final int numStateServerQueryThreads = config.getInteger(QueryableStateOptions.SERVER_ASYNC_QUERY_THREADS);
return new QueryableStateConfiguration(
proxyPorts,
serverPorts,
numProxyServerNetworkThreads,
numProxyServerQueryThreads,
numStateServerNetworkThreads,
numStateServerQueryThreads);
}
示例3: getIntegerWithDeprecatedKeys
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Returns the value associated with the given key as an Integer in the
* given Configuration.
*
* <p>The regular key has precedence over any deprecated keys. The
* precedence of deprecated keys depends on the argument order, first
* deprecated keys have higher precedence than later ones.
*
* @param config Configuration to access
* @param key Configuration key (highest precedence)
* @param defaultValue Default value (if no key is set)
* @param deprecatedKeys Optional deprecated keys in precedence order
* @return Integer value associated with first found key or the default value
*/
public static int getIntegerWithDeprecatedKeys(
Configuration config,
String key,
int defaultValue,
String... deprecatedKeys) {
if (config.containsKey(key)) {
return config.getInteger(key, defaultValue);
} else {
// Check deprecated keys
for (String deprecatedKey : deprecatedKeys) {
if (config.containsKey(deprecatedKey)) {
LOG.warn("Configuration key '{}' has been deprecated. Please use '{}' instead.", deprecatedKey, key);
return config.getInteger(deprecatedKey, defaultValue);
}
}
return defaultValue;
}
}
示例4: open
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Override
public void open(Configuration config) throws Exception {
String hostname = config.getString("redisHostname", "localhost");
int port = config.getInteger("redisPort", 6379);
this.pool = new JedisPool(hostname, port);
this.jedis = pool.getResource();
}
示例5: setup
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
this.container = containingTask;
this.config = config;
try {
OperatorMetricGroup operatorMetricGroup = container.getEnvironment().getMetricGroup().addOperator(config.getOperatorID(), config.getOperatorName());
this.output = new CountingOutput(output, operatorMetricGroup.getIOMetricGroup().getNumRecordsOutCounter());
if (config.isChainStart()) {
operatorMetricGroup.getIOMetricGroup().reuseInputMetricsForTask();
}
if (config.isChainEnd()) {
operatorMetricGroup.getIOMetricGroup().reuseOutputMetricsForTask();
}
this.metrics = operatorMetricGroup;
} catch (Exception e) {
LOG.warn("An error occurred while instantiating task metrics.", e);
this.metrics = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
this.output = output;
}
Configuration taskManagerConfig = container.getEnvironment().getTaskManagerInfo().getConfiguration();
int historySize = taskManagerConfig.getInteger(MetricOptions.LATENCY_HISTORY_SIZE);
if (historySize <= 0) {
LOG.warn("{} has been set to a value equal or below 0: {}. Using default.", MetricOptions.LATENCY_HISTORY_SIZE, historySize);
historySize = MetricOptions.LATENCY_HISTORY_SIZE.defaultValue();
}
latencyGauge = this.metrics.gauge("latency", new LatencyGauge(historySize));
this.runtimeContext = new StreamingRuntimeContext(this, container.getEnvironment(), container.getAccumulatorMap());
stateKeySelector1 = config.getStatePartitioner(0, getUserCodeClassloader());
stateKeySelector2 = config.getStatePartitioner(1, getUserCodeClassloader());
}
示例6: readParametersFromConfig
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void readParametersFromConfig(Configuration config, ClassLoader cl) throws ClassNotFoundException {
// figure out how many key fields there are
final int numKeyFields = config.getInteger(NUM_KEYS, -1);
if (numKeyFields < 0) {
throw new IllegalConfigurationException("The number of keys for the comparator is invalid: " + numKeyFields);
}
final int[] positions = new int[numKeyFields];
final Class<? extends Value>[] types = new Class[numKeyFields];
final boolean[] direction = new boolean[numKeyFields];
// read the individual key positions and types
for (int i = 0; i < numKeyFields; i++) {
// next key position
final int p = config.getInteger(KEY_POS_PREFIX + i, -1);
if (p >= 0) {
positions[i] = p;
} else {
throw new IllegalConfigurationException("Contained invalid position for key no positions for keys.");
}
// next key type
final String name = config.getString(KEY_CLASS_PREFIX + i, null);
if (name != null) {
types[i] = (Class<? extends Value>) Class.forName(name, true, cl).asSubclass(Value.class);
} else {
throw new IllegalConfigurationException("The key type (" + i +
") for the comparator is null");
}
// next key sort direction
direction[i] = config.getBoolean(KEY_SORT_DIRECTION_PREFIX + i, true);
}
this.positions = positions;
this.types = types;
this.sortDirections = direction;
}
示例7: 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);
}
示例8: sendBroadCastVariables
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Sends all broadcast-variables encoded in the configuration to the external process.
*
* @param config configuration object containing broadcast-variable count and names
* @throws IOException
*/
public final void sendBroadCastVariables(Configuration config) throws IOException {
try {
int broadcastCount = config.getInteger(PLANBINDER_CONFIG_BCVAR_COUNT, 0);
String[] names = new String[broadcastCount];
for (int x = 0; x < names.length; x++) {
names[x] = config.getString(PLANBINDER_CONFIG_BCVAR_NAME_PREFIX + x, null);
}
out.write(new IntSerializer().serializeWithoutTypeInfo(broadcastCount));
StringSerializer stringSerializer = new StringSerializer();
for (String name : names) {
Iterator<byte[]> bcv = function.getRuntimeContext().<byte[]>getBroadcastVariable(name).iterator();
out.write(stringSerializer.serializeWithoutTypeInfo(name));
while (bcv.hasNext()) {
out.writeByte(1);
out.write(bcv.next());
}
out.writeByte(0);
}
} catch (SocketTimeoutException ignored) {
throw new RuntimeException("External process for task " + function.getRuntimeContext().getTaskName() + " stopped responding." + msg);
}
}
示例9: fromConfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static ClusterSpecification fromConfiguration(Configuration configuration) {
int slots = configuration.getInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, 1);
int jobManagerMemoryMb = configuration.getInteger(JobManagerOptions.JOB_MANAGER_HEAP_MEMORY);
int taskManagerMemoryMb = configuration.getInteger(TaskManagerOptions.TASK_MANAGER_HEAP_MEMORY);
return new ClusterSpecificationBuilder()
.setMasterMemoryMB(jobManagerMemoryMb)
.setTaskManagerMemoryMB(taskManagerMemoryMb)
.setNumberTaskManagers(1)
.setSlotsPerTaskManager(slots)
.createClusterSpecification();
}
示例10: checkJobManagerAddress
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static void checkJobManagerAddress(Configuration config, String expectedAddress, int expectedPort) {
String jobManagerAddress = config.getString(JobManagerOptions.ADDRESS);
int jobManagerPort = config.getInteger(JobManagerOptions.PORT, -1);
assertEquals(expectedAddress, jobManagerAddress);
assertEquals(expectedPort, jobManagerPort);
}
示例11: checkJobManagerAddress
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
private static void checkJobManagerAddress(Configuration config, String expectedAddress, int expectedPort) {
String jobManagerAddress = config.getString(JobManagerOptions.ADDRESS);
int jobManagerPort = config.getInteger(JobManagerOptions.PORT, -1);
assertEquals(expectedAddress, jobManagerAddress);
assertEquals(expectedPort, jobManagerPort);
}
示例12: StandaloneMiniCluster
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public StandaloneMiniCluster(Configuration configuration) throws Exception {
this.configuration = Preconditions.checkNotNull(configuration);
timeout = AkkaUtils.getTimeout(configuration);
actorSystem = JobManager.startActorSystem(
configuration,
LOCAL_HOSTNAME,
0);
port = configuration.getInteger(JobManagerOptions.PORT);
scheduledExecutorService = new ScheduledThreadPoolExecutor(1);
highAvailabilityServices = HighAvailabilityServicesUtils.createHighAvailabilityServices(
configuration,
Executors.directExecutor(),
HighAvailabilityServicesUtils.AddressResolution.TRY_ADDRESS_RESOLUTION);
metricRegistry = new MetricRegistryImpl(
MetricRegistryConfiguration.fromConfiguration(configuration));
metricRegistry.startQueryService(actorSystem, null);
JobManager.startJobManagerActors(
configuration,
actorSystem,
scheduledExecutorService,
scheduledExecutorService,
highAvailabilityServices,
metricRegistry,
Option.empty(),
JobManager.class,
MemoryArchivist.class);
final ResourceID taskManagerResourceId = ResourceID.generate();
ActorRef taskManager = TaskManager.startTaskManagerComponentsAndActor(
configuration,
taskManagerResourceId,
actorSystem,
highAvailabilityServices,
metricRegistry,
LOCAL_HOSTNAME,
Option.<String>empty(),
true,
TaskManager.class);
Future<Object> registrationFuture = Patterns.ask(
taskManager,
TaskManagerMessages.getNotifyWhenRegisteredAtJobManagerMessage(),
timeout.toMillis());
Await.ready(registrationFuture, timeout);
}
示例13: createActorProps
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Creates the props needed to instantiate this actor.
*
* <p>Rather than extracting and validating parameters in the constructor, this factory method takes
* care of that. That way, errors occur synchronously, and are not swallowed simply in a
* failed asynchronous attempt to start the actor.
*
* @param actorClass
* The actor class, to allow overriding this actor with subclasses for testing.
* @param flinkConfig
* The Flink configuration object.
* @param yarnConfig
* The YARN configuration object.
* @param applicationMasterHostName
* The hostname where this application master actor runs.
* @param webFrontendURL
* The URL of the tracking web frontend.
* @param taskManagerParameters
* The parameters for launching TaskManager containers.
* @param taskManagerLaunchContext
* The parameters for launching the TaskManager processes in the TaskManager containers.
* @param numInitialTaskManagers
* The initial number of TaskManagers to allocate.
* @param log
* The logger to log to.
*
* @return The Props object to instantiate the YarnFlinkResourceManager actor.
*/
public static Props createActorProps(Class<? extends YarnFlinkResourceManager> actorClass,
Configuration flinkConfig,
YarnConfiguration yarnConfig,
LeaderRetrievalService leaderRetrievalService,
String applicationMasterHostName,
String webFrontendURL,
ContaineredTaskManagerParameters taskManagerParameters,
ContainerLaunchContext taskManagerLaunchContext,
int numInitialTaskManagers,
Logger log) {
final int yarnHeartbeatIntervalMS = flinkConfig.getInteger(
YarnConfigOptions.HEARTBEAT_DELAY_SECONDS) * 1000;
final long yarnExpiryIntervalMS = yarnConfig.getLong(
YarnConfiguration.RM_AM_EXPIRY_INTERVAL_MS,
YarnConfiguration.DEFAULT_RM_AM_EXPIRY_INTERVAL_MS);
if (yarnHeartbeatIntervalMS >= yarnExpiryIntervalMS) {
log.warn("The heartbeat interval of the Flink Application master ({}) is greater " +
"than YARN's expiry interval ({}). The application is likely to be killed by YARN.",
yarnHeartbeatIntervalMS, yarnExpiryIntervalMS);
}
final int maxFailedContainers = flinkConfig.getInteger(
YarnConfigOptions.MAX_FAILED_CONTAINERS.key(), numInitialTaskManagers);
if (maxFailedContainers >= 0) {
log.info("YARN application tolerates {} failed TaskManager containers before giving up",
maxFailedContainers);
}
return Props.create(actorClass,
flinkConfig,
yarnConfig,
leaderRetrievalService,
applicationMasterHostName,
webFrontendURL,
taskManagerParameters,
taskManagerLaunchContext,
yarnHeartbeatIntervalMS,
maxFailedContainers,
numInitialTaskManagers);
}
示例14: open
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Override
public void open(Configuration config) {
int val = config.getInteger(TEST_KEY, -1);
Assert.assertEquals(TEST_VALUE, val);
}
示例15: createActorProps
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Creates the props needed to instantiate this actor.
*
* <p>Rather than extracting and validating parameters in the constructor, this factory method takes
* care of that. That way, errors occur synchronously, and are not swallowed simply in a
* failed asynchronous attempt to start the actor.
* @param actorClass
* The actor class, to allow overriding this actor with subclasses for testing.
* @param flinkConfig
* The Flink configuration object.
* @param taskManagerParameters
* The parameters for launching TaskManager containers.
* @param taskManagerContainerSpec
* The container specification.
* @param artifactResolver
* The artifact resolver to locate artifacts
* @param log
* The logger to log to.
*
* @return The Props object to instantiate the MesosFlinkResourceManager actor.
*/
public static Props createActorProps(
Class<? extends MesosFlinkResourceManager> actorClass,
Configuration flinkConfig,
MesosConfiguration mesosConfig,
MesosWorkerStore workerStore,
LeaderRetrievalService leaderRetrievalService,
MesosTaskManagerParameters taskManagerParameters,
ContainerSpecification taskManagerContainerSpec,
MesosArtifactResolver artifactResolver,
Logger log) {
final int numInitialTaskManagers = flinkConfig.getInteger(
MesosOptions.INITIAL_TASKS);
if (numInitialTaskManagers >= 0) {
log.info("Mesos framework to allocate {} initial tasks",
numInitialTaskManagers);
}
else {
throw new IllegalConfigurationException("Invalid value for " +
MesosOptions.INITIAL_TASKS.key() + ", which must be at least zero.");
}
final int maxFailedTasks = flinkConfig.getInteger(
MesosOptions.MAX_FAILED_TASKS.key(), numInitialTaskManagers);
if (maxFailedTasks >= 0) {
log.info("Mesos framework tolerates {} failed tasks before giving up",
maxFailedTasks);
}
return Props.create(actorClass,
flinkConfig,
mesosConfig,
workerStore,
leaderRetrievalService,
taskManagerParameters,
taskManagerContainerSpec,
artifactResolver,
maxFailedTasks,
numInitialTaskManagers);
}