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); } }
/** * 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; } }
/** * * @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); }
public HITResults(HIT hit, Assignment[] assignments, ClientConfig config) { this.hit = hit; this.assignments = assignments; this.config = config; }
public AWSService(ClientConfig config) { this.config = config; }
public ClientConfig getConfig() { return this.config; }
public FilteredAWSService(ClientConfig config) { this(config, Collections.EMPTY_LIST); }
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); }
public GortRequesterService(ClientConfig config) { super(config); }
/** * Creates a new instance of this class using the configuration information * from the ClientConfig class. */ public RequesterService(ClientConfig config) { super(config); }