Skip to content

Commit

Permalink
issue #1078: adds log for DeletionCompareNotifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-vi authored and danielecalda committed Oct 1, 2024
1 parent 790b813 commit 1310d63
Showing 1 changed file with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.openk9.datasource.pipeline.service.SchedulingService;
import io.openk9.datasource.pipeline.service.dto.SchedulerDTO;
import io.openk9.datasource.pipeline.stages.closing.CloseStage;
import org.jboss.logging.Logger;

import java.util.List;

Expand Down Expand Up @@ -99,24 +100,7 @@ private Behavior<AggregateItem.Command> onStart(
return Behaviors.same();
}

private Behavior<AggregateItem.Command> onSendEvents(SendEvents sendEvents) {
var scheduler = sendEvents.scheduler();
var list = sendEvents.list();
var tenantId = shardingKey.tenantId();
var replyTo = sendEvents.replyTo();

Long datasourceId = scheduler.getDatasourceId();
String newDataIndexName = scheduler.getNewDataIndexName();

for (String deletedContentId : list) {
DatasourceEventBus.sendDeleteEvent(
tenantId, datasourceId, newDataIndexName, deletedContentId);
}

getContext().getSelf().tell(new Stop(replyTo));

return Behaviors.same();
}
private static Logger log = Logger.getLogger(DeletionCompareNotifier.class);

private Behavior<AggregateItem.Command> onStop(Stop stop) {
stop.replyTo().tell(Success.INSTANCE);
Expand All @@ -137,4 +121,30 @@ private record SendEvents(
ActorRef<AggregateItem.Reply> replyTo
) implements AggregateItem.Command {}

private Behavior<AggregateItem.Command> onSendEvents(SendEvents sendEvents) {
var scheduler = sendEvents.scheduler();
var list = sendEvents.list();
var tenantId = shardingKey.tenantId();
var replyTo = sendEvents.replyTo();

Long datasourceId = scheduler.getDatasourceId();
String newDataIndexName = scheduler.getNewDataIndexName();

if (list != null) {
for (String deletedContentId : list) {
DatasourceEventBus.sendDeleteEvent(
tenantId, datasourceId, newDataIndexName, deletedContentId);
}
}
else {
log.warnf(
"%s cannot send delete events because deleted contents are unknown.",
shardingKey
);
}

getContext().getSelf().tell(new Stop(replyTo));

return Behaviors.same();
}
}

0 comments on commit 1310d63

Please sign in to comment.