use of org.glassfish.api.admin.progress.JobInfo in project Payara by payara.
the class JobPersistenceService method doPersist.
public void doPersist(JobInfos jobInfos, JobInfo jobInfo) {
File file = jobInfo.getJobsFile();
synchronized (file) {
if (jobInfos == null) {
jobInfos = new JobInfos();
}
try {
JAXBContext jaxbContext = JAXBContext.newInstance(JobInfos.class);
jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
CopyOnWriteArrayList<JobInfo> jobList = new CopyOnWriteArrayList<JobInfo>(jobInfos.getJobInfoList());
jobInfos.setJobInfoList(jobList);
jobList.add(jobInfo);
jaxbMarshaller.marshal(jobInfos, file);
jobManager.addToCompletedJobs(new CompletedJob(jobInfo.jobId, jobInfo.commandCompletionDate, jobInfo.getJobsFile()));
jobManager.purgeJob(jobInfo.jobId);
} catch (JAXBException e) {
throw new RuntimeException(adminStrings.getLocalString("error.persisting.jobs", "Error while persisting jobs", jobInfo.jobId, e.getLocalizedMessage()), e);
}
}
}
use of org.glassfish.api.admin.progress.JobInfo in project Payara by payara.
the class AttachCommand method execute.
@Override
public void execute(AdminCommandContext context) {
eventBroker = context.getEventBroker();
attached = registry.get(jobID);
JobInfo jobInfo = null;
String jobName = null;
if (attached == null) {
// try for completed jobs
if (registry.getCompletedJobs(registry.getJobsFile()) != null) {
jobInfo = (JobInfo) registry.getCompletedJobForId(jobID);
}
if (jobInfo != null) {
jobName = jobInfo.jobName;
}
}
attach(attached, jobInfo, context, jobName);
}
use of org.glassfish.api.admin.progress.JobInfo in project Payara by payara.
the class JobAuthorizationAttributeProcessor method describeAuthorization.
@Override
public void describeAuthorization(Subject subject, String resourceName, String action, AdminCommand command, Map<String, Object> context, Map<String, String> subjectAttributes, Map<String, String> resourceAttributes, Map<String, String> actionAttributes) {
final Matcher m = JOB_PATTERN.matcher(resourceName);
if (!m.matches()) {
return;
}
if (m.groupCount() == 0) {
/*
* The resource name pattern did not match for including a job ID,
* so we will not be able to attach a user attribute to the resource.
*/
return;
}
final String jobID = m.group(1);
final Job job = jobManager.get(jobID);
String userID = null;
/*
* This logic might run before any validation in the command has run,
* in which case the job ID would be invalid and the job manager and/or
* the completed jobs store might not know about the job.
*/
if (job != null && job.getSubjectUsernames().size() > 0) {
userID = job.getSubjectUsernames().get(0);
} else {
if (jobManager.getCompletedJobs(jobManager.getJobsFile()) != null) {
final JobInfo jobInfo = (JobInfo) jobManager.getCompletedJobForId(jobID);
if (jobInfo != null) {
userID = jobInfo.user;
}
}
}
if (userID != null) {
resourceAttributes.put(USER_ATTRIBUTE_NAME, userID);
}
}
use of org.glassfish.api.admin.progress.JobInfo in project Payara by payara.
the class JobCleanUpService method cleanUpExpiredJobs.
/**
* This will periodically purge expired jobs
*/
private void cleanUpExpiredJobs(File file) {
ArrayList<JobInfo> expiredJobs = jobManagerService.getExpiredJobs(file);
if (expiredJobs.size() > 0) {
for (JobInfo job : expiredJobs) {
// remove from Job registy
jobManagerService.purgeJob(job.jobId);
// remove from jobs.xml file
jobManagerService.purgeCompletedJobForId(job.jobId, file);
// remove from local cache for completed jobs
jobManagerService.removeFromCompletedJobs(job.jobId);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, KernelLoggerInfo.cleaningJob, job.jobId);
}
}
}
}
use of org.glassfish.api.admin.progress.JobInfo in project Payara by payara.
the class JobPersistenceService method persist.
@Override
public void persist(Object obj) {
JobInfo jobInfo = (JobInfo) obj;
jobInfos = jobManager.getCompletedJobs(jobManager.getJobsFile());
doPersist(jobInfos, jobInfo);
}
Aggregations