mirror of
https://github.com/valitydev/schedulator-proxy.git
synced 2024-11-06 08:25:18 +00:00
BJ-686: add revision id (#6)
This commit is contained in:
parent
a6902a3020
commit
89f0099920
2
pom.xml
2
pom.xml
@ -53,7 +53,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rbkmoney</groupId>
|
<groupId>com.rbkmoney</groupId>
|
||||||
<artifactId>schedulator-proto</artifactId>
|
<artifactId>schedulator-proto</artifactId>
|
||||||
<version>1.14-eecbfda</version>
|
<version>1.11-efc08c2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--spring-->
|
<!--spring-->
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package com.rbkmoney.schedulatorproxy;
|
package com.rbkmoney.schedulatorproxy;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.schedule.ContextValidationResponse;
|
import com.rbkmoney.damsel.schedule.*;
|
||||||
import com.rbkmoney.damsel.schedule.ExecuteJobRequest;
|
|
||||||
import com.rbkmoney.damsel.schedule.ScheduledJobContext;
|
|
||||||
import com.rbkmoney.damsel.schedule.ScheduledJobExecutorSrv;
|
|
||||||
import com.rbkmoney.schedulatorproxy.model.JobContext;
|
import com.rbkmoney.schedulatorproxy.model.JobContext;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -26,7 +23,9 @@ public class JobExecutor implements ScheduledJobExecutorSrv.Iface {
|
|||||||
log.info("Validate job state: {}", jobState);
|
log.info("Validate job state: {}", jobState);
|
||||||
|
|
||||||
ContextValidationResponse contextValidationResponse = new ContextValidationResponse();
|
ContextValidationResponse contextValidationResponse = new ContextValidationResponse();
|
||||||
contextValidationResponse.setErrors(Collections.emptyList());
|
ValidationResponseStatus validationResponseStatus = new ValidationResponseStatus();
|
||||||
|
validationResponseStatus.setSuccess(new ValidationSuccess());
|
||||||
|
contextValidationResponse.setResponseStatus(validationResponseStatus);
|
||||||
return contextValidationResponse;
|
return contextValidationResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,10 @@ public class SchedulatorProxyController {
|
|||||||
jobContext.setSchedulerId(registerJobDto.getSchedulerId());
|
jobContext.setSchedulerId(registerJobDto.getSchedulerId());
|
||||||
jobContext.setServicePath(registerJobDto.getServicePath());
|
jobContext.setServicePath(registerJobDto.getServicePath());
|
||||||
registerJobRequest.setContext(jobStateSerializer.writeByte(jobContext));
|
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 {
|
try {
|
||||||
schedulatorClient.registerJob(registerJobDto.getJobId(), registerJobRequest);
|
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();
|
Schedule schedule = new Schedule();
|
||||||
DominantBasedSchedule dominantBasedSchedule = new DominantBasedSchedule()
|
DominantBasedSchedule dominantBasedSchedule = new DominantBasedSchedule()
|
||||||
.setBusinessScheduleRef(new BusinessScheduleRef().setId(scheduleRefId))
|
.setBusinessScheduleRef(new BusinessScheduleRef().setId(scheduleRefId))
|
||||||
.setCalendarRef(new CalendarRef().setId(calendarRefId));
|
.setCalendarRef(new CalendarRef().setId(calendarRefId))
|
||||||
|
.setRevision(revision);
|
||||||
schedule.setDominantSchedule(dominantBasedSchedule);
|
schedule.setDominantSchedule(dominantBasedSchedule);
|
||||||
|
|
||||||
return schedule;
|
return schedule;
|
||||||
|
@ -24,6 +24,9 @@ public class RegisterJobDto {
|
|||||||
@JsonProperty("calendar_id")
|
@JsonProperty("calendar_id")
|
||||||
private Integer calendarId;
|
private Integer calendarId;
|
||||||
|
|
||||||
|
@JsonProperty("revision_id")
|
||||||
|
private Long revisionId;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
@JsonProperty("service_path")
|
@JsonProperty("service_path")
|
||||||
private String servicePath;
|
private String servicePath;
|
||||||
|
@ -39,6 +39,7 @@ public class SchedulatorControllerTest {
|
|||||||
.servicePath("testServicePath")
|
.servicePath("testServicePath")
|
||||||
.calendarId(1)
|
.calendarId(1)
|
||||||
.schedulerId(64)
|
.schedulerId(64)
|
||||||
|
.revisionId(4325L)
|
||||||
.build();
|
.build();
|
||||||
String json = objectMapper.writer().withDefaultPrettyPrinter().writeValueAsString(registerJobDto);
|
String json = objectMapper.writer().withDefaultPrettyPrinter().writeValueAsString(registerJobDto);
|
||||||
mvc.perform(post("/schedulator/proxy/register")
|
mvc.perform(post("/schedulator/proxy/register")
|
||||||
|
Loading…
Reference in New Issue
Block a user