Java 类com.amazonaws.mturk.util.ClientConfig 实例源码

项目:java-aws-mturk    文件:RequesterServiceRaw.java   
protected RequesterServiceRaw( ClientConfig config ) {
  super(config);

  try {

    // instantiate port for main thread to fail-fast in case it is misconfigured
    AWSMechanicalTurkRequesterLocator locator = new AWSMechanicalTurkRequesterLocator();
    locator.setEndpointAddress(PORT_NAME, this.config.getServiceURL());

    getPort();      

    // Read the access keys from config
    this.setAccessKeyId(this.config.getAccessKeyId());
    this.setSigner(this.config.getSecretAccessKey());
    //add default Retry Filter to list of filters
    this.addFilter(new ErrorProcessingFilter());
    this.addFilter(new RetryFilter(config.getRetriableErrors(), config.getRetryAttempts(), config.getRetryDelayMillis()));

  } catch (Exception e) {
    throw new RuntimeException("Invalid configuration for port", e);
  }
}
项目:mturksdk-java-code-maven    文件:RequesterServiceRaw.java   
protected RequesterServiceRaw( ClientConfig config ) {
  super(config);

  try {

    // instantiate port for main thread to fail-fast in case it is misconfigured
    AWSMechanicalTurkRequesterLocator locator = new AWSMechanicalTurkRequesterLocator();
    locator.setEndpointAddress(PORT_NAME, this.config.getServiceURL());

    getPort();      

    // Read the access keys from config
    this.setAccessKeyId(this.config.getAccessKeyId());
    this.setSigner(this.config.getSecretAccessKey());
    //add default Retry Filter to list of filters
    this.addFilter(new ErrorProcessingFilter());
    this.addFilter(new RetryFilter(config.getRetriableErrors(), config.getRetryAttempts(), config.getRetryDelayMillis()));

  } catch (Exception e) {
    throw new RuntimeException("Invalid configuration for port", e);
  }
}
项目:java-aws-mturk    文件:DeleteHITCommand.java   
/**
 * Handles/logs throttling errors in the sandbox environment
 * @param ex
 */
private void handleException(Exception ex) throws InternalServiceException {
  if (ex instanceof InternalServiceException &&
      service.getConfig().getServiceURL().equalsIgnoreCase(ClientConfig.SANDBOX_SERVICE_URL)) {
    logFailure(ex);

    throw (InternalServiceException)ex;
  }
}
项目:java-aws-mturk    文件:FilteredAWSService.java   
/**
 * 
 * @param filterList - List of Filters that should be executed.
 * Also appends the FinalFilter, which makes the wsdl call, to the List
 */
public FilteredAWSService(ClientConfig config, List<Filter> filterList) {
    super(config);
    this.filterList = new LinkedList<Filter>(filterList);
    this.filterList.addLast(new FinalFilter(this));
    Filter.linkFilters(this.filterList);
}
项目:mturksdk-java-code-maven    文件:DeleteHITCommand.java   
/**
 * Handles/logs throttling errors in the sandbox environment
 * @param ex
 */
private void handleException(Exception ex) throws InternalServiceException {
  if (ex instanceof InternalServiceException &&
      service.getConfig().getServiceURL().equalsIgnoreCase(ClientConfig.SANDBOX_SERVICE_URL)) {
    logFailure(ex);

    throw (InternalServiceException)ex;
  }
}
项目:mturksdk-java-code-maven    文件:FilteredAWSService.java   
/**
 * 
 * @param filterList - List of Filters that should be executed.
 * Also appends the FinalFilter, which makes the wsdl call, to the List
 */
public FilteredAWSService(ClientConfig config, List<Filter> filterList) {
    super(config);
    this.filterList = new LinkedList<Filter>(filterList);
    this.filterList.addLast(new FinalFilter(this));
    Filter.linkFilters(this.filterList);
}
项目:java-aws-mturk    文件:HITResults.java   
public HITResults(HIT hit, Assignment[] assignments, ClientConfig config) {
  this.hit = hit;
  this.assignments = assignments;
  this.config = config;
}
项目:java-aws-mturk    文件:AWSService.java   
public AWSService(ClientConfig config) {
    this.config = config;
}
项目:java-aws-mturk    文件:AWSService.java   
public ClientConfig getConfig() {
  return this.config;
}
项目:java-aws-mturk    文件:FilteredAWSService.java   
public FilteredAWSService(ClientConfig config) {
    this(config, Collections.EMPTY_LIST);
}
项目:java-aws-mturk    文件:TestRequesterServiceRaw.java   
public void testCreateHITsAsync() {

    if (service.getConfig().getServiceURL().equals(ClientConfig.SANDBOX_SERVICE_URL)) {
      // since we test that async performs better, let's wait a 20 secs
      // so that we can execute the requests without throttling skewing the times
      try {
        Thread.sleep(5000);
      }
      catch (InterruptedException ie) {
        //do nothing
      }
    }

    long t1 = System.currentTimeMillis();

    AsyncReply[] replies = new AsyncReply[10];

    // submit to work queue
    for (int i = 0; i < replies.length; i++) {
      replies[i] = service.createHITAsync(
          null, // HITTypeId
          "Async_" + String.valueOf(i) + "_" + defaultHITTitle
          + unique,
          "Async_" + String.valueOf(i) + "_" + defaultHITDescription,
          null, // keywords
          RequesterService.getBasicFreeTextQuestion(defaultQuestion),
          defaultReward, defaultAssignmentDurationInSeconds,
          defaultAutoApprovalDelayInSeconds,
          defaultLifetimeInSeconds, defaultMaxAssignments, null, // requesterAnnotation
          null, 
          null, // responseGroup
          null, // uniqueRequestToken
          null, // assignmentReviewPolicy
          null, // hitReviewPolicy
          null  // callback
      );

      assertNotNull(replies[i]);
      assertNotNull(replies[i].getFuture());
      assertFalse(replies[i].getFuture().isDone());
    }

    // get results
    for (AsyncReply reply : replies) {
      HIT hit = ((HIT[]) reply.getResult())[0];

      assertNotNull(hit);
      assertNotNull(hit.getHITId());
      assertTrue(reply.getFuture().isDone());
    }

    long t2 = System.currentTimeMillis();

    // create same amount of HITs synchronously
    for (int i = 0; i < replies.length; i++) {
      createHIT();
    }

    long t3 = System.currentTimeMillis();

    long timeAsync = t2 - t1;
    long timeSync  = t3 - t2;

    assertTrue(timeAsync < timeSync);
  }
项目:mturksdk-java-code-maven    文件:HITResults.java   
public HITResults(HIT hit, Assignment[] assignments, ClientConfig config) {
  this.hit = hit;
  this.assignments = assignments;
  this.config = config;
}
项目:mturksdk-java-code-maven    文件:AWSService.java   
public AWSService(ClientConfig config) {
    this.config = config;
}
项目:mturksdk-java-code-maven    文件:AWSService.java   
public ClientConfig getConfig() {
  return this.config;
}
项目:mturksdk-java-code-maven    文件:FilteredAWSService.java   
public FilteredAWSService(ClientConfig config) {
    this(config, Collections.EMPTY_LIST);
}
项目:mturksdk-java-code-maven    文件:TestRequesterServiceRaw.java   
public void testCreateHITsAsync() {

    if (service.getConfig().getServiceURL().equals(ClientConfig.SANDBOX_SERVICE_URL)) {
      // since we test that async performs better, let's wait a 20 secs
      // so that we can execute the requests without throttling skewing the times
      try {
        Thread.sleep(5000);
      }
      catch (InterruptedException ie) {
        //do nothing
      }
    }

    long t1 = System.currentTimeMillis();

    AsyncReply[] replies = new AsyncReply[10];

    // submit to work queue
    for (int i = 0; i < replies.length; i++) {
      replies[i] = service.createHITAsync(
          null, // HITTypeId
          "Async_" + String.valueOf(i) + "_" + defaultHITTitle
          + unique,
          "Async_" + String.valueOf(i) + "_" + defaultHITDescription,
          null, // keywords
          RequesterService.getBasicFreeTextQuestion(defaultQuestion),
          defaultReward, defaultAssignmentDurationInSeconds,
          defaultAutoApprovalDelayInSeconds,
          defaultLifetimeInSeconds, defaultMaxAssignments, null, // requesterAnnotation
          null, 
          null, // responseGroup
          null, // uniqueRequestToken
          null, // assignmentReviewPolicy
          null, // hitReviewPolicy
          null  // callback
      );

      assertNotNull(replies[i]);
      assertNotNull(replies[i].getFuture());
      assertFalse(replies[i].getFuture().isDone());
    }

    // get results
    for (AsyncReply reply : replies) {
      HIT hit = ((HIT[]) reply.getResult())[0];

      assertNotNull(hit);
      assertNotNull(hit.getHITId());
      assertTrue(reply.getFuture().isDone());
    }

    long t2 = System.currentTimeMillis();

    // create same amount of HITs synchronously
    for (int i = 0; i < replies.length; i++) {
      createHIT();
    }

    long t3 = System.currentTimeMillis();

    long timeAsync = t2 - t1;
    long timeSync  = t3 - t2;

    assertTrue(timeAsync < timeSync);
  }
项目:gort-public    文件:GortRequesterService.java   
public GortRequesterService(ClientConfig config) {
    super(config);
}
项目:java-aws-mturk    文件:RequesterService.java   
/**
 * Creates a new instance of this class using the configuration information 
 * from the ClientConfig class.
 */
public RequesterService(ClientConfig config) {
  super(config);
}
项目:mturksdk-java-code-maven    文件:RequesterService.java   
/**
 * Creates a new instance of this class using the configuration information 
 * from the ClientConfig class.
 */
public RequesterService(ClientConfig config) {
  super(config);
}