Search in sources :

Example 1 with ClusterDetail

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

ClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail)1 EmulatorClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail)1 HDInsightAdditionalClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail)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