public void restore(AWSCredentials awsCredentials, String region, String vault, String archiveId, String snsTopic, String correlationId) { try { runtimeCredentialsProvider.setAwsCredentials(awsCredentials); amazonGlacier.setRegion(Region.getRegion(Regions.fromName(region))); JobParameters jobParameters = new JobParameters(); jobParameters.setType(ARCHIVE_RETRIEVAL); jobParameters.setArchiveId(archiveId); jobParameters.setSNSTopic(snsTopic); jobParameters.setDescription(correlationId); InitiateJobResult result = amazonGlacier.initiateJob(new InitiateJobRequest(vault, jobParameters)); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Created restore job " + result.getJobId() + " for archive " + archiveId + " in region/vault" + region + "/" + vault); } } catch (AmazonClientException e) { throw new OmakaseRuntimeException(e); } }
/** * Start a job to get the inventory of a vault. * * @param sns_topic_string region appropriate SNS topic string * @return job id string if successful; null on error */ public String makeVaultInventoryJob(final String sns_topic_string){ final JobParameters jp = new JobParameters() .withType("inventory-retrieval") .withSNSTopic(sns_topic_string); final InitiateJobRequest initJobRequest = new InitiateJobRequest() .withVaultName(name) .withJobParameters(jp); InitiateJobResult JobResult = null; try{ JobResult = GlacierFrame .getClient(region).initiateJob(initJobRequest); } catch(Exception e){ LGR.log(Level.SEVERE, null, e); return null; } return JobResult.getJobId(); }
private String sendInventoryRetrievalJobRequest(String format, String description, int interval) { log.info("Description: " + description); log.info("Interval: " + interval); // craete an inventory retrival request JobParameters params = new JobParameters().withType("inventory-retrieval").withFormat(format).withDescription(description); InitiateJobRequest request = new InitiateJobRequest(account, vault, params); // Initiate job and start polling for its completion InitiateJobResult initiateJobResult = this.awsClient.initiateJob(request); String jobId = initiateJobResult.getJobId(); this.log.info("Initiated job 'inventory-retrieval'. jobId=" + jobId); // wait for the job to complete GlacierJobDescription jobDescription = retreiveJobResultByJobId(jobId); while (jobDescription == null || ! jobDescription.isCompleted()) { // log this.log.info("Job not completed! Will try again in " + interval + " minutes"); // wait before accessing again (remember: AWS are counting API calls!!) try { TimeUnit.MINUTES.sleep(interval); } catch (InterruptedException ie) {} // re-check job status jobDescription = retreiveJobResultByJobId(jobId); } return jobId; }
@Override public Job initiateInventoryRetrieval(InitiateJobRequest request, ResultCapture<InitiateJobResult> extractor) { ActionResult result = resource.performAction("InitiateInventoryRetrieval", request, extractor); if (result == null) return null; return new JobImpl(result.getResource()); }
@Override public Job initiateInventoryRetrieval(ResultCapture<InitiateJobResult> extractor) { InitiateJobRequest request = new InitiateJobRequest(); return initiateInventoryRetrieval(request, extractor); }
@Override public Job initiateArchiveRetreival(InitiateJobRequest request, ResultCapture<InitiateJobResult> extractor) { ActionResult result = resource.performAction("InitiateArchiveRetreival", request, extractor); if (result == null) return null; return new JobImpl(result.getResource()); }
@Override public Job initiateArchiveRetreival(ResultCapture<InitiateJobResult> extractor) { InitiateJobRequest request = new InitiateJobRequest(); return initiateArchiveRetreival(request, extractor); }
@Override public Job initiateInventoryRetrieval(InitiateJobRequest request) { return initiateInventoryRetrieval(request, null); }
@Override public Job initiateArchiveRetreival(InitiateJobRequest request) { return initiateArchiveRetreival(request, null); }
/** * Performs the <code>InitiateArchiveRetreival</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Archive</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VaultName</code></b> * - mapped from the <code>Name</code> identifier. * </li> * <li> * <b><code>AccountId</code></b> * - mapped from the <code>AccountId</code> identifier. * </li> * <li> * <b><code>JobParameters.ArchiveId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * <li> * <b><code>JobParameters.Type</code></b> * - constant value <code>archive-retrieval</code>. * </li> * </ul> * * <p> * * @return The <code>Job</code> resource object associated with the result * of this action. * @see InitiateJobRequest */ Job initiateArchiveRetreival(InitiateJobRequest request);
/** * Performs the <code>InitiateArchiveRetreival</code> action and use a * ResultCapture to retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Archive</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VaultName</code></b> * - mapped from the <code>Name</code> identifier. * </li> * <li> * <b><code>AccountId</code></b> * - mapped from the <code>AccountId</code> identifier. * </li> * <li> * <b><code>JobParameters.ArchiveId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * <li> * <b><code>JobParameters.Type</code></b> * - constant value <code>archive-retrieval</code>. * </li> * </ul> * * <p> * * @return The <code>Job</code> resource object associated with the result * of this action. * @see InitiateJobRequest */ Job initiateArchiveRetreival(InitiateJobRequest request, ResultCapture<InitiateJobResult> extractor);
/** * Performs the <code>InitiateInventoryRetrieval</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Vault</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VaultName</code></b> * - mapped from the <code>Name</code> identifier. * </li> * <li> * <b><code>AccountId</code></b> * - mapped from the <code>AccountId</code> identifier. * </li> * <li> * <b><code>JobParameters.Type</code></b> * - constant value <code>inventory-retrieval</code>. * </li> * </ul> * * <p> * * @return The <code>Job</code> resource object associated with the result * of this action. * @see InitiateJobRequest */ com.amazonaws.resources.glacier.Job initiateInventoryRetrieval( InitiateJobRequest request);
/** * Performs the <code>InitiateInventoryRetrieval</code> action and use a * ResultCapture to retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Vault</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VaultName</code></b> * - mapped from the <code>Name</code> identifier. * </li> * <li> * <b><code>AccountId</code></b> * - mapped from the <code>AccountId</code> identifier. * </li> * <li> * <b><code>JobParameters.Type</code></b> * - constant value <code>inventory-retrieval</code>. * </li> * </ul> * * <p> * * @return The <code>Job</code> resource object associated with the result * of this action. * @see InitiateJobRequest */ com.amazonaws.resources.glacier.Job initiateInventoryRetrieval( InitiateJobRequest request, ResultCapture<InitiateJobResult> extractor);