Package com.socrata.datasync.job

Examples of com.socrata.datasync.job.JobStatus


     * @param jobId the jobId returned from a succesful commit post
     * @return either success or a publish error
     */
    private JobStatus getJobStatus(String datasetId, String jobId) throws
            URISyntaxException, IOException, InterruptedException, HttpException {
        JobStatus jobStatus = null;
        String status = null;
        StatusLine statusLine = null;
        URI statusUri = baseUri.setPath(datasyncPath + "/" + datasetId + statusPath + "/" + jobId).build();
        URI logUri = baseUri.setPath(datasyncPath + "/" + datasetId + logPath + "/" + jobId + ".json").build();
        int retries = 0;
        while (jobStatus == null && retries < httpRetries) {
            try(CloseableHttpResponse response = http.get(statusUri, ContentType.APPLICATION_JSON.getMimeType())) {
                statusLine = response.getStatusLine();
                int statusCode = statusLine.getStatusCode();
                if (statusCode == HttpStatus.SC_OK) {
                    status = IOUtils.toString(response.getEntity().getContent());
                    System.out.print("Polling the job status: " + status);
                    if (status.startsWith("SUCCESS")) {
                        jobStatus = JobStatus.SUCCESS;
                    } else if (status.startsWith("FAILURE")) {
                        jobStatus = JobStatus.PUBLISH_ERROR;
                    } else {
                        Thread.sleep(1000);
                    }
                } else if (statusCode != HttpStatus.SC_NOT_MODIFIED) {
                    retries += 1;
                    Thread.sleep(1000);
                }
            }
        }
        if (jobStatus == null) {
            throw new HttpException(statusLine.toString());
        }
        jobStatus.setMessage(status + "(jobId:" + jobId + ")");
        if(!jobStatus.isError()) loadStatusWithCRUD(jobStatus, logUri);
        return jobStatus;
    }
View Full Code Here


                "      \"overrides\" : {}\n" +
                "    }\n" +
                "}";

        File threeRowsFile = new File("src/test/resources/datasync_unit_test_four_rows_multidate.csv");
        JobStatus result = FTPDropbox2Publisher.publishViaFTPDropboxV2(
                userPrefs, UNITTEST_DATASET_ID, threeRowsFile,
                controlFileContent);

        TestCase.assertEquals(JobStatus.SUCCESS, result);
        TestCase.assertEquals(4, getTotalRows(UNITTEST_DATASET_ID));
View Full Code Here

TOP

Related Classes of com.socrata.datasync.job.JobStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.