Search in sources :

Example 66 with SaturnJobConsoleHttpException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.

the class RestApiServiceImpl method runDownStream.

@Override
public List<BatchJobResult> runDownStream(final String namespace, final String jobName, final Map<String, Object> triggeredData) throws SaturnJobConsoleException {
    return ReuseUtils.reuse(namespace, jobName, registryCenterService, curatorRepository, new ReuseCallBack<List<BatchJobResult>>() {

        @Override
        public List<BatchJobResult> call(CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) throws SaturnJobConsoleException {
            JobConfig4DB jobConfig = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
            if (jobConfig == null) {
                throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), "不能触发该作业(" + jobName + ")的下游,因为该作业不存在");
            }
            List<BatchJobResult> batchJobResultList = new ArrayList<>();
            String downStream = jobConfig.getDownStream();
            if (StringUtils.isBlank(downStream)) {
                return batchJobResultList;
            }
            // Maybe should validate downStream, but it seems unnecessary, because it's validated when add/copy/import/update job
            String[] split = downStream.split(",");
            for (String childName : split) {
                String childNameTrim = childName.trim();
                if (childNameTrim.isEmpty()) {
                    continue;
                }
                BatchJobResult batchJobResult = new BatchJobResult();
                batchJobResult.setJobName(childNameTrim);
                try {
                    runJobAtOnce(namespace, childNameTrim, triggeredData);
                    batchJobResult.setSuccess(true);
                } catch (SaturnJobConsoleException e) {
                    batchJobResult.setSuccess(false);
                    batchJobResult.setMessage(e.getMessage());
                } finally {
                    batchJobResultList.add(batchJobResult);
                }
            }
            return batchJobResultList;
        }
    });
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)

Example 67 with SaturnJobConsoleHttpException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.

the class NamespaceServiceImplTest method testDestNamespaceIsNull.

@Test
public void testDestNamespaceIsNull() throws SaturnJobConsoleException {
    SaturnJobConsoleHttpException exception = null;
    try {
        namespaceService.importJobsFromNamespaceToNamespace("saturn.vip.vip.com", null, null);
    } catch (SaturnJobConsoleHttpException e) {
        exception = e;
    }
    Assert.assertNotNull(exception);
    Assert.assertEquals(exception.getMessage(), "destNamespace should not be null");
}
Also used : SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) Test(org.junit.Test)

Example 68 with SaturnJobConsoleHttpException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.

the class NamespaceServiceImplTest method testSrcNamespaceIsNull.

@Test
public void testSrcNamespaceIsNull() throws SaturnJobConsoleException {
    SaturnJobConsoleHttpException exception = null;
    try {
        namespaceService.importJobsFromNamespaceToNamespace(null, null, null);
    } catch (SaturnJobConsoleHttpException e) {
        exception = e;
    }
    Assert.assertNotNull(exception);
    Assert.assertEquals(exception.getMessage(), "srcNamespace should not be null");
}
Also used : SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) Test(org.junit.Test)

Aggregations

SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)68 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)40 ResponseEntity (org.springframework.http.ResponseEntity)30 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 Test (org.junit.Test)15 HttpHeaders (org.springframework.http.HttpHeaders)13 Audit (com.vip.saturn.job.console.aop.annotation.Audit)12 JobConfig (com.vip.saturn.job.console.domain.JobConfig)10 Matchers.anyString (org.mockito.Matchers.anyString)8 NamespaceDomainInfo (com.vip.saturn.job.console.domain.NamespaceDomainInfo)7 AbstractSaturnConsoleTest (com.vip.saturn.job.console.AbstractSaturnConsoleTest)5 CurrentJobConfig (com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)5 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)5 MvcResult (org.springframework.test.web.servlet.MvcResult)5 Transactional (org.springframework.transaction.annotation.Transactional)5 NamespaceInfo (com.vip.saturn.job.console.mybatis.entity.NamespaceInfo)4 AlarmInfo (com.vip.saturn.job.integrate.entity.AlarmInfo)4 ParseException (java.text.ParseException)4 Map (java.util.Map)4 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)3