private void serializeFileAmount(Gson gson, String recordingPath) { try { JsonWriter writer = new JsonWriter(new FileWriter(recordingPath + FILE_AMOUNT)); gson.toJson(recordAndReplayUtils.getFileAmount(), Integer.class, writer); writer.close(); logger.info("File Amount Serialization completed!"); } catch (Exception e) { logger.error("Error while serializing file amount:", e); } }
/** * Serialize RecordedEvents. * @param recordingPath path where the data should be saved. */ public void serializeRecordedEvents(String recordingPath) { String filepath = recordingPath + EVENT_DIR + recordAndReplayUtils.getFileCount() + JSON; recordAndReplayUtils.setFileAmount(recordAndReplayUtils.getFileAmount() + 1); recordAndReplayUtils.setFileCount(recordAndReplayUtils.getFileCount() + 1); recordedEventSerializer.serializeRecordedEvents(recordedEventStore.popEvents(), filepath); logger.info("RecordedEvents Serialization completed!"); }
/** * Processes recorded events for a certain amount of time and only if the timestamp is right. */ private void processRecordedEvents() { if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING && !this.areRecordedEventsLoaded) { initialiseReplayData(); } //If replay is ready, process some recorded events if the time is right. if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING) { processRecordedEventsBatch(1); if (this.recordedEvents.isEmpty()) { if (recordAndReplayUtils.getFileCount() <= recordAndReplayUtils.getFileAmount()) { //Get next recorded events file loadNextRecordedEventFile(); } else { finishReplay(); } } } }