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;
}
});
}
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");
}
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");
}
Aggregations