You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2017/09/26 22:26:37 UTC
[38/50] [abbrv] ambari git commit: AMBARI-22050. Infra Manager jobs
should handle their own configuration (mgergely)
AMBARI-22050. Infra Manager jobs should handle their own configuration (mgergely)
Change-Id: I035c439bbe72e27efba87943bea5651ca8da4806
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/af0db350
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/af0db350
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/af0db350
Branch: refs/heads/branch-3.0-ams
Commit: af0db3509add0c4df4d6d2f70a4b70af9fcfa484
Parents: 398690a
Author: Miklos Gergely <mg...@hortonworks.com>
Authored: Tue Sep 26 11:15:47 2017 +0200
Committer: Miklos Gergely <mg...@hortonworks.com>
Committed: Tue Sep 26 11:16:00 2017 +0200
----------------------------------------------------------------------
.../conf/batch/InfraManagerBatchConfig.java | 86 ---------------
.../infra/job/dummy/DummyJobConfiguration.java | 108 +++++++++++++++++++
2 files changed, 108 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/af0db350/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/batch/InfraManagerBatchConfig.java
----------------------------------------------------------------------
diff --git a/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/batch/InfraManagerBatchConfig.java b/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/batch/InfraManagerBatchConfig.java
index 98a4901..b1169b4 100644
--- a/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/batch/InfraManagerBatchConfig.java
+++ b/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/batch/InfraManagerBatchConfig.java
@@ -18,11 +18,6 @@
*/
package org.apache.ambari.infra.conf.batch;
-import org.apache.ambari.infra.job.dummy.DummyItemProcessor;
-import org.apache.ambari.infra.job.dummy.DummyItemWriter;
-import org.apache.ambari.infra.job.dummy.DummyJobListener;
-import org.apache.ambari.infra.job.dummy.DummyObject;
-import org.apache.ambari.infra.job.dummy.DummyStepListener;
import org.springframework.batch.admin.service.JdbcSearchableJobExecutionDao;
import org.springframework.batch.admin.service.JdbcSearchableJobInstanceDao;
import org.springframework.batch.admin.service.JdbcSearchableStepExecutionDao;
@@ -31,12 +26,8 @@ import org.springframework.batch.admin.service.SearchableJobExecutionDao;
import org.springframework.batch.admin.service.SearchableJobInstanceDao;
import org.springframework.batch.admin.service.SearchableStepExecutionDao;
import org.springframework.batch.admin.service.SimpleJobService;
-import org.springframework.batch.core.Job;
-import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
-import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
-import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.launch.JobLauncher;
@@ -49,22 +40,10 @@ import org.springframework.batch.core.repository.dao.ExecutionContextDao;
import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
import org.springframework.batch.core.repository.dao.JdbcExecutionContextDao;
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
-import org.springframework.batch.item.ItemProcessor;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.ItemWriter;
-import org.springframework.batch.item.file.FlatFileItemReader;
-import org.springframework.batch.item.file.LineMapper;
-import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper;
-import org.springframework.batch.item.file.mapping.DefaultLineMapper;
-import org.springframework.batch.item.file.mapping.FieldSetMapper;
-import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
-import org.springframework.batch.item.file.transform.LineTokenizer;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -104,12 +83,6 @@ public class InfraManagerBatchConfig {
private String databasePassword;
@Inject
- private StepBuilderFactory steps;
-
- @Inject
- private JobBuilderFactory jobs;
-
- @Inject
private JobRegistry jobRegistry;
@Inject
@@ -231,63 +204,4 @@ public class InfraManagerBatchConfig {
SimpleJobService(searchableJobInstanceDao(), searchableJobExecutionDao(), searchableStepExecutionDao(),
jobRepository(), jobLauncher(), jobRegistry, executionContextDao());
}
-
- @Bean(name = "dummyStep")
- protected Step dummyStep(ItemReader<DummyObject> reader,
- ItemProcessor<DummyObject, String> processor,
- ItemWriter<String> writer) {
- return steps.get("dummyStep").listener(new DummyStepListener()).<DummyObject, String> chunk(2)
- .reader(reader).processor(processor).writer(writer).build();
- }
-
- @Bean(name = "dummyJob")
- public Job job(@Qualifier("dummyStep") Step dummyStep) {
- return jobs.get("dummyJob").listener(new DummyJobListener()).start(dummyStep).build();
- }
-
- @Bean
- public ItemReader<DummyObject> dummyItemReader() {
- FlatFileItemReader<DummyObject> csvFileReader = new FlatFileItemReader<>();
- csvFileReader.setResource(new ClassPathResource("dummy/dummy.txt"));
- csvFileReader.setLinesToSkip(1);
- LineMapper<DummyObject> lineMapper = dummyLineMapper();
- csvFileReader.setLineMapper(lineMapper);
- return csvFileReader;
- }
-
- @Bean
- public ItemProcessor<DummyObject, String> dummyItemProcessor() {
- return new DummyItemProcessor();
- }
-
- @Bean
- public ItemWriter<String> dummyItemWriter() {
- return new DummyItemWriter();
- }
-
- private LineMapper<DummyObject> dummyLineMapper() {
- DefaultLineMapper<DummyObject> lineMapper = new DefaultLineMapper<>();
-
- LineTokenizer dummyTokenizer = dummyTokenizer();
- lineMapper.setLineTokenizer(dummyTokenizer);
-
- FieldSetMapper<DummyObject> dummyFieldSetMapper = dummyFieldSetMapper();
- lineMapper.setFieldSetMapper(dummyFieldSetMapper);
-
- return lineMapper;
- }
-
- private FieldSetMapper<DummyObject> dummyFieldSetMapper() {
- BeanWrapperFieldSetMapper<DummyObject> studentInformationMapper = new BeanWrapperFieldSetMapper<>();
- studentInformationMapper.setTargetType(DummyObject.class);
- return studentInformationMapper;
- }
-
- private LineTokenizer dummyTokenizer() {
- DelimitedLineTokenizer studentLineTokenizer = new DelimitedLineTokenizer();
- studentLineTokenizer.setDelimiter(",");
- studentLineTokenizer.setNames(new String[]{"f1", "f2"});
- return studentLineTokenizer;
- }
-
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/af0db350/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyJobConfiguration.java
----------------------------------------------------------------------
diff --git a/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyJobConfiguration.java b/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyJobConfiguration.java
new file mode 100644
index 0000000..a4f5369
--- /dev/null
+++ b/ambari-infra/ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyJobConfiguration.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ambari.infra.job.dummy;
+
+import javax.inject.Inject;
+
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.Step;
+import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
+import org.springframework.batch.item.ItemProcessor;
+import org.springframework.batch.item.ItemReader;
+import org.springframework.batch.item.ItemWriter;
+import org.springframework.batch.item.file.FlatFileItemReader;
+import org.springframework.batch.item.file.LineMapper;
+import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper;
+import org.springframework.batch.item.file.mapping.DefaultLineMapper;
+import org.springframework.batch.item.file.mapping.FieldSetMapper;
+import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
+import org.springframework.batch.item.file.transform.LineTokenizer;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+
+@Configuration
+public class DummyJobConfiguration {
+ @Inject
+ private StepBuilderFactory steps;
+
+ @Inject
+ private JobBuilderFactory jobs;
+
+ @Bean(name = "dummyStep")
+ protected Step dummyStep(ItemReader<DummyObject> reader,
+ ItemProcessor<DummyObject, String> processor,
+ @Qualifier("dummyItemWriter") ItemWriter<String> writer) {
+ return steps.get("dummyStep").listener(new DummyStepListener()).<DummyObject, String> chunk(2)
+ .reader(reader).processor(processor).writer(writer).build();
+ }
+
+ @Bean(name = "dummyJob")
+ public Job job(@Qualifier("dummyStep") Step dummyStep) {
+ return jobs.get("dummyJob").listener(new DummyJobListener()).start(dummyStep).build();
+ }
+
+ @Bean
+ public ItemReader<DummyObject> dummyItemReader() {
+ FlatFileItemReader<DummyObject> csvFileReader = new FlatFileItemReader<>();
+ csvFileReader.setResource(new ClassPathResource("dummy/dummy.txt"));
+ csvFileReader.setLinesToSkip(1);
+ LineMapper<DummyObject> lineMapper = dummyLineMapper();
+ csvFileReader.setLineMapper(lineMapper);
+ return csvFileReader;
+ }
+
+ @Bean
+ public ItemProcessor<DummyObject, String> dummyItemProcessor() {
+ return new DummyItemProcessor();
+ }
+
+ @Bean(name = "dummyItemWriter")
+ public ItemWriter<String> dummyItemWriter() {
+ return new DummyItemWriter();
+ }
+
+ private LineMapper<DummyObject> dummyLineMapper() {
+ DefaultLineMapper<DummyObject> lineMapper = new DefaultLineMapper<>();
+
+ LineTokenizer dummyTokenizer = dummyTokenizer();
+ lineMapper.setLineTokenizer(dummyTokenizer);
+
+ FieldSetMapper<DummyObject> dummyFieldSetMapper = dummyFieldSetMapper();
+ lineMapper.setFieldSetMapper(dummyFieldSetMapper);
+
+ return lineMapper;
+ }
+
+ private FieldSetMapper<DummyObject> dummyFieldSetMapper() {
+ BeanWrapperFieldSetMapper<DummyObject> studentInformationMapper = new BeanWrapperFieldSetMapper<>();
+ studentInformationMapper.setTargetType(DummyObject.class);
+ return studentInformationMapper;
+ }
+
+ private LineTokenizer dummyTokenizer() {
+ DelimitedLineTokenizer studentLineTokenizer = new DelimitedLineTokenizer();
+ studentLineTokenizer.setDelimiter(",");
+ studentLineTokenizer.setNames(new String[]{"f1", "f2"});
+ return studentLineTokenizer;
+ }
+}