Answer the question
In order to leave comments, you need to log in
Controlling the number of sent events with constant and real time adjustment.?
The bottom line is that you need to write an algorithm that would control the number of lines sent when reading the file, depending on the time written to these lines, real time (ms) and the specified maximum limit, which would be the control lever of the entire mechanism. And now to the details... ))
Let's imagine a common situation in the main:
the format of a line with Unix time, let it be like this)) -> line = "125342740, 43, 245": every 300 lines = plus 10ms.
while(line = reader.readLine()) != null) {
sendEvent(line); // этот sendEvent надо обвернуть в оболочку, которая бы служила контроллером для ожидания или продолжения пересылки считывания фаила. подумал об:
long time = split... //достаем время
while(checkTime(time)) {
sendEvent(line);
}
}
Инициализация глобального таймера... пусть будет long timer;
class timeControl {
private eventsToSend = x; //кол-во максимальных строк для отправки за промежуток "у" времени.
private eventsToSendTimeLimit = y; //как раз таки это время для eventsToSend
private timeStart = время первой строки для фиксации константного начала.
public boolean checkTime(long time) {
//иииии вот оно место где я взываю о помощи)))
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question