use of org.xwiki.extension.distribution.internal.job.DistributionRequest in project xwiki-platform by xwiki.
the class DefaultDistributionManager method startWikiJob.
@Override
public DistributionJob startWikiJob(String wiki) {
try {
DistributionJob wikiJob = this.componentManager.getInstance(Job.class, DefaultDistributionJob.HINT);
this.wikiDistributionJobs.put(wiki, wikiJob);
final DistributionRequest request = new DistributionRequest();
request.setId(getWikiJobId(wiki));
request.setWiki(wiki);
request.setUserReference(this.xcontextProvider.get().getUserReference());
request.setInteractive(this.configuration.getProperty("distribution.job.interactive.wiki", true));
Thread distributionJobThread = new Thread(new Runnable() {
@Override
public void run() {
// Create a clean Execution Context
ExecutionContext context = new ExecutionContext();
try {
executionContextManager.initialize(context);
} catch (ExecutionContextException e) {
throw new RuntimeException("Failed to initialize wiki distribution job execution context", e);
}
DistributionJob job = wikiDistributionJobs.get(request.getWiki());
job.initialize(request);
job.run();
}
});
distributionJobThread.setDaemon(true);
distributionJobThread.setName("Distribution initialization of wiki [" + wiki + "]");
distributionJobThread.start();
// Wait until the job is ready (or finished)
wikiJob.awaitReady();
return wikiJob;
} catch (Exception e) {
this.logger.error("Failed to create distribution job for wiki [" + wiki + "]", e);
}
return null;
}
use of org.xwiki.extension.distribution.internal.job.DistributionRequest in project xwiki-platform by xwiki.
the class DefaultDistributionManager method copyPreviousWikiJobStatus.
@Override
public void copyPreviousWikiJobStatus(String sourceWiki, String targetWiki) {
DistributionJobStatus sourceStatus = getPreviousWikiJobStatus(sourceWiki);
if (sourceStatus != null) {
DistributionJobStatus targetStatus = new DistributionJobStatus(sourceStatus, this.observationManagerProvider.get(), this.loggerManagerProvider.get());
DistributionRequest request = targetStatus.getRequest();
request.setId(getWikiJobId(targetWiki));
request.setWiki(targetWiki);
this.jobStatusStorage.store(targetStatus);
}
}
use of org.xwiki.extension.distribution.internal.job.DistributionRequest in project xwiki-platform by xwiki.
the class DefaultDistributionManager method startFarmJob.
@Override
public DefaultDistributionJob startFarmJob() {
try {
this.farmDistributionJob = this.componentManager.getInstance(Job.class, DefaultDistributionJob.HINT);
XWikiContext xcontext = this.xcontextProvider.get();
final DistributionRequest request = new DistributionRequest();
request.setId(getFarmJobId());
request.setWiki(xcontext.getMainXWiki());
request.setUserReference(xcontext.getUserReference());
request.setInteractive(this.configuration.getProperty("distribution.job.interactive", true));
Thread distributionJobThread = new Thread(new Runnable() {
@Override
public void run() {
// Create a clean Execution Context
ExecutionContext context = new ExecutionContext();
try {
executionContextManager.initialize(context);
} catch (ExecutionContextException e) {
throw new RuntimeException("Failed to initialize farm distribution job execution context", e);
}
farmDistributionJob.initialize(request);
farmDistributionJob.run();
}
});
distributionJobThread.setDaemon(true);
distributionJobThread.setName("Farm distribution initialization");
distributionJobThread.start();
// Wait until the job is ready (or finished)
this.farmDistributionJob.awaitReady();
return this.farmDistributionJob;
} catch (Exception e) {
this.logger.error("Failed to create farm distribution job", e);
}
return null;
}
Aggregations