Search in sources :

Example 1 with AzureDeploymentProgressNotification

use of com.microsoft.intellij.deploy.AzureDeploymentProgressNotification in project azure-tools-for-java by Microsoft.

the class DockerContainerDeployTask method run.

@Override
public void run(@NotNull final ProgressIndicator indicator) {
    openViews(project);
    AzurePlugin.removeUnNecessaryListener();
    DeploymentEventListener deployListnr = new DeploymentEventListener() {

        @Override
        public void onDeploymentStep(DeploymentEventArgs args) {
            indicator.setFraction(args.getDeployCompleteness() / 100.0);
            indicator.setText(AzureBundle.message("deployingToAzure"));
            indicator.setText2(args.toString());
        }
    };
    AzurePlugin.addDeploymentEventListener(deployListnr);
    AzurePlugin.depEveList.add(deployListnr);
    new AzureDeploymentProgressNotification(project).deployToDockerContainer(dockerImageInstance, url);
    new Thread("Warm up the target site") {

        public void run() {
            try {
                LOG.info("To warm the site up - implicitly trying to connect it");
                WebAppUtils.sendGet(url);
            } catch (Exception ex) {
                LOG.info(ex.getMessage(), ex);
            }
        }
    }.start();
}
Also used : DeploymentEventArgs(com.microsoft.azuretools.azurecommons.deploy.DeploymentEventArgs) AzureDeploymentProgressNotification(com.microsoft.intellij.deploy.AzureDeploymentProgressNotification) DeploymentEventListener(com.microsoft.azuretools.azurecommons.deploy.DeploymentEventListener)

Example 2 with AzureDeploymentProgressNotification

use of com.microsoft.intellij.deploy.AzureDeploymentProgressNotification in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method deploy.

private void deploy() {
    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    int selectedRow = table.getSelectedRow();
    WebAppDetails wad = webAppWebAppDetailsMap.get(tableModel.getValueAt(selectedRow, 0));
    WebApp webApp = wad.webApp;
    boolean isDeployToRoot = deployToRootCheckBox.isSelected();
    ProgressManager.getInstance().run(new Task.Backgroundable(project, "Deploy Web App Progress", true) {

        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            AzureDeploymentProgressNotification azureDeploymentProgressNotification = new AzureDeploymentProgressNotification(project);
            try {
                progressIndicator.setIndeterminate(true);
                PublishingProfile pp = webApp.getPublishingProfile();
                Date startDate = new Date();
                azureDeploymentProgressNotification.notifyProgress(webApp.name(), startDate, null, 5, "Deploying Web App...");
                WebAppUtils.deployArtifact(artifact.getName(), artifact.getOutputFilePath(), pp, isDeployToRoot, new UpdateProgressIndicator(progressIndicator));
                String sitePath = buildSiteLink(wad.webApp, isDeployToRoot ? null : artifact.getName());
                progressIndicator.setText("Checking Web App availability...");
                progressIndicator.setText2("Link: " + sitePath);
                azureDeploymentProgressNotification.notifyProgress(webApp.name(), startDate, sitePath, 75, "Checking Web App availability...");
                int stepLimit = 5;
                int sleepMs = 2000;
                // to make warn up cancelable
                Thread thread = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            for (int step = 0; step < stepLimit; ++step) {
                                if (WebAppUtils.isUrlAccessible(sitePath)) {
                                    // warm up
                                    break;
                                }
                                Thread.sleep(sleepMs);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            LOGGER.error("deploy::warmup", e);
                        }
                    }
                });
                thread.start();
                while (thread.isAlive()) {
                    if (progressIndicator.isCanceled())
                        return;
                    else
                        Thread.sleep(sleepMs);
                }
                azureDeploymentProgressNotification.notifyProgress(webApp.name(), startDate, sitePath, 100, message("runStatus"));
                showLink(sitePath);
            } catch (IOException | InterruptedException ex) {
                ex.printStackTrace();
                //LOGGER.error("deploy", ex);
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        ErrorWindow.show(project, ex.getMessage(), "Deploy Web App Error");
                    }
                });
            }
        }
    });
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) Task(com.intellij.openapi.progress.Task) DefaultTableModel(javax.swing.table.DefaultTableModel) AzureDeploymentProgressNotification(com.microsoft.intellij.deploy.AzureDeploymentProgressNotification) Date(java.util.Date) CanceledByUserException(com.microsoft.azuretools.utils.CanceledByUserException) IOException(java.io.IOException) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) PublishingProfile(com.microsoft.azure.management.appservice.PublishingProfile) WebApp(com.microsoft.azure.management.appservice.WebApp)

Aggregations

AzureDeploymentProgressNotification (com.microsoft.intellij.deploy.AzureDeploymentProgressNotification)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)1 PublishingProfile (com.microsoft.azure.management.appservice.PublishingProfile)1 WebApp (com.microsoft.azure.management.appservice.WebApp)1 DeploymentEventArgs (com.microsoft.azuretools.azurecommons.deploy.DeploymentEventArgs)1 DeploymentEventListener (com.microsoft.azuretools.azurecommons.deploy.DeploymentEventListener)1 UpdateProgressIndicator (com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator)1 CanceledByUserException (com.microsoft.azuretools.utils.CanceledByUserException)1 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)1 IOException (java.io.IOException)1 Date (java.util.Date)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1