Java Code Examples for autotest.afe.HostSelector

Following code examples demonstrate how to use autotest.afe.HostSelectorfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use autotest.afe.HostSelectorand various code implementation of this class.

    private void submitJob(final boolean isTemplate) {
        final int timeoutValue, maxRuntimeValue;
        final JSONValue synchCount;
        try {
            timeoutValue = parsePositiveIntegerInput(display.getTimeout().getText(), "timeout");
            maxRuntimeValue = parsePositiveIntegerInput(
                    display.getMaxRuntime().getText(), "max runtime");

            if (display.getHostless().getValue()) {
                synchCount = JSONNull.getInstance();
            } else {
                synchCount = new JSONNumber(parsePositiveIntegerInput(
                    display.getSynchCountInput().getText(),
                    "number of machines used per execution"));
            }
        } catch (IllegalArgumentException exc) {
            return;
        }

        display.getSubmitJobButton().setEnabled(false);

        final SimpleCallback doSubmit = new SimpleCallback() {
            public void doCallback(Object source) {
                JSONObject args = new JSONObject();
                args.put("name", new JSONString(display.getJobName().getText()));
                String priority = display.getPriorityList().getSelectedName();
                args.put("priority", new JSONString(priority));
                args.put("control_file", new JSONString(display.getControlFile().getText()));
                args.put("control_type",
                         new JSONString(controlTypeSelect.getControlType()));
                args.put("synch_count", synchCount);
                args.put("timeout", new JSONNumber(timeoutValue));
                args.put("max_runtime_hrs", new JSONNumber(maxRuntimeValue));
                args.put("email_list", new JSONString(display.getEmailList().getText()));
                args.put("run_verify", JSONBoolean.getInstance(
                        !display.getSkipVerify().getValue()));
                args.put("is_template", JSONBoolean.getInstance(isTemplate));
                args.put("dependencies", getSelectedDependencies());
                args.put("reboot_before", new JSONString(rebootBefore.getSelectedChoice()));
                args.put("reboot_after", new JSONString(rebootAfter.getSelectedChoice()));
                args.put("parse_failed_repair",
                         JSONBoolean.getInstance(display.getParseFailedRepair().getValue()));
                args.put("hostless", JSONBoolean.getInstance(display.getHostless().getValue()));
                args.put("reserve_hosts", JSONBoolean.getInstance(display.getReserveHosts().getValue()));

                if (staticData.getData("drone_sets_enabled").isBoolean().booleanValue()) {
                    args.put("drone_set", new JSONString(display.getDroneSet().getSelectedName()));
                }

                HostSelector.HostSelection hosts = hostSelector.getSelectedHosts();
                args.put("hosts", Utils.stringsToJSON(hosts.hosts));
                args.put("profiles", Utils.stringsToJSON(hosts.profiles));
                args.put("meta_hosts", Utils.stringsToJSON(hosts.metaHosts));
                args.put("meta_host_profiles", Utils.stringsToJSON(hosts.metaHostProfiles));
                args.put("one_time_hosts",
                    Utils.stringsToJSON(hosts.oneTimeHosts));

                rpcProxy.rpcCall("create_job", args, new JsonRpcCallback() {
                    @Override
                    public void onSuccess(JSONValue result) {
                        int id = (int) result.isNumber().doubleValue();
                        NotifyManager.getInstance().showMessage(
                                    "Job " + Integer.toString(id) + " created");
                        reset();
                        if (listener != null) {
                            listener.onJobCreated(id);
                        }
                        display.getSubmitJobButton().setEnabled(true);
                    }

                    @Override
                    public void onError(JSONObject errorObject) {
                        super.onError(errorObject);
                        display.getSubmitJobButton().setEnabled(true);
                    }
                });
            }
        };

        if (!controlReadyForSubmit) {
            generateControlFile(true, doSubmit, new SimpleCallback() {
                public void doCallback(Object source) {
                    display.getSubmitJobButton().setEnabled(true);
                }
            });
        } else {
            doSubmit.doCallback(this);
        }
    } 


Advertisement
Javadoc
A widget to facilitate selection of a group of hosts for running a job. The widget displays two side

-by-side tables; the left table is a normal HostTable displaying available, unselected hosts, and the right table displays selected hosts. Click on a host in either table moves it to the other (i.e. selects or deselects a host). The widget provides several convenience controls (such as one to remove all selected hosts) and a special section for adding meta-host entries.

Read More
Advertisement