本文整理匯總了Java中org.apache.kylin.job.JobInstance類的典型用法代碼示例。如果您正苦於以下問題:Java JobInstance類的具體用法?Java JobInstance怎麽用?Java JobInstance使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JobInstance類屬於org.apache.kylin.job包,在下文中一共展示了JobInstance類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeExtract
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
@Override
protected void executeExtract(OptionsHelper optionsHelper, File exportDir) throws Exception {
String cube = optionsHelper.hasOption(OPTION_CUBE) ? optionsHelper.getOptionValue(OPTION_CUBE) : null;
String project = optionsHelper.hasOption(OPTION_PROJECT) ? optionsHelper.getOptionValue(OPTION_PROJECT) : null;
int period = optionsHelper.hasOption(OPTION_PERIOD) ? Integer.valueOf(optionsHelper.getOptionValue(OPTION_PERIOD)) : DEFAULT_PERIOD;
long endTime = System.currentTimeMillis();
long startTime = endTime - period * 24 * 3600 * 1000; // time in Millis
List<JobInstance> jobInstances = listJobInstances(project, cube, startTime, endTime);
logger.info("There are {} jobInstances to extract.", jobInstances.size());
ObjectMapper mapper = new ObjectMapper();
for (JobInstance jobInstance : jobInstances) {
mapper.writeValue(new File(exportDir, jobInstance.getUuid() + ".json"), jobInstance);
}
}
示例2: listJobInstances
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
private List<JobInstance> listJobInstances(String project, String cube, long startTime, long endTime) {
final List<JobInstance> result = Lists.newArrayList();
final List<AbstractExecutable> executables = executableManager.getAllExecutables(startTime, endTime);
final Map<String, Output> allOutputs = executableManager.getAllOutputs();
for (AbstractExecutable executable : executables) {
if (executable instanceof CubingJob) {
String cubeName = CubingExecutableUtil.getCubeName(executable.getParams());
boolean shouldExtract = false;
if (cube == null || cube.equalsIgnoreCase(cubeName)) {
if (project == null) {
shouldExtract = true;
} else {
ProjectInstance projectInstance = projectManager.getProject(project);
if (projectInstance != null && projectInstance.containsRealization(RealizationType.CUBE, cubeName)) {
shouldExtract = true;
}
}
}
if (shouldExtract) {
result.add(parseToJobInstance((CubingJob) executable, allOutputs));
}
}
}
return result;
}
示例3: parseToJobStep
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
private JobInstance.JobStep parseToJobStep(AbstractExecutable task, int i, Output stepOutput) {
Preconditions.checkNotNull(stepOutput);
JobInstance.JobStep result = new JobInstance.JobStep();
result.setId(task.getId());
result.setName(task.getName());
result.setSequenceID(i);
result.setStatus(parseToJobStepStatus(stepOutput.getState()));
for (Map.Entry<String, String> entry : stepOutput.getExtra().entrySet()) {
if (entry.getKey() != null && entry.getValue() != null) {
result.putInfo(entry.getKey(), entry.getValue());
}
}
result.setExecStartTime(AbstractExecutable.getStartTime(stepOutput));
result.setExecEndTime(AbstractExecutable.getEndTime(stepOutput));
if (task instanceof ShellExecutable) {
result.setExecCmd(((ShellExecutable) task).getCmd());
}
if (task instanceof MapReduceExecutable) {
result.setExecCmd(((MapReduceExecutable) task).getMapReduceParams());
result.setExecWaitTime(AbstractExecutable.getExtraInfoAsLong(stepOutput, MapReduceExecutable.MAP_REDUCE_WAIT_TIME, 0L) / 1000);
}
if (task instanceof HadoopShellExecutable) {
result.setExecCmd(((HadoopShellExecutable) task).getJobParams());
}
return result;
}
示例4: testBasics
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
@Test
public void testBasics() throws IOException, PersistentException {
CubeDesc cubeDesc = cubeDescManager.getCubeDesc("test_kylin_cube_with_slr_left_join_desc");
CubeInstance cube = cubeManager.createCube(CUBE_NAME, "DEFAULT", cubeDesc, "test");
assertNotNull(cube);
JobListRequest jobRequest = new JobListRequest();
jobRequest.setTimeFilter(4);
Assert.assertNotNull(jobSchedulerController.list(jobRequest));
JobBuildRequest jobBuildRequest = new JobBuildRequest();
jobBuildRequest.setBuildType("BUILD");
jobBuildRequest.setStartTime(0L);
jobBuildRequest.setEndTime(new Date().getTime());
JobInstance job = cubeController.rebuild(CUBE_NAME, jobBuildRequest);
Assert.assertNotNull(jobSchedulerController.get(job.getId()));
executableDAO.deleteJob(job.getId());
if (cubeManager.getCube(CUBE_NAME) != null) {
cubeManager.dropCube(CUBE_NAME, false);
}
// jobSchedulerController.cancel(job.getId());
}
示例5: build2
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
/** Build/Rebuild a cube segment by source offset */
@RequestMapping(value = "/{cubeName}/build2", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public JobInstance build2(@PathVariable String cubeName, @RequestBody JobBuildRequest2 req) {
boolean existKafkaClient = false;
try {
Class<?> clazz = Class.forName("org.apache.kafka.clients.consumer.KafkaConsumer");
if (clazz != null) {
existKafkaClient = true;
}
} catch (ClassNotFoundException e) {
existKafkaClient = false;
}
if (!existKafkaClient) {
throw new InternalErrorException("Could not find Kafka dependency");
}
return rebuild2(cubeName, req);
}
示例6: buildInternal
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
private JobInstance buildInternal(String cubeName, TSRange tsRange, SegmentRange segRange, //
Map<Integer, Long> sourcePartitionOffsetStart, Map<Integer, Long> sourcePartitionOffsetEnd,
String buildType, boolean force) {
try {
String submitter = SecurityContextHolder.getContext().getAuthentication().getName();
CubeInstance cube = jobService.getCubeManager().getCube(cubeName);
if (cube == null) {
throw new InternalErrorException("Cannot find cube " + cubeName);
}
return jobService.submitJob(cube, tsRange, segRange, sourcePartitionOffsetStart, sourcePartitionOffsetEnd,
CubeBuildTypeEnum.valueOf(buildType), force, submitter);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
throw new InternalErrorException(e.getLocalizedMessage(), e);
}
}
示例7: getCheckpointJobInstance
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
protected JobInstance getCheckpointJobInstance(AbstractExecutable job) {
Message msg = MsgPicker.getMsg();
if (job == null) {
return null;
}
if (!(job instanceof CheckpointExecutable)) {
throw new BadRequestException(String.format(msg.getILLEGAL_JOB_TYPE(), job.getId()));
}
CheckpointExecutable checkpointExecutable = (CheckpointExecutable) job;
final JobInstance result = new JobInstance();
result.setName(job.getName());
result.setRelatedCube(CubingExecutableUtil.getCubeName(job.getParams()));
result.setLastModified(job.getLastModified());
result.setSubmitter(job.getSubmitter());
result.setUuid(job.getId());
result.setType(CubeBuildTypeEnum.CHECKPOINT);
result.setStatus(JobInfoConverter.parseToJobStatus(job.getStatus()));
result.setDuration(job.getDuration() / 1000);
for (int i = 0; i < checkpointExecutable.getTasks().size(); ++i) {
AbstractExecutable task = checkpointExecutable.getTasks().get(i);
result.addStep(JobInfoConverter.parseToJobStep(task, i, getExecutableManager().getOutput(task.getId())));
}
return result;
}
示例8: searchJobs
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
/**
* currently only support substring match
*
* @return
*/
public List<JobInstance> searchJobs(final String cubeNameSubstring, final String projectName,
final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue,
final JobTimeFilterEnum timeFilter) {
Integer limit = (null == limitValue) ? 30 : limitValue;
Integer offset = (null == offsetValue) ? 0 : offsetValue;
List<JobInstance> jobs = searchJobsByCubeName(cubeNameSubstring, projectName, statusList, timeFilter);
Collections.sort(jobs);
if (jobs.size() <= offset) {
return Collections.emptyList();
}
if ((jobs.size() - offset) < limit) {
return jobs.subList(offset, jobs.size());
}
return jobs.subList(offset, offset + limit);
}
示例9: innerSearchJobs
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
public List<JobInstance> innerSearchJobs(final String cubeName, final String jobName, final String projectName,
final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter, JobSearchMode jobSearchMode) {
List<JobInstance> result = Lists.newArrayList();
switch (jobSearchMode) {
case CUBING_ONLY:
result.addAll(innerSearchCubingJobs(cubeName, jobName, projectName, statusList, timeFilter));
break;
case CHECKPOINT_ONLY:
result.addAll(innerSearchCheckpointJobs(cubeName, jobName, projectName, statusList, timeFilter));
break;
case ALL:
default:
result.addAll(innerSearchCubingJobs(cubeName, jobName, projectName, statusList, timeFilter));
result.addAll(innerSearchCheckpointJobs(cubeName, jobName, projectName, statusList, timeFilter));
}
return result;
}
示例10: innerSearchCheckpointJobs
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
public List<JobInstance> innerSearchCheckpointJobs(final String cubeName, final String jobName,
final String projectName, final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter) {
// prepare time range
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
long timeStartInMillis = getTimeStartInMillis(calendar, timeFilter);
long timeEndInMillis = Long.MAX_VALUE;
Set<ExecutableState> states = convertStatusEnumToStates(statusList);
final Map<String, Output> allOutputs = getExecutableManager().getAllOutputs(timeStartInMillis, timeEndInMillis);
return Lists
.newArrayList(FluentIterable
.from(innerSearchCheckpointJobs(cubeName, jobName, states, timeStartInMillis, timeEndInMillis,
allOutputs, false, projectName))
.transform(new Function<CheckpointExecutable, JobInstance>() {
@Override
public JobInstance apply(CheckpointExecutable checkpointExecutable) {
return JobInfoConverter.parseToJobInstanceQuietly(checkpointExecutable, allOutputs);
}
}));
}
示例11: createAclEntity
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
public static RootPersistentEntity createAclEntity(String entityType, String uuid) {
if ("CubeInstance".equals(entityType)) {
CubeInstance cubeInstance = new CubeInstance();
cubeInstance.setUuid(uuid);
return cubeInstance;
}
if ("JobInstance".equals(entityType)) {
JobInstance jobInstance = new JobInstance();
jobInstance.setUuid(uuid);
return jobInstance;
}
if ("ProjectInstance".equals(entityType)) {
ProjectInstance projectInstance = new ProjectInstance();
projectInstance.setUuid(uuid);
return projectInstance;
}
throw new RuntimeException("Unsupported entity type!");
}
示例12: list
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
/**
* get all cube jobs
*
* @return
* @throws IOException
*/
@RequestMapping(value = "", method = { RequestMethod.GET })
@ResponseBody
public List<JobInstance> list(JobListRequest jobRequest) {
List<JobInstance> jobInstanceList = Collections.emptyList();
List<JobStatusEnum> statusList = new ArrayList<JobStatusEnum>();
if (null != jobRequest.getStatus()) {
for (int status : jobRequest.getStatus()) {
statusList.add(JobStatusEnum.getByCode(status));
}
}
try {
jobInstanceList = jobService.listAllJobs(jobRequest.getCubeName(), jobRequest.getProjectName(), statusList, jobRequest.getLimit(), jobRequest.getOffset());
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
throw new InternalErrorException(e);
}
return jobInstanceList;
}
示例13: listAllJobs
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
public List<JobInstance> listAllJobs(final String cubeName, final String projectName, final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue) throws IOException, JobException {
Integer limit = (null == limitValue) ? 30 : limitValue;
Integer offset = (null == offsetValue) ? 0 : offsetValue;
List<JobInstance> jobs = listAllJobs(cubeName, projectName, statusList);
Collections.sort(jobs);
if (jobs.size() <= offset) {
return Collections.emptyList();
}
if ((jobs.size() - offset) < limit) {
return jobs.subList(offset, jobs.size());
}
return jobs.subList(offset, offset + limit);
}
示例14: listCubeJobInstance
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
private List<JobInstance> listCubeJobInstance(final String cubeName, final String projectName, List<JobStatusEnum> statusList) {
Set<ExecutableState> states;
if (statusList == null || statusList.isEmpty()) {
states = EnumSet.allOf(ExecutableState.class);
} else {
states = Sets.newHashSet();
for (JobStatusEnum status : statusList) {
states.add(parseToExecutableState(status));
}
}
return Lists.newArrayList(FluentIterable.from(listAllCubingJobs(cubeName, projectName, states)).transform(new Function<CubingJob, JobInstance>() {
@Override
public JobInstance apply(CubingJob cubingJob) {
return parseToJobInstance(cubingJob);
}
}));
}
示例15: parseToJobInstance
import org.apache.kylin.job.JobInstance; //導入依賴的package包/類
private JobInstance parseToJobInstance(AbstractExecutable job) {
if (job == null) {
return null;
}
Preconditions.checkState(job instanceof CubingJob, "illegal job type, id:" + job.getId());
CubingJob cubeJob = (CubingJob) job;
final JobInstance result = new JobInstance();
result.setName(job.getName());
result.setRelatedCube(cubeJob.getCubeName());
result.setRelatedSegment(cubeJob.getSegmentId());
result.setLastModified(cubeJob.getLastModified());
result.setSubmitter(cubeJob.getSubmitter());
result.setUuid(cubeJob.getId());
result.setType(CubeBuildTypeEnum.BUILD);
result.setStatus(parseToJobStatus(job.getStatus()));
result.setMrWaiting(cubeJob.getMapReduceWaitTime() / 1000);
result.setDuration(cubeJob.getDuration() / 1000);
for (int i = 0; i < cubeJob.getTasks().size(); ++i) {
AbstractExecutable task = cubeJob.getTasks().get(i);
result.addStep(parseToJobStep(task, i));
}
return result;
}