Skip to content

Commit 7a75467

Browse files
committed
configure rate limit
1 parent f6b6724 commit 7a75467

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

dist/mserver.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<system-proxy-port></system-proxy-port>
3232
<system-debug>1</system-debug>
3333
<sr-rate-limit>1.0</sr-rate-limit>
34+
<arte-rate-limit>6.0</arte-rate-limit>
3435
</system>
3536

3637

src/main/java/mServer/crawler/sender/arte/tasks/ArteRateLimitedJsonRestTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import mServer.crawler.sender.MediathekReader;
66
import mServer.crawler.sender.base.AbstractJsonRestTask;
77
import mServer.crawler.sender.base.CrawlerUrlDTO;
8+
import mServer.tool.MserverDaten;
89

910
import java.util.Optional;
1011
import java.util.concurrent.ConcurrentLinkedQueue;
1112

1213
public abstract class ArteRateLimitedJsonRestTask<T, R, D extends CrawlerUrlDTO> extends AbstractJsonRestTask<T, R, D> {
1314
private static final long serialVersionUID = 1L;
14-
private static final RateLimiter rateLimiter = RateLimiter.create(6.0);
15+
private static final RateLimiter rateLimiter = RateLimiter.create(MserverDaten.getArteRateLimit());
1516

1617
protected ArteRateLimitedJsonRestTask(MediathekReader aCrawler, ConcurrentLinkedQueue<D> urlToCrawlDTOs, Optional<String> authKey) {
1718
super(aCrawler, urlToCrawlDTOs, authKey);

src/main/java/mServer/tool/MserverDaten.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ public static double getSrRateLimit() {
7777
}
7878
}
7979

80+
public static double getArteRateLimit() {
81+
String rateLimitValue = system[MserverKonstanten.SYSTEM_ARTE_RATELIMIT_NR];
82+
if (rateLimitValue == null || rateLimitValue.trim().equals("")) {
83+
return 6.0;
84+
}
85+
86+
try {
87+
double rateLimit = Double.parseDouble(system[MserverKonstanten.SYSTEM_ARTE_RATELIMIT_NR].trim());
88+
MserverLog.systemMeldung("ARTE rate limit: " + Double.toString(rateLimit));
89+
return rateLimit;
90+
} catch (NumberFormatException ignored) {
91+
MserverLog.fehlerMeldung(963487218, MserverDaten.class.getName(), new String[]{"ARTE rate limit falsch: ", system[MserverKonstanten.SYSTEM_ARTE_RATELIMIT_NR]});
92+
return 6.0;
93+
}
94+
}
95+
8096
public static void setBasisVerzeichnis(String b) {
8197
if (b.isEmpty()) {
8298
basisverzeichnis = getBasisVerzeichnis(b, true);

src/main/java/mServer/tool/MserverKonstanten.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,20 @@ public class MserverKonstanten {
8787
public static final int SYSTEM_RESTART_AFTER_RUN_NR = 14;
8888
public static final String SYSTEM_SR_RATELIMIT_RUN = "sr-rate-limit";
8989
public static final int SYSTEM_SR_RATELIMIT_NR = 15;
90-
90+
public static final String SYSTEM_ARTE_RATELIMIT_RUN = "arte-rate-limit";
91+
public static final int SYSTEM_ARTE_RATELIMIT_NR = 16;
92+
9193
public static final String SYSTEM_BANNEDFILMLIST = "system-bannedFilmList";
92-
public static final int SYSTEM_BANNEDFILMLIST_NR = 16;
94+
public static final int SYSTEM_BANNEDFILMLIST_NR = 17;
9395

9496
public static final String SYSTEM_CRAWLER_LIST = "system-crawler-list";
95-
public static final int SYSTEM_CRAWLER_LIST_NR = 17;
97+
public static final int SYSTEM_CRAWLER_LIST_NR = 18;
9698

9799
public static final String[] SYSTEM_COLUMN_NAMES = {
98100
SYSTEM_USER_AGENT, SYSTEM_IMPORT_URL_1, SYSTEM_IMPORT_URL_2, SYSTEM_IMPORT_OLD,
99101
SYSTEM_IMPORT_AKT, SYSTEM_EXPORT_AKT, SYSTEM_IMPORT_LIVE,
100102
SYSTEM_EXPORT_FILMLISTE_AKT, SYSTEM_EXPORT_FILMLISTE_ORG, SYSTEM_EXPORT_FILMLISTE_DIFF, SYSTEM_FILMLISTE_ORG,
101-
SYSTEM_PROXY_URL, SYSTEM_PROXY_PORT, SYSTEM_DEBUG, SYSTEM_RESTART_AFTER_RUN, SYSTEM_SR_RATELIMIT_RUN, SYSTEM_BANNEDFILMLIST, SYSTEM_CRAWLER_LIST
103+
SYSTEM_PROXY_URL, SYSTEM_PROXY_PORT, SYSTEM_DEBUG, SYSTEM_RESTART_AFTER_RUN, SYSTEM_SR_RATELIMIT_RUN, SYSTEM_ARTE_RATELIMIT_RUN, SYSTEM_BANNEDFILMLIST, SYSTEM_CRAWLER_LIST
102104
};
103105

104106
public static final int SYSTEM_MAX_ELEM = SYSTEM_COLUMN_NAMES.length;

0 commit comments

Comments
 (0)