Skip to content

Commit 4c13b21

Browse files
committed
Add storage key into conf, but has regressions
1 parent 513a1a4 commit 4c13b21

File tree

5 files changed

+184
-93
lines changed

5 files changed

+184
-93
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/serverexplore/ui/AddNewClusterFrom.form

Lines changed: 64 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.microsoft.azure.hdinsight.serverexplore.ui.AddNewClusterFrom">
3-
<grid id="27dc6" binding="addNewClusterPanel" layout-manager="GridLayoutManager" row-count="15" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="27dc6" binding="addNewClusterPanel" layout-manager="GridLayoutManager" row-count="13" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="456" height="426"/>
6+
<xy x="20" y="20" width="554" height="472"/>
77
</constraints>
88
<properties>
99
<doubleBuffered value="true"/>
@@ -16,7 +16,7 @@
1616
<children>
1717
<component id="75f7e" class="javax.swing.JLabel" binding="clusterNameLabel">
1818
<constraints>
19-
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="2" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
19+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="2" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
2020
</constraints>
2121
<properties>
2222
<text value="Cluster Name:"/>
@@ -32,7 +32,7 @@
3232
</component>
3333
<component id="500cb" class="javax.swing.JTextField" binding="clusterNameFiled">
3434
<constraints>
35-
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
35+
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
3636
<preferred-size width="270" height="24"/>
3737
</grid>
3838
</constraints>
@@ -42,7 +42,7 @@
4242
</component>
4343
<component id="32905" class="javax.swing.JTextField" binding="errorMessageField">
4444
<constraints>
45-
<grid row="13" column="1" row-span="1" col-span="2" vsize-policy="2" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
45+
<grid row="12" column="1" row-span="1" col-span="2" vsize-policy="2" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
4646
<preferred-size width="150" height="-1"/>
4747
</grid>
4848
</constraints>
@@ -54,16 +54,9 @@
5454
<visible value="true"/>
5555
</properties>
5656
</component>
57-
<vspacer id="78d3b">
58-
<constraints>
59-
<grid row="14" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
60-
<preferred-size width="270" height="15"/>
61-
</grid>
62-
</constraints>
63-
</vspacer>
6457
<component id="5f906" class="javax.swing.JPasswordField" binding="passwordField">
6558
<constraints>
66-
<grid row="11" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
59+
<grid row="10" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
6760
<preferred-size width="270" height="25"/>
6861
</grid>
6962
</constraints>
@@ -73,7 +66,7 @@
7366
</component>
7467
<component id="beb" class="javax.swing.JLabel" binding="passwordLabel">
7568
<constraints>
76-
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
69+
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
7770
</constraints>
7871
<properties>
7972
<text value="Password:"/>
@@ -90,103 +83,104 @@
9083
<toolTipText value="The user name of the HDInsight cluster.&#10;&#10;Press the F1 key or click the '?'(Help) button to get more details."/>
9184
</properties>
9285
</component>
93-
<vspacer id="f887">
94-
<constraints>
95-
<grid row="10" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
96-
<preferred-size width="270" height="5"/>
97-
</grid>
98-
</constraints>
99-
</vspacer>
100-
<vspacer id="7f432">
101-
<constraints>
102-
<grid row="8" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
103-
<preferred-size width="270" height="5"/>
104-
</grid>
105-
</constraints>
106-
</vspacer>
10786
<component id="7586e" class="javax.swing.JLabel" binding="storageKeyLabel">
10887
<constraints>
109-
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="5" fill="0" indent="0" use-parent-layout="false"/>
88+
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="5" fill="0" indent="0" use-parent-layout="false"/>
11089
</constraints>
11190
<properties>
11291
<text value="Storage Key:"/>
11392
</properties>
11493
</component>
11594
<component id="d806b" class="javax.swing.JLabel" binding="storageNameLabel">
11695
<constraints>
117-
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
96+
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
11897
</constraints>
11998
<properties>
120-
<text value="Default Storage Account:"/>
99+
<text value="Storage Account:"/>
121100
</properties>
122101
</component>
123102
<component id="ccca8" class="javax.swing.JTextField" binding="storageNameField">
124103
<constraints>
125-
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
104+
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
126105
<preferred-size width="270" height="24"/>
127106
</grid>
128107
</constraints>
129108
<properties>
130109
<toolTipText value="The default storage account of the HDInsight cluster, which can be found from HDInsight cluster properties of Azure portal.&#10;&#10;Press the F1 key or click the '?'(Help) button to get more details."/>
131110
</properties>
132111
</component>
133-
<vspacer id="ecbce">
112+
<component id="88bef" class="javax.swing.JTextArea" binding="storageKeyTextField">
134113
<constraints>
135-
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
136-
<preferred-size width="270" height="30"/>
114+
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
115+
<preferred-size width="150" height="50"/>
137116
</grid>
138117
</constraints>
139-
</vspacer>
140-
<vspacer id="4641b">
118+
<properties>
119+
<columns value="0"/>
120+
<lineWrap value="true"/>
121+
<toolTipText value="The storage key of the default storage account, which can be found from HDInsight cluster storage accounts of Azure portal.&#10;&#10;Press the F1 key or click the '?'(Help) button to get more details."/>
122+
</properties>
123+
<clientProperties>
124+
<html.disable class="java.lang.Boolean" value="false"/>
125+
</clientProperties>
126+
</component>
127+
<component id="c4bf7" class="javax.swing.JLabel">
141128
<constraints>
142-
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
143-
<preferred-size width="270" height="20"/>
144-
</grid>
129+
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="2" hsize-policy="2" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
145130
</constraints>
146-
</vspacer>
147-
<vspacer id="b5dd7">
131+
<properties>
132+
<font size="16" style="1"/>
133+
<text value="HDInsight Cluster To Link"/>
134+
</properties>
135+
</component>
136+
<component id="90809" class="javax.swing.JComboBox" binding="containersComboBox">
148137
<constraints>
149-
<grid row="12" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
150-
<preferred-size width="270" height="10"/>
151-
</grid>
138+
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
152139
</constraints>
153-
</vspacer>
154-
<vspacer id="40ef">
140+
<properties/>
141+
</component>
142+
<component id="2dce8" class="javax.swing.JLabel" binding="storageContainerLabel">
155143
<constraints>
156-
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
157-
<preferred-size width="270" height="14"/>
158-
</grid>
144+
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
159145
</constraints>
160-
</vspacer>
161-
<vspacer id="49387">
146+
<properties>
147+
<text value="Storage Container:"/>
148+
</properties>
149+
</component>
150+
<component id="195a7" class="javax.swing.JSeparator">
162151
<constraints>
163-
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
164-
<preferred-size width="270" height="14"/>
165-
</grid>
152+
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
166153
</constraints>
167-
</vspacer>
168-
<component id="88bef" class="javax.swing.JTextArea" binding="storageKeyTextField">
154+
<properties/>
155+
</component>
156+
<component id="8b19" class="javax.swing.JLabel">
169157
<constraints>
170-
<grid row="7" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
171-
<preferred-size width="150" height="50"/>
172-
</grid>
158+
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
173159
</constraints>
174160
<properties>
175-
<columns value="0"/>
176-
<lineWrap value="true"/>
177-
<toolTipText value="The storage key of the default storage account, which can be found from HDInsight cluster storage accounts of Azure portal.&#10;&#10;Press the F1 key or click the '?'(Help) button to get more details."/>
161+
<font size="16" style="1"/>
162+
<text value="The Storage To Upload Spark Batch Job Files"/>
178163
</properties>
179-
<clientProperties>
180-
<html.disable class="java.lang.Boolean" value="false"/>
181-
</clientProperties>
182164
</component>
183-
<component id="c4bf7" class="javax.swing.JLabel">
165+
<component id="9350a" class="javax.swing.JSeparator">
166+
<constraints>
167+
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
168+
</constraints>
169+
<properties/>
170+
</component>
171+
<component id="21136" class="javax.swing.JSeparator">
172+
<constraints>
173+
<grid row="11" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
174+
</constraints>
175+
<properties/>
176+
</component>
177+
<component id="c082e" class="javax.swing.JLabel">
184178
<constraints>
185-
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="2" hsize-policy="2" anchor="1" fill="0" indent="0" use-parent-layout="false"/>
179+
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
186180
</constraints>
187181
<properties>
188-
<font size="26"/>
189-
<text value="Link A Cluster"/>
182+
<font size="16" style="1"/>
183+
<text value="The Cluster Account For Logging In"/>
190184
</properties>
191185
</component>
192186
</children>

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/serverexplore/ui/AddNewClusterFrom.java

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@
3838
import com.microsoft.azuretools.azurecommons.helpers.StringHelper;
3939
import com.microsoft.azuretools.telemetry.AppInsightsClient;
4040
import com.microsoft.intellij.hdinsight.messages.HDInsightBundle;
41+
import com.microsoft.tooling.msservices.helpers.azure.sdk.StorageClientSDKManager;
42+
import com.microsoft.tooling.msservices.model.storage.BlobContainer;
43+
import com.microsoft.tooling.msservices.model.storage.ClientStorageAccount;
44+
import org.apache.commons.lang.StringUtils;
4145
import org.jetbrains.annotations.NotNull;
4246
import org.jetbrains.annotations.Nullable;
4347

4448
import javax.swing.*;
4549
import java.awt.*;
4650
import java.awt.event.ActionEvent;
51+
import java.awt.event.FocusAdapter;
52+
import java.awt.event.FocusEvent;
53+
import java.util.Optional;
4754
import java.util.stream.Stream;
4855

4956
public class AddNewClusterFrom extends DialogWrapper {
@@ -55,6 +62,7 @@ public class AddNewClusterFrom extends DialogWrapper {
5562

5663
private String storageName;
5764
private String storageKey;
65+
private String storageContainer;
5866

5967
private HDStorageAccount storageAccount;
6068

@@ -73,6 +81,8 @@ public class AddNewClusterFrom extends DialogWrapper {
7381
private JLabel storageKeyLabel;
7482
private JLabel userNameLabel;
7583
private JLabel passwordLabel;
84+
private JComboBox<BlobContainer> containersComboBox;
85+
private JLabel storageContainerLabel;
7686

7787
private HDInsightRootModule hdInsightModule;
7888

@@ -93,8 +103,58 @@ public AddNewClusterFrom(final Project project, HDInsightRootModule hdInsightMod
93103
errorMessageField.setBorder(BorderFactory.createEmptyBorder());
94104

95105
this.setModal(true);
106+
107+
storageKeyTextField.addFocusListener(new FocusAdapter() {
108+
@Override
109+
public void focusLost(FocusEvent e) {
110+
super.focusLost(e);
111+
112+
if (StringUtils.isNotBlank(storageNameField.getText()) && StringUtils.isNotBlank(storageKeyTextField.getText())) {
113+
ClientStorageAccount storageAccount = new ClientStorageAccount(storageNameField.getText());
114+
storageAccount.setPrimaryKey(storageKeyTextField.getText());
115+
116+
refreshContainers(storageAccount);
117+
}
118+
}
119+
});
120+
121+
storageNameField.addFocusListener(new FocusAdapter() {
122+
@Override
123+
public void focusLost(FocusEvent e) {
124+
super.focusLost(e);
125+
126+
if (StringUtils.isNotBlank(storageNameField.getText()) && StringUtils.isNotBlank(storageKeyTextField.getText())) {
127+
ClientStorageAccount storageAccount = new ClientStorageAccount(storageNameField.getText());
128+
storageAccount.setPrimaryKey(storageKeyTextField.getText());
129+
130+
refreshContainers(storageAccount);
131+
}
132+
}
133+
});
96134
}
97135

136+
private void refreshContainers(@NotNull ClientStorageAccount storageAccount) {
137+
try {
138+
containersComboBox.removeAllItems();
139+
140+
StorageClientSDKManager.getManager().getBlobContainers(storageAccount.getConnectionString())
141+
.forEach(containersComboBox::addItem);
142+
143+
containersComboBox.setMaximumRowCount(6);
144+
} catch (AzureCmdException e) {
145+
containersComboBox.removeAllItems();
146+
}
147+
}
148+
149+
// Optional<HDStorageAccount> getBlobStorageAccount() {
150+
// if (StringUtils.isBlank(storageName) || StringUtils.isBlank(storageKey) || StringUtils.isBlank(storageContainer)) {
151+
// return Optional.empty();
152+
// }
153+
//
154+
// return Optional.of(new HDStorageAccount(
155+
// null, ClusterManagerEx.getInstance().getBlobFullName(storageName), storageKey, true, storageContainer));
156+
// }
157+
98158
private class HelpAction extends AbstractAction {
99159
private HelpAction() {
100160
this.putValue("Name", CommonBundle.getHelpButtonText());
@@ -157,6 +217,13 @@ protected void doOKAction() {
157217
isCarryOnNextStep = false;
158218
}
159219
}
220+
221+
if (containersComboBox.getSelectedItem() == null) {
222+
errorMessage = "The storage container isn't selected";
223+
isCarryOnNextStep = false;
224+
} else {
225+
storageContainer = ((BlobContainer) containersComboBox.getSelectedItem()).getName();
226+
}
160227
}
161228

162229
if (isCarryOnNextStep) {
@@ -190,17 +257,18 @@ private static String getClusterName(String userNameOrUrl) {
190257
private void getStorageAccount() {
191258
addNewClusterPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
192259

193-
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
194-
@Override
195-
public void run() {
196-
try {
197-
storageAccount = AddHDInsightAdditionalClusterImpl.getStorageAccount(clusterName, storageName, storageKey, userName, password);
198-
isCarryOnNextStep = true;
199-
} catch (AzureCmdException | HDIException e) {
200-
isCarryOnNextStep = false;
201-
errorMessage = e.getMessage();
202-
}
203-
}
260+
ApplicationManager.getApplication().invokeAndWait(() -> {
261+
// try {
262+
// storageAccount = AddHDInsightAdditionalClusterImpl.getStorageAccount(clusterName, storageName, storageKey, userName, password);
263+
// isCarryOnNextStep = true;
264+
// } catch (AzureCmdException | HDIException e) {
265+
// isCarryOnNextStep = false;
266+
// errorMessage = e.getMessage();
267+
// }
268+
269+
storageAccount = new HDStorageAccount(
270+
null, ClusterManagerEx.getInstance().getBlobFullName(storageName), storageKey, false, storageContainer);
271+
isCarryOnNextStep = true;
204272
}, ModalityState.NON_MODAL);
205273

206274
addNewClusterPanel.setCursor(Cursor.getDefaultCursor());

0 commit comments

Comments
 (0)