Search in sources :

Example 16 with StructuredDeploymentTracing

use of org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing in project Payara by payara.

the class ApplicationLoaderService method processApplication.

public List<Deployment.ApplicationDeployment> processApplication(Application app, ApplicationRef appRef) {
    long operationStartTime = Calendar.getInstance().getTimeInMillis();
    initializeRuntimeDependencies();
    String source = app.getLocation();
    final String appName = app.getName();
    // lifecycle modules are loaded separately
    if (Boolean.valueOf(app.getDeployProperties().getProperty(ServerTags.IS_LIFECYCLE))) {
        return Collections.emptyList();
    }
    URI uri;
    try {
        uri = new URI(source);
    } catch (URISyntaxException e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.cantDetermineLocation, e.getLocalizedMessage());
        return Collections.emptyList();
    }
    List<Deployment.ApplicationDeployment> appDeployments = new ArrayList<>();
    File sourceFile = new File(uri);
    if (sourceFile.exists()) {
        try {
            ReadableArchive archive = null;
            try {
                StructuredDeploymentTracing structuredTracing = deploymentTracingEnabled != null ? StructuredDeploymentTracing.create(app.getName()) : StructuredDeploymentTracing.createDisabled(app.getName());
                DeploymentTracing tracing = null;
                DeployCommandParameters deploymentParams = app.getDeployParameters(appRef);
                deploymentParams.target = server.getName();
                deploymentParams.origin = DeployCommandParameters.Origin.load;
                deploymentParams.command = DeployCommandParameters.Command.startup_server;
                if (domain.isAppReferencedByPaaSTarget(appName)) {
                    if (server.isDas()) {
                        // for loading PaaS application on DAS
                        // we set it to the real PaaS target
                        deploymentParams.target = deployment.getDefaultTarget(appName, deploymentParams.origin, deploymentParams._classicstyle);
                    }
                }
                archive = archiveFactoryProvider.get().openArchive(sourceFile, deploymentParams);
                ActionReport report = new HTMLActionReporter();
                ExtendedDeploymentContext depContext = deployment.getBuilder(logger, deploymentParams, report).source(archive).build();
                tracing = structuredTracing.register(depContext);
                depContext.getAppProps().putAll(app.getDeployProperties());
                depContext.setModulePropsMap(app.getModulePropertiesMap());
                new ApplicationConfigInfo(app).store(depContext.getAppProps());
                appDeployments.add(deployment.prepare(deployment.getSniffersFromApp(app), depContext));
                appDeployments.addAll(loadApplicationForTenants(app, appRef, report));
                if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
                    if (tracing != null) {
                        tracing.print(System.out);
                    }
                    logger.log(Level.INFO, KernelLoggerInfo.loadingApplicationTime, new Object[] { appName, (Calendar.getInstance().getTimeInMillis() - operationStartTime) });
                } else {
                    logger.log(Level.SEVERE, KernelLoggerInfo.deployFail, report.getMessage());
                }
            } finally {
                if (archive != null) {
                    try {
                        archive.close();
                    } catch (IOException e) {
                        logger.log(Level.FINE, KernelLoggerInfo.deployException, e);
                    }
                }
            }
        } catch (IOException e) {
            logger.log(Level.SEVERE, KernelLoggerInfo.exceptionOpenArtifact, e);
        }
    } else {
        logger.log(Level.SEVERE, KernelLoggerInfo.notFoundInOriginalLocation, source);
    }
    appDeployments.removeIf(t -> t == null);
    return appDeployments;
}
Also used : URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) URI(java.net.URI) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) HTMLActionReporter(com.sun.enterprise.admin.report.HTMLActionReporter) ApplicationConfigInfo(org.glassfish.deployment.common.ApplicationConfigInfo) StructuredDeploymentTracing(org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing) StructuredDeploymentTracing(org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) File(java.io.File)

Aggregations

StructuredDeploymentTracing (org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing)16 DeploymentSpan (org.glassfish.internal.deployment.analysis.DeploymentSpan)14 PropertyVetoException (java.beans.PropertyVetoException)9 IOException (java.io.IOException)8 ActionReport (org.glassfish.api.ActionReport)8 Deployer (org.glassfish.api.deployment.Deployer)7 Logger (java.util.logging.Logger)6 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)6 DeploymentException (org.glassfish.deployment.common.DeploymentException)6 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)6 MultiException (org.glassfish.hk2.api.MultiException)6 EngineInfo (org.glassfish.internal.data.EngineInfo)6 RetryableException (org.jvnet.hk2.config.RetryableException)6 ApplicationMetaDataProvider (org.glassfish.api.deployment.ApplicationMetaDataProvider)4 PayaraExecutorService (fish.payara.nucleus.executorservice.PayaraExecutorService)3 HotDeployService (fish.payara.nucleus.hotdeploy.HotDeployService)3 File (java.io.File)3 URI (java.net.URI)3 ApplicationConfigInfo (org.glassfish.deployment.common.ApplicationConfigInfo)3 com.sun.enterprise.config.serverbeans (com.sun.enterprise.config.serverbeans)2