private GlacierJobDescription retreiveJobResultByJobId(String jobId) { this.log.info("Looking for specific job by Job Id: " + jobId); // Prepare a job list request to figure out the status of the job ListJobsRequest listJobsRequest = new ListJobsRequest().withAccountId(this.account).withVaultName(this.vault).withCompleted("true").withStatuscode("Succeeded"); for (GlacierJobDescription job : this.awsClient.listJobs(listJobsRequest).getJobList()){ // found our job? if (job.getJobId().equals(jobId)) { return job; } } // job not found return null; }
private GlacierJobDescription retreiveLatestJobResults(String format) { this.log.info("Looking for recently successfully completed jobs of format: " + format); GlacierJobDescription latest = null; Date latestCompletionDate = null; // set the DateFormat to be able to parse and compare AWS jlacier job completion dates SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); // Traverse a job list that potentially matches the request to list archives in the given format ListJobsRequest listJobsRequest = new ListJobsRequest().withAccountId(this.account).withVaultName(this.vault).withCompleted("true").withStatuscode("Succeeded"); for (GlacierJobDescription job : this.awsClient.listJobs(listJobsRequest).getJobList()) { // skip irrelevant job types if (! job.getAction().equalsIgnoreCase("InventoryRetrieval") ) continue; // skip irrelevant formats if (! format.equalsIgnoreCase(job.getInventoryRetrievalParameters().getFormat()) ) continue; Date currentCompletionDate = null; try { currentCompletionDate = dateFormat.parse(job.getCompletionDate()); } catch (Exception e) { log.warn(e); // no point in continue checking more jobs given that we have the date format wrong :( break; } // compare against previously found jobs (if any) to pick that latest if (latestCompletionDate == null || currentCompletionDate.after(latestCompletionDate)) { latest = job; latestCompletionDate = currentCompletionDate; } } // job not found return latest; }
@Override public JobCollection getJobsInProgress(ListJobsRequest request) { ResourceCollectionImpl result = resource.getCollection("JobsInProgress", request); if (result == null) return null; return new JobCollectionImpl(result); }
@Override public JobCollection getSucceededJobs(ListJobsRequest request) { ResourceCollectionImpl result = resource.getCollection("SucceededJobs", request); if (result == null) return null; return new JobCollectionImpl(result); }
@Override public JobCollection getCompletedJobs(ListJobsRequest request) { ResourceCollectionImpl result = resource.getCollection("CompletedJobs", request); if (result == null) return null; return new JobCollectionImpl(result); }
@Override public JobCollection getFailedJobs(ListJobsRequest request) { ResourceCollectionImpl result = resource.getCollection("FailedJobs", request); if (result == null) return null; return new JobCollectionImpl(result); }
/** * Gets a list of jobs attached to this vault. * * @return a list of <code>GlacierJobDescription</code> */ public List<GlacierJobDescription> listJobs(){ final ListJobsRequest ljr = new ListJobsRequest(); final ListJobsResult ljres = GlacierFrame.getClient(region) .listJobs(ljr.withVaultName(name).withCompleted("true")); return ljres.getJobList(); }
@Override public JobCollection getJobs(ListJobsRequest request) { ResourceCollectionImpl result = resource.getCollection("Jobs", request); if (result == null) return null; return new JobCollectionImpl(result); }
/** * Retrieves the JobsInProgress collection referenced by this resource. */ JobCollection getJobsInProgress(ListJobsRequest request);
/** * Retrieves the Jobs collection referenced by this resource. */ JobCollection getJobs(ListJobsRequest request);
/** * Retrieves the SucceededJobs collection referenced by this resource. */ JobCollection getSucceededJobs(ListJobsRequest request);
/** * Retrieves the CompletedJobs collection referenced by this resource. */ JobCollection getCompletedJobs(ListJobsRequest request);
/** * Retrieves the FailedJobs collection referenced by this resource. */ JobCollection getFailedJobs(ListJobsRequest request);