当前位置: 首页>>代码示例>>Java>>正文


Java TaskExecutionException类代码示例

本文整理汇总了Java中io.digdag.spi.TaskExecutionException的典型用法代码示例。如果您正苦于以下问题:Java TaskExecutionException类的具体用法?Java TaskExecutionException怎么用?Java TaskExecutionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TaskExecutionException类属于io.digdag.spi包,在下文中一共展示了TaskExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processFinish

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private TaskResult processFinish(int result, Config state) {
    if (result != 0) {
        throw new TaskExecutionException(String.format(
                "retz_run: Job(id=%s) failed. " +
                        "| retz-info: state=%s, reason=%s " +
                        "| log: `digdag log %s %s`",
                state.get(STATE_JOB_ID, String.class),
                state.get(STATE_JOB_STATE, String.class), state.get(STATE_REASON, String.class),
                request.getAttemptId(), request.getTaskName()));
    }

    TaskResult taskResult = TaskResult.empty(request);
    taskResult.getStoreParams()
            .getNestedOrSetEmpty(RetzOperatorConfig.KEY_CONFIG_ROOT)
            .set("last_job_id", state.get(STATE_JOB_ID, String.class));

    return taskResult;
}
 
开发者ID:retz,项目名称:retz-digdag-plugin,代码行数:19,代码来源:RetzRunApiOperator.java

示例2: processSchedule

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private Job processSchedule(Client webClient, Config state) {
    Job job = createJob();
    Response res;
    try {
        res = webClient.schedule(job);
    } catch (IOException ex) {
        throw new RuntimeException("Failed to schedule Retz job", ex);
    }
    if (!(res instanceof ScheduleResponse)) {
        throw new TaskExecutionException(String.format(
                "Failed to schedule Retz job: %s",
                res.status()));
    }

    Job scheduled = ((ScheduleResponse) res).job();
    LOGGER.info("Job(id={}) scheduled: {}", scheduled.id(), scheduled.state());

    initializeTaskState(scheduled, state);

    return scheduled;
}
 
开发者ID:retz,项目名称:retz-digdag-plugin,代码行数:22,代码来源:RetzRunApiOperator.java

示例3: processGetFile

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private TaskExecutionException processGetFile(Job job, Client webClient, Config state) {

        switch(job.state()) {
            case QUEUED:
                checkTimeout(job, webClient);
                return nextPolling(state);
            case STARTING:
            case STARTED:
                checkTimeout(job, webClient);
                getWholeFileByState(job, webClient, "stdout", state);
                return nextPolling(state);
            case FINISHED:
            case KILLED:
                getWholeFileByState(job, webClient, "stdout", state);
                if (config.getVerbose()) {
                    LOGGER.info("Job(id={}) finished to get stdout, will get stderr", job.id());
                }
                getWholeFile(job, webClient, "stderr", 0);
                return finishJob(job, state);
            default:
                throw new IllegalStateException("unexpected status: " + job.state());
        }
    }
 
开发者ID:retz,项目名称:retz-digdag-plugin,代码行数:24,代码来源:RetzRunApiOperator.java

示例4: finishJob

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private TaskExecutionException finishJob(Job job, Config state) {
    String duration = getDuration(job.started(), job.finished());

    LOGGER.info("Job(id={}) finished in {}. status: {}",
            job.id(), duration, job.state());

    state.set(STATE_RESULT_CODE, job.result());
    state.set(STATE_DURATION, duration);
    state.remove(STATE_POLL_ITERATION);
    state.remove(STATE_OFFSET);

    if (job.result() != 0) {
        state.set(STATE_REASON, job.reason());
    }

    return TaskExecutionException.ofNextPolling(0, ConfigElement.copyOf(state));
}
 
开发者ID:retz,项目名称:retz-digdag-plugin,代码行数:18,代码来源:RetzRunApiOperator.java

示例5: getJob

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private Job getJob(int id, Client webClient) {
    Response res;
    try {
        res = webClient.getJob(id);
    } catch (IOException ex) {
        throw Throwables.propagate(ex);
    }

    if (res instanceof GetJobResponse) {
        GetJobResponse getJobResponse = (GetJobResponse) res;
        if (getJobResponse.job().isPresent()) {
            return getJobResponse.job().get();
        } else {
            throw Throwables.propagate(new JobNotFoundException(id));
        }
    } else {
        throw new TaskExecutionException(String.format(
                "Job(id=%s) getJob received invalid response: %s",
                id, res.status()));
    }
}
 
开发者ID:retz,项目名称:retz-digdag-plugin,代码行数:22,代码来源:RetzRunApiOperator.java

示例6: storeResultsInTaskResult

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private void storeResultsInTaskResult(JdbcResultSet jdbcResultSet, StoreLastResultsOption option, ImmutableTaskResult.Builder builder)
{
    int columnsCount = jdbcResultSet.getColumnNames().size();
    if (columnsCount > maxStoreLastResultsColumns) {
        throw new TaskExecutionException("The number of result columns exceeded the limit: " + columnsCount + " > " + maxStoreLastResultsColumns);
    }

    Object lastResults;
    switch (option) {
    case ALL:
        lastResults = collectAllResults(jdbcResultSet);
        break;
    case FIRST:
        lastResults = collectFirstResults(jdbcResultSet);
        break;
    default:
        throw new AssertionError("Unexpected StoreLastResultsOption: " + option);
    }

    Config storeParams = request.getConfig().getFactory().create();
    storeParams.getNestedOrSetEmpty(type())
        .set("last_results", lastResults);
    builder.storeParams(storeParams);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:25,代码来源:AbstractJdbcJobOperator.java

示例7: collectAllResults

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private List<Map<String, Object>> collectAllResults(JdbcResultSet jdbcResultSet)
{
    List<String> columnNames = jdbcResultSet.getColumnNames();
    ImmutableList.Builder<Map<String, Object>> lastResults = ImmutableList.builder();

    long rows = 0;
    while (true) {
        List<Object> values = jdbcResultSet.next();
        if (values == null) {
            break;
        }

        rows += 1;
        if (rows > maxStoreLastResultsRows) {
            throw new TaskExecutionException("The number of result rows exceeded the limit: " + rows + " > " + maxStoreLastResultsRows);
        }

        lastResults.add(buildResultsMap(columnNames, values));
    }

    return lastResults.build();
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:23,代码来源:AbstractJdbcJobOperator.java

示例8: error

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private RuntimeException error(Request req, boolean uriIsSecret, Response res)
{
    if (HttpStatus.isClientError(res.getStatus())) {
        switch (res.getStatus()) {
            case HttpStatus.REQUEST_TIMEOUT_408:
            case HttpStatus.TOO_MANY_REQUESTS_429:
                // Retry these.
                return new RuntimeException("Failed HTTP request: " + requestStatus(req, res, uriIsSecret));
            default:
                // 4xx: The request is invalid for this resource. Fail hard without retrying.
                return new TaskExecutionException("HTTP 4XX Client Error: " + requestStatus(req, res, uriIsSecret));
        }
    }
    else if (res.getStatus() >= 500 && res.getStatus() < 600) {
        // 5xx: Server Error. This is hopefully ephemeral.
        return ephemeralError("HTTP 5XX Server Error: " + requestStatus(req, res, uriIsSecret));
    }
    else {
        // Unknown status code. Treat as an ephemeral error.
        return ephemeralError("Unexpected HTTP status: " + requestStatus(req, res, uriIsSecret));
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:23,代码来源:HttpOperatorFactory.java

示例9: client

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private HttpClient client()
{
    boolean insecure = params.get("insecure", boolean.class, false);

    HttpClient httpClient = new HttpClient(new SslContextFactory(insecure));

    configureProxy(httpClient);

    boolean followRedirects = params.get("follow_redirects", boolean.class, true);

    httpClient.setFollowRedirects(followRedirects);
    httpClient.setMaxRedirects(maxRedirects);

    httpClient.setUserAgentField(new HttpField(
            USER_AGENT, userAgent + ' ' + httpClient.getUserAgentField().getValue()));

    try {
        httpClient.start();
    }
    catch (Exception e) {
        throw new TaskExecutionException(e);
    }
    return httpClient;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:25,代码来源:HttpOperatorFactory.java

示例10: fetchRows

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private List<Config> fetchRows(TDJobOperator job)
{
    return PollingRetryExecutor.pollingRetryExecutor(state, RESULT)
            .retryUnless(TDOperator::isDeterministicClientException)
            .withErrorMessage("Failed to download result of job '%s'", job.getJobId())
            .run(s -> {
                List<String> columnNames = job.getResultColumnNames();
                List<Config> result = job.getResult(ite -> {
                    List<Config> rows = new ArrayList<>();
                    while (ite.hasNext()) {
                        rows.add(row(columnNames, ite.next().asArrayValue()));
                        if (rows.size() > Limits.maxWorkflowTasks()) {
                            TaskLimitExceededException cause = new TaskLimitExceededException("Too many tasks. Limit: " + Limits.maxWorkflowTasks());
                            throw new TaskExecutionException(cause);
                        }
                    }
                    return rows;
                });
                return result;
            });
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:22,代码来源:TdForEachOperatorFactory.java

示例11: fetchJobResult

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
private boolean fetchJobResult(TDJobOperator job)
{
    Optional<ArrayValue> firstRow = pollingRetryExecutor(state, RESULT)
            .retryUnless(TDOperator::isDeterministicClientException)
            .withErrorMessage("Failed to download result of job '%s'", job.getJobId())
            .run(s -> job.getResult(
                    ite -> ite.hasNext()
                            ? Optional.of(ite.next())
                            : Optional.absent()));

    // There must be at least one row in the result for the wait condition to be fulfilled.
    if (!firstRow.isPresent()) {
        return false;
    }

    ArrayValue row = firstRow.get();
    if (row.size() < 1) {
        throw new TaskExecutionException("Got empty row in result of query");
    }

    Value firstCol = row.get(0);
    return isTruthy(firstCol);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:24,代码来源:TdWaitOperatorFactory.java

示例12: respondSlowlyThanTimeout

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
@Test
public void respondSlowlyThanTimeout() throws IOException {
	stubFor(get("/api/foobar")
			.willReturn(aResponse()
					.withStatus(200)
					.withFixedDelay(5000)));

	Operator op = factory.newOperator(newContext(
			tempPath,
			newTaskRequest().withConfig(config)));
	try {
		op.run();
		fail("should be thrown Exception.");
	} catch (TaskExecutionException ignore) {
	}
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:17,代码来源:HttpOperatorFactoryTest.java

示例13: respondQuicklyThanTimeout

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
@Test
public void respondQuicklyThanTimeout() throws IOException {
	stubFor(get("/api/foobar")
			.willReturn(aResponse()
					.withStatus(200)
					.withFixedDelay(1000)));

	Operator op = factory.newOperator(newContext(
			tempPath,
			newTaskRequest().withConfig(config)));
	try {
		op.run();
	} catch (TaskExecutionException ignore) {
		fail("should be success.");
	}
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:17,代码来源:HttpOperatorFactoryTest.java

示例14: testVersionId

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
@Test
public void testVersionId()
        throws Exception
{
    Config config = newConfig();
    config.set("_command", BUCKET + "/" + KEY);
    config.set("version_id", VERSION_ID);
    when(taskRequest.getConfig()).thenReturn(config);

    when(s3Secrets.getSecretOptional("region")).thenReturn(Optional.of(REGION));

    when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenThrow(NOT_FOUND_EXCEPTION);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    try {
        operator.run();
        fail();
    }
    catch (TaskExecutionException ignore) {
    }

    GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue();

    assertThat(objectMetadataRequest.getVersionId(), is(VERSION_ID));
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:27,代码来源:S3WaitOperatorFactoryTest.java

示例15: testSSEC

import io.digdag.spi.TaskExecutionException; //导入依赖的package包/类
@Test
public void testSSEC()
        throws Exception
{
    Config config = newConfig();
    config.set("_command", BUCKET + "/" + KEY);
    when(taskRequest.getConfig()).thenReturn(config);

    when(s3Secrets.getSecretOptional("sse_c_key")).thenReturn(Optional.of(SSE_C_KEY));

    when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenThrow(NOT_FOUND_EXCEPTION);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    try {
        operator.run();
        fail();
    }
    catch (TaskExecutionException ignore) {
    }

    GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue();
    assertThat(objectMetadataRequest.getSSECustomerKey().getKey(), is(SSE_C_KEY));
    assertThat(objectMetadataRequest.getSSECustomerKey().getAlgorithm(), is("AES256"));
    assertThat(objectMetadataRequest.getSSECustomerKey().getMd5(), is(nullValue()));
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:27,代码来源:S3WaitOperatorFactoryTest.java


注:本文中的io.digdag.spi.TaskExecutionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。