-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from JakduK/batch
엘라스틱서치 업그레이드 및 초기화 배치 추가
- Loading branch information
Showing
22 changed files
with
589 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
jakduk-batch/src/main/java/com/jakduk/batch/InitElasticsearchIndexBatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.jakduk.batch; | ||
|
||
import com.jakduk.core.service.SearchService; | ||
import org.elasticsearch.index.IndexNotFoundException; | ||
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.core.launch.support.RunIdIncrementer; | ||
import org.springframework.batch.repeat.RepeatStatus; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Created by pyohwan on 16. 9. 18. | ||
*/ | ||
|
||
@Configuration | ||
public class InitElasticsearchIndexBatch { | ||
|
||
@Autowired | ||
private JobBuilderFactory jobBuilderFactory; | ||
|
||
@Autowired | ||
private StepBuilderFactory stepBuilderFactory; | ||
|
||
@Autowired | ||
private SearchService searchService; | ||
|
||
@Bean | ||
public Step step1() { | ||
return stepBuilderFactory.get("initElasticsearchIndexStep") | ||
.tasklet((contribution, chunkContext) -> { | ||
|
||
try { | ||
searchService.deleteIndex(); | ||
} catch (IndexNotFoundException e) { | ||
} | ||
|
||
searchService.initSearchIndex(); | ||
searchService.initSearchType(); | ||
searchService.initSearchDocuments(); | ||
|
||
return RepeatStatus.FINISHED; | ||
}) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public Job job(Step step1) throws Exception { | ||
return jobBuilderFactory.get("initElasticsearchIndexJob") | ||
.incrementer(new RunIdIncrementer()) | ||
.start(step1) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.