Search in sources :

Example 1 with SpringCloudDeployment

use of com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfigurationState method execute.

@AzureOperation(name = "springcloud|app.create_update", params = { "this.config.getAppConfig().getAppName()" }, type = AzureOperation.Type.ACTION)
public SpringCloudDeployment execute(IAzureMessager messager) {
    AzureMessager.getContext().setMessager(messager);
    AzureTelemetry.getContext().setProperties(getTelemetryProperties());
    final SpringCloudAppConfig appConfig = this.config.getAppConfig();
    final DeploySpringCloudAppTask task = new DeploySpringCloudAppTask(appConfig);
    final SpringCloudDeployment deployment = task.execute();
    final SpringCloudApp app = deployment.app();
    final SpringCloudCluster cluster = app.getCluster();
    if (!deployment.waitUntilReady(GET_STATUS_TIMEOUT)) {
        messager.warning(GET_DEPLOYMENT_STATUS_TIMEOUT, NOTIFICATION_TITLE);
    }
    printPublicUrl(app);
    return deployment;
}
Also used : DeploySpringCloudAppTask(com.microsoft.azure.toolkit.lib.springcloud.task.DeploySpringCloudAppTask) SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment) SpringCloudCluster(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with SpringCloudDeployment

use of com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment in project azure-tools-for-java by Microsoft.

the class SpringCloudAppPropertiesEditor method refresh.

private void refresh() {
    this.reset.setVisible(false);
    this.saveButton.setEnabled(false);
    AzureTaskManager.getInstance().runLater(() -> {
        final String refreshTitle = String.format("Refreshing app(%s)...", Objects.requireNonNull(this.app).name());
        AzureTaskManager.getInstance().runInBackground(refreshTitle, () -> {
            this.app.refresh();
            final SpringCloudDeployment deployment = Optional.ofNullable(this.app.activeDeployment()).map(AbstractAzureResource::refresh).orElse(null);
            AzureTaskManager.getInstance().runLater(this::rerender);
        });
    });
}
Also used : SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment)

Example 3 with SpringCloudDeployment

use of com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment in project azure-tools-for-java by Microsoft.

the class CreateSpringCloudAppAction method createApp.

@AzureOperation(name = "springcloud|app.create", params = "config.getAppName()", type = AzureOperation.Type.ACTION)
private static void createApp(SpringCloudAppConfig config) {
    AzureTaskManager.getInstance().runInBackground(AzureOperationBundle.title("springcloud|app.create", config.getAppName()), () -> {
        final DeploySpringCloudAppTask task = new DeploySpringCloudAppTask(config);
        final SpringCloudDeployment deployment = task.execute();
        if (!deployment.waitUntilReady(GET_STATUS_TIMEOUT)) {
            AzureMessager.getMessager().warning(GET_DEPLOYMENT_STATUS_TIMEOUT, NOTIFICATION_TITLE);
        }
    });
}
Also used : DeploySpringCloudAppTask(com.microsoft.azure.toolkit.lib.springcloud.task.DeploySpringCloudAppTask) SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 4 with SpringCloudDeployment

use of com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment in project azure-tools-for-java by Microsoft.

the class SpringCloudStreamingLogAction method startLogStreaming.

public static void startLogStreaming(@Nonnull SpringCloudApp app, @Nullable Project project) {
    final IAzureMessager messager = AzureMessager.getMessager();
    final AzureString title = AzureOperationBundle.title("springcloud|log_stream.open", app.name());
    AzureTaskManager.getInstance().runInBackground(new AzureTask<>(project, title, false, () -> {
        try {
            final SpringCloudDeployment deployment = app.activeDeployment();
            if (deployment == null || !deployment.exists()) {
                messager.warning(NO_ACTIVE_DEPLOYMENT, FAILED_TO_START_LOG_STREAMING);
                return;
            }
            final List<SpringCloudDeploymentInstanceEntity> instances = deployment.entity().getInstances();
            if (CollectionUtils.isEmpty(instances)) {
                messager.warning(NO_AVAILABLE_INSTANCES, FAILED_TO_START_LOG_STREAMING);
            } else {
                showLogStreamingDialog(instances, app, project);
            }
        } catch (final Exception e) {
            final String errorMessage = StringUtils.isEmpty(e.getMessage()) ? FAILED_TO_LIST_INSTANCES : String.format(FAILED_TO_LIST_INSTANCES_WITH_MESSAGE, e.getMessage());
            messager.error(errorMessage, FAILED_TO_START_LOG_STREAMING);
        }
    }));
}
Also used : IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment) List(java.util.List) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

SpringCloudDeployment (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment)4 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 DeploySpringCloudAppTask (com.microsoft.azure.toolkit.lib.springcloud.task.DeploySpringCloudAppTask)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 IAzureMessager (com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager)1 SpringCloudApp (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp)1 SpringCloudCluster (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster)1 SpringCloudAppConfig (com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig)1 List (java.util.List)1