Spring Batch & Spring Cloud Task & Spring Cloud Data Flow & Spring Cloud Deployer

整理之前的筆記,發現有一些內容沒有發出來,陸續發出來。。。

  1. Partitioner
  2. StepExecutionSplitter
  3. PartitionHandler

Configuration

  1. JobFactory:創建Job對象,可以進一步獲取Job的名稱
  2. JobLocator:根據任務名稱獲取任務詳情,ListableJobLocator,JobRegistry
  3. StepRegistry:分步註冊器
  4. JobRepository:作業倉庫
  5. JobLauncher:作業啓動器

Configurer

BatchConfigurer

concept

org.springframework.batch.core

  1. Job

  2. JobInstance

  3. JobExecution:一個JobInstance可能因爲運行時錯誤運行多次,每一此時一個JobExecution對象

  4. JobParameter

  5. Step

  6. StepExecution

  7. JobLauncher/JobExplorer/JobOperator:Job執行相關的接口。JobOperator=JobLauncher+JobExplorer。JobOperator適用於命令行或者JMX使用。

  8. 通過自定義tasklet可以複用開發者已有的企業服務

Chunk攔截器接口

  1. ChunkListener
  2. ItemProcessListener
  3. ItemReadListener
  4. ItemWriterListener
  5. SkipListener
  6. RetryListener

ItemReader

  1. 只實現ItemReader接口的讀實現是不支持重啓的,爲了支持重啓,自定義的ItemReader需要實現接口ItemStream。

Spring Batch提供了跳過、重試、重啓等的策略。根據處理過程中的錯誤類型選擇,比如網絡錯誤,數據庫鎖錯誤等的錯誤可以選擇重試,像類型轉換錯誤,數據格式不對啊,重試多少次還是不會行,這種就選擇跳過,重啓,暫時還沒想到例子。

*Context

  1. JobContext
  2. StepContext
  3. ChunkContext

Spring Cloud Task

使用@EnableTask標記一個SpringBootApplication之後,這個應用就成了一個生存時間短的Task應用了。整個Jar包,直接給Spring Cloud Data Flow就可以運行了。
舉個生動的例子,就知道了,使用@EnableTask標記的SpringBootApplication的spring.application.name配置的值就是spring cloud task在數據庫中的任務記錄的task的名字。當然了,如果配置了spring.cloud.task.name,那任務的名字就是這個key指定的值了。
一個被@EnableTask標記的SpringBootApplication,獨立運行與一個JVM中,是一個進程。

TaskConfigurer一共需要三個東西:TaskRepository(任務的增刪改)、TaskExplorer(任務的查詢)、PlatformTransactionManager(事務管理器)

spring-cloud-task-batch模塊

TaskBatchExecutionListener:負責存儲Spring Batch job和Spring Cloud task的關係
真正負載存儲的是TaskBatchDao接口的實現,有兩個內置的實現JdbcTaskBatchDao和MapTaskBatchDao。

TaskBatchExecutionListenerBeanPostProcessor會給ioc容器中所有的Jobbean註冊TaskBatchExecutionListener。Job對象有一個registerJobExecutionListener方法。

此模塊的主要作用是跟spring batch整合

spring-cloud-task-stream

此模塊的作用是監聽一個sink,啓動任務
將任務執行過程中配置的事件發送到mq中

Spring Cloud Deployer

The Spring Cloud Deployer project defines an SPI for deploying long lived applications and short lived tasks

Spring Cloud Data Flow

Spring Cloud Data Flow is a toolkit for building data integration and real-time data processing pipelines.

Pipelines consist of Spring Boot apps, built using the Spring Cloud Stream or Spring Cloud Task microservice frameworks. This makes Spring Cloud Data Flow suitable for a range of data processing use cases, from import/export to event streaming and predictive analytics.

架構

Application、Data Flow Server、target runtime
Application有兩種:

  1. 通過消息中間件生產或者消費無限大的數據的存活時間長的Stream Application
  2. 處理有限數據然後結束的存活時間短的Task Application

Application可以根據運行時環境打包成兩種形式:

  1. Spring Boot uber-jar,通過Spring Resource的實現可以加在,比如說maven Repository,file,http等。
  2. Docker

運行時環境(runtime )是application執行的地方。
應用的target runtimes是應用部署的platform。目前支持的target runtimes有:

  1. Cloud Foundry
  2. Apache YARN
  3. Kubernetes
  4. Apache Mesos
  5. Local Server for development

Spring Data Flow定義了一套部署應用到target runtimes的SPI,你可以去擴展他,支持其他的平臺,比如說Docker Swarm。

負責將應用部署到runtime的是Data Flow Server這個組件。Data Flow Server 簡化了應用的部署。

要操作hadoop,當然用spring hadoop,看看spring hadoop中有沒有yarn和mapreduce

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章