當前位置: 首頁>>代碼示例>>Java>>正文


Java PAActiveObject類代碼示例

本文整理匯總了Java中org.objectweb.proactive.api.PAActiveObject的典型用法代碼示例。如果您正苦於以下問題:Java PAActiveObject類的具體用法?Java PAActiveObject怎麽用?Java PAActiveObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PAActiveObject類屬於org.objectweb.proactive.api包,在下文中一共展示了PAActiveObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createScheduler

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
/**
 * Create a new scheduler on the local host plugged on the given resource manager.<br>
 * This will provide a connection interface to allow the access to a restricted number of user.<br>
 * Use {@link SchedulerConnection} class to join the Scheduler.
 *
 * @param rmURL the resource manager URL on which the scheduler will connect
 * @param policyFullClassName the full policy class name for the scheduler.
 * @throws AdminSchedulerException If an error occurred during creation process
 */
public static void createScheduler(URI rmURL, String policyFullClassName) throws AdminSchedulerException {
    logger.debug("Starting new Scheduler");

    //check arguments...
    if (rmURL == null) {
        String msg = "The Resource Manager URL must not be null";
        logger.error(msg);
        throw new AdminSchedulerException(msg);
    }

    try {
        // creating the scheduler
        // if this fails then it will not continue.
        logger.debug("Creating scheduler frontend...");
        PAActiveObject.newActive(SchedulerFrontend.class.getName(), new Object[] { rmURL, policyFullClassName });

        //ready
        logger.debug("Scheduler is now ready to be started!");
        ServerJobAndTaskLogs.configure();
    } catch (Exception e) {
        logger.error(e);
        e.printStackTrace();
        throw new AdminSchedulerException(e.getMessage());
    }
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:35,代碼來源:SchedulerFactory.java

示例2: terminate

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
/**
 * Terminate the schedulerConnexion active object and then this object.
 *
 * @return always true;
 */
public boolean terminate() {
    logger.debug("Closing Scheduler database");
    dbManager.close();

    if (authentication != null) {
        authentication.terminate();
    }

    ClientRequestHandler.terminate();

    PAActiveObject.terminateActiveObject(false);
    logger.info("Scheduler frontend is now shutdown !");

    return true;
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:21,代碼來源:SchedulerFrontend.java

示例3: toExecuterInformation

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
/**
 * Rebuild an executer information from the data. A stub to the task
 * launcher is attempted to be retrieved.
 * @param loadFullState whether it is important to have a task launcher
 *                      stub in the end (it is important if the task is
 *                      running)
 */
public ExecuterInformation toExecuterInformation(boolean loadFullState) {
    TaskLauncher taskLauncher = new TaskLauncher();
    if (taskLauncherNodeUrl != null) {
        try {
            taskLauncher = PAActiveObject.lookupActive(TaskLauncher.class, taskLauncherNodeUrl);
            logger.info("Retrieve task launcher " + taskLauncherNodeUrl + " successfully for task " + taskId);
        } catch (Exception e) {
            if (loadFullState) {
                logger.warn("Task launcher " + taskLauncherNodeUrl + " of task " + taskId +
                            " cannot be looked up. Trying to rebind it", e);
                taskLauncher = getRebindedTaskLauncher();
            }
        }
    }
    return new ExecuterInformation(taskLauncher, nodes, nodeName, hostName);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:24,代碼來源:ExecuterInformationData.java

示例4: checkChangeJobPriority

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
synchronized void checkChangeJobPriority(JobId jobId, JobPriority priority)
        throws NotConnectedException, UnknownJobException, PermissionException, JobAlreadyFinishedException {

    checkPermissions("changeJobPriority",
                     getIdentifiedJob(jobId),
                     YOU_DO_NOT_HAVE_PERMISSION_TO_CHANGE_THE_PRIORITY_OF_THIS_JOB);

    UserIdentificationImpl ui = identifications.get(PAActiveObject.getContext()
                                                                  .getCurrentRequest()
                                                                  .getSourceBodyID())
                                               .getUser();

    try {
        ui.checkPermission(new ChangePriorityPermission(priority.getPriority()),
                           ui.getUsername() + " does not have permissions to set job priority to " + priority);
    } catch (PermissionException ex) {
        logger.info(ex.getMessage());
        throw ex;
    }

    if (jobs.get(jobId).isFinished()) {
        String msg = " is already finished";
        jlogger.info(jobId, msg);
        throw new JobAlreadyFinishedException("Job " + jobId + msg);
    }
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:27,代碼來源:SchedulerFrontendState.java

示例5: SchedulingMethodImpl

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
public SchedulingMethodImpl(SchedulingService schedulingService) throws Exception {
    this.schedulingService = schedulingService;
    this.checkEligibleTaskDescriptorScript = new CheckEligibleTaskDescriptorScript();
    terminateNotification = new TerminateNotification(schedulingService);
    Node terminateNotificationNode = NodeFactory.createLocalNode("taskTerminationNode",
                                                                 true,
                                                                 "taskTerminationVNode");
    terminateNotification = PAActiveObject.turnActive(terminateNotification,
                                                      TaskTerminateNotification.class.getName(),
                                                      terminateNotificationNode);
    terminateNotificationNodeURL = terminateNotificationNode.getNodeInformation().getURL();

    this.threadPool = TimeoutThreadPoolExecutor.newFixedThreadPool(PASchedulerProperties.SCHEDULER_STARTTASK_THREADNUMBER.getValueAsInt(),
                                                                   new NamedThreadFactory("DoTask_Action"));
    this.corePrivateKey = Credentials.getPrivateKey(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.SCHEDULER_AUTH_PRIVKEY_PATH.getValueAsString()));
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:17,代碼來源:SchedulingMethodImpl.java

示例6: execute

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
@Override
public Serializable execute(TaskResult... results) throws Throwable {
    CommunicationObject communicationObject = PAActiveObject.lookupActive(CommunicationObject.class,
                                                                          communicationObjectUrl);

    while (true) {
        String command = communicationObject.getCommand();
        if (command == null) {
            Thread.sleep(1000);
            continue;
        }
        if (command.equals("stop")) {
            break;
        } else if (command.startsWith("output")) {
            getOut().println(command);
        } else {
            throw new IllegalArgumentException(command);
        }
    }

    return "OK";
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:23,代碼來源:TestListenJobLogs.java

示例7: begin

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
public void begin() {
    //non blocking method to use futur management
    try {
        //connect the Scheduler
        //get the authentication interface using the SchedulerConnection
        SchedulerAuthenticationInterface auth = SchedulerConnection.waitAndJoin(SchedulerTHelper.getLocalUrl());
        //get the user interface using the retrieved SchedulerAuthenticationInterface
        user = auth.login(Credentials.createCredentials(new CredData(TestUsers.DEMO.username,
                                                                     TestUsers.DEMO.password),
                                                        auth.getPublicKey()));

        //let the client be notified of its own 'job termination' -> job running to finished event
        user.addEventListener((SubmitJob) PAActiveObject.getStubOnThis(),
                              true,
                              SchedulerEvent.TASK_RUNNING_TO_FINISHED,
                              SchedulerEvent.JOB_RUNNING_TO_FINISHED,
                              SchedulerEvent.JOB_PENDING_TO_FINISHED);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:22,代碼來源:SubmitJob.java

示例8: testJobInstantGetTaskResult

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
@Test
public void testJobInstantGetTaskResult() throws Throwable {
    //create Scheduler client as an active object
    SubmitJob client = (SubmitJob) PAActiveObject.newActive(SubmitJob.class.getName(), new Object[] {});
    //begin to use the client : must be a futur result in order to start the scheduler at next step
    client.begin();

    //create job
    TaskFlowJob job = new TaskFlowJob();

    for (int i = 0; i < 50; i++) {
        JavaTask t = new JavaTask();
        t.setExecutableClassName(ResultAsArray.class.getName());
        t.setName("task" + i);
        job.addTask(t);
    }

    JobId id = schedulerHelper.submitJob(job);
    client.setJobId(id);

    schedulerHelper.waitForEventJobRemoved(id);
    PAActiveObject.terminateActiveObject(client, true);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:24,代碼來源:TestJobInstantGetTaskResult.java

示例9: kill_while_sleeping_in_task

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_while_sleeping_in_task() throws Exception {

    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("java.lang.Thread.sleep(10000)",
                                                                                                                        "javascript")));

    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));

    Semaphore taskRunning = new Semaphore(0);

    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer,
                                                                      new TestTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);

    taskLauncherPA.doTask(executableContainer, null, null);

    taskRunning.acquire();
    taskLauncherPA.kill();

    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:25,代碼來源:KillTaskLauncherTest.java

示例10: kill_while_looping_in_task

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_while_looping_in_task() throws Exception {

    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("for(;;){}",
                                                                                                                        "javascript")));

    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));

    Semaphore taskRunning = new Semaphore(0);
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer,
                                                                      new TestTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);

    taskLauncherPA.doTask(executableContainer, null, null);

    taskRunning.acquire();
    taskLauncherPA.kill();

    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:24,代碼來源:KillTaskLauncherTest.java

示例11: finished_but_terminate_not_called_back

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void finished_but_terminate_not_called_back() throws Throwable {

    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'",
                                                                                                                        "javascript")));

    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));

    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer,
                                                                      new TestTaskLauncherFactory(new Semaphore(0)));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);

    TaskResultWaiter taskResultWaiter = new TaskResultWaiter();
    WaitForResultNotification waitForResultNotification = new WaitForResultNotification(taskResultWaiter);
    waitForResultNotification = PAActiveObject.turnActive(waitForResultNotification);
    taskLauncherPA.doTask(executableContainer, null, waitForResultNotification);

    assertEquals("done", taskResultWaiter.getTaskResult().value());

    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:25,代碼來源:KillTaskLauncherTest.java

示例12: kill_when_copying

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_when_copying() throws Throwable {

    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'",
                                                                                                                        "javascript")));

    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));

    Semaphore taskRunning = new Semaphore(0);
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer,
                                                                      new SlowDataspacesTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);

    taskLauncherPA.doTask(executableContainer, null, null);

    taskRunning.acquire();
    taskLauncherPA.kill();

    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:24,代碼來源:KillTaskLauncherTest.java

示例13: addRMEventListener

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
/** Register a new Resource manager listener.
 * Way to a monitor object to ask at RMMonitoring to throw
 * RM events to it.
 * @param stub a listener object which implements {@link RMEventListener}
 * interface.
 * @param events list of wanted events that must be received.
 * @return RMInitialState snapshot of RM's current state : nodes and node sources.
 *  */
public RMInitialState addRMEventListener(RMEventListener stub, RMEventType... events) {
    UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();

    logger.debug("Adding the RM listener for " + id.shortString());
    synchronized (dispatchers) {
        Client client = null;
        synchronized (RMCore.clients) {
            client = RMCore.clients.get(id);
        }
        if (client == null) {
            throw new IllegalArgumentException("Unknown client " + id.shortString());
        }

        if (stub instanceof RMGroupEventListener) {
            this.dispatchers.put(id, new GroupEventDispatcher(client, stub, events));
        } else {
            this.dispatchers.put(id, new EventDispatcher(client, stub, events));
        }
    }
    return rmcore.getRMInitialState();
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:30,代碼來源:RMMonitoringImpl.java

示例14: shutdown

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
/** 
 * Stop and remove monitoring active object
 */
public BooleanWrapper shutdown() {
    //throwing shutdown event
    rmEvent(new RMEvent(RMEventType.SHUTDOWN));
    PAActiveObject.terminateActiveObject(false);

    RMJMXHelper.getInstance().shutdown();
    // initiating shutdown
    eventDispatcherThreadPool.shutdown();
    try {
        // waiting until all clients will be notified
        eventDispatcherThreadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        logger.warn("", e);
    }

    return new BooleanWrapper(true);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:21,代碼來源:RMMonitoringImpl.java

示例15: Client

import org.objectweb.proactive.api.PAActiveObject; //導入依賴的package包/類
/**
 * Constructs the client object from given client subject.
 * @param subject with the name of the client authenticated in the resource manager (can be null)
 * @param pingable defines if client has to be pinged
 */
public Client(Subject subject, boolean pingable) {
    this.subject = subject;
    this.pingable = pingable;

    if (subject != null) {
        UserNamePrincipal unPrincipal = subject.getPrincipals(UserNamePrincipal.class).iterator().next();
        this.name = unPrincipal.getName();
    }
    if (pingable) {
        Request r = PAActiveObject.getContext().getCurrentRequest();
        this.id = r.getSourceBodyID();
        this.url = r.getSender().getNodeURL() + "/" + this.id.shortString();
        this.body = r.getSender();
    }
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:21,代碼來源:Client.java


注:本文中的org.objectweb.proactive.api.PAActiveObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。