Skip to content

Commit 5b4c762

Browse files
authored
1 parent aa5fd66 commit 5b4c762

File tree

10 files changed

+116
-63
lines changed

10 files changed

+116
-63
lines changed

PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.webapp/src/com/microsoft/azuretools/webapp/ui/AppServiceCreateDialog.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,17 +1022,19 @@ public static void initAspCache() {
10221022
try {
10231023
Map<String, List<AppServicePlan>> map = new ConcurrentHashMap<>();
10241024
Set<SubscriptionDetail> sdl = AzureModel.getInstance().getSubscriptionToResourceGroupMap().keySet();
1025-
Observable.from(sdl).flatMap((sd) ->
1026-
Observable.create((subscriber) -> {
1027-
try {
1028-
List<AppServicePlan> appServicePlans = AzureWebAppMvpModel.getInstance()
1029-
.listAppServicePlanBySubscriptionId(sd.getSubscriptionId());
1030-
map.put(sd.getSubscriptionId(), appServicePlans);
1031-
subscriber.onCompleted();
1032-
} catch (Exception e) {
1033-
Exceptions.propagate(e);
1034-
}
1035-
}).subscribeOn(Schedulers.io()), sdl.size()).subscribeOn(Schedulers.io()).toBlocking().subscribe();
1025+
if (sdl.size() > 0) {
1026+
Observable.from(sdl).flatMap((sd) ->
1027+
Observable.create((subscriber) -> {
1028+
try {
1029+
List<AppServicePlan> appServicePlans = AzureWebAppMvpModel.getInstance()
1030+
.listAppServicePlanBySubscriptionId(sd.getSubscriptionId());
1031+
map.put(sd.getSubscriptionId(), appServicePlans);
1032+
subscriber.onCompleted();
1033+
} catch (Exception e) {
1034+
Exceptions.propagate(e);
1035+
}
1036+
}).subscribeOn(Schedulers.io()), sdl.size()).subscribeOn(Schedulers.io()).toBlocking().subscribe();
1037+
}
10361038
sidAspMap = map;
10371039
} catch (Exception ignore) {
10381040
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/utility/AzureAnAction.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,19 @@ protected String getOperationName(AnActionEvent event) {
104104
* @return
105105
*/
106106
private String transformHDInsight(String serviceName, AnActionEvent event) {
107-
if (serviceName.equals(TelemetryConstants.ACTION)) {
108-
String text = event.getPresentation().getText().toLowerCase();
109-
if (text.contains("spark") || text.contains("hdinsight")) {
110-
return TelemetryConstants.HDINSIGHT;
111-
}
112-
String place = event.getPlace().toLowerCase();
113-
if (place.contains("spark") || place.contains("hdinsight")) {
114-
return TelemetryConstants.HDINSIGHT;
107+
try {
108+
if (serviceName.equals(TelemetryConstants.ACTION)) {
109+
String text = event.getPresentation().getText().toLowerCase();
110+
if (text.contains("spark") || text.contains("hdinsight")) {
111+
return TelemetryConstants.HDINSIGHT;
112+
}
113+
String place = event.getPlace().toLowerCase();
114+
if (place.contains("spark") || place.contains("hdinsight")) {
115+
return TelemetryConstants.HDINSIGHT;
116+
}
115117
}
118+
return serviceName;
119+
} catch (Exception ignore) {
116120
}
117121
return serviceName;
118122
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/NodeActionListener.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,21 @@ public ListenableFuture<Void> actionPerformedAsync(NodeActionEvent e) {
102102
* @return
103103
*/
104104
private String transformHDInsight(String serviceName, Node node) {
105-
if (serviceName.equals(TelemetryConstants.ACTION)) {
106-
String nodeName = node.getName().toLowerCase();
107-
if (nodeName.contains("spark") || nodeName.contains("hdinsight")) {
108-
return TelemetryConstants.HDINSIGHT;
109-
}
110-
if (node.getParent() != null) {
111-
String parentName = node.getParent().getName().toLowerCase();
112-
if (parentName.contains("spark") || parentName.contains("hdinsight")) {
105+
try {
106+
if (serviceName.equals(TelemetryConstants.ACTION)) {
107+
String nodeName = node.getName().toLowerCase();
108+
if (nodeName.contains("spark") || nodeName.contains("hdinsight")) {
113109
return TelemetryConstants.HDINSIGHT;
114110
}
111+
if (node.getParent() != null) {
112+
String parentName = node.getParent().getName().toLowerCase();
113+
if (parentName.contains("spark") || parentName.contains("hdinsight")) {
114+
return TelemetryConstants.HDINSIGHT;
115+
}
116+
}
115117
}
118+
return serviceName;
119+
} catch (Exception ignore) {
116120
}
117121
return serviceName;
118122
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/docker/DockerContainerNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ public void run() {
213213
});
214214
}
215215
}));
216-
addAction(ACTION_DELETE, ACTION_DELETE_ICON, new WrappedTelemetryNodeActionListener(DOCKER, DELETE_DOCKER_CONTAINER,
217-
new DeleteDockerContainerAction()));
216+
addAction(ACTION_DELETE, ACTION_DELETE_ICON, new DeleteDockerContainerAction());
218217
super.loadActions();
219218
}
220219

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/docker/DockerHostNode.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,8 @@ public void run() {
189189
});
190190
}
191191
}));
192-
addAction(ACTION_RESTART, ACTION_START_ICON, new WrappedTelemetryNodeActionListener(DOCKER, RESTART_DOCKER_HOST,
193-
new RestartDockerHostAction()));
194-
addAction(ACTION_SHUTDOWN, ACTION_SHUTDOWN_ICON, new WrappedTelemetryNodeActionListener(DOCKER, SHUTDOWN_DOCKER_HOST,
195-
new ShutdownDockerHostAction()));
192+
addAction(ACTION_RESTART, ACTION_START_ICON, new RestartDockerHostAction());
193+
addAction(ACTION_SHUTDOWN, ACTION_SHUTDOWN_ICON, new ShutdownDockerHostAction());
196194
super.loadActions();
197195
}
198196

@@ -243,6 +241,16 @@ protected void azureNodeAction(NodeActionEvent e)
243241
@Override
244242
protected void onSubscriptionsChanged(NodeActionEvent e) throws AzureCmdException {
245243
}
244+
245+
@Override
246+
protected String getServiceName() {
247+
return DOCKER;
248+
}
249+
250+
@Override
251+
protected String getOperationName(NodeActionEvent event) {
252+
return RESTART_DOCKER_HOST;
253+
}
246254
}
247255

248256
public class ShutdownDockerHostAction extends AzureNodeActionPromptListener {
@@ -282,6 +290,16 @@ protected void azureNodeAction(NodeActionEvent e)
282290
@Override
283291
protected void onSubscriptionsChanged(NodeActionEvent e) throws AzureCmdException {
284292
}
293+
294+
@Override
295+
protected String getServiceName() {
296+
return DOCKER;
297+
}
298+
299+
@Override
300+
protected String getOperationName(NodeActionEvent event) {
301+
return SHUTDOWN_DOCKER_HOST;
302+
}
285303
}
286304

287305
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/rediscache/RedisCacheNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
153153
@Override
154154
protected void loadActions() {
155155
if (!CREATING_STATE.equals(this.provisionState)) {
156-
addAction(DELETE_ACTION, null, new WrappedTelemetryNodeActionListener(REDIS, DELETE_REDIS,
157-
new DeleteRedisCacheAction()));
156+
addAction(DELETE_ACTION, null, new DeleteRedisCacheAction());
158157
addAction(SHOW_PROPERTY_ACTION, null, new WrappedTelemetryNodeActionListener(REDIS, REDIS_READPROP,
159158
new ShowRedisCachePropertyAction()));
160159
addAction(OPEN_EXPLORER, null, new WrappedTelemetryNodeActionListener(REDIS, REDIS_OPEN_EXPLORER,

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/webapp/WebAppNode.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ protected void loadActions() {
8787
createBackgroundActionListener("Starting Web App", () -> startWebApp())));
8888
addAction(ACTION_RESTART, new WrappedTelemetryNodeActionListener(WEBAPP, RESTART_WEBAPP,
8989
createBackgroundActionListener("Restarting Web App", () -> restartWebApp())));
90-
addAction(ACTION_DELETE, new WrappedTelemetryNodeActionListener(WEBAPP, DELETE_WEBAPP,
91-
new DeleteWebAppAction()));
90+
addAction(ACTION_DELETE, new DeleteWebAppAction());
9291
addAction(ACTION_OPEN_IN_BROWSER, new WrappedTelemetryNodeActionListener(WEBAPP, WEBAPP_OPEN_INBROWSER,
9392
new NodeActionListener() {
9493
@Override
@@ -163,5 +162,15 @@ protected void azureNodeAction(NodeActionEvent e) {
163162
@Override
164163
protected void onSubscriptionsChanged(NodeActionEvent e) {
165164
}
165+
166+
@Override
167+
protected String getServiceName() {
168+
return WEBAPP;
169+
}
170+
171+
@Override
172+
protected String getOperationName(NodeActionEvent event) {
173+
return DELETE_WEBAPP;
174+
}
166175
}
167176
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/webapp/deploymentslot/DeploymentSlotNode.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ protected void actionPerformed(NodeActionEvent e) {
100100
DefaultLoader.getUIHelper().openInBrowser("http://" + hostName);
101101
}
102102
}));
103-
addAction(ACTION_DELETE, new WrappedTelemetryNodeActionListener(WEBAPP, DELETE_WEBAPP_SLOT,
104-
new DeleteDeploymentSlotAction()));
103+
addAction(ACTION_DELETE, new DeleteDeploymentSlotAction());
105104
addAction(ACTION_SHOW_PROPERTY, new WrappedTelemetryNodeActionListener(WEBAPP, SHOW_WEBAPP_SLOT_PROP,
106105
new NodeActionListener() {
107106
@Override
@@ -180,5 +179,15 @@ protected void azureNodeAction(NodeActionEvent e) {
180179
@Override
181180
protected void onSubscriptionsChanged(NodeActionEvent e) {
182181
}
182+
183+
@Override
184+
protected String getServiceName() {
185+
return WEBAPP;
186+
}
187+
188+
@Override
189+
protected String getOperationName(NodeActionEvent event) {
190+
return DELETE_WEBAPP_SLOT;
191+
}
183192
}
184193
}

Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/webapp/AzureWebAppMvpModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ public List<ResourceEx<WebApp>> listWebAppsOnLinuxBySubscriptionId(final String
516516
public List<ResourceEx<WebApp>> listAllWebApps(final boolean force) {
517517
final List<ResourceEx<WebApp>> webApps = new ArrayList<>();
518518
List<Subscription> subs = AzureMvpModel.getInstance().getSelectedSubscriptions();
519+
if (subs.size() == 0) {
520+
return webApps;
521+
}
519522
Observable.from(subs).flatMap((sd) ->
520523
Observable.create((subscriber) -> {
521524
List<ResourceEx<WebApp>> webAppList = listWebApps(sd.subscriptionId(), force);

Utils/azuretools-core/src/com/microsoft/azuretools/utils/AzureModelController.java

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -268,32 +268,33 @@ public static synchronized void updateSubscriptionMaps(IProgressIndicator progre
268268
subscriptionManager.addListener(subscriptionSelectionListener);
269269

270270
List<SubscriptionDetail> sdl = subscriptionManager.getSubscriptionDetails();
271-
Observable.from(sdl).flatMap((sd) ->
272-
Observable.create((subscriber) -> {
273-
try {
274-
if (progressIndicator != null && progressIndicator.isCanceled()) {
275-
clearAll();
276-
throw new CanceledByUserException();
277-
}
278-
if (sd.isSelected()) {
279-
if (progressIndicator != null) {
280-
progressIndicator.setText("Reading subscription");
271+
if (sdl.size() > 0) {
272+
Observable.from(sdl).flatMap((sd) ->
273+
Observable.create((subscriber) -> {
274+
try {
275+
if (progressIndicator != null && progressIndicator.isCanceled()) {
276+
clearAll();
277+
throw new CanceledByUserException();
278+
}
279+
if (sd.isSelected()) {
280+
if (progressIndicator != null) {
281+
progressIndicator.setText("Reading subscription");
282+
}
283+
Azure azure = azureManager.getAzure(sd.getSubscriptionId());
284+
285+
List<ResourceGroup> rgList = azure.resourceGroups().list();
286+
sdrgMap.put(sd, rgList);
287+
288+
List<Location> locl = sidToSubscriptionMap.get(sd.getSubscriptionId()).listLocations();
289+
Collections.sort(locl, Comparator.comparing(Location::displayName));
290+
sdlocMap.put(sd, locl);
281291
}
282-
Azure azure = azureManager.getAzure(sd.getSubscriptionId());
283-
284-
List<ResourceGroup> rgList = azure.resourceGroups().list();
285-
sdrgMap.put(sd, rgList);
286-
287-
List<Location> locl = sidToSubscriptionMap.get(sd.getSubscriptionId()).listLocations();
288-
Collections.sort(locl, Comparator.comparing(Location::displayName));
289-
sdlocMap.put(sd, locl);
290292
subscriber.onCompleted();
293+
} catch (Exception e) {
294+
Exceptions.propagate(e);
291295
}
292-
} catch (Exception e) {
293-
Exceptions.propagate(e);
294-
}
295-
}).subscribeOn(Schedulers.io()), sdl.size()).subscribeOn(Schedulers.io()).toBlocking().subscribe();
296-
296+
}).subscribeOn(Schedulers.io()), sdl.size()).subscribeOn(Schedulers.io()).toBlocking().subscribe();
297+
}
297298
azureModel.setSubscriptionToResourceGroupMap(sdrgMap);
298299
azureModel.setSubscriptionToLocationMap(sdlocMap);
299300
}
@@ -308,8 +309,13 @@ public static synchronized void updateResourceGroupMaps(IProgressIndicator progr
308309
Map<ResourceGroup, List<WebApp>> rgwaMap = azureModel.createResourceGroupToWebAppMap();
309310
Map<ResourceGroup, List<AppServicePlan>> rgspMap = azureModel.createResourceGroupToAppServicePlanMap();
310311
Set<SubscriptionDetail> sdSet = azureModel.getSubscriptionToResourceGroupMap().keySet();
311-
CountDownLatch countDownLatch = new CountDownLatch(sdSet.size());
312+
if (sdSet.size() == 0) {
313+
azureModel.setResourceGroupToWebAppMap(rgwaMap);
314+
azureModel.setResourceGroupToAppServicePlanMap(rgspMap);
315+
return;
316+
}
312317

318+
CountDownLatch countDownLatch = new CountDownLatch(sdSet.size());
313319
Observable.from(sdSet).flatMap((sd) ->
314320
Observable.create((subscriber) -> {
315321
try {

0 commit comments

Comments
 (0)