Search in sources :

Example 1 with SparkSubmissionParameter

use of com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter in project azure-tools-for-java by Microsoft.

the class SparkSubmissionExDialog method constructSubmissionParameter.

private SparkSubmissionParameter constructSubmissionParameter() {
    IClusterDetail selectedClusterDetail = getSelectedCluster(clustersListComboBox.getText());
    String selectedArtifactName = projectArtifactSelectComboBox.getText();
    String className = mainClassCombo.getText().trim();
    String commandLine = commandLineTextField.getText().trim();
    String localArtifactPath = localArtifactInput.getText();
    String selectedClusterName = selectedClusterDetail.getName();
    List<String> referencedFileList = new ArrayList<>();
    for (String singleReferencedFile : referencedFilesTextField.getText().split(";")) {
        singleReferencedFile = singleReferencedFile.trim();
        if (!StringHelper.isNullOrWhiteSpace(singleReferencedFile)) {
            referencedFileList.add(singleReferencedFile);
        }
    }
    List<String> uploadedFilePathList = new ArrayList<>();
    for (String singleReferencedJars : referencedJarsTextField.getText().split(";")) {
        singleReferencedJars = singleReferencedJars.trim();
        if (!StringHelper.isNullOrWhiteSpace(singleReferencedJars)) {
            uploadedFilePathList.add(singleReferencedJars);
        }
    }
    List<String> argsList = new ArrayList<>();
    for (String singleArs : commandLine.split(" ")) {
        if (!StringHelper.isNullOrWhiteSpace(singleArs)) {
            argsList.add(singleArs.trim());
        }
    }
    // FIXME: need a duplicated keys check when creating a new row is allowed
    final Map<String, Object> jobConfigMap = jobConfigs.stream().collect(Collectors.toMap(Pair::first, Pair::second));
    return new SparkSubmissionParameter(selectedClusterName, localArtifactRadioButton.getSelection(), selectedArtifactName, localArtifactPath, null, className, referencedFileList, uploadedFilePathList, argsList, jobConfigMap);
}
Also used : SparkSubmissionParameter(com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter) ArrayList(java.util.ArrayList) EventObject(java.util.EventObject) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)

Example 2 with SparkSubmissionParameter

use of com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter in project azure-tools-for-java by Microsoft.

the class RemoteDebugRunConfiguration method readExternal.

@Override
public void readExternal(Element rootElement) throws InvalidDataException {
    super.readExternal(rootElement);
    SparkSubmitModel model = getSubmitModel();
    SparkSubmissionParameter parameter = Optional.ofNullable(model.getSubmissionParameter()).orElse(new SparkSubmissionParameter("", false, "", "", "", "", new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), Arrays.stream(SparkSubmissionParameter.defaultParameters).collect(Collectors.toMap(Pair::first, Pair::second))));
    Optional.ofNullable(rootElement.getChild(SUBMISSION_CONTENT_NAME)).ifPresent((element -> {
        Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_CLUSTER_NAME)).ifPresent(attribute -> parameter.setClusterName(attribute.getValue()));
        Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_IS_LOCAL_ARTIFACT)).ifPresent(attribute -> parameter.setLocalArtifact(attribute.getValue().toLowerCase().equals("true")));
        Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_ARTIFACT_NAME)).ifPresent(attribute -> parameter.setArtifactName(attribute.getValue()));
        Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_CLASSNAME)).ifPresent(attribute -> parameter.setClassName(attribute.getValue()));
        model.setSubmissionParameters(parameter);
    }));
}
Also used : SparkSubmissionParameter(com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter) Arrays(java.util.Arrays) ExecutionException(com.intellij.execution.ExecutionException) Collection(java.util.Collection) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) SparkSubmissionParameter(com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter) Executor(com.intellij.execution.Executor) InvalidDataException(com.intellij.openapi.util.InvalidDataException) Collectors(java.util.stream.Collectors) com.intellij.execution.configurations(com.intellij.execution.configurations) ArrayList(java.util.ArrayList) Pair(com.microsoft.azuretools.utils.Pair) Nullable(org.jetbrains.annotations.Nullable) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) SparkSubmissionContentPanel(com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel) Project(com.intellij.openapi.project.Project) Optional(java.util.Optional) SparkSubmitModel(com.microsoft.azure.hdinsight.spark.common.SparkSubmitModel) Module(com.intellij.openapi.module.Module) WriteExternalException(com.intellij.openapi.util.WriteExternalException) SparkBatchJobSubmissionState(com.microsoft.azure.hdinsight.spark.run.SparkBatchJobSubmissionState) NotNull(org.jetbrains.annotations.NotNull) Element(org.jdom.Element) SettingsEditor(com.intellij.openapi.options.SettingsEditor) SparkSubmitModel(com.microsoft.azure.hdinsight.spark.common.SparkSubmitModel) ArrayList(java.util.ArrayList)

Example 3 with SparkSubmissionParameter

use of com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter in project azure-tools-for-java by Microsoft.

the class RemoteDebugRunConfiguration method writeExternal.

@Override
public void writeExternal(Element rootElement) throws WriteExternalException {
    super.writeExternal(rootElement);
    SparkSubmitModel model = getSubmitModel();
    SparkSubmissionParameter submissionParameter = model.getSubmissionParameter();
    // The element to save editor's setting
    Element remoteDebugSettingsElement = new Element(SUBMISSION_CONTENT_NAME);
    remoteDebugSettingsElement.setAttribute(SUBMISSION_ATTRIBUTE_CLUSTER_NAME, submissionParameter.getClusterName());
    remoteDebugSettingsElement.setAttribute(SUBMISSION_ATTRIBUTE_IS_LOCAL_ARTIFACT, Boolean.toString(model.isLocalArtifact()));
    remoteDebugSettingsElement.setAttribute(SUBMISSION_ATTRIBUTE_ARTIFACT_NAME, submissionParameter.getArtifactName());
    remoteDebugSettingsElement.setAttribute(SUBMISSION_ATTRIBUTE_CLASSNAME, submissionParameter.getMainClassName());
    rootElement.addContent(remoteDebugSettingsElement);
}
Also used : SparkSubmissionParameter(com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter) SparkSubmitModel(com.microsoft.azure.hdinsight.spark.common.SparkSubmitModel) Element(org.jdom.Element)

Aggregations

SparkSubmissionParameter (com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter)3 SparkSubmitModel (com.microsoft.azure.hdinsight.spark.common.SparkSubmitModel)2 ArrayList (java.util.ArrayList)2 Element (org.jdom.Element)2 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 com.intellij.execution.configurations (com.intellij.execution.configurations)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 Module (com.intellij.openapi.module.Module)1 SettingsEditor (com.intellij.openapi.options.SettingsEditor)1 Project (com.intellij.openapi.project.Project)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 WriteExternalException (com.intellij.openapi.util.WriteExternalException)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 SparkBatchJobSubmissionState (com.microsoft.azure.hdinsight.spark.run.SparkBatchJobSubmissionState)1 SparkSubmissionContentPanel (com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel)1 Pair (com.microsoft.azuretools.utils.Pair)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1