package org.oran.dmaapadapter.repository;
+import java.time.Duration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Getter;
import org.immutables.gson.Gson;
+import org.oran.dmaapadapter.clients.AsyncRestClient;
public class Job {
@Gson.TypeAdapters
public static class Parameters {
- public String filter;
- public BufferTimeout bufferTimeout;
+ @Getter
+ private String filter;
+ @Getter
+ private BufferTimeout bufferTimeout;
- public Parameters() {
- }
+ private int maxConcurrency;
+
+ public Parameters() {}
- public Parameters(String filter, BufferTimeout bufferTimeout) {
+ public Parameters(String filter, BufferTimeout bufferTimeout, int maxConcurrency) {
this.filter = filter;
this.bufferTimeout = bufferTimeout;
+ this.maxConcurrency = maxConcurrency;
}
- public static class BufferTimeout {
- public BufferTimeout(int maxSize, int maxTimeMiliseconds) {
- this.maxSize = maxSize;
- this.maxTimeMiliseconds = maxTimeMiliseconds;
- }
+ public int getMaxConcurrency() {
+ return maxConcurrency == 0 ? 1 : maxConcurrency;
+ }
+ }
- public BufferTimeout() {
- }
+ @Gson.TypeAdapters
+ public static class BufferTimeout {
+ public BufferTimeout(int maxSize, long maxTimeMiliseconds) {
+ this.maxSize = maxSize;
+ this.maxTimeMiliseconds = maxTimeMiliseconds;
+ }
- public int maxSize;
- public int maxTimeMiliseconds;
+ public BufferTimeout() {}
+
+ @Getter
+ private int maxSize;
+
+ private long maxTimeMiliseconds;
+
+ public Duration getMaxTime() {
+ return Duration.ofMillis(maxTimeMiliseconds);
}
}
private final Pattern jobDataFilter;
- public Job(String id, String callbackUrl, InfoType type, String owner, String lastUpdated, Parameters parameters) {
+ @Getter
+ private final AsyncRestClient consumerRestClient;
+
+ public Job(String id, String callbackUrl, InfoType type, String owner, String lastUpdated, Parameters parameters,
+ AsyncRestClient consumerRestClient) {
this.id = id;
this.callbackUrl = callbackUrl;
this.type = type;
} else {
jobDataFilter = null;
}
+ this.consumerRestClient = consumerRestClient;
}
public boolean isFilterMatch(String data) {