Search in sources :

Example 1 with NamingService

use of org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService in project scheduling by ow2-proactive.

the class TaskLauncherTest method scratchDirDeletedAfterTaskCompleted.

@Test
public void scratchDirDeletedAfterTaskCompleted() throws Throwable {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    final TaskDataspaces dataspacesMock = mock(TaskDataspaces.class);
    when(dataspacesMock.getScratchFolder()).thenReturn(tmpFolder.newFolder());
    runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory() {

        @Override
        public TaskDataspaces createTaskDataspaces(TaskId taskId, NamingService namingService, boolean isRunAsUser) {
            return dataspacesMock;
        }
    }), executableContainer);
    verify(dataspacesMock).close();
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskDataspaces(org.ow2.proactive.scheduler.task.data.TaskDataspaces) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Test(org.junit.Test)

Example 2 with NamingService

use of org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService in project scheduling by ow2-proactive.

the class SchedulerDataspace method endActivity.

@Override
public void endActivity(Body body) {
    taskDataSpaceApplication.terminateDataSpaceApplication();
    Set<String> registeredApplications = dataSpaceServiceStarter.getNamingService().getRegisteredApplications();
    NamingService namingService = dataSpaceServiceStarter.getNamingService();
    for (String registeredApplication : registeredApplications) {
        try {
            namingService.unregisterApplication(registeredApplication);
        } catch (WrongApplicationIdException e) {
            throw new IllegalStateException(e);
        }
    }
    dataSpaceServiceStarter.terminateNamingService();
    dataSpaceServiceStarter.clearSpaceConfigurations();
}
Also used : WrongApplicationIdException(org.objectweb.proactive.extensions.dataspaces.exceptions.WrongApplicationIdException) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService)

Example 3 with NamingService

use of org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService in project scheduling by ow2-proactive.

the class TaskLauncherTest method taskLogsAreNotCopiedToUserSpace_PreciousLogsDisabled.

@Test
public void taskLogsAreNotCopiedToUserSpace_PreciousLogsDisabled() throws Exception {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setPreciousLogs(false);
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    final TaskDataspaces dataspacesMock = mock(TaskDataspaces.class);
    when(dataspacesMock.getScratchFolder()).thenReturn(tmpFolder.newFolder());
    runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory() {

        @Override
        public TaskDataspaces createTaskDataspaces(TaskId taskId, NamingService namingService, boolean isRunAsUser) {
            return dataspacesMock;
        }
    }), executableContainer);
    verify(dataspacesMock, times(1)).copyScratchDataToOutput(Matchers.<List<OutputSelector>>any());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) TaskDataspaces(org.ow2.proactive.scheduler.task.data.TaskDataspaces) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Test(org.junit.Test)

Example 4 with NamingService

use of org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService in project scheduling by ow2-proactive.

the class TaskLauncherTest method taskLogsAreCopiedToUserSpace.

@Test
public void taskLogsAreCopiedToUserSpace() throws Exception {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setPreciousLogs(true);
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    final TaskDataspaces dataspacesMock = mock(TaskDataspaces.class);
    when(dataspacesMock.getScratchFolder()).thenReturn(tmpFolder.newFolder());
    runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory() {

        @Override
        public TaskDataspaces createTaskDataspaces(TaskId taskId, NamingService namingService, boolean isRunAsUser) {
            return dataspacesMock;
        }
    }), executableContainer);
    verify(dataspacesMock, times(2)).copyScratchDataToOutput(Matchers.<List<OutputSelector>>any());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) TaskDataspaces(org.ow2.proactive.scheduler.task.data.TaskDataspaces) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Test(org.junit.Test)

Example 5 with NamingService

use of org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService in project scheduling by ow2-proactive.

the class NodeDataspace method init.

public void init(TaskId taskId, String namingServiceUrl) throws Exception {
    dataSpaceNodeConfigurationAgent = (DataSpaceNodeConfigurationAgent) PAActiveObject.newActive(DataSpaceNodeConfigurationAgent.class.getName(), null, PAActiveObject.getNode());
    if (!dataSpaceNodeConfigurationAgent.configureNode()) {
        throw new IllegalStateException("Could not configure node for dataspaces");
    }
    NamingService namingServiceStub = NamingService.createNamingServiceStub(namingServiceUrl);
    taskProActiveDataspaces = new TaskProActiveDataspaces(taskId, namingServiceStub, false);
    System.out.println("Node scratch folder is " + getScratchFolder());
}
Also used : NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) TaskProActiveDataspaces(org.ow2.proactive.scheduler.task.data.TaskProActiveDataspaces) DataSpaceNodeConfigurationAgent(org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)

Aggregations

NamingService (org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService)6 Test (org.junit.Test)3 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)3 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)3 TaskDataspaces (org.ow2.proactive.scheduler.task.data.TaskDataspaces)3 SimpleScript (org.ow2.proactive.scripting.SimpleScript)3 TaskScript (org.ow2.proactive.scripting.TaskScript)3 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DataSpacesFileObject (org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject)1 SpaceInstanceInfo (org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo)1 WrongApplicationIdException (org.objectweb.proactive.extensions.dataspaces.exceptions.WrongApplicationIdException)1 FileSystemServerDeployer (org.objectweb.proactive.extensions.vfsprovider.FileSystemServerDeployer)1 DataSpaceNodeConfigurationAgent (org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)1 DataSpaceServiceStarter (org.ow2.proactive.scheduler.core.DataSpaceServiceStarter)1 TaskDataSpaceApplication (org.ow2.proactive.scheduler.job.TaskDataSpaceApplication)1 TaskProActiveDataspaces (org.ow2.proactive.scheduler.task.data.TaskProActiveDataspaces)1