Search in sources :

Example 1 with JobResource

use of com.sequenceiq.cloudbreak.quartz.model.JobResource in project cloudbreak by hortonworks.

the class ExistingStackPatcherJobService method schedule.

public void schedule(Long stackId, StackPatchType stackPatchType) {
    JobResource jobResource = stackService.getJobResource(stackId);
    schedule(new ExistingStackPatcherJobAdapter(jobResource, stackPatchType));
}
Also used : JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource)

Example 2 with JobResource

use of com.sequenceiq.cloudbreak.quartz.model.JobResource in project cloudbreak by hortonworks.

the class DBStackJobInizializer method initJobs.

@Override
public void initJobs() {
    Set<JobResource> dbStacks = checkedMeasure(() -> dbStackService.findAllForAutoSync(), LOGGER, ":::Auto sync::: db stacks are fetched from db in {}ms");
    for (JobResource jobResource : dbStacks) {
        dbStackJobService.schedule(jobResource);
    }
    LOGGER.info("Auto syncer is inited with {} db stacks on start", dbStacks.size());
}
Also used : JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource)

Example 3 with JobResource

use of com.sequenceiq.cloudbreak.quartz.model.JobResource in project cloudbreak by hortonworks.

the class StackJobInitializer method initJobs.

@Override
public void initJobs() {
    List<JobResource> jobResources = checkedMeasure(() -> stackService.findAllForAutoSync(), LOGGER, ":::Auto sync::: Stacks are fetched from db in {}ms");
    for (JobResource jobResource : jobResources) {
        freeipaJobService.schedule(jobResource);
    }
    LOGGER.info("Auto syncer is inited with {} stacks on start", jobResources.size());
}
Also used : JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource)

Example 4 with JobResource

use of com.sequenceiq.cloudbreak.quartz.model.JobResource in project cloudbreak by hortonworks.

the class ExistingStackPatcherJobInitializer method initJobs.

@Override
public void initJobs() {
    Set<StackPatchType> enabledStackPatchTypes = getEnabledStackPatchTypes();
    LOGGER.info("Existing stack patch types enabled: {}", enabledStackPatchTypes);
    List<JobResource> stacks = getAliveJobResources();
    Set<Long> stackIds = stacks.stream().map(JobResource::getLocalId).map(Long::valueOf).collect(Collectors.toSet());
    enabledStackPatchTypes.forEach(stackPatchType -> {
        LOGGER.info("Scheduling stack patcher jobs for {}", stackPatchType);
        Map<Long, List<StackPatch>> stackPatchesByStack = stackPatchService.findAllByTypeForStackIds(stackPatchType, stackIds).stream().collect(Collectors.groupingBy(StackPatch::getStackId));
        for (JobResource stack : stacks) {
            Long stackId = Long.valueOf(stack.getLocalId());
            List<StackPatch> stackPatches = stackPatchesByStack.get(stackId);
            boolean stackPatchIsFinalized = stackPatches != null && stackPatches.stream().anyMatch(stackPatch -> stackPatch.getStatus().isFinal());
            if (!stackPatchIsFinalized) {
                ExistingStackPatcherJobAdapter jobAdapter = new ExistingStackPatcherJobAdapter(stack, stackPatchType);
                stackPatchService.getOrCreate(stackId, stackPatchType);
                jobService.schedule(jobAdapter);
            }
        }
    });
}
Also used : ExistingStackPatcherConfig(com.sequenceiq.cloudbreak.job.stackpatcher.config.ExistingStackPatcherConfig) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource) Collectors(java.util.stream.Collectors) StackPatch(com.sequenceiq.cloudbreak.domain.stack.StackPatch) StackPatchType(com.sequenceiq.cloudbreak.domain.stack.StackPatchType) Inject(javax.inject.Inject) StackPatchService(com.sequenceiq.cloudbreak.service.stackpatch.StackPatchService) List(java.util.List) Component(org.springframework.stereotype.Component) Map(java.util.Map) AbstractStackJobInitializer(com.sequenceiq.cloudbreak.job.AbstractStackJobInitializer) JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource) StackPatchType(com.sequenceiq.cloudbreak.domain.stack.StackPatchType) StackPatch(com.sequenceiq.cloudbreak.domain.stack.StackPatch) List(java.util.List)

Example 5 with JobResource

use of com.sequenceiq.cloudbreak.quartz.model.JobResource in project cloudbreak by hortonworks.

the class EnvironmentJobInitializer method initJobs.

@Override
public void initJobs() {
    List<JobResource> jobResources = environmentService.findAllForAutoSync();
    for (JobResource jobResource : jobResources) {
        environmentJobService.schedule(jobResource);
    }
    LOGGER.info("Auto syncer is inited with {} environments on start", jobResources.size());
}
Also used : JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource)

Aggregations

JobResource (com.sequenceiq.cloudbreak.quartz.model.JobResource)7 StackPatch (com.sequenceiq.cloudbreak.domain.stack.StackPatch)1 StackPatchType (com.sequenceiq.cloudbreak.domain.stack.StackPatchType)1 AbstractStackJobInitializer (com.sequenceiq.cloudbreak.job.AbstractStackJobInitializer)1 ExistingStackPatcherConfig (com.sequenceiq.cloudbreak.job.stackpatcher.config.ExistingStackPatcherConfig)1 StackPatchService (com.sequenceiq.cloudbreak.service.stackpatch.StackPatchService)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Test (org.junit.jupiter.api.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Component (org.springframework.stereotype.Component)1