use of com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException in project azure-tools-for-java by Microsoft.
the class FunctionDeploymentState method listFunctions.
// todo: Move to toolkit lib as shared task
private List<FunctionEntity> listFunctions(final IFunctionApp functionApp) {
final int[] count = { 0 };
final IAzureMessager azureMessager = AzureMessager.getMessager();
return Mono.fromCallable(() -> {
final AzureString message = count[0]++ == 0 ? AzureString.fromString(SYNCING_TRIGGERS) : AzureString.format(SYNCING_TRIGGERS_WITH_RETRY, count[0], LIST_TRIGGERS_MAX_RETRY);
azureMessager.info(message);
return Optional.ofNullable(functionApp.listFunctions(true)).filter(CollectionUtils::isNotEmpty).orElseThrow(() -> new AzureToolkitRuntimeException(NO_TRIGGERS_FOUNDED));
}).subscribeOn(Schedulers.boundedElastic()).retryWhen(Retry.fixedDelay(LIST_TRIGGERS_MAX_RETRY - 1, Duration.ofSeconds(LIST_TRIGGERS_RETRY_PERIOD_IN_SECONDS))).block();
}
use of com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException in project azure-tools-for-java by Microsoft.
the class FunctionDeploymentState method prepareStagingFolder.
@AzureOperation(name = "function.prepare_staging_folder_detail", params = { "stagingFolder.getName()", "this.deployModel.getFunctionAppConfig().getName()" }, type = AzureOperation.Type.TASK)
private void prepareStagingFolder(File stagingFolder, RunProcessHandler processHandler, @NotNull final Operation operation) {
AzureTaskManager.getInstance().read(() -> {
final Path hostJsonPath = FunctionUtils.getDefaultHostJson(project);
final PsiMethod[] methods = FunctionUtils.findFunctionsByAnnotation(functionDeployConfiguration.getModule());
final Path folder = stagingFolder.toPath();
try {
final Map<String, FunctionConfiguration> configMap = FunctionUtils.prepareStagingFolder(folder, hostJsonPath, functionDeployConfiguration.getModule(), methods);
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, StringUtils.join(FunctionUtils.getFunctionBindingList(configMap), ","));
} catch (final AzureExecutionException | IOException e) {
final String error = String.format("failed prepare staging folder[%s]", folder);
throw new AzureToolkitRuntimeException(error, e);
}
});
}
use of com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException in project azure-tools-for-java by Microsoft.
the class AuthMethodManager method persistAuthMethodDetails.
@AzureOperation(name = "account|auth_setting.persist", type = AzureOperation.Type.TASK)
public void persistAuthMethodDetails() {
waitInitFinish();
try {
System.out.println("saving authMethodDetails...");
String sd = JsonHelper.serialize(authMethodDetails);
AzureStoreManager.getInstance().getIdeStore().setProperty(ACCOUNT, AUTH_METHOD_DETAIL, sd);
} catch (final IOException e) {
final String error = "Failed to persist auth method settings while updating";
final String action = "Retry later";
throw new AzureToolkitRuntimeException(error, e, action);
}
}
use of com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException in project azure-tools-for-java by Microsoft.
the class SubscriptionManager method setSubscriptionDetails.
public void setSubscriptionDetails(List<SubscriptionDetail> subscriptionDetails) {
System.out.println(Thread.currentThread().getId() + " SubscriptionManager.setSubscriptionDetails()");
synchronized (this) {
try {
saveSubscriptions(subscriptionDetails);
notifyAllListeners(CollectionUtils.isEmpty(subscriptionDetails));
} catch (final IOException e) {
final String error = "Failed to update local subscriptions cache while updating";
final String action = "Retry later";
throw new AzureToolkitRuntimeException(error, e, action);
}
}
}
use of com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException in project azure-tools-for-java by Microsoft.
the class DefaultMachineStore method load.
public void load() {
try {
if (Files.exists(Paths.get(dataFile))) {
String json = FileUtils.readFileToString(new File(dataFile), "utf8");
Type type = new TypeToken<Map<String, String>>() {
}.getType();
map = JsonUtils.getGson().fromJson(json, type);
}
} catch (Exception ex) {
throw new AzureToolkitRuntimeException("Cannot load property.", ex);
}
}
Aggregations