amazon glacier Job Status Getter - Java AWS

Java examples for AWS:Glacier

Description

amazon glacier Job Status Getter

Demo Code


import java.io.IOException;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.glacier.AmazonGlacierClient;
import com.amazonaws.services.glacier.model.DescribeJobRequest;
import com.amazonaws.services.glacier.model.DescribeJobResult;


public class JobStatusGetter {

    public static String vaultName = "GLACIER_TEST";
    public static String jobId = "JobId";

    public static void main(String[] args) throws IOException {
        ClientConfiguration clientConfiguration = new ClientConfiguration();

        clientConfiguration.setProxyHost("xx.xx.xx.xx");
        clientConfiguration.setProxyPort(0);

        AWSCredentials credentials = new PropertiesCredentials(
                VaultCreator.class
                        .getResourceAsStream("AwsCredentials.properties"));
        AmazonGlacierClient client = new AmazonGlacierClient(credentials,
                clientConfiguration);//from w  w w  .ja  va2s .  c o m
        client.setEndpoint("https://glacier.ap-northeast-1.amazonaws.com/");
        try {
            DescribeJobRequest describeJobRequest = new DescribeJobRequest()
                    .withVaultName(vaultName).withJobId(jobId);
            DescribeJobResult describeJobResult = client
                    .describeJob(describeJobRequest);

            System.out.println("JobId:" + jobId);
            System.out.println("Completed:"
                    + describeJobResult.getCompleted());
            System.out.println("StatusCode:"
                    + describeJobResult.getStatusCode());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials