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");
}
}
});
});
}
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");
}
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:
}
}
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));
}
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));
}
Aggregations