@Test public void getTimeoutFromServer() throws Exception { String token = "gettingTimeoutFromServer"; String type = random(8); String loggerName = "getTimeoutFromServer"; int drainTimeout = 1; int serverTimeout = 2000; String message1 = "Log that will be sent - " + random(5); String message2 = "Log that would timeout and then being re-sent - " + random(5); int socketTimeout = serverTimeout / 2; LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, socketTimeout, serverTimeout, tasks, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); sleepSeconds(2 * drainTimeout); mockListener.assertNumberOfReceivedMsgs(1); mockListener.assertLogReceivedIs(message1, token, type, loggerName, LOGLEVEL); mockListener.setTimeoutMillis(serverTimeout); mockListener.setServerTimeoutMode(true); testSender.send(createJsonMessage(loggerName, message2)); sleepSeconds((socketTimeout / 1000) * MAX_RETRIES_ATTEMPTS + retryTotalDelay()); mockListener.assertNumberOfReceivedMsgs(1); mockListener.setServerTimeoutMode(false); sleepSeconds(2 * drainTimeout); mockListener.assertNumberOfReceivedMsgs(2); mockListener.assertLogReceivedIs(message2, token, type, loggerName, LOGLEVEL); }
public void send(JsonObject jsonMessage) { logsQueue.enqueue(jsonMessage.toString().getBytes(StandardCharsets.UTF_8)); }
LogzioSender { public void send(JsonObject jsonMessage) { logsQueue.enqueue(jsonMessage.toString().getBytes(StandardCharsets.UTF_8)); } }
LogzioSender { public void send(JsonObject jsonMessage) { logsQueue.enqueue(jsonMessage.toString().getBytes(StandardCharsets.UTF_8)); } private  LogzioSender(HttpsRequestConfiguration httpsRequestConfiguration, int drainTimeout, boolean debug,
                         SenderStatusReporter reporter, ScheduledExecutorService tasksExecutor,
                         LogsQueue logsQueue); }
LogzioSender { public void send(JsonObject jsonMessage) { logsQueue.enqueue(jsonMessage.toString().getBytes(StandardCharsets.UTF_8)); } private  LogzioSender(HttpsRequestConfiguration httpsRequestConfiguration, int drainTimeout, boolean debug,
                         SenderStatusReporter reporter, ScheduledExecutorService tasksExecutor,
                         LogsQueue logsQueue); void start(); void stop(); void drainQueueAndSend(); void send(JsonObject jsonMessage); void send(byte[] jsonStringAsUTF8ByteArray); static Builder builder(); }
LogzioSender { public void send(JsonObject jsonMessage) { logsQueue.enqueue(jsonMessage.toString().getBytes(StandardCharsets.UTF_8)); } private  LogzioSender(HttpsRequestConfiguration httpsRequestConfiguration, int drainTimeout, boolean debug,
                         SenderStatusReporter reporter, ScheduledExecutorService tasksExecutor,
                         LogsQueue logsQueue); void start(); void stop(); void drainQueueAndSend(); void send(JsonObject jsonMessage); void send(byte[] jsonStringAsUTF8ByteArray); static Builder builder();  }