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);
}
}
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();
}
}
});
}
}
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);
}
}
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();
}
}
}
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();
}
}
}
Aggregations