Search in sources :

Example 1 with HDInsightAdditionalClusterDetail

use of com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail in project azure-tools-for-java by Microsoft.

the class AddNewClusterFrom method addActionListener.

private void addActionListener() {
    Okbutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            synchronized (AddNewClusterFrom.class) {
                isCarryOnNextStep = true;
                errorMessage = null;
                errorMessageField.setVisible(false);
                String clusterNameOrUrl = clusterNameFiled.getText().trim();
                userName = userNameField.getText().trim();
                storageName = storageNameField.getText().trim();
                storageKey = storageKeyTextField.getText().trim();
                password = String.valueOf(passwordField.getPassword());
                if (StringHelper.isNullOrWhiteSpace(clusterNameOrUrl) || StringHelper.isNullOrWhiteSpace(storageName) || StringHelper.isNullOrWhiteSpace(storageKey) || StringHelper.isNullOrWhiteSpace(userName) || StringHelper.isNullOrWhiteSpace(password)) {
                    errorMessage = "Cluster Name, Storage Key, User Name, or Password shouldn't be empty";
                    isCarryOnNextStep = false;
                } else {
                    clusterName = getClusterName(clusterNameOrUrl);
                    if (clusterName == null) {
                        errorMessage = "Wrong cluster name or endpoint";
                        isCarryOnNextStep = false;
                    } else {
                        int status = ClusterManagerEx.getInstance().isHDInsightAdditionalStorageExist(clusterName, storageName);
                        if (status == 1) {
                            errorMessage = "Cluster already exist in current list";
                            isCarryOnNextStep = false;
                        } else if (status == 2) {
                            errorMessage = "Default storage account is required";
                            isCarryOnNextStep = false;
                        }
                    }
                }
                if (isCarryOnNextStep) {
                    getStorageAccount();
                }
                if (isCarryOnNextStep) {
                    if (storageAccount != null) {
                        HDInsightAdditionalClusterDetail hdInsightAdditionalClusterDetail = new HDInsightAdditionalClusterDetail(clusterName, userName, password, storageAccount);
                        ClusterManagerEx.getInstance().addHDInsightAdditionalCluster(hdInsightAdditionalClusterDetail);
                        hdInsightModule.refreshWithoutAsync();
                    }
                    close(DialogWrapper.OK_EXIT_CODE, true);
                } else {
                    errorMessageField.setText(errorMessage);
                    errorMessageField.setVisible(true);
                }
            }
        }
    });
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            close(DialogWrapper.CANCEL_EXIT_CODE, true);
        }
    });
}
Also used : HDInsightAdditionalClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 2 with HDInsightAdditionalClusterDetail

use of com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail in project azure-tools-for-java by Microsoft.

the class AddNewClusterForm method okPressed.

@Override
protected void okPressed() {
    synchronized (AddNewClusterForm.class) {
        isCarryOnNextStep = true;
        setErrorMessage(null);
        String clusterNameOrUrl = clusterNameField.getText().trim();
        userName = userNameField.getText().trim();
        storageName = storageNameField.getText().trim();
        storageKey = storageKeyField.getText().trim();
        password = passwordField.getText();
        if (StringHelper.isNullOrWhiteSpace(clusterNameOrUrl) || StringHelper.isNullOrWhiteSpace(storageName) || StringHelper.isNullOrWhiteSpace(storageKey) || StringHelper.isNullOrWhiteSpace(userName) || StringHelper.isNullOrWhiteSpace(password)) {
            setErrorMessage("Cluster Name, Storage Key, User Name, or Password shouldn't be empty");
            isCarryOnNextStep = false;
        } else {
            clusterName = getClusterName(clusterNameOrUrl);
            if (clusterName == null) {
                setErrorMessage("Wrong cluster name or endpoint");
                isCarryOnNextStep = false;
            } else {
                int status = ClusterManagerEx.getInstance().isHDInsightAdditionalStorageExist(clusterName, storageName);
                if (status == 1) {
                    setErrorMessage("Cluster already exist in current list");
                    isCarryOnNextStep = false;
                } else if (status == 2) {
                    setErrorMessage("Default storage account is required");
                    isCarryOnNextStep = false;
                }
            }
        }
        if (isCarryOnNextStep) {
            getStorageAccount();
        }
        if (isCarryOnNextStep) {
            if (storageAccount != null) {
                HDInsightAdditionalClusterDetail hdInsightAdditionalClusterDetail = new HDInsightAdditionalClusterDetail(clusterName, userName, password, storageAccount);
                ClusterManagerEx.getInstance().addHDInsightAdditionalCluster(hdInsightAdditionalClusterDetail);
                hdInsightModule.refreshWithoutAsync();
            }
            super.okPressed();
        }
    }
}
Also used : HDInsightAdditionalClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail)

Example 3 with HDInsightAdditionalClusterDetail

use of com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail in project azure-tools-for-java by Microsoft.

the class ClusterNode method loadActions.

@Override
protected void loadActions() {
    super.loadActions();
    addAction("Open Spark History UI", new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            String sparkHistoryUrl = clusterDetail.isEmulator() ? ((EmulatorClusterDetail) clusterDetail).getSparkHistoryEndpoint() : String.format("https://%s.azurehdinsight.net/sparkhistory", clusterDetail.getName());
            openUrlLink(sparkHistoryUrl);
        }
    });
    addAction("Open Cluster Management Portal(Ambari)", new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            String ambariUrl = clusterDetail.isEmulator() ? ((EmulatorClusterDetail) clusterDetail).getAmbariEndpoint() : String.format(CommonConstant.DEFAULT_CLUSTER_ENDPOINT, clusterDetail.getName());
            openUrlLink(ambariUrl);
        }
    });
    if (clusterDetail instanceof ClusterDetail) {
        addAction("Open Jupyter Notebook", new NodeActionListener() {

            @Override
            protected void actionPerformed(NodeActionEvent e) {
                String jupyterUrl = String.format("https://%s.azurehdinsight.net/jupyter/tree", clusterDetail.getName());
                openUrlLink(jupyterUrl);
            }
        });
        addAction("Open Azure Management Portal", new NodeActionListener() {

            @Override
            protected void actionPerformed(NodeActionEvent e) {
                String resourceGroupName = clusterDetail.getResourceGroup();
                if (resourceGroupName != null) {
                    String webPortHttpLink = String.format("https://portal.azure.com/#resource/subscriptions/%s/resourcegroups/%s/providers/Microsoft.HDInsight/clusters/%s", clusterDetail.getSubscription().getSubscriptionId(), resourceGroupName, clusterDetail.getName());
                    openUrlLink(webPortHttpLink);
                } else {
                    DefaultLoader.getUIHelper().showError("Failed to get resource group name.", "HDInsight Explorer");
                }
            }
        });
    }
    if (clusterDetail instanceof HDInsightAdditionalClusterDetail) {
        addAction("Unlink", new NodeActionListener() {

            @Override
            protected void actionPerformed(NodeActionEvent e) {
                boolean choice = DefaultLoader.getUIHelper().showConfirmation("Do you really want to unlink the HDInsight cluster?", "Unlink HDInsight Cluster", new String[] { "Yes", "No" }, null);
                if (choice) {
                    ClusterManagerEx.getInstance().removeHDInsightAdditionalCluster((HDInsightAdditionalClusterDetail) clusterDetail);
                    ((HDInsightRootModule) getParent()).refreshWithoutAsync();
                }
            }
        });
    }
    if (clusterDetail instanceof EmulatorClusterDetail) {
        addAction("Unlink", new NodeActionListener() {

            @Override
            protected void actionPerformed(NodeActionEvent e) {
                boolean choice = DefaultLoader.getUIHelper().showConfirmation("Do you really want to unlink the Emulator cluster?", "Unlink HDInsight Cluster", new String[] { "Yes", "No" }, null);
                if (choice) {
                    ClusterManagerEx.getInstance().removeEmulatorCluster((EmulatorClusterDetail) clusterDetail);
                    ((HDInsightRootModule) getParent()).refreshWithoutAsync();
                }
            }
        });
    }
}
Also used : EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail) HDInsightAdditionalClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail) EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail) HDInsightAdditionalClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail) ClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)

Aggregations

HDInsightAdditionalClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail)3 ClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail)1 EmulatorClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 NodeActionEvent (com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)1 NodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1