use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class PostDeployCommand method execute.
@Override
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
final Logger logger = context.getLogger();
final DeployCommandSupplementalInfo suppInfo = context.getActionReport().getResultType(DeployCommandSupplementalInfo.class);
final DeploymentContext dc = suppInfo.deploymentContext();
final DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
final InterceptorNotifier notifier = new InterceptorNotifier(habitat, dc);
// if the target is DAS, we do not need to do anything more
if (DeploymentUtils.isDASTarget(params.target)) {
return;
}
try {
final ParameterMap paramMap = deployment.prepareInstanceDeployParamMap(dc);
List<String> targets = new ArrayList<String>();
if (!DeploymentUtils.isDomainTarget(params.target)) {
targets.add(params.target);
} else {
targets = suppInfo.previousTargets();
}
ClusterOperationUtil.replicateCommand("_deploy", FailurePolicy.Warn, FailurePolicy.Warn, FailurePolicy.Ignore, targets, context, paramMap, habitat);
notifier.ensureAfterReported(Phase.REPLICATION);
} catch (Exception e) {
report.failure(logger, e.getMessage());
}
}
use of org.glassfish.api.deployment.DeployCommandParameters 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 ImmutableList.of();
}
URI uri;
try {
uri = new URI(source);
} catch (URISyntaxException e) {
logger.log(Level.SEVERE, KernelLoggerInfo.cantDetermineLocation, e.getLocalizedMessage());
return ImmutableList.of();
}
List<Deployment.ApplicationDeployment> appDeployments = new ArrayList<>();
File sourceFile = new File(uri);
if (sourceFile.exists()) {
try {
ReadableArchive archive = null;
try {
DeploymentTracing tracing = null;
if (deploymentTracingEnabled != null) {
tracing = new DeploymentTracing();
}
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();
if (tracing != null) {
depContext.addModuleMetaData(tracing);
}
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);
}
return FluentIterable.from(appDeployments).filter(Predicates.notNull()).toList();
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class UpgradeStartup method redeployApp.
private boolean redeployApp(Application app) {
// we don't need to redeploy any v3 type application
if (app.getModule().size() > 0) {
logger.log(Level.INFO, "Skip redeploying v3 type application " + app.getName());
return true;
}
// populate the params and properties from application element first
DeployCommandParameters deployParams = app.getDeployParameters(null);
// we should not have to repackage for any upgrade from v3
if (!Boolean.valueOf(app.getDirectoryDeployed())) {
File repackagedFile = null;
try {
repackagedFile = repackageArchive(app);
} catch (IOException ioe) {
logger.log(Level.SEVERE, "Repackaging of application " + app.getName() + " failed: " + ioe.getMessage(), ioe);
return false;
}
if (repackagedFile == null) {
logger.log(Level.SEVERE, "Repackaging of application " + app.getName() + " failed.");
return false;
}
logger.log(Level.INFO, "Repackaged application " + app.getName() + " at " + repackagedFile.getPath());
deployParams.path = repackagedFile;
}
deployParams.properties = app.getDeployProperties();
// remove the marker properties so they don't get carried over
// through redeployment
deployParams.properties.remove(MODULE_TYPE);
// add the compatibility property so the applications are
// upgraded/redeployed in a backward compatible way
deployParams.properties.setProperty(DeploymentProperties.COMPATIBILITY, "v2");
// now override the ones needed for the upgrade
deployParams.enabled = null;
deployParams.force = true;
deployParams.dropandcreatetables = false;
deployParams.createtables = false;
deployParams.target = DOMAIN_TARGET;
ActionReport report = new DoNothingActionReporter();
commandRunner.getCommandInvocation("deploy", report, kernelIdentity.getSubject()).parameters(deployParams).execute();
if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
logger.log(Level.SEVERE, "Redeployment of application " + app.getName() + " failed: " + report.getMessage() + "\nPlease redeploy " + app.getName() + " manually.", report.getFailureCause());
return false;
}
return true;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class EmbeddedDeployerImpl method deploy.
@Override
public String deploy(ReadableArchive archive, DeployCommandParameters params) {
// ensure server is started. start it if not started.
try {
server.start();
} catch (LifecycleException e) {
throw new RuntimeException(e);
}
ActionReport report = new PlainTextActionReporter();
if (params == null) {
params = new DeployCommandParameters();
}
ExtendedDeploymentContext initialContext = new DeploymentContextImpl(report, archive, params, env);
ArchiveHandler archiveHandler = null;
try {
archiveHandler = deployment.getArchiveHandler(archive);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (archiveHandler == null) {
throw new RuntimeException("Cannot find archive handler for source archive");
}
if (params.name == null) {
params.name = archiveHandler.getDefaultApplicationName(archive, initialContext);
}
ExtendedDeploymentContext context = null;
try {
context = deployment.getBuilder(logger, params, report).source(archive).archiveHandler(archiveHandler).build(initialContext);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (params.property != null) {
context.getAppProps().putAll(params.property);
}
if (params.properties != null) {
context.getAppProps().putAll(params.properties);
}
ApplicationInfo appInfo = null;
try {
appInfo = deployment.deploy(context);
} catch (Exception e) {
logger.log(Level.SEVERE, KernelLoggerInfo.deployException, e);
}
if (appInfo != null) {
boolean isDirectory = new File(archive.getURI().getPath()).isDirectory();
EmbeddedDeployedInfo info = new EmbeddedDeployedInfo(appInfo, context.getModulePropsMap(), context.getAppProps(), isDirectory);
deployedApps.put(appInfo.getName(), info);
return appInfo.getName();
}
return null;
}
Aggregations