Added javadoc
This commit is contained in:
		| @@ -20,15 +20,25 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| //TODO: Add javadoc | ||||
| /** | ||||
|  * Builds Event list based on logs created via {@link com.release11.klaus.utilis.TrackingClient} and {@link com.release11.klaus.utilis.RedisAppender} | ||||
|  * @author Rafał Żukowicz | ||||
|  */ | ||||
| @Repository | ||||
| @AllArgsConstructor | ||||
| public class EventRepositoryImpl implements EventRepository { | ||||
|  | ||||
|     //TODO: create one constant for both Impl and well as RedisAppender | ||||
|     private final String LOG_PREFIX = "logstash_"; | ||||
|     private final JedisPool jedisPool; | ||||
|     private final ObjectMapper objectMapper; | ||||
|  | ||||
|     /** | ||||
|      * Creates list of {@link Event} based on {@link com.release11.klaus.model.EventRequestDto} data via searching logs | ||||
|      * @param localDateTimeFrom date from which logs are retrieved | ||||
|      * @param localDateTimeTo date to which logs are retrieved | ||||
|      * @param businessKeys set keys for redis values | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public List<Event> findEvents(LocalDateTime localDateTimeFrom, LocalDateTime localDateTimeTo, | ||||
|                                    Map<BusinessKey, String> businessKeys) { | ||||
| @@ -45,6 +55,12 @@ public class EventRepositoryImpl implements EventRepository { | ||||
|                 .collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns logs between given dates | ||||
|      * @param localDateFrom date from which logs are retrieved | ||||
|      * @param localDateTo date to which logs are retrieved | ||||
|      * @return | ||||
|      */ | ||||
|     private List<String> findEventsBetweenDates(LocalDate localDateFrom, LocalDate localDateTo) { | ||||
|         try (Jedis jedis = jedisPool.getResource()) { | ||||
|             return localDateFrom.datesUntil(localDateTo.plusDays(1)).map(day -> LOG_PREFIX + day.toString()) | ||||
| @@ -52,6 +68,12 @@ public class EventRepositoryImpl implements EventRepository { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Filters keys so only the ones queried are retirned | ||||
|      * @param events list of logs | ||||
|      * @param businessKeys set keys for redis values | ||||
|      * @return filtered list of logs | ||||
|      */ | ||||
|     private List<String> businessKeysFilter(List<String> events, Map<BusinessKey, String> businessKeys) { | ||||
|         for (Map.Entry<BusinessKey, String> entry : businessKeys.entrySet()) { | ||||
|             String stringPattern =  entry.getKey().getReasonPhrase()+ "\"" + ":" + "\"" + entry.getValue() + "\""; | ||||
| @@ -60,6 +82,11 @@ public class EventRepositoryImpl implements EventRepository { | ||||
|         return events; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Parses list of logs into list of {@link Event} | ||||
|      * @param eventStrings list of logs | ||||
|      * @return list of {@link Event} | ||||
|      */ | ||||
|     private List<Event> parseEvents(List<String> eventStrings) { | ||||
|         List<Event> events = new ArrayList<>(); | ||||
|         for (String eventString : eventStrings) { | ||||
|   | ||||
| @@ -15,7 +15,10 @@ import redis.clients.jedis.Jedis; | ||||
| import redis.clients.jedis.JedisPool; | ||||
| import redis.clients.jedis.Protocol; | ||||
|  | ||||
| //TODO: Add javadoc | ||||
| /** | ||||
|  * Class is used to insert logs directly to Redis. {@link com.release11.klaus.repository.EventRepositoryImpl} is using those logs. | ||||
|  * @author Rafał Żukowicz | ||||
|  */ | ||||
| public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { | ||||
|  | ||||
|     JedisPool pool; | ||||
| @@ -37,6 +40,10 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { | ||||
|         jsonlayout = new JSONEventLayout(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Appends JedisPool by another log | ||||
|      * @param event object containing log info | ||||
|      */ | ||||
|     @Override | ||||
|     protected void append(ILoggingEvent event) { | ||||
|         Jedis client = pool.getResource(); | ||||
| @@ -208,6 +215,9 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { | ||||
|         this.layout = layout; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Starts new instance of JedisPool | ||||
|      */ | ||||
|     @Override | ||||
|     public void start() { | ||||
|         super.start(); | ||||
| @@ -216,6 +226,9 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { | ||||
|         pool = new JedisPool(config, host, port, timeout, password, database); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Stops and destroys JedisPool object | ||||
|      */ | ||||
|     @Override | ||||
|     public void stop() { | ||||
|         super.stop(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user