本文整理汇总了Java中org.apache.samza.config.Config.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java Config.containsKey方法的具体用法?Java Config.containsKey怎么用?Java Config.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.samza.config.Config
的用法示例。
在下文中一共展示了Config.containsKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ConfigManager
import org.apache.samza.config.Config; //导入方法依赖的package包/类
public ConfigManager(Config config) {
//get rm address and port
if (!config.containsKey(rmAddressOpt) || !config.containsKey(rmPortOpt)) {
throw new IllegalArgumentException("Missing config: the config file does not contain the rm host or port.");
}
String rmAddress = config.get(rmAddressOpt);
int rmPort = config.getInt(rmPortOpt);
//get job name and id;
if (!config.containsKey(JobConfig.JOB_NAME())) {
throw new IllegalArgumentException("Missing config: the config does not contain the job name");
}
jobName = config.get(JobConfig.JOB_NAME());
jobID = config.getInt(JobConfig.JOB_ID(), 1);
//set polling interval
if (config.containsKey(pollingIntervalOpt)) {
long pollingInterval = config.getLong(pollingIntervalOpt);
if (pollingInterval <= 0) {
throw new IllegalArgumentException("polling interval cannot be a negative value");
}
this.interval = pollingInterval;
} else {
this.interval = defaultPollingInterval;
}
this.config = config;
CoordinatorStreamSystemFactory coordinatorStreamSystemFactory = new CoordinatorStreamSystemFactory();
this.coordinatorStreamConsumer = coordinatorStreamSystemFactory.getCoordinatorStreamSystemConsumer(config, new MetricsRegistryMap());
this.yarnUtil = new YarnUtil(rmAddress, rmPort);
}
示例2: main
import org.apache.samza.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ApplicationRunnerCommandLine cmdLine = new ApplicationRunnerCommandLine();
OptionSet options = cmdLine.parser().parse(args);
Config orgConfig = cmdLine.loadConfig(options);
Config config = Util.rewriteConfig(orgConfig);
ApplicationRunnerOperation op = cmdLine.getOperation(options);
if (config.containsKey(STREAM_APPLICATION_CLASS_CONFIG)) {
ApplicationRunner runner = ApplicationRunner.fromConfig(config);
StreamApplication app =
(StreamApplication) Class.forName(config.get(STREAM_APPLICATION_CLASS_CONFIG)).newInstance();
switch (op) {
case RUN:
runner.run(app);
break;
case KILL:
runner.kill(app);
break;
case STATUS:
System.out.println(runner.status(app));
break;
default:
throw new IllegalArgumentException("Unrecognized operation: " + op);
}
} else {
JobRunner$.MODULE$.main(args);
}
}
示例3: GroupBySystemStreamPartition
import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
* A constructor that accepts job config as the parameter
*
* @param config job config
*/
public GroupBySystemStreamPartition(Config config) {
if (config.containsKey(TaskConfigJava.BROADCAST_INPUT_STREAMS)) {
taskConfig = new TaskConfigJava(config);
broadcastStreams = taskConfig.getBroadcastSystemStreamPartitions();
}
}
示例4: GroupByPartition
import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
* Accepts the config in the constructor
*
* @param config job's config
*/
public GroupByPartition(Config config) {
if (config.containsKey(TaskConfigJava.BROADCAST_INPUT_STREAMS)) {
taskConfig = new TaskConfigJava(config);
this.broadcastStreams = taskConfig.getBroadcastSystemStreamPartitions();
}
}
示例5: findJobInstances
import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
* Finds all the job instances in the specified path and adds a corresponding {@link JobInstance} and
* {@link InstallationRecord} for each instance.
*
* @param jobInstallPath the path to search for job instances.
* @param jobs the map to which the job instances will be added.
*/
private void findJobInstances(final File jobInstallPath, final Map<JobInstance, InstallationRecord> jobs) {
try {
String jobInstallCanonPath = jobInstallPath.getCanonicalPath();
File configPath = Paths.get(jobInstallCanonPath, CFG_SUBPATH).toFile();
if (!(configPath.exists() && configPath.isDirectory())) {
log.debug("Config path not found: " + configPath);
return;
}
for (File configFile : configPath.listFiles()) {
if (configFile.isFile()) {
String configFilePath = configFile.getCanonicalPath();
Config config = jobConfigFactory.getConfig(new URI("file://" + configFilePath));
if (config.containsKey(JobConfig.JOB_NAME()) && config.containsKey(JobConfig.STREAM_JOB_FACTORY_CLASS())) {
String jobName = config.get(JobConfig.JOB_NAME());
String jobId = config.get(JobConfig.JOB_ID(), "1");
JobInstance jobInstance = new JobInstance(jobName, jobId);
if (jobs.containsKey(jobInstance)) {
throw new IllegalStateException(
String.format("Found more than one job config with jobName:%s and jobId:%s", jobName, jobId));
}
InstallationRecord jobInstall =
new InstallationRecord(jobName, jobId, jobInstallCanonPath, configFilePath, getBinPath(jobInstallCanonPath));
jobs.put(jobInstance, jobInstall);
}
}
}
} catch (Exception e) {
throw new SamzaException("Exception finding job instance in path: " + jobInstallPath, e);
}
}
示例6: getResourceInstances
import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public List<? extends Object> getResourceInstances(Config config) {
List<Object> resources = new ArrayList<>();
if (config.containsKey(JobsResourceConfig.CONFIG_JOB_PROXY_FACTORY)) {
resources.add(new JobsResource(new JobsResourceConfig(config)));
}
if (config.containsKey(TaskResourceConfig.CONFIG_TASK_PROXY_FACTORY)) {
resources.add(new TasksResource(new TaskResourceConfig(config)));
}
return resources;
}