Search in sources :

Example 6 with SdkStatus

use of com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineRuntimeInstance method deploy.

@Override
public void deploy(@NotNull final DeploymentTask<AppEngineDeploymentConfiguration> task, @NotNull final DeploymentLogManager logManager, @NotNull final DeploymentOperationCallback callback) {
    FileDocumentManager.getInstance().saveAllDocuments();
    Services.getLoginService().logInIfNot();
    if (!Services.getLoginService().isLoggedIn()) {
        callback.errorOccurred(GctBundle.message("appengine.deployment.error.not.logged.in"));
        return;
    }
    AppEngineDeploymentConfiguration deploymentConfig = task.getConfiguration();
    AppEngineHelper appEngineHelper = new CloudSdkAppEngineHelper(task.getProject());
    ProjectManager.getInstance().addProjectManagerListener(task.getProject(), projectClosingListener);
    appEngineHelper.createDeployRunner(logManager.getMainLoggingHandler(), task.getSource(), deploymentConfig, callback).ifPresent(deployRunner -> {
        // keep track of any active deployments
        synchronized (createdDeployments) {
            createdDeployments.put(task.getProject(), deployRunner);
        }
        CloudSdkServiceManager.getInstance().runWhenSdkReady(task.getProject(), deployRunner, GctBundle.message("appengine.deployment.status.deploying"), new CloudSdkStatusHandler() {

            @Override
            public void log(String message) {
                logManager.getMainLoggingHandler().print(message + "\n");
            }

            @Override
            public void onError(String message) {
                callback.errorOccurred(message);
            }

            @Override
            public void onUserCancel() {
                String cancelMessage = GctBundle.message("appengine.deployment.user.cancel");
                callback.errorOccurred(cancelMessage);
                logManager.getMainLoggingHandler().print(cancelMessage + "\n");
            }

            @Override
            public String getErrorMessage(SdkStatus sdkStatus) {
                switch(sdkStatus) {
                    case INVALID:
                        return GctBundle.message("appengine.deployment.error.sdk.invalid");
                    case NOT_AVAILABLE:
                        return GctBundle.message("appengine.deployment.error.sdk.not.available");
                    default:
                        return GctBundle.message("appengine.deployment.error.sdk.retry");
                }
            }
        });
    });
}
Also used : CloudSdkStatusHandler(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkServiceManager.CloudSdkStatusHandler) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)

Example 7 with SdkStatus

use of com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfiguration method checkCommonConfig.

private void checkCommonConfig(AppEngineDeployable deployable) throws RuntimeConfigurationError {
    // do not check SDK if it supports dynamic install - the deployment runner will block itself
    // until installation is done.
    CloudSdkService cloudSdkService = CloudSdkService.getInstance();
    SdkStatus sdkStatus = cloudSdkService.getStatus();
    if (sdkStatus != SdkStatus.READY && !cloudSdkService.isInstallSupported()) {
        Set<CloudSdkValidationResult> sdkValidationResult = CloudSdkValidator.getInstance().validateCloudSdk();
        if (!sdkValidationResult.isEmpty()) {
            CloudSdkValidationResult result = Iterables.getFirst(sdkValidationResult, null);
            throw new RuntimeConfigurationError(GctBundle.message("appengine.flex.config.server.error", result.getMessage()));
        }
    }
    check(deployable instanceof UserSpecifiedPathDeploymentSource || deployable.isValid(), "appengine.config.deployment.source.error");
    check(StringUtils.isNotBlank(cloudProjectName), "appengine.flex.config.project.missing.message");
}
Also used : UserSpecifiedPathDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource) CloudSdkService(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) CloudSdkValidationResult(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkValidationResult)

Example 8 with SdkStatus

use of com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudSdkServiceManager method handleErrors.

/**
 * Checks the current SDK status after waiting for readiness, notifies and logs about errors.
 */
private void handleErrors(CloudSdkStatusHandler sdkLogging) {
    // check the status of SDK after install.
    SdkStatus postInstallSdkStatus = CloudSdkService.getInstance().getStatus();
    switch(postInstallSdkStatus) {
        case READY:
            // can continue without logging anything.
            break;
        case INSTALLING:
            // still installing, do nothing, up to caller to decide which message to show.
            break;
        case NOT_AVAILABLE:
        case INVALID:
            String message = sdkLogging.getErrorMessage(postInstallSdkStatus);
            sdkLogging.onError(message);
            showCloudSdkNotification(message, NotificationType.ERROR);
            break;
        default:
    }
}
Also used : SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)

Example 9 with SdkStatus

use of com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method failed_install_appEngineException_changesSdkStatus_inProgress.

@Test
public void failed_install_appEngineException_changesSdkStatus_inProgress() throws Exception {
    sdkService.addStatusUpdateListener(mockStatusUpdateListener);
    emulateMockSdkInstallationProcess(MOCK_SDK_PATH);
    SdkComponentInstaller mockComponentInstaller = mockManagedCloudSdk.newComponentInstaller();
    doThrow(new CommandExecutionException(new UnsupportedOperationException())).when(mockComponentInstaller).installComponent(any(), any(), any());
    sdkService.install();
    ArgumentCaptor<SdkStatus> statusCaptor = ArgumentCaptor.forClass(SdkStatus.class);
    verify(mockStatusUpdateListener, times(2)).onSdkStatusChange(any(), statusCaptor.capture());
    assertThat(statusCaptor.getAllValues()).isEqualTo(Arrays.asList(SdkStatus.INSTALLING, SdkStatus.NOT_AVAILABLE));
}
Also used : SdkComponentInstaller(com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller) CommandExecutionException(com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Example 10 with SdkStatus

use of com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method interrupted_update_keepsSdkStatus_available.

@Test
public void interrupted_update_keepsSdkStatus_available() throws Exception {
    makeMockSdkInstalled(MOCK_SDK_PATH);
    emulateMockSdkUpdateProcess();
    SdkUpdater mockUpdater = mockManagedCloudSdk.newUpdater();
    doThrow(new InterruptedException()).when(mockUpdater).update(any(), any());
    sdkService.addStatusUpdateListener(mockStatusUpdateListener);
    sdkService.update();
    ArgumentCaptor<SdkStatus> statusCaptor = ArgumentCaptor.forClass(SdkStatus.class);
    verify(mockStatusUpdateListener, times(2)).onSdkStatusChange(any(), statusCaptor.capture());
    assertThat(statusCaptor.getAllValues()).isEqualTo(Arrays.asList(SdkStatus.INSTALLING, SdkStatus.READY));
}
Also used : SdkUpdater(com.google.cloud.tools.managedcloudsdk.components.SdkUpdater) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Aggregations

SdkStatus (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)11 Test (org.junit.Test)6 SdkUpdater (com.google.cloud.tools.managedcloudsdk.components.SdkUpdater)4 CloudSdkService (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService)2 CloudSdkStatusHandler (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkServiceManager.CloudSdkStatusHandler)2 CommandExitException (com.google.cloud.tools.managedcloudsdk.command.CommandExitException)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)2 AppEngineExecutor (com.google.cloud.tools.intellij.appengine.cloud.executor.AppEngineExecutor)1 AppEngineStandardRunTask (com.google.cloud.tools.intellij.appengine.cloud.executor.AppEngineStandardRunTask)1 UserSpecifiedPathDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource)1 CloudSdkValidationResult (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkValidationResult)1 AppEngineServerModel (com.google.cloud.tools.intellij.appengine.server.instance.AppEngineServerModel)1 CommandExecutionException (com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException)1 SdkComponentInstaller (com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller)1 SdkInstaller (com.google.cloud.tools.managedcloudsdk.install.SdkInstaller)1 ExecutionException (com.intellij.execution.ExecutionException)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 CommonModel (com.intellij.javaee.run.configuration.CommonModel)1 ExecutableObject (com.intellij.javaee.run.localRun.ExecutableObject)1 ScriptHelper (com.intellij.javaee.run.localRun.ScriptHelper)1