Search in sources :

Example 1 with EmulatorClusterDetail

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

the class AddNewEmulatorForm method showEmulatorSetup.

private void showEmulatorSetup() {
    if (isCarryOnNextStep) {
        EmulatorClusterDetail emulatorClusterDetail = new EmulatorClusterDetail(clusterName, userName, password, livyEndpoint, sshEndpoint, sparkHistoryEndpoint, ambariEndpoint);
        ClusterManagerEx.getInstance().addEmulatorCluster(emulatorClusterDetail);
        hdInsightModule.refreshWithoutAsync();
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                close(DialogWrapper.OK_EXIT_CODE, true);
            }
        });
    } else {
        errorMessageField.setText(errorMessage);
    }
}
Also used : EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail)

Example 2 with EmulatorClusterDetail

use of com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail 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)

Example 3 with EmulatorClusterDetail

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

the class AddNewEmulatorForm method showEmulatorSetup.

private void showEmulatorSetup() {
    if (isCarryOnNextStep) {
        EmulatorClusterDetail emulatorClusterDetail = new EmulatorClusterDetail(clusterName, userName, password, livyEndpoint, sshEndpoint, sparkHistoryEndpoint, ambariEndpoint);
        ClusterManagerEx.getInstance().addEmulatorCluster(emulatorClusterDetail);
        hdInsightModule.refreshWithoutAsync();
        super.okPressed();
    } else {
        errorMessageField.setText(errorMessage);
        errorMessageField.setVisible(true);
    }
}
Also used : EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail)

Example 4 with EmulatorClusterDetail

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

the class SparkSubmitHelper method sftpFileToEmulator.

public String sftpFileToEmulator(Project project, String localFile, String folderPath, IClusterDetail clusterDetail) throws IOException, HDIException, JSchException, SftpException {
    EmulatorClusterDetail emulatorClusterDetail = (EmulatorClusterDetail) clusterDetail;
    final File file = new File(localFile);
    try (FileInputStream fileInputStream = new FileInputStream(file)) {
        try (BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream)) {
            String sshEndpoint = emulatorClusterDetail.getSSHEndpoint();
            URL url = new URL(sshEndpoint);
            String host = url.getHost();
            int port = url.getPort();
            JSch jsch = new JSch();
            Session session = jsch.getSession(emulatorClusterDetail.getHttpUserName(), host, port);
            session.setPassword(emulatorClusterDetail.getHttpPassword());
            java.util.Properties config = new java.util.Properties();
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect();
            ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
            channel.connect();
            String[] folders = folderPath.split("/");
            for (String folder : folders) {
                if (folder.length() > 0) {
                    try {
                        channel.cd(folder);
                    } catch (SftpException e) {
                        channel.mkdir(folder);
                        channel.cd(folder);
                    }
                }
            }
            channel.put(bufferedInputStream, file.getName());
            channel.disconnect();
            session.disconnect();
            return file.getName();
        }
    }
}
Also used : EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail) URL(java.net.URL) java.util(java.util)

Example 5 with EmulatorClusterDetail

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

the class SparkSubmitHelper method sftpFileToEmulator.

public String sftpFileToEmulator(String localFile, String folderPath, IClusterDetail clusterDetail) throws IOException, HDIException, JSchException, SftpException {
    EmulatorClusterDetail emulatorClusterDetail = (EmulatorClusterDetail) clusterDetail;
    final File file = new File(localFile);
    try (FileInputStream fileInputStream = new FileInputStream(file)) {
        try (BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream)) {
            String sshEndpoint = emulatorClusterDetail.getSSHEndpoint();
            URL url = new URL(sshEndpoint);
            String host = url.getHost();
            int port = url.getPort();
            JSch jsch = new JSch();
            Session session = jsch.getSession(emulatorClusterDetail.getHttpUserName(), host, port);
            session.setPassword(emulatorClusterDetail.getHttpPassword());
            java.util.Properties config = new java.util.Properties();
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect();
            ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
            channel.connect();
            String[] folders = folderPath.split("/");
            for (String folder : folders) {
                if (folder.length() > 0) {
                    try {
                        channel.cd(folder);
                    } catch (SftpException e) {
                        channel.mkdir(folder);
                        channel.cd(folder);
                    }
                }
            }
            channel.put(bufferedInputStream, file.getName());
            channel.disconnect();
            session.disconnect();
            return file.getName();
        }
    }
}
Also used : EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail) SftpException(com.jcraft.jsch.SftpException) JSch(com.jcraft.jsch.JSch) FileInputStream(java.io.FileInputStream) URL(java.net.URL) ChannelSftp(com.jcraft.jsch.ChannelSftp) BufferedInputStream(java.io.BufferedInputStream) File(java.io.File) Session(com.jcraft.jsch.Session)

Aggregations

EmulatorClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail)7 URL (java.net.URL)3 File (java.io.File)2 java.util (java.util)2 UISettings (com.intellij.ide.ui.UISettings)1 UISettingsListener (com.intellij.ide.ui.UISettingsListener)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 ChannelSftp (com.jcraft.jsch.ChannelSftp)1 JSch (com.jcraft.jsch.JSch)1 Session (com.jcraft.jsch.Session)1 SftpException (com.jcraft.jsch.SftpException)1 ClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail)1 HDInsightAdditionalClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 LivyCluster (com.microsoft.azure.hdinsight.sdk.cluster.LivyCluster)1 HttpResponse (com.microsoft.azure.hdinsight.sdk.common.HttpResponse)1 SparkSession (com.microsoft.azure.hdinsight.sdk.common.livy.interactive.SparkSession)1 LivySession (com.microsoft.azure.hdinsight.spark.jobs.livy.LivySession)1 NodeActionEvent (com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)1 NodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener)1