BJ-686: add revision id (#6)

This commit is contained in:
vitaxa 2019-12-04 17:06:17 +03:00 committed by GitHub
parent a6902a3020
commit 89f0099920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 9 deletions

View File

@ -53,7 +53,7 @@
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>schedulator-proto</artifactId>
<version>1.14-eecbfda</version>
<version>1.11-efc08c2</version>
</dependency>
<!--spring-->

View File

@ -1,9 +1,6 @@
package com.rbkmoney.schedulatorproxy;
import com.rbkmoney.damsel.schedule.ContextValidationResponse;
import com.rbkmoney.damsel.schedule.ExecuteJobRequest;
import com.rbkmoney.damsel.schedule.ScheduledJobContext;
import com.rbkmoney.damsel.schedule.ScheduledJobExecutorSrv;
import com.rbkmoney.damsel.schedule.*;
import com.rbkmoney.schedulatorproxy.model.JobContext;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -26,7 +23,9 @@ public class JobExecutor implements ScheduledJobExecutorSrv.Iface {
log.info("Validate job state: {}", jobState);
ContextValidationResponse contextValidationResponse = new ContextValidationResponse();
contextValidationResponse.setErrors(Collections.emptyList());
ValidationResponseStatus validationResponseStatus = new ValidationResponseStatus();
validationResponseStatus.setSuccess(new ValidationSuccess());
contextValidationResponse.setResponseStatus(validationResponseStatus);
return contextValidationResponse;
}

View File

@ -44,7 +44,10 @@ public class SchedulatorProxyController {
jobContext.setSchedulerId(registerJobDto.getSchedulerId());
jobContext.setServicePath(registerJobDto.getServicePath());
registerJobRequest.setContext(jobStateSerializer.writeByte(jobContext));
registerJobRequest.setSchedule(buildsSchedule(registerJobDto.getSchedulerId(), registerJobDto.getCalendarId()));
Schedule schedule = buildsSchedule(registerJobDto.getSchedulerId(),
registerJobDto.getCalendarId(),
registerJobDto.getRevisionId());
registerJobRequest.setSchedule(schedule);
try {
schedulatorClient.registerJob(registerJobDto.getJobId(), registerJobRequest);
@ -65,11 +68,12 @@ public class SchedulatorProxyController {
}
}
private Schedule buildsSchedule(int scheduleRefId, int calendarRefId) {
private Schedule buildsSchedule(int scheduleRefId, int calendarRefId, long revision) {
Schedule schedule = new Schedule();
DominantBasedSchedule dominantBasedSchedule = new DominantBasedSchedule()
.setBusinessScheduleRef(new BusinessScheduleRef().setId(scheduleRefId))
.setCalendarRef(new CalendarRef().setId(calendarRefId));
.setCalendarRef(new CalendarRef().setId(calendarRefId))
.setRevision(revision);
schedule.setDominantSchedule(dominantBasedSchedule);
return schedule;

View File

@ -24,6 +24,9 @@ public class RegisterJobDto {
@JsonProperty("calendar_id")
private Integer calendarId;
@JsonProperty("revision_id")
private Long revisionId;
@NotEmpty
@JsonProperty("service_path")
private String servicePath;

View File

@ -39,6 +39,7 @@ public class SchedulatorControllerTest {
.servicePath("testServicePath")
.calendarId(1)
.schedulerId(64)
.revisionId(4325L)
.build();
String json = objectMapper.writer().withDefaultPrettyPrinter().writeValueAsString(registerJobDto);
mvc.perform(post("/schedulator/proxy/register")