mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 00:45:17 -05:00
feat(glue): create, run and chain triggers (#4436)
Glue had no triggers: CreateTrigger and the rest answered InvalidAction. Add CreateTrigger, GetTrigger, GetTriggers, ListTriggers, BatchGetTriggers, UpdateTrigger, DeleteTrigger, StartTrigger and StopTrigger. StartTrigger runs an ON_DEMAND trigger's actions. An activated CONDITIONAL trigger fires when a watched job run or crawl finishes in the named state, evaluated after every Glue request, so a chain of triggers completes within the request that starts it when runs finish at once. Runs started by a trigger carry its TriggerName. SCHEDULED triggers are stored and can be activated but do not fire on a timer. Part of #4380
This commit is contained in:
1 parent
7a583cc293
commit
0d813adf95
23 files changed
+2015
-14
No files matched your search
@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.Crawler;
|
||||
import io.github.hectorvent.floci.services.glue.model.CrawlerRunRecord;
|
||||
import io.github.hectorvent.floci.services.glue.model.FinishedCrawl;
|
||||
import io.github.hectorvent.floci.services.glue.model.LastCrawlInfo;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -43,6 +44,7 @@ public class GlueCrawlerRunService {
|
||||
static final String STATUS_CANCELLED = "CANCELLED";
|
||||
|
||||
private static final String LOG_GROUP = "/aws-glue/crawlers";
|
||||
static final String CRAWL_ID_PREFIX = "crawl:";
|
||||
// Enough history for a stable median without letting a long-lived crawler grow without bound.
|
||||
private static final int MAX_RUNTIME_HISTORY = 100;
|
||||
|
||||
@@ -69,17 +71,30 @@ public class GlueCrawlerRunService {
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
public synchronized void startCrawler(String name) {
|
||||
public synchronized String startCrawler(String name) {
|
||||
return startCrawler(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a crawl and returns its crawl id ({@code crawl:} and a UUID, so ids never repeat, even for
|
||||
* a crawler deleted and created again). A trigger passes the origin of its chain; a null origin
|
||||
* makes the crawl its own origin.
|
||||
*/
|
||||
public synchronized String startCrawler(String name, String originRunId) {
|
||||
glueService.getCrawler(name);
|
||||
CrawlerRunRecord record = settledRecord(name);
|
||||
if (record.getCurrentStart() != null) {
|
||||
throw new AwsException("CrawlerRunningException", "Crawler with name " + name + " has already started", 400);
|
||||
}
|
||||
String crawlId = CRAWL_ID_PREFIX + UUID.randomUUID();
|
||||
record.setCurrentStart(clock.instant());
|
||||
record.setCurrentMessagePrefix(UUID.randomUUID().toString());
|
||||
record.setCurrentCrawlId(crawlId);
|
||||
record.setCurrentOriginRunId(originRunId != null ? originRunId : crawlId);
|
||||
recordStore.put(name, record);
|
||||
LOG.infov("Started Glue crawler {0}", name);
|
||||
settle(record);
|
||||
return crawlId;
|
||||
}
|
||||
|
||||
public synchronized void stopCrawler(String name) {
|
||||
@@ -149,6 +164,43 @@ public class GlueCrawlerRunService {
|
||||
return glueService.paginate(metrics, maxResults, nextToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* The crawler's finished crawls after {@code afterPosition} (all kept history when null or empty), oldest
|
||||
* first; what a conditional trigger on the crawler processes. Positions are crawl sequence numbers.
|
||||
*/
|
||||
public synchronized List<GlueRunCompletion> completionsAfter(String name, String afterPosition) {
|
||||
CrawlerRunRecord record = settledRecord(name);
|
||||
long after = afterPosition == null || afterPosition.isEmpty() ? 0 : Long.parseLong(afterPosition);
|
||||
List<GlueRunCompletion> completions = new ArrayList<>();
|
||||
for (FinishedCrawl crawl : record.getRecentCrawls()) {
|
||||
if (crawl.getSequence() > after) {
|
||||
completions.add(new GlueRunCompletion(Long.toString(crawl.getSequence()), crawl.getFinishedAt(),
|
||||
crawl.getStatus(), crawl.getOriginRunId()));
|
||||
}
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records that triggers are about to start {@code runs} more runs on behalf of the origin crawl, if
|
||||
* that keeps it within {@code limit}. False when the crawl is no longer in its crawler's history.
|
||||
*/
|
||||
public synchronized boolean claimTriggeredRuns(String originCrawlId, int runs, int limit) {
|
||||
for (CrawlerRunRecord record : recordStore.scan(key -> true)) {
|
||||
for (FinishedCrawl crawl : record.getRecentCrawls()) {
|
||||
if (originCrawlId.equals(crawl.getCrawlId())) {
|
||||
if (crawl.getTriggeredRuns() + runs > limit) {
|
||||
return false;
|
||||
}
|
||||
crawl.setTriggeredRuns(crawl.getTriggeredRuns() + runs);
|
||||
recordStore.put(record.getCrawlerName(), record);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void updateCrawler(Crawler update) {
|
||||
requireNotRunning(update.getName());
|
||||
glueService.updateCrawler(update);
|
||||
@@ -235,11 +287,27 @@ public class GlueCrawlerRunService {
|
||||
runtimes.removeFirst();
|
||||
}
|
||||
record.setRuntimeSeconds(runtimes);
|
||||
FinishedCrawl finished = new FinishedCrawl();
|
||||
finished.setSequence(record.getFinishedCount() + 1);
|
||||
finished.setStartedAt(record.getCurrentStart());
|
||||
finished.setFinishedAt(finishedAt);
|
||||
finished.setStatus(status);
|
||||
finished.setCrawlId(record.getCurrentCrawlId());
|
||||
finished.setOriginRunId(record.getCurrentOriginRunId());
|
||||
List<FinishedCrawl> recent = new ArrayList<>(record.getRecentCrawls());
|
||||
recent.add(finished);
|
||||
if (recent.size() > MAX_RUNTIME_HISTORY) {
|
||||
recent.removeFirst();
|
||||
}
|
||||
record.setRecentCrawls(recent);
|
||||
record.setFinishedCount(finished.getSequence());
|
||||
record.setLastStart(record.getCurrentStart());
|
||||
record.setLastStatus(status);
|
||||
record.setLastMessagePrefix(record.getCurrentMessagePrefix());
|
||||
record.setCurrentStart(null);
|
||||
record.setCurrentMessagePrefix(null);
|
||||
record.setCurrentCrawlId(null);
|
||||
record.setCurrentOriginRunId(null);
|
||||
recordStore.put(record.getCrawlerName(), record);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.ExecutionProperty;
|
||||
import io.github.hectorvent.floci.services.glue.model.Job;
|
||||
import io.github.hectorvent.floci.services.glue.model.JobRun;
|
||||
import io.github.hectorvent.floci.services.glue.model.JobRunBookkeeping;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
@@ -18,6 +19,7 @@ import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -50,6 +52,10 @@ public class GlueJobRunService {
|
||||
private static final String LOG_GROUP_NAME = "/aws-glue/jobs";
|
||||
|
||||
private final StorageBackend<String, JobRun> runStore;
|
||||
// Per run: the order in which Floci saw it finish (a conditional trigger's position; unlike
|
||||
// CompletedOn it never ties), its trigger chain origin, and that origin's triggered run count.
|
||||
private final StorageBackend<String, JobRunBookkeeping> bookkeepingStore;
|
||||
private long nextCompletionOrder;
|
||||
private final GlueService glueService;
|
||||
private final int runDurationSeconds;
|
||||
private final Clock clock;
|
||||
@@ -57,16 +63,18 @@ public class GlueJobRunService {
|
||||
@Inject
|
||||
public GlueJobRunService(StorageFactory storageFactory, GlueService glueService, EmulatorConfig config) {
|
||||
this(storageFactory.create("glue", "job_runs.json", new TypeReference<>() {}),
|
||||
storageFactory.create("glue", "job_run_bookkeeping.json", new TypeReference<>() {}),
|
||||
glueService, config.services().glue().jobRunDurationSeconds(), Clock.systemUTC());
|
||||
}
|
||||
|
||||
GlueJobRunService(StorageBackend<String, JobRun> runStore, GlueService glueService,
|
||||
int runDurationSeconds, Clock clock) {
|
||||
GlueJobRunService(StorageBackend<String, JobRun> runStore, StorageBackend<String, JobRunBookkeeping> bookkeepingStore,
|
||||
GlueService glueService, int runDurationSeconds, Clock clock) {
|
||||
if (runDurationSeconds < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"floci.services.glue.job-run-duration-seconds must not be negative: " + runDurationSeconds);
|
||||
}
|
||||
this.runStore = runStore;
|
||||
this.bookkeepingStore = bookkeepingStore;
|
||||
this.glueService = glueService;
|
||||
this.runDurationSeconds = runDurationSeconds;
|
||||
this.clock = clock;
|
||||
@@ -79,6 +87,15 @@ public class GlueJobRunService {
|
||||
* unset field falls back to the job definition.
|
||||
*/
|
||||
public synchronized JobRun startJobRun(String jobName, String previousRunId, JobRun overrides) {
|
||||
return startJobRun(jobName, previousRunId, overrides, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* As {@link #startJobRun(String, String, JobRun)}, for a run a trigger starts on behalf of
|
||||
* {@code originRunId}; a null origin makes the run its own origin.
|
||||
*/
|
||||
public synchronized JobRun startJobRun(String jobName, String previousRunId, JobRun overrides,
|
||||
String originRunId) {
|
||||
Job job = glueService.getJob(jobName);
|
||||
// The job's own Timeout is stored as given by CreateJob/UpdateJob, so check what the run inherits.
|
||||
Integer timeout = firstNonNull(overrides.getTimeout(), job.getTimeout());
|
||||
@@ -102,6 +119,7 @@ public class GlueJobRunService {
|
||||
run.setId(newRunId());
|
||||
run.setAttempt(0);
|
||||
run.setPreviousRunId(previousRunId);
|
||||
run.setTriggerName(overrides.getTriggerName());
|
||||
run.setJobName(job.getName());
|
||||
run.setJobMode(job.getJobMode());
|
||||
run.setJobRunQueuingEnabled(queuingEnabled);
|
||||
@@ -123,6 +141,9 @@ public class GlueJobRunService {
|
||||
run.setLogGroupName(LOG_GROUP_NAME);
|
||||
run.setExecutionTime(0);
|
||||
runStore.put(run.getId(), run);
|
||||
JobRunBookkeeping bookkeeping = new JobRunBookkeeping();
|
||||
bookkeeping.setOriginRunId(originRunId != null ? originRunId : run.getId());
|
||||
bookkeepingStore.put(run.getId(), bookkeeping);
|
||||
LOG.infov("Started Glue job run {0} for job {1}", run.getId(), jobName);
|
||||
return settle(run);
|
||||
}
|
||||
@@ -180,10 +201,37 @@ public class GlueJobRunService {
|
||||
return new StopResult(stopped, errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* The job's finished runs after {@code afterPosition} (all when null or empty), in the order Floci saw
|
||||
* them finish; what a conditional trigger on the job processes. Every run that has finished by now
|
||||
* is settled first, so a run settled later always comes after the last position a trigger has seen.
|
||||
*/
|
||||
public synchronized List<GlueRunCompletion> completionsAfter(String jobName, String afterPosition) {
|
||||
List<GlueRunCompletion> completions = new ArrayList<>();
|
||||
for (JobRun run : runsOf(jobName)) {
|
||||
settle(run);
|
||||
if (isTerminal(run)) {
|
||||
String position = positionOf(run);
|
||||
if (afterPosition == null || afterPosition.isEmpty() || position.compareTo(afterPosition) > 0) {
|
||||
completions.add(new GlueRunCompletion(position, run.getCompletedOn(), run.getJobRunState(),
|
||||
bookkeepingOf(run.getId()).getOriginRunId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
completions.sort(Comparator.comparing(GlueRunCompletion::position));
|
||||
return completions;
|
||||
}
|
||||
|
||||
// Zero padded so that comparing positions as strings follows the completion order.
|
||||
private String positionOf(JobRun run) {
|
||||
return String.format("%020d", bookkeepingOf(run.getId()).getCompletionOrder());
|
||||
}
|
||||
|
||||
/** Runs belong to their job: deleting the job removes them, as it does on AWS. */
|
||||
public synchronized void deleteRuns(String jobName) {
|
||||
for (JobRun run : runsOf(jobName)) {
|
||||
runStore.delete(run.getId());
|
||||
bookkeepingStore.delete(run.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +263,42 @@ public class GlueJobRunService {
|
||||
run.setExecutionTime((int) Duration.between(run.getStartedOn(), completedOn).toSeconds());
|
||||
run.setErrorMessage(errorMessage);
|
||||
runStore.put(run.getId(), run);
|
||||
JobRunBookkeeping bookkeeping = bookkeepingOf(run.getId());
|
||||
bookkeeping.setCompletionOrder(nextCompletionOrder());
|
||||
bookkeepingStore.put(run.getId(), bookkeeping);
|
||||
}
|
||||
|
||||
private long nextCompletionOrder() {
|
||||
if (nextCompletionOrder == 0) {
|
||||
long highest = 0;
|
||||
for (JobRunBookkeeping bookkeeping : bookkeepingStore.scan(key -> true)) {
|
||||
highest = Math.max(highest, bookkeeping.getCompletionOrder());
|
||||
}
|
||||
nextCompletionOrder = highest + 1;
|
||||
}
|
||||
return nextCompletionOrder++;
|
||||
}
|
||||
|
||||
private JobRunBookkeeping bookkeepingOf(String runId) {
|
||||
return bookkeepingStore.get(runId).orElseGet(() -> {
|
||||
JobRunBookkeeping fresh = new JobRunBookkeeping();
|
||||
fresh.setOriginRunId(runId);
|
||||
return fresh;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Records that triggers are about to start {@code runs} more runs on behalf of the origin job run,
|
||||
* if that keeps the origin within {@code limit}. False when the origin run no longer exists.
|
||||
*/
|
||||
public synchronized boolean claimTriggeredRuns(String originRunId, int runs, int limit) {
|
||||
Optional<JobRunBookkeeping> origin = bookkeepingStore.get(originRunId);
|
||||
if (origin.isEmpty() || origin.get().getTriggeredRuns() + runs > limit) {
|
||||
return false;
|
||||
}
|
||||
origin.get().setTriggeredRuns(origin.get().getTriggeredRuns() + runs);
|
||||
bookkeepingStore.put(originRunId, origin.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
private JobRun findRun(String jobName, String runId) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@ApplicationScoped
|
||||
public class GlueJsonHandler {
|
||||
@@ -29,10 +30,17 @@ public class GlueJsonHandler {
|
||||
private static final TypeReference<Map<String, String>> STRING_MAP = new TypeReference<>() {};
|
||||
private static final TypeReference<List<Map<String, Object>>> MAP_LIST = new TypeReference<>() {};
|
||||
private static final TypeReference<List<Partition>> PARTITION_LIST = new TypeReference<>() {};
|
||||
private static final TypeReference<List<TriggerAction>> TRIGGER_ACTIONS = new TypeReference<>() {};
|
||||
private static final Set<String> RUN_ACTIONS = Set.of(
|
||||
"StartJobRun", "GetJobRun", "GetJobRuns", "BatchStopJobRun",
|
||||
"StartCrawler", "StopCrawler", "GetCrawler", "GetCrawlers", "BatchGetCrawlers", "GetCrawlerMetrics",
|
||||
"UpdateCrawler",
|
||||
"StartTrigger");
|
||||
|
||||
private final GlueService glueService;
|
||||
private final GlueJobRunService jobRunService;
|
||||
private final GlueCrawlerRunService crawlerRunService;
|
||||
private final GlueTriggerService triggerService;
|
||||
private final GlueSchemaRegistryService schemaRegistryService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@@ -40,16 +48,29 @@ public class GlueJsonHandler {
|
||||
public GlueJsonHandler(GlueService glueService,
|
||||
GlueJobRunService jobRunService,
|
||||
GlueCrawlerRunService crawlerRunService,
|
||||
GlueTriggerService triggerService,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
ObjectMapper mapper) {
|
||||
this.glueService = glueService;
|
||||
this.jobRunService = jobRunService;
|
||||
this.crawlerRunService = crawlerRunService;
|
||||
this.triggerService = triggerService;
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) throws Exception {
|
||||
Response response = dispatch(action, request, region);
|
||||
// Runs and crawls finish when they are started, stopped or read (they settle on read), so
|
||||
// after those requests an activated CONDITIONAL trigger watching them gets to fire. Catalog
|
||||
// and definition requests cannot finish a run and skip the evaluation.
|
||||
if (RUN_ACTIONS.contains(action)) {
|
||||
triggerService.fireConditionalTriggers();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private Response dispatch(String action, JsonNode request, String region) throws Exception {
|
||||
return switch (action) {
|
||||
case "CreateDatabase" -> {
|
||||
Database db = mapper.treeToValue(request.get("DatabaseInput"), Database.class);
|
||||
@@ -438,10 +459,84 @@ public class GlueJsonHandler {
|
||||
case "ListDataQualityRulesets" -> Response.ok(Map.of("Rulesets", List.of())).build();
|
||||
case "GetSecurityConfigurations" -> Response.ok(Map.of(
|
||||
"SecurityConfigurations", glueService.getSecurityConfigurations(region))).build();
|
||||
case "CreateTrigger" -> {
|
||||
Trigger trigger = toTrigger(request);
|
||||
trigger.setName(request.path("Name").asText(null));
|
||||
trigger.setWorkflowName(request.path("WorkflowName").asText(null));
|
||||
trigger.setType(request.path("Type").asText(null));
|
||||
Map<String, String> tags = request.hasNonNull("Tags")
|
||||
? mapper.convertValue(request.get("Tags"), STRING_MAP)
|
||||
: null;
|
||||
triggerService.createTrigger(trigger, request.path("StartOnCreation").asBoolean(false), tags, region);
|
||||
yield Response.ok(Map.of("Name", trigger.getName())).build();
|
||||
}
|
||||
case "GetTrigger" -> Response.ok(Map.of(
|
||||
"Trigger", glueService.getTrigger(request.path("Name").asText(null)))).build();
|
||||
case "GetTriggers" -> {
|
||||
GlueService.Page<Trigger> page = glueService.getTriggers(
|
||||
request.path("DependentJobName").asText(null), readMaxResults(request), readNextToken(request));
|
||||
yield Response.ok(pageResponse("Triggers", page.items(), page.nextToken())).build();
|
||||
}
|
||||
case "ListTriggers" -> {
|
||||
Map<String, String> tags = request.hasNonNull("Tags")
|
||||
? mapper.convertValue(request.get("Tags"), STRING_MAP)
|
||||
: null;
|
||||
GlueService.Page<String> page = glueService.listTriggers(request.path("DependentJobName").asText(null),
|
||||
readMaxResults(request), readNextToken(request), tags, region);
|
||||
yield Response.ok(pageResponse("TriggerNames", page.items(), page.nextToken())).build();
|
||||
}
|
||||
case "BatchGetTriggers" -> {
|
||||
List<String> names = request.hasNonNull("TriggerNames")
|
||||
? mapper.convertValue(request.get("TriggerNames"), STRING_LIST)
|
||||
: null;
|
||||
GlueService.BatchGetTriggersResult result = glueService.batchGetTriggers(names);
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("Triggers", result.triggers());
|
||||
response.put("TriggersNotFound", result.triggersNotFound());
|
||||
yield Response.ok(response).build();
|
||||
}
|
||||
case "UpdateTrigger" -> {
|
||||
Trigger update = request.hasNonNull("TriggerUpdate") ? toTrigger(request.get("TriggerUpdate")) : null;
|
||||
yield Response.ok(Map.of("Trigger",
|
||||
triggerService.updateTrigger(request.path("Name").asText(null), update))).build();
|
||||
}
|
||||
case "DeleteTrigger" -> {
|
||||
String name = request.path("Name").asText(null);
|
||||
triggerService.deleteTrigger(name, region);
|
||||
yield Response.ok(Map.of("Name", name)).build();
|
||||
}
|
||||
case "StartTrigger" -> {
|
||||
String name = request.path("Name").asText(null);
|
||||
triggerService.startTrigger(name);
|
||||
yield Response.ok(Map.of("Name", name)).build();
|
||||
}
|
||||
case "StopTrigger" -> {
|
||||
String name = request.path("Name").asText(null);
|
||||
triggerService.stopTrigger(name);
|
||||
yield Response.ok(Map.of("Name", name)).build();
|
||||
}
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
};
|
||||
}
|
||||
|
||||
/** The definition members CreateTrigger and TriggerUpdate share. */
|
||||
private Trigger toTrigger(JsonNode node) throws Exception {
|
||||
Trigger trigger = new Trigger();
|
||||
trigger.setDescription(node.path("Description").asText(null));
|
||||
trigger.setSchedule(node.path("Schedule").asText(null));
|
||||
if (node.hasNonNull("Actions")) {
|
||||
trigger.setActions(mapper.convertValue(node.get("Actions"), TRIGGER_ACTIONS));
|
||||
}
|
||||
if (node.hasNonNull("Predicate")) {
|
||||
trigger.setPredicate(mapper.treeToValue(node.get("Predicate"), Predicate.class));
|
||||
}
|
||||
if (node.hasNonNull("EventBatchingCondition")) {
|
||||
trigger.setEventBatchingCondition(
|
||||
mapper.treeToValue(node.get("EventBatchingCondition"), EventBatchingCondition.class));
|
||||
}
|
||||
return trigger;
|
||||
}
|
||||
|
||||
private Response handleUpdateColumnStatisticsForTable(JsonNode request) {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("TableName").asText();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* One finished job run or crawl, as a conditional trigger sees it. {@code position} orders the
|
||||
* completions of one job or crawler; a trigger remembers the last position it has processed.
|
||||
* {@code originRunId} is the run that set off the trigger chain this run belongs to (the run itself
|
||||
* when no trigger started it): a job run id, or a crawl id beginning {@code crawl:}.
|
||||
*/
|
||||
public record GlueRunCompletion(String position, Instant finishedAt, String state, String originRunId) {}
|
||||
@@ -14,23 +14,27 @@ import io.github.hectorvent.floci.services.glue.model.Column;
|
||||
import io.github.hectorvent.floci.services.glue.model.Connection;
|
||||
import io.github.hectorvent.floci.services.glue.model.ConnectionInput;
|
||||
import io.github.hectorvent.floci.services.glue.model.ConnectionPasswordEncryption;
|
||||
import io.github.hectorvent.floci.services.glue.model.DataCatalogEncryptionSettings;
|
||||
import io.github.hectorvent.floci.services.glue.model.EncryptionAtRest;
|
||||
import io.github.hectorvent.floci.services.glue.model.GluePolicy;
|
||||
import io.github.hectorvent.floci.services.glue.model.Crawler;
|
||||
import io.github.hectorvent.floci.services.glue.model.CrawlerTargets;
|
||||
import io.github.hectorvent.floci.services.glue.model.DataCatalogEncryptionSettings;
|
||||
import io.github.hectorvent.floci.services.glue.model.Database;
|
||||
import io.github.hectorvent.floci.services.glue.model.EncryptionAtRest;
|
||||
import io.github.hectorvent.floci.services.glue.model.GluePolicy;
|
||||
import io.github.hectorvent.floci.services.glue.model.Job;
|
||||
import io.github.hectorvent.floci.services.glue.model.JobUpdate;
|
||||
import io.github.hectorvent.floci.services.glue.model.KeySchemaElement;
|
||||
import io.github.hectorvent.floci.services.glue.model.Partition;
|
||||
import io.github.hectorvent.floci.services.glue.model.PartitionIndex;
|
||||
import io.github.hectorvent.floci.services.glue.model.PartitionIndexDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.Predicate;
|
||||
import io.github.hectorvent.floci.services.glue.model.Schedule;
|
||||
import io.github.hectorvent.floci.services.glue.model.SchemaReference;
|
||||
import io.github.hectorvent.floci.services.glue.model.SecurityConfiguration;
|
||||
import io.github.hectorvent.floci.services.glue.model.StorageDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import io.github.hectorvent.floci.services.glue.model.Trigger;
|
||||
import io.github.hectorvent.floci.services.glue.model.TriggerAction;
|
||||
import io.github.hectorvent.floci.services.glue.model.TriggerCondition;
|
||||
import io.github.hectorvent.floci.services.glue.model.UserDefinedFunction;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.GlueSchemaRegistryService;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.SchemaToColumnsConverter;
|
||||
@@ -153,6 +157,12 @@ public class GlueService {
|
||||
private static final String SCHEDULE_SCHEDULED = "SCHEDULED";
|
||||
private static final String SCHEDULE_NOT_SCHEDULED = "NOT_SCHEDULED";
|
||||
private static final Pattern CRON_FIELD = Pattern.compile("[0-9A-Za-z*?/,#-]+");
|
||||
private static final Set<String> TRIGGER_TYPES = Set.of("SCHEDULED", "CONDITIONAL", "ON_DEMAND", "EVENT");
|
||||
// The job run and crawl states a trigger condition may name (JobRunState / CrawlState in the model
|
||||
// allow more, but only final states are meaningful as conditions).
|
||||
private static final Set<String> CONDITION_JOB_STATES = Set.of("SUCCEEDED", "STOPPED", "FAILED", "TIMEOUT");
|
||||
private static final Set<String> CONDITION_CRAWL_STATES = Set.of("SUCCEEDED", "CANCELLED", "FAILED");
|
||||
private static final int MAX_TRIGGERS_PAGE_SIZE = 200;
|
||||
// BatchGetCrawlers takes a CrawlerNameList, which the API model caps at 100 names.
|
||||
private static final int MAX_BATCH_GET_CRAWLERS = 100;
|
||||
|
||||
@@ -171,6 +181,7 @@ public class GlueService {
|
||||
private final StorageBackend<String, GluePolicy> resourcePolicyStore;
|
||||
private final StorageBackend<String, DataCatalogEncryptionSettings> encryptionSettingsStore;
|
||||
private final StorageBackend<String, SecurityConfiguration> securityConfigurationStore;
|
||||
private final StorageBackend<String, Trigger> triggerStore;
|
||||
private final GlueSchemaRegistryService schemaRegistryService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ResourceGroupsTaggingService resourceGroupsTaggingService;
|
||||
@@ -201,6 +212,7 @@ public class GlueService {
|
||||
"glue", "catalog_encryption_settings.json", new TypeReference<>() {});
|
||||
this.securityConfigurationStore = storageFactory.create(
|
||||
"glue", "security_configurations.json", new TypeReference<>() {});
|
||||
this.triggerStore = storageFactory.create("glue", "triggers.json", new TypeReference<>() {});
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.resourceGroupsTaggingService = resourceGroupsTaggingService;
|
||||
@@ -222,6 +234,7 @@ public class GlueService {
|
||||
StorageBackend<String, GluePolicy> resourcePolicyStore,
|
||||
StorageBackend<String, DataCatalogEncryptionSettings> encryptionSettingsStore,
|
||||
StorageBackend<String, SecurityConfiguration> securityConfigurationStore,
|
||||
StorageBackend<String, Trigger> triggerStore,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
RegionResolver regionResolver,
|
||||
ResourceGroupsTaggingService resourceGroupsTaggingService,
|
||||
@@ -241,6 +254,7 @@ public class GlueService {
|
||||
this.resourcePolicyStore = resourcePolicyStore;
|
||||
this.encryptionSettingsStore = encryptionSettingsStore;
|
||||
this.securityConfigurationStore = securityConfigurationStore;
|
||||
this.triggerStore = triggerStore;
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.resourceGroupsTaggingService = resourceGroupsTaggingService;
|
||||
@@ -1501,6 +1515,10 @@ public class GlueService {
|
||||
return regionResolver.buildArn("glue", region, "crawler/" + crawlerName);
|
||||
}
|
||||
|
||||
private String triggerArn(String region, String triggerName) {
|
||||
return regionResolver.buildArn("glue", region, "trigger/" + triggerName);
|
||||
}
|
||||
|
||||
private static Pattern compileFunctionPattern(String pattern) {
|
||||
if (pattern == null) {
|
||||
return Pattern.compile(".*");
|
||||
@@ -2148,6 +2166,212 @@ public class GlueService {
|
||||
crawlerStore.put(name, crawler);
|
||||
}
|
||||
|
||||
// ---- Triggers ---------------------------------------------------------------------------
|
||||
|
||||
public void createTrigger(Trigger trigger, Map<String, String> tags, String region) {
|
||||
validateRequired(trigger.getName(), "Name");
|
||||
validateRequired(trigger.getType(), "Type");
|
||||
if (!TRIGGER_TYPES.contains(trigger.getType())) {
|
||||
throw new AwsException("InvalidInputException", "Invalid trigger type: " + trigger.getType(), 400);
|
||||
}
|
||||
if (trigger.getWorkflowName() != null) {
|
||||
throw new AwsException("EntityNotFoundException",
|
||||
"Workflow " + trigger.getWorkflowName() + " not found.", 400);
|
||||
}
|
||||
if ("EVENT".equals(trigger.getType())) {
|
||||
throw new AwsException("InvalidInputException", "An EVENT trigger must belong to a workflow.", 400);
|
||||
}
|
||||
validateTriggerDefinition(trigger);
|
||||
String name = trigger.getName();
|
||||
if (triggerStore.get(name).isPresent()) {
|
||||
throw new AwsException("AlreadyExistsException", "Trigger " + name + " already exists.", 400);
|
||||
}
|
||||
triggerStore.put(name, trigger);
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
resourceGroupsTaggingService.tagResources(List.of(triggerArn(region, name)), tags, region);
|
||||
}
|
||||
LOG.infov("Created Glue trigger {0}", name);
|
||||
}
|
||||
|
||||
public Trigger getTrigger(String name) {
|
||||
validateRequired(name, "Name");
|
||||
return triggerStore.get(name)
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException", "Trigger " + name + " not found.", 400));
|
||||
}
|
||||
|
||||
public List<Trigger> allTriggers() {
|
||||
List<Trigger> triggers = triggerStore.scan(k -> true);
|
||||
triggers.sort(Comparator.comparing(Trigger::getName));
|
||||
return triggers;
|
||||
}
|
||||
|
||||
public void putTrigger(Trigger trigger) {
|
||||
triggerStore.put(trigger.getName(), trigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetTriggers. With DependentJobName, the triggers that can start that job; AWS documents that
|
||||
* all triggers are returned when none can.
|
||||
*/
|
||||
public Page<Trigger> getTriggers(String dependentJobName, Integer maxResults, String nextToken) {
|
||||
if (maxResults != null && (maxResults < 1 || maxResults > MAX_TRIGGERS_PAGE_SIZE)) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"MaxResults must be between 1 and " + MAX_TRIGGERS_PAGE_SIZE, 400);
|
||||
}
|
||||
return paginate(triggersStarting(dependentJobName), maxResults, nextToken);
|
||||
}
|
||||
|
||||
public Page<String> listTriggers(String dependentJobName, Integer maxResults, String nextToken,
|
||||
Map<String, String> tags, String region) {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Trigger trigger : triggersStarting(dependentJobName)) {
|
||||
if (tags == null || tags.isEmpty() || hasTags(triggerArn(region, trigger.getName()), tags, region)) {
|
||||
names.add(trigger.getName());
|
||||
}
|
||||
}
|
||||
return paginate(names, maxResults, nextToken);
|
||||
}
|
||||
|
||||
public BatchGetTriggersResult batchGetTriggers(List<String> names) {
|
||||
if (names == null || names.isEmpty()) {
|
||||
throw new AwsException("InvalidInputException", "TriggerNames is required.", 400);
|
||||
}
|
||||
List<Trigger> triggers = new ArrayList<>();
|
||||
List<String> notFound = new ArrayList<>();
|
||||
for (String name : names) {
|
||||
Optional<Trigger> trigger = name == null ? Optional.empty() : triggerStore.get(name);
|
||||
if (trigger.isPresent()) {
|
||||
triggers.add(trigger.get());
|
||||
} else {
|
||||
notFound.add(name);
|
||||
}
|
||||
}
|
||||
return new BatchGetTriggersResult(triggers, notFound);
|
||||
}
|
||||
|
||||
public record BatchGetTriggersResult(List<Trigger> triggers, List<String> triggersNotFound) {}
|
||||
|
||||
/**
|
||||
* Applies the members a TriggerUpdate sets; the rest of the trigger is kept. The update is built
|
||||
* and validated on a copy, so a rejected update leaves the stored trigger as it was.
|
||||
*/
|
||||
public Trigger updateTrigger(String name, Trigger update) {
|
||||
validateRequired(update, "TriggerUpdate");
|
||||
Trigger stored = getTrigger(name);
|
||||
Trigger trigger = new Trigger();
|
||||
trigger.setName(stored.getName());
|
||||
trigger.setWorkflowName(stored.getWorkflowName());
|
||||
trigger.setType(stored.getType());
|
||||
trigger.setState(stored.getState());
|
||||
trigger.setDescription(stored.getDescription());
|
||||
trigger.setSchedule(stored.getSchedule());
|
||||
trigger.setActions(stored.getActions());
|
||||
trigger.setPredicate(stored.getPredicate());
|
||||
trigger.setEventBatchingCondition(stored.getEventBatchingCondition());
|
||||
if (update.getDescription() != null) {
|
||||
trigger.setDescription(update.getDescription());
|
||||
}
|
||||
if (update.getSchedule() != null) {
|
||||
trigger.setSchedule(update.getSchedule());
|
||||
}
|
||||
if (update.getActions() != null) {
|
||||
trigger.setActions(update.getActions());
|
||||
}
|
||||
if (update.getPredicate() != null) {
|
||||
trigger.setPredicate(update.getPredicate());
|
||||
}
|
||||
if (update.getEventBatchingCondition() != null) {
|
||||
trigger.setEventBatchingCondition(update.getEventBatchingCondition());
|
||||
}
|
||||
validateTriggerDefinition(trigger);
|
||||
triggerStore.put(name, trigger);
|
||||
return trigger;
|
||||
}
|
||||
|
||||
/** DeleteTrigger declares no EntityNotFoundException: deleting a missing trigger succeeds. */
|
||||
public void deleteTrigger(String name, String region) {
|
||||
validateRequired(name, "Name");
|
||||
triggerStore.delete(name);
|
||||
resourceGroupsTaggingService.deleteResources(List.of(triggerArn(region, name)), region);
|
||||
}
|
||||
|
||||
private List<Trigger> triggersStarting(String dependentJobName) {
|
||||
List<Trigger> all = allTriggers();
|
||||
if (dependentJobName == null) {
|
||||
return all;
|
||||
}
|
||||
getJob(dependentJobName);
|
||||
List<Trigger> starting = new ArrayList<>();
|
||||
for (Trigger trigger : all) {
|
||||
for (TriggerAction action : trigger.getActions()) {
|
||||
if (dependentJobName.equals(action.getJobName())) {
|
||||
starting.add(trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return starting.isEmpty() ? all : starting;
|
||||
}
|
||||
|
||||
private void validateTriggerDefinition(Trigger trigger) {
|
||||
List<TriggerAction> actions = trigger.getActions();
|
||||
if (actions == null || actions.isEmpty()) {
|
||||
throw new AwsException("InvalidInputException", "Actions must contain at least one action.", 400);
|
||||
}
|
||||
for (TriggerAction action : actions) {
|
||||
boolean hasJob = action.getJobName() != null;
|
||||
boolean hasCrawler = action.getCrawlerName() != null;
|
||||
if (hasJob == hasCrawler) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"Each action must name exactly one of JobName and CrawlerName.", 400);
|
||||
}
|
||||
if (hasJob) {
|
||||
getJob(action.getJobName());
|
||||
} else {
|
||||
getCrawler(action.getCrawlerName());
|
||||
}
|
||||
if (action.getTimeout() != null && action.getTimeout() < 1) {
|
||||
throw new AwsException("InvalidInputException", "Timeout must be at least 1 minute.", 400);
|
||||
}
|
||||
}
|
||||
if ("SCHEDULED".equals(trigger.getType())) {
|
||||
validateCronExpression(trigger.getSchedule());
|
||||
}
|
||||
if ("CONDITIONAL".equals(trigger.getType())) {
|
||||
validatePredicate(trigger.getPredicate());
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePredicate(Predicate predicate) {
|
||||
if (predicate == null || predicate.getConditions() == null || predicate.getConditions().isEmpty()) {
|
||||
throw new AwsException("InvalidInputException", "A CONDITIONAL trigger needs a predicate.", 400);
|
||||
}
|
||||
if (predicate.getLogical() != null && !Set.of("AND", "ANY").contains(predicate.getLogical())) {
|
||||
throw new AwsException("InvalidInputException", "Logical must be AND or ANY.", 400);
|
||||
}
|
||||
for (TriggerCondition condition : predicate.getConditions()) {
|
||||
if (condition.getLogicalOperator() != null && !"EQUALS".equals(condition.getLogicalOperator())) {
|
||||
throw new AwsException("InvalidInputException", "LogicalOperator must be EQUALS.", 400);
|
||||
}
|
||||
if (condition.getJobName() != null) {
|
||||
if (condition.getState() == null || !CONDITION_JOB_STATES.contains(condition.getState())) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"A job condition's State must be one of " + CONDITION_JOB_STATES, 400);
|
||||
}
|
||||
getJob(condition.getJobName());
|
||||
} else if (condition.getCrawlerName() != null) {
|
||||
if (condition.getCrawlState() == null || !CONDITION_CRAWL_STATES.contains(condition.getCrawlState())) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"A crawler condition's CrawlState must be one of " + CONDITION_CRAWL_STATES, 400);
|
||||
}
|
||||
getCrawler(condition.getCrawlerName());
|
||||
} else {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"Each condition must name a JobName or a CrawlerName.", 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCrawler(Crawler update) {
|
||||
validateRequired(update.getName(), "Name");
|
||||
// Jobs and crawlers skip normalizeName because AWS preserves their case
|
||||
@@ -2603,6 +2827,9 @@ public class GlueService {
|
||||
} else if (resource.startsWith("crawler/")) {
|
||||
getCrawler(resource.substring(8));
|
||||
return;
|
||||
} else if (resource.startsWith("trigger/")) {
|
||||
getTrigger(resource.substring(8));
|
||||
return;
|
||||
} else if (resource.startsWith("connection/")) {
|
||||
getConnection(resource.substring(11), false);
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.JobRun;
|
||||
import io.github.hectorvent.floci.services.glue.model.Trigger;
|
||||
import io.github.hectorvent.floci.services.glue.model.TriggerAction;
|
||||
import io.github.hectorvent.floci.services.glue.model.TriggerCondition;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Glue trigger lifecycle and firing. An ON_DEMAND trigger fires when started. A CONDITIONAL trigger,
|
||||
* once ACTIVATED, fires when a job run or crawl its predicate watches finishes in the named state:
|
||||
* after each Glue request that starts, stops or reads job runs or crawls,
|
||||
* {@link #fireConditionalTriggers()} processes every completion of a watched job or crawler this
|
||||
* trigger has not seen yet, in finishing order. A SCHEDULED trigger is stored and can be activated,
|
||||
* but no timer fires it.
|
||||
*
|
||||
* <p>Every public method is synchronized. This service calls the job run and crawler run services
|
||||
* and they never call back, so the lock order is always this service first.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class GlueTriggerService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(GlueTriggerService.class);
|
||||
|
||||
static final String TYPE_ON_DEMAND = "ON_DEMAND";
|
||||
static final String TYPE_CONDITIONAL = "CONDITIONAL";
|
||||
static final String STATE_CREATED = "CREATED";
|
||||
static final String STATE_ACTIVATED = "ACTIVATED";
|
||||
static final String STATE_DEACTIVATED = "DEACTIVATED";
|
||||
|
||||
// Work done within one request; a longer chain continues on the next run-related request.
|
||||
private static final int MAX_FIRING_ROUNDS = 25;
|
||||
// Emulator safeguard, not an AWS limit: triggers start at most this many runs on behalf of one run
|
||||
// that no trigger started (the origin of a chain). Here every run succeeds, so without it a trigger
|
||||
// loop of any shape, branching or not, would never stop.
|
||||
static final int MAX_TRIGGERED_RUNS_PER_ORIGIN = 100;
|
||||
private static final String JOB_KEY = "job:";
|
||||
private static final String CRAWLER_KEY = "crawler:";
|
||||
// Per watched job or crawler, the seen map holds the last processed position and that outcome's state.
|
||||
private static final String POSITION = "position:";
|
||||
private static final String STATE = "state:";
|
||||
|
||||
private final StorageBackend<String, Map<String, String>> seenStore;
|
||||
private final GlueService glueService;
|
||||
private final GlueJobRunService jobRunService;
|
||||
private final GlueCrawlerRunService crawlerRunService;
|
||||
|
||||
@Inject
|
||||
public GlueTriggerService(StorageFactory storageFactory, GlueService glueService,
|
||||
GlueJobRunService jobRunService, GlueCrawlerRunService crawlerRunService) {
|
||||
this(storageFactory.create("glue", "trigger_seen_runs.json", new TypeReference<>() {}),
|
||||
glueService, jobRunService, crawlerRunService);
|
||||
}
|
||||
|
||||
GlueTriggerService(StorageBackend<String, Map<String, String>> seenStore, GlueService glueService,
|
||||
GlueJobRunService jobRunService, GlueCrawlerRunService crawlerRunService) {
|
||||
this.seenStore = seenStore;
|
||||
this.glueService = glueService;
|
||||
this.jobRunService = jobRunService;
|
||||
this.crawlerRunService = crawlerRunService;
|
||||
}
|
||||
|
||||
public synchronized void createTrigger(Trigger trigger, boolean startOnCreation, Map<String, String> tags,
|
||||
String region) {
|
||||
if (startOnCreation && TYPE_ON_DEMAND.equals(trigger.getType())) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"StartOnCreation is not supported for ON_DEMAND triggers.", 400);
|
||||
}
|
||||
trigger.setState(startOnCreation ? STATE_ACTIVATED : STATE_CREATED);
|
||||
glueService.createTrigger(trigger, tags, region);
|
||||
if (isActiveConditional(trigger)) {
|
||||
markAlreadyFinishedAsSeen(trigger, false);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Trigger updateTrigger(String name, Trigger update) {
|
||||
Trigger trigger = glueService.updateTrigger(name, update);
|
||||
if (isActiveConditional(trigger)) {
|
||||
// Completions not yet evaluated for what the trigger already watched must still fire it;
|
||||
// only a newly watched job or crawler starts from what has finished so far.
|
||||
markAlreadyFinishedAsSeen(trigger, true);
|
||||
}
|
||||
return trigger;
|
||||
}
|
||||
|
||||
public synchronized void deleteTrigger(String name, String region) {
|
||||
glueService.deleteTrigger(name, region);
|
||||
seenStore.delete(name);
|
||||
}
|
||||
|
||||
/** ON_DEMAND: runs the actions now. SCHEDULED and CONDITIONAL: activates the trigger. */
|
||||
public synchronized void startTrigger(String name) {
|
||||
Trigger trigger = glueService.getTrigger(name);
|
||||
if (TYPE_ON_DEMAND.equals(trigger.getType())) {
|
||||
fire(trigger, null, true);
|
||||
return;
|
||||
}
|
||||
boolean wasActive = STATE_ACTIVATED.equals(trigger.getState());
|
||||
trigger.setState(STATE_ACTIVATED);
|
||||
glueService.putTrigger(trigger);
|
||||
if (isActiveConditional(trigger)) {
|
||||
markAlreadyFinishedAsSeen(trigger, wasActive);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopTrigger(String name) {
|
||||
Trigger trigger = glueService.getTrigger(name);
|
||||
if (TYPE_ON_DEMAND.equals(trigger.getType())) {
|
||||
throw new AwsException("InvalidInputException", "An ON_DEMAND trigger cannot be stopped.", 400);
|
||||
}
|
||||
trigger.setState(STATE_DEACTIVATED);
|
||||
glueService.putTrigger(trigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires every activated CONDITIONAL trigger for each new job run or crawl completion that meets
|
||||
* its predicate, repeating while firing finishes more runs (a chain of triggers with the default
|
||||
* run duration of 0 completes within one request, up to {@link #MAX_FIRING_ROUNDS} rounds; the rest
|
||||
* continues on the next run-related request). A trigger loop of any shape stops once triggers have
|
||||
* started {@link #MAX_TRIGGERED_RUNS_PER_ORIGIN} runs on behalf of the run that set it off.
|
||||
*/
|
||||
public synchronized void fireConditionalTriggers() {
|
||||
for (int round = 0; round < MAX_FIRING_ROUNDS; round++) {
|
||||
boolean anyFired = false;
|
||||
for (Trigger trigger : glueService.allTriggers()) {
|
||||
if (!isActiveConditional(trigger)) {
|
||||
continue;
|
||||
}
|
||||
for (GlueRunCompletion cause : newFirings(trigger)) {
|
||||
String origin = cause.originRunId();
|
||||
if (!claimTriggeredRuns(origin, trigger.getActions().size())) {
|
||||
LOG.warnv("Glue trigger {0} not fired: triggers already started {1} runs on behalf of {2}, "
|
||||
+ "so they probably form a loop", trigger.getName(), MAX_TRIGGERED_RUNS_PER_ORIGIN, origin);
|
||||
continue;
|
||||
}
|
||||
fire(trigger, origin, false);
|
||||
anyFired = true;
|
||||
}
|
||||
}
|
||||
if (!anyFired) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the completions this trigger has not seen yet, in finishing order, and returns the
|
||||
* completions that fire it. ANY fires on
|
||||
* each completion that matches one of its conditions; AND fires on a matching completion once
|
||||
* every condition's latest outcome matches.
|
||||
*/
|
||||
private List<GlueRunCompletion> newFirings(Trigger trigger) {
|
||||
Map<String, String> before = seenStore.get(trigger.getName()).orElse(Map.of());
|
||||
Map<String, String> seen = new HashMap<>(before);
|
||||
List<KeyedCompletion> fresh = new ArrayList<>();
|
||||
for (String key : watchedKeys(trigger)) {
|
||||
for (GlueRunCompletion completion : completionsAfter(key, seen.get(POSITION + key))) {
|
||||
fresh.add(new KeyedCompletion(key, completion));
|
||||
}
|
||||
}
|
||||
fresh.sort(Comparator.comparing((KeyedCompletion k) -> k.completion().finishedAt())
|
||||
.thenComparing(k -> k.completion().position()));
|
||||
boolean any = "ANY".equals(trigger.getPredicate().getLogical());
|
||||
List<GlueRunCompletion> firings = new ArrayList<>();
|
||||
for (KeyedCompletion event : fresh) {
|
||||
// Events run in finishing order, which need not be completion order (a run can be stopped
|
||||
// before an earlier started one is seen succeeding), so keep the highest position processed.
|
||||
String processed = seen.get(POSITION + event.key());
|
||||
if (processed == null || event.completion().position().compareTo(processed) > 0) {
|
||||
seen.put(POSITION + event.key(), event.completion().position());
|
||||
}
|
||||
seen.put(STATE + event.key(), event.completion().state());
|
||||
boolean eventMatches = false;
|
||||
boolean allMatch = true;
|
||||
for (TriggerCondition condition : trigger.getPredicate().getConditions()) {
|
||||
boolean matches = expectedState(condition).equals(seen.get(STATE + keyOf(condition)));
|
||||
allMatch &= matches;
|
||||
eventMatches |= matches && keyOf(condition).equals(event.key())
|
||||
&& expectedState(condition).equals(event.completion().state());
|
||||
}
|
||||
if (eventMatches && (any || allMatch)) {
|
||||
firings.add(event.completion());
|
||||
}
|
||||
}
|
||||
if (!seen.equals(before)) {
|
||||
seenStore.put(trigger.getName(), seen);
|
||||
}
|
||||
return firings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks what has already finished as seen, so that only later completions count. With
|
||||
* {@code keepProcessed}, a watched job or crawler the trigger already tracks keeps its position, so
|
||||
* its unevaluated completions still fire the trigger; only newly watched ones are marked.
|
||||
*/
|
||||
private void markAlreadyFinishedAsSeen(Trigger trigger, boolean keepProcessed) {
|
||||
Map<String, String> seen = new HashMap<>();
|
||||
Map<String, String> previous = keepProcessed ? seenStore.get(trigger.getName()).orElse(Map.of()) : Map.of();
|
||||
for (String key : watchedKeys(trigger)) {
|
||||
if (previous.containsKey(POSITION + key)) {
|
||||
seen.put(POSITION + key, previous.get(POSITION + key));
|
||||
if (previous.containsKey(STATE + key)) {
|
||||
seen.put(STATE + key, previous.get(STATE + key));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
List<GlueRunCompletion> completions = completionsAfter(key, null);
|
||||
if (completions.isEmpty()) {
|
||||
// Tracked from the start: an empty position means every completion is still unseen.
|
||||
seen.put(POSITION + key, "");
|
||||
} else {
|
||||
GlueRunCompletion last = completions.getLast();
|
||||
seen.put(POSITION + key, last.position());
|
||||
seen.put(STATE + key, last.state());
|
||||
}
|
||||
}
|
||||
seenStore.put(trigger.getName(), seen);
|
||||
}
|
||||
|
||||
private static Set<String> watchedKeys(Trigger trigger) {
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
for (TriggerCondition condition : trigger.getPredicate().getConditions()) {
|
||||
keys.add(keyOf(condition));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
private List<GlueRunCompletion> completionsAfter(String key, String position) {
|
||||
if (key.startsWith(JOB_KEY)) {
|
||||
return jobRunService.completionsAfter(key.substring(JOB_KEY.length()), position);
|
||||
}
|
||||
return crawlerRunService.completionsAfter(key.substring(CRAWLER_KEY.length()), position);
|
||||
}
|
||||
|
||||
private boolean claimTriggeredRuns(String originRunId, int runs) {
|
||||
if (originRunId == null) {
|
||||
return false;
|
||||
}
|
||||
return originRunId.startsWith(GlueCrawlerRunService.CRAWL_ID_PREFIX)
|
||||
? crawlerRunService.claimTriggeredRuns(originRunId, runs, MAX_TRIGGERED_RUNS_PER_ORIGIN)
|
||||
: jobRunService.claimTriggeredRuns(originRunId, runs, MAX_TRIGGERED_RUNS_PER_ORIGIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the trigger's actions on behalf of {@code originRunId}; with a null origin (StartTrigger on
|
||||
* an ON_DEMAND trigger) each run or crawl started is its own origin.
|
||||
*/
|
||||
private void fire(Trigger trigger, String originRunId, boolean propagateFailures) {
|
||||
LOG.infov("Firing Glue trigger {0}", trigger.getName());
|
||||
for (TriggerAction action : trigger.getActions()) {
|
||||
try {
|
||||
if (action.getJobName() != null) {
|
||||
JobRun overrides = new JobRun();
|
||||
overrides.setArguments(action.getArguments());
|
||||
overrides.setTimeout(action.getTimeout());
|
||||
overrides.setSecurityConfiguration(action.getSecurityConfiguration());
|
||||
overrides.setNotificationProperty(action.getNotificationProperty());
|
||||
overrides.setTriggerName(trigger.getName());
|
||||
jobRunService.startJobRun(action.getJobName(), null, overrides, originRunId);
|
||||
} else {
|
||||
crawlerRunService.startCrawler(action.getCrawlerName(), originRunId);
|
||||
}
|
||||
} catch (AwsException e) {
|
||||
if (propagateFailures) {
|
||||
throw e;
|
||||
}
|
||||
LOG.warnv("Glue trigger {0} could not start {1}: {2}", trigger.getName(),
|
||||
action.getJobName() != null ? action.getJobName() : action.getCrawlerName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String expectedState(TriggerCondition condition) {
|
||||
return condition.getJobName() != null ? condition.getState() : condition.getCrawlState();
|
||||
}
|
||||
|
||||
private static String keyOf(TriggerCondition condition) {
|
||||
return condition.getJobName() != null ? JOB_KEY + condition.getJobName() : CRAWLER_KEY + condition.getCrawlerName();
|
||||
}
|
||||
|
||||
private static boolean isActiveConditional(Trigger trigger) {
|
||||
return TYPE_CONDITIONAL.equals(trigger.getType()) && STATE_ACTIVATED.equals(trigger.getState());
|
||||
}
|
||||
|
||||
private record KeyedCompletion(String key, GlueRunCompletion completion) {}
|
||||
}
|
||||
@@ -15,10 +15,14 @@ public class CrawlerRunRecord {
|
||||
private String crawlerName;
|
||||
private Instant currentStart;
|
||||
private String currentMessagePrefix;
|
||||
private String currentCrawlId;
|
||||
private String currentOriginRunId;
|
||||
private Instant lastStart;
|
||||
private String lastStatus;
|
||||
private String lastMessagePrefix;
|
||||
private List<Double> runtimeSeconds = new ArrayList<>();
|
||||
private long finishedCount;
|
||||
private List<FinishedCrawl> recentCrawls = new ArrayList<>();
|
||||
|
||||
public CrawlerRunRecord() {}
|
||||
|
||||
@@ -34,6 +38,12 @@ public class CrawlerRunRecord {
|
||||
public Instant getLastStart() { return lastStart; }
|
||||
public void setLastStart(Instant lastStart) { this.lastStart = lastStart; }
|
||||
|
||||
public String getCurrentCrawlId() { return currentCrawlId; }
|
||||
public void setCurrentCrawlId(String currentCrawlId) { this.currentCrawlId = currentCrawlId; }
|
||||
|
||||
public String getCurrentOriginRunId() { return currentOriginRunId; }
|
||||
public void setCurrentOriginRunId(String currentOriginRunId) { this.currentOriginRunId = currentOriginRunId; }
|
||||
|
||||
public String getLastStatus() { return lastStatus; }
|
||||
public void setLastStatus(String lastStatus) { this.lastStatus = lastStatus; }
|
||||
|
||||
@@ -42,4 +52,10 @@ public class CrawlerRunRecord {
|
||||
|
||||
public List<Double> getRuntimeSeconds() { return runtimeSeconds; }
|
||||
public void setRuntimeSeconds(List<Double> runtimeSeconds) { this.runtimeSeconds = runtimeSeconds; }
|
||||
|
||||
public long getFinishedCount() { return finishedCount; }
|
||||
public void setFinishedCount(long finishedCount) { this.finishedCount = finishedCount; }
|
||||
|
||||
public List<FinishedCrawl> getRecentCrawls() { return recentCrawls; }
|
||||
public void setRecentCrawls(List<FinishedCrawl> recentCrawls) { this.recentCrawls = recentCrawls; }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class EventBatchingCondition {
|
||||
@JsonProperty("BatchSize")
|
||||
private Integer batchSize;
|
||||
|
||||
@JsonProperty("BatchWindow")
|
||||
private Integer batchWindow;
|
||||
|
||||
public EventBatchingCondition() {}
|
||||
|
||||
public Integer getBatchSize() { return batchSize; }
|
||||
public void setBatchSize(Integer batchSize) { this.batchSize = batchSize; }
|
||||
|
||||
public Integer getBatchWindow() { return batchWindow; }
|
||||
public void setBatchWindow(Integer batchWindow) { this.batchWindow = batchWindow; }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/** One finished crawl in a crawler's recent history; Floci bookkeeping, never sent on the wire. */
|
||||
@RegisterForReflection
|
||||
public class FinishedCrawl {
|
||||
private long sequence;
|
||||
private Instant startedAt;
|
||||
private Instant finishedAt;
|
||||
private String status;
|
||||
private String crawlId;
|
||||
private String originRunId;
|
||||
private int triggeredRuns;
|
||||
|
||||
public FinishedCrawl() {}
|
||||
|
||||
public long getSequence() { return sequence; }
|
||||
public void setSequence(long sequence) { this.sequence = sequence; }
|
||||
|
||||
public Instant getStartedAt() { return startedAt; }
|
||||
public void setStartedAt(Instant startedAt) { this.startedAt = startedAt; }
|
||||
|
||||
public Instant getFinishedAt() { return finishedAt; }
|
||||
public void setFinishedAt(Instant finishedAt) { this.finishedAt = finishedAt; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
|
||||
public String getCrawlId() { return crawlId; }
|
||||
public void setCrawlId(String crawlId) { this.crawlId = crawlId; }
|
||||
|
||||
public String getOriginRunId() { return originRunId; }
|
||||
public void setOriginRunId(String originRunId) { this.originRunId = originRunId; }
|
||||
|
||||
public int getTriggeredRuns() { return triggeredRuns; }
|
||||
public void setTriggeredRuns(int triggeredRuns) { this.triggeredRuns = triggeredRuns; }
|
||||
}
|
||||
@@ -20,6 +20,9 @@ public class JobRun {
|
||||
@JsonProperty("PreviousRunId")
|
||||
private String previousRunId;
|
||||
|
||||
@JsonProperty("TriggerName")
|
||||
private String triggerName;
|
||||
|
||||
@JsonProperty("JobName")
|
||||
private String jobName;
|
||||
|
||||
@@ -94,6 +97,9 @@ public class JobRun {
|
||||
public String getPreviousRunId() { return previousRunId; }
|
||||
public void setPreviousRunId(String previousRunId) { this.previousRunId = previousRunId; }
|
||||
|
||||
public String getTriggerName() { return triggerName; }
|
||||
public void setTriggerName(String triggerName) { this.triggerName = triggerName; }
|
||||
|
||||
public String getJobName() { return jobName; }
|
||||
public void setJobName(String jobName) { this.jobName = jobName; }
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* Floci's own bookkeeping for one job run, never sent on the wire, and deleted with the run: the order
|
||||
* in which Floci saw it finish, the run that set off its trigger chain, and, when the run is itself
|
||||
* such an origin, how many runs triggers have started on its behalf.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class JobRunBookkeeping {
|
||||
private long completionOrder;
|
||||
private String originRunId;
|
||||
private int triggeredRuns;
|
||||
|
||||
public JobRunBookkeeping() {}
|
||||
|
||||
public long getCompletionOrder() { return completionOrder; }
|
||||
public void setCompletionOrder(long completionOrder) { this.completionOrder = completionOrder; }
|
||||
|
||||
public String getOriginRunId() { return originRunId; }
|
||||
public void setOriginRunId(String originRunId) { this.originRunId = originRunId; }
|
||||
|
||||
public int getTriggeredRuns() { return triggeredRuns; }
|
||||
public void setTriggeredRuns(int triggeredRuns) { this.triggeredRuns = triggeredRuns; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Predicate {
|
||||
@JsonProperty("Logical")
|
||||
private String logical;
|
||||
|
||||
@JsonProperty("Conditions")
|
||||
private List<TriggerCondition> conditions;
|
||||
|
||||
public Predicate() {}
|
||||
|
||||
public String getLogical() { return logical; }
|
||||
public void setLogical(String logical) { this.logical = logical; }
|
||||
|
||||
public List<TriggerCondition> getConditions() { return conditions; }
|
||||
public void setConditions(List<TriggerCondition> conditions) { this.conditions = conditions; }
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Trigger {
|
||||
@JsonProperty("Name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("WorkflowName")
|
||||
private String workflowName;
|
||||
|
||||
@JsonProperty("Type")
|
||||
private String type;
|
||||
|
||||
@JsonProperty("State")
|
||||
private String state;
|
||||
|
||||
@JsonProperty("Description")
|
||||
private String description;
|
||||
|
||||
@JsonProperty("Schedule")
|
||||
private String schedule;
|
||||
|
||||
@JsonProperty("Actions")
|
||||
private List<TriggerAction> actions;
|
||||
|
||||
@JsonProperty("Predicate")
|
||||
private Predicate predicate;
|
||||
|
||||
@JsonProperty("EventBatchingCondition")
|
||||
private EventBatchingCondition eventBatchingCondition;
|
||||
|
||||
public Trigger() {}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getWorkflowName() { return workflowName; }
|
||||
public void setWorkflowName(String workflowName) { this.workflowName = workflowName; }
|
||||
|
||||
public String getType() { return type; }
|
||||
public void setType(String type) { this.type = type; }
|
||||
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public String getSchedule() { return schedule; }
|
||||
public void setSchedule(String schedule) { this.schedule = schedule; }
|
||||
|
||||
public List<TriggerAction> getActions() { return actions; }
|
||||
public void setActions(List<TriggerAction> actions) { this.actions = actions; }
|
||||
|
||||
public Predicate getPredicate() { return predicate; }
|
||||
public void setPredicate(Predicate predicate) { this.predicate = predicate; }
|
||||
|
||||
public EventBatchingCondition getEventBatchingCondition() { return eventBatchingCondition; }
|
||||
public void setEventBatchingCondition(EventBatchingCondition eventBatchingCondition) { this.eventBatchingCondition = eventBatchingCondition; }
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/** One action of a trigger: start a job run or a crawl. */
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class TriggerAction {
|
||||
@JsonProperty("JobName")
|
||||
private String jobName;
|
||||
|
||||
@JsonProperty("Arguments")
|
||||
private Map<String, String> arguments;
|
||||
|
||||
@JsonProperty("Timeout")
|
||||
private Integer timeout;
|
||||
|
||||
@JsonProperty("SecurityConfiguration")
|
||||
private String securityConfiguration;
|
||||
|
||||
@JsonProperty("NotificationProperty")
|
||||
private NotificationProperty notificationProperty;
|
||||
|
||||
@JsonProperty("CrawlerName")
|
||||
private String crawlerName;
|
||||
|
||||
public TriggerAction() {}
|
||||
|
||||
public String getJobName() { return jobName; }
|
||||
public void setJobName(String jobName) { this.jobName = jobName; }
|
||||
|
||||
public Map<String, String> getArguments() { return arguments; }
|
||||
public void setArguments(Map<String, String> arguments) { this.arguments = arguments; }
|
||||
|
||||
public Integer getTimeout() { return timeout; }
|
||||
public void setTimeout(Integer timeout) { this.timeout = timeout; }
|
||||
|
||||
public String getSecurityConfiguration() { return securityConfiguration; }
|
||||
public void setSecurityConfiguration(String securityConfiguration) { this.securityConfiguration = securityConfiguration; }
|
||||
|
||||
public NotificationProperty getNotificationProperty() { return notificationProperty; }
|
||||
public void setNotificationProperty(NotificationProperty notificationProperty) { this.notificationProperty = notificationProperty; }
|
||||
|
||||
public String getCrawlerName() { return crawlerName; }
|
||||
public void setCrawlerName(String crawlerName) { this.crawlerName = crawlerName; }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/** One condition of a trigger predicate: a job run state or a crawl state. */
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class TriggerCondition {
|
||||
@JsonProperty("LogicalOperator")
|
||||
private String logicalOperator;
|
||||
|
||||
@JsonProperty("JobName")
|
||||
private String jobName;
|
||||
|
||||
@JsonProperty("State")
|
||||
private String state;
|
||||
|
||||
@JsonProperty("CrawlerName")
|
||||
private String crawlerName;
|
||||
|
||||
@JsonProperty("CrawlState")
|
||||
private String crawlState;
|
||||
|
||||
public TriggerCondition() {}
|
||||
|
||||
public String getLogicalOperator() { return logicalOperator; }
|
||||
public void setLogicalOperator(String logicalOperator) { this.logicalOperator = logicalOperator; }
|
||||
|
||||
public String getJobName() { return jobName; }
|
||||
public void setJobName(String jobName) { this.jobName = jobName; }
|
||||
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
public String getCrawlerName() { return crawlerName; }
|
||||
public void setCrawlerName(String crawlerName) { this.crawlerName = crawlerName; }
|
||||
|
||||
public String getCrawlState() { return crawlState; }
|
||||
public void setCrawlState(String crawlState) { this.crawlState = crawlState; }
|
||||
}
|
||||
Reference in new issue
Block a user