use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by zeebe-io.
the class BpmnJobBehavior method writeJobCancelCommand.
private void writeJobCancelCommand(final long jobKey) {
final State state = jobState.getState(jobKey);
if (state == State.ACTIVATABLE || state == State.ACTIVATED || state == State.FAILED) {
final JobRecord job = jobState.getJob(jobKey);
commandWriter.appendFollowUpCommand(jobKey, JobIntent.CANCEL, job);
}
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe-process-test by camunda.
the class GrpcToLogStreamGateway method throwError.
@Override
public void throwError(final ThrowErrorRequest request, final StreamObserver<ThrowErrorResponse> responseObserver) {
executor.submit(() -> {
final Long requestId = registerNewRequest(responseObserver);
prepareRecordMetadata().requestId(requestId).valueType(ValueType.JOB).intent(JobIntent.THROW_ERROR);
final JobRecord jobRecord = new JobRecord();
jobRecord.setErrorCode(BufferUtil.wrapString(request.getErrorCode()));
jobRecord.setErrorMessage(request.getErrorMessage());
writeCommandWithKey(request.getJobKey(), recordMetadata, jobRecord);
});
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe-process-test by camunda.
the class GrpcToLogStreamGateway method updateJobRetries.
@Override
public void updateJobRetries(final UpdateJobRetriesRequest request, final StreamObserver<UpdateJobRetriesResponse> responseObserver) {
executor.submit(() -> {
final Long requestId = registerNewRequest(responseObserver);
prepareRecordMetadata().requestId(requestId).valueType(ValueType.JOB).intent(JobIntent.UPDATE_RETRIES);
final JobRecord jobRecord = new JobRecord();
jobRecord.setRetries(request.getRetries());
writeCommandWithKey(request.getJobKey(), recordMetadata, jobRecord);
});
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobFailProcessor method acceptCommand.
private void acceptCommand(final TypedRecord<JobRecord> command, final CommandControl<JobRecord> commandControl, final Consumer<SideEffectProducer> sideEffect) {
final long key = command.getKey();
final JobRecord failedJob = jobState.getJob(key);
final var retries = command.getValue().getRetries();
final var retryBackOff = command.getValue().getRetryBackoff();
failedJob.setRetries(retries);
failedJob.setErrorMessage(command.getValue().getErrorMessageBuffer());
failedJob.setRetryBackoff(retryBackOff);
if (retries > 0 && retryBackOff > 0) {
final long receivedTime = command.getTimestamp();
failedJob.setRecurringTime(receivedTime + retryBackOff);
sideEffect.accept(() -> {
jobBackoffChecker.scheduleBackOff(retryBackOff + receivedTime);
return true;
});
}
commandControl.accept(JobIntent.FAILED, failedJob);
jobMetrics.jobFailed(failedJob.getType());
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobUpdateRetriesProcessor method onCommand.
@Override
public boolean onCommand(final TypedRecord<JobRecord> command, final CommandControl<JobRecord> commandControl) {
final long key = command.getKey();
final int retries = command.getValue().getRetries();
if (retries > 0) {
final JobRecord job = jobState.getJob(key);
if (job != null) {
// update retries for response sent to client
job.setRetries(retries);
commandControl.accept(JobIntent.RETRIES_UPDATED, job);
} else {
commandControl.reject(RejectionType.NOT_FOUND, String.format(NO_JOB_FOUND_MESSAGE, key));
}
} else {
commandControl.reject(RejectionType.INVALID_ARGUMENT, String.format(NEGATIVE_RETRIES_MESSAGE, key, retries));
}
return true;
}
Aggregations