Skip to content

Commit 0eb6110

Browse files
authored
Merge pull request #109 from saasmax/fix/wireup-set-crawl-limit
Implement `setCrawlLimit` inside the service
2 parents 542d748 + 3b7547c commit 0eb6110

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

service/src/main/java/crawlercommons/urlfrontier/service/AbstractFrontierService.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import crawlercommons.urlfrontier.Urlfrontier.AckMessage.Status;
1212
import crawlercommons.urlfrontier.Urlfrontier.BlockQueueParams;
1313
import crawlercommons.urlfrontier.Urlfrontier.Boolean;
14+
import crawlercommons.urlfrontier.Urlfrontier.CrawlLimitParams;
1415
import crawlercommons.urlfrontier.Urlfrontier.Empty;
1516
import crawlercommons.urlfrontier.Urlfrontier.GetParams;
1617
import crawlercommons.urlfrontier.Urlfrontier.KnownURLItem;
@@ -870,6 +871,26 @@ public void close() throws IOException {
870871
}
871872
}
872873

874+
public void setCrawlLimit(CrawlLimitParams params, StreamObserver<Empty> responseObserver) {
875+
QueueWithinCrawl searchKey = new QueueWithinCrawl(params.getKey(), params.getCrawlID());
876+
synchronized (getQueues()) {
877+
QueueInterface qi = getQueues().get(searchKey);
878+
if (qi != null) {
879+
qi.setCrawlLimit(params.getLimit());
880+
} else {
881+
LOG.error(
882+
"Queue with key: {} and CrawlId: {} was not found.",
883+
searchKey.getQueue(),
884+
searchKey.getCrawlid());
885+
responseObserver.onError(
886+
new RuntimeException("CrawlId and Queue combination is not found."));
887+
return;
888+
}
889+
}
890+
891+
responseObserver.onCompleted();
892+
}
893+
873894
public abstract void getURLStatus(
874895
crawlercommons.urlfrontier.Urlfrontier.URLStatusRequest request,
875896
io.grpc.stub.StreamObserver<URLItem> responseObserver);

0 commit comments

Comments
 (0)