Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add service interface for metricD/metricV/metricTag tables. #667

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

toyboxman
Copy link
Member

No description provided.

@guoyuepeng
Copy link
Contributor

there are conflicts, could you fix it first?
@toyboxman

# Conflicts:
#	griffin-metric/src/main/java/org/apache/griffin/metric/entity/MetricTagD.java
#	griffin-metric/src/main/java/org/apache/griffin/metric/entity/TagAttachment.java
#	griffin-metric/src/main/java/org/apache/griffin/metric/service/MetricDService.java
#	griffin-metric/src/main/java/org/apache/griffin/metric/service/MetricTagDService.java
#	griffin-metric/src/main/resources/sql/create_h2.sql
@guoyuepeng
Copy link
Contributor

@toyboxman

the following is the poc, based on which i am designing the local workflow.

`package demo.workflows;

import org.springframework.batch.core.job.builder.FlowBuilder;
import org.springframework.batch.core.job.flow.Flow;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.stereotype.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.PlatformTransactionManager;

@component
public class DQCompareFlow {
@Autowired
public JobRepository jobRepository;
@Autowired
public PlatformTransactionManager transactionManager;
Logger logger = LoggerFactory.getLogger(DQCompareFlow.class);

@Bean
public Job dqcFlow() {
    return new JobBuilder("DQC_JOB", this.jobRepository)
            .start(new StepBuilder("setup", this.jobRepository).tasklet(new Tasklet() {
                @Override
                public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                    logger.info("PrepareJob was run");
                    return RepeatStatus.FINISHED;
                }
            }, transactionManager).build())
            .split(new SimpleAsyncTaskExecutor()).add(
                    new FlowBuilder<Flow>("fetchSourceCount")
                            .start(new StepBuilder("fetchSourceStep", this.jobRepository).tasklet(new Tasklet() {
                                @Override
                                public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                                    logger.info("FetchSourceStep started");
                                    Thread.sleep(90000); // Sleep for 90 seconds
                                    logger.info("FetchSourceStep was run");
                                    return RepeatStatus.FINISHED;
                                }
                            }, transactionManager).build())
                            .build(),
                    new FlowBuilder<Flow>("fetchTargetCount")
                            .start(new StepBuilder("fetchTargetStep", this.jobRepository).tasklet(new Tasklet() {
                                @Override
                                public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                                    logger.info("FetchTargetStep was run");
                                    return RepeatStatus.FINISHED;
                                }
                            }, transactionManager).build())
                            .build()
            )
            .next(new StepBuilder("compareResult", this.jobRepository).tasklet(new Tasklet() {
                @Override
                public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                    logger.info("CompareStep was run");
                    return RepeatStatus.FINISHED;
                }
            }, transactionManager).build())
            .end() // Add this line to end the job definition
            .build(); // Add this line to build the Job object
}

}
`

@guoyuepeng
Copy link
Contributor

guoyuepeng commented Oct 14, 2024

and this is local mode, flexible and programmatically way.

for high volume mode, we can abstract the workflow based on spring cloud data flow, and leverage spring cloud to schedule our cloud native tasks.

@toyboxman
Copy link
Member Author

@guoyuepeng

Yes, there're some conflicts in code. I'm working on code refactory and development.

will follow up your comment to make it work well.

@guoyuepeng guoyuepeng merged commit 47af255 into apache:griffin-2.0.0-dev Oct 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants