Search in sources :

Example 86 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class TaskLogger method createFileAppender.

public File createFileAppender(File pathToFolder) throws IOException {
    if (taskLogAppender.getAppender(FILE_APPENDER_NAME) != null) {
        throw new IllegalStateException("Only one file appender can be created");
    }
    File logFile = new File(pathToFolder, new TaskLoggerRelativePathGenerator(taskId).getRelativePath());
    logFile.getParentFile().mkdirs();
    FileUtils.touch(logFile);
    logFile.setWritable(true, false);
    FileAppender fap = new FileAppender(Log4JTaskLogs.getTaskLogLayout(), logFile.getAbsolutePath(), false);
    fap.setName(FILE_APPENDER_NAME);
    taskLogAppender.addAppender(fap);
    return logFile;
}
Also used : FileAppender(org.apache.log4j.FileAppender) File(java.io.File) TaskLoggerRelativePathGenerator(org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator)

Example 87 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class SchedulerStateRest method getTaskIdsByTag.

@Override
public RestPage<String> getTaskIdsByTag(String sessionId, String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedRestException, PermissionRestException {
    Scheduler s = checkAccess(sessionId, "tasks");
    PageBoundaries boundaries = Pagination.getTasksPageBoundaries(offset, limit, TASKS_PAGE_SIZE);
    Page<TaskId> page = null;
    try {
        page = s.getTaskIds(taskTag, from, to, mytasks, running, pending, finished, boundaries.getOffset(), boundaries.getLimit());
        List<TaskId> taskIds = page.getList();
        List<String> taskNames = new ArrayList<>(taskIds.size());
        for (TaskId taskId : taskIds) {
            taskNames.add(taskId.getReadableName());
        }
        return new RestPage<String>(taskNames, page.getSize());
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ArrayList(java.util.ArrayList) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) PageBoundaries(org.ow2.proactive.scheduler.common.util.PageBoundaries)

Example 88 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class RestTestUtils method newTaskState.

protected static TaskState newTaskState(String jobIdStr, String tag, long cnt, int nbTasks) {
    TaskId mockedTaskId = mock(TaskId.class);
    TaskState mockedState = mock(TaskState.class);
    when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
    when(mockedTaskId.longValue()).thenReturn(cnt);
    when(mockedState.getTag()).thenReturn(tag);
    when(mockedState.getId()).thenReturn(mockedTaskId);
    when(mockedState.getName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
    return mockedState;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 89 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class RestTestUtils method newMockedTaskIdPage.

protected static Page<TaskId> newMockedTaskIdPage(String jobIdStr, int nbTasks, String tag) {
    List<TaskId> lTaskId = new ArrayList<TaskId>(nbTasks);
    for (int i = 0; i < nbTasks; i++) {
        TaskId mockedTaskId = mock(TaskId.class);
        when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, i, nbTasks));
        when(mockedTaskId.getTag()).thenReturn(tag);
        lTaskId.add(mockedTaskId);
    }
    return new Page<TaskId>(lTaskId, nbTasks);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) Page(org.ow2.proactive.scheduler.common.Page) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)

Example 90 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class SchedulerStateRestPaginationTest method newMockedJob.

private JobState newMockedJob(final String jobIdStr, final int nbTasks) {
    JobState mockedJob = mock(JobState.class);
    JobId mockedJobId = mock(JobId.class);
    List<TaskState> dumbList = new ArrayList<TaskState>(nbTasks);
    for (int i = 0; i < nbTasks; i++) {
        TaskState mockedTask = mock(TaskState.class);
        TaskId mockedTaskId = mock(TaskId.class);
        when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, i, nbTasks));
        when(mockedTask.getId()).thenReturn(mockedTaskId);
        dumbList.add(mockedTask);
    }
    when(mockedJobId.value()).thenReturn(jobIdStr);
    when(mockedJob.getId()).thenReturn(mockedJobId);
    when(mockedJob.getTasksPaginated(0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
    when(mockedJob.getTaskByTagPaginated("", 0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
    return mockedJob;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

TaskId (org.ow2.proactive.scheduler.common.task.TaskId)100 Test (org.junit.Test)43 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)43 JobId (org.ow2.proactive.scheduler.common.job.JobId)33 ArrayList (java.util.ArrayList)27 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)25 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)25 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)22 HashMap (java.util.HashMap)18 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)18 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)15 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)12 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)12 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)11 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)11 List (java.util.List)10 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)9 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)9