Search in sources :

Example 1 with InternalBackend

use of gov.sandia.n2a.backend.internal.InternalBackend in project n2a by frothga.

the class PanelEquations method launchJob.

public void launchJob() {
    if (record == null)
        return;
    prepareForTabChange();
    String jobKey = new SimpleDateFormat("yyyy-MM-dd-HHmmss", Locale.ROOT).format(new Date());
    MDoc job = (MDoc) AppData.runs.childOrCreate(jobKey);
    NodeJob.collectJobParameters(root.source, record.key(), job);
    // Force directory (and job file) to exist, so Backends can work with the dir.
    job.save();
    NodeJob.saveSnapshot(record, job);
    MainTabbedPane mtp = (MainTabbedPane) MainFrame.instance.tabs;
    mtp.setPreferredFocus(PanelRun.instance, PanelRun.instance.tree);
    mtp.selectTab("Runs");
    NodeJob node = PanelRun.instance.addNewRun(job, true);
    // Hack to allow local jobs to bypass the wait-for-host queue.
    // It would be better for all jobs to check for resources before starting.
    // However, the time cost for the local check could be as long as the job itself
    // (for very simple models). There is some expectation that the user knows
    // the state of their own system when they choose to hit the play button.
    Backend backend = Backend.getBackend(job.get("backend"));
    String backendName = backend.getName().toLowerCase();
    Host h = Host.get(job);
    boolean internal = backend instanceof InternalBackend;
    boolean localhost = !(h instanceof Remote);
    boolean forbidden = h.config.get("backend", backendName).equals("0");
    if (// use of Internal overrides host selection
    internal || (localhost && !forbidden)) {
        // In case it was "internal" but not "localhost", set host to correct value.
        job.set("localhost", "host");
        backend.start(job);
        h.monitor(node);
        return;
    }
    Host.waitForHost(node);
}
Also used : Backend(gov.sandia.n2a.plugins.extpoints.Backend) InternalBackend(gov.sandia.n2a.backend.internal.InternalBackend) MainTabbedPane(gov.sandia.n2a.ui.MainTabbedPane) Remote(gov.sandia.n2a.host.Remote) Host(gov.sandia.n2a.host.Host) NodeJob(gov.sandia.n2a.ui.jobs.NodeJob) InternalBackend(gov.sandia.n2a.backend.internal.InternalBackend) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) MDoc(gov.sandia.n2a.db.MDoc)

Aggregations

InternalBackend (gov.sandia.n2a.backend.internal.InternalBackend)1 MDoc (gov.sandia.n2a.db.MDoc)1 Host (gov.sandia.n2a.host.Host)1 Remote (gov.sandia.n2a.host.Remote)1 Backend (gov.sandia.n2a.plugins.extpoints.Backend)1 MainTabbedPane (gov.sandia.n2a.ui.MainTabbedPane)1 NodeJob (gov.sandia.n2a.ui.jobs.NodeJob)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1