Merge branch 'modzeleg' into developer
This commit is contained in:
@@ -20,15 +20,25 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
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
|
@Repository
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class EventRepositoryImpl implements EventRepository {
|
public class EventRepositoryImpl implements EventRepository {
|
||||||
|
//TODO: create one constant for both Impl and well as RedisAppender
|
||||||
private final String LOG_PREFIX = "logstash_";
|
private final String LOG_PREFIX = "logstash_";
|
||||||
private final JedisPool jedisPool;
|
private final JedisPool jedisPool;
|
||||||
private final ObjectMapper objectMapper;
|
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
|
@Override
|
||||||
public List<Event> findEvents(LocalDateTime localDateTimeFrom, LocalDateTime localDateTimeTo,
|
public List<Event> findEvents(LocalDateTime localDateTimeFrom, LocalDateTime localDateTimeTo,
|
||||||
Map<BusinessKey, String> businessKeys) {
|
Map<BusinessKey, String> businessKeys) {
|
||||||
@@ -45,6 +55,12 @@ public class EventRepositoryImpl implements EventRepository {
|
|||||||
.collect(Collectors.toList());
|
.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) {
|
private List<String> findEventsBetweenDates(LocalDate localDateFrom, LocalDate localDateTo) {
|
||||||
try (Jedis jedis = jedisPool.getResource()) {
|
try (Jedis jedis = jedisPool.getResource()) {
|
||||||
return localDateFrom.datesUntil(localDateTo.plusDays(1)).map(day -> LOG_PREFIX + day.toString())
|
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) {
|
private List<String> businessKeysFilter(List<String> events, Map<BusinessKey, String> businessKeys) {
|
||||||
for (Map.Entry<BusinessKey, String> entry : businessKeys.entrySet()) {
|
for (Map.Entry<BusinessKey, String> entry : businessKeys.entrySet()) {
|
||||||
String stringPattern = entry.getKey().getReasonPhrase()+ "\"" + ":" + "\"" + entry.getValue() + "\"";
|
String stringPattern = entry.getKey().getReasonPhrase()+ "\"" + ":" + "\"" + entry.getValue() + "\"";
|
||||||
@@ -60,6 +82,11 @@ public class EventRepositoryImpl implements EventRepository {
|
|||||||
return events;
|
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) {
|
private List<Event> parseEvents(List<String> eventStrings) {
|
||||||
List<Event> events = new ArrayList<>();
|
List<Event> events = new ArrayList<>();
|
||||||
for (String eventString : eventStrings) {
|
for (String eventString : eventStrings) {
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import redis.clients.jedis.Jedis;
|
|||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.Protocol;
|
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> {
|
public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
|
||||||
|
|
||||||
JedisPool pool;
|
JedisPool pool;
|
||||||
@@ -37,6 +40,10 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
|
|||||||
jsonlayout = new JSONEventLayout();
|
jsonlayout = new JSONEventLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends JedisPool by another log
|
||||||
|
* @param event object containing log info
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void append(ILoggingEvent event) {
|
protected void append(ILoggingEvent event) {
|
||||||
Jedis client = pool.getResource();
|
Jedis client = pool.getResource();
|
||||||
@@ -208,6 +215,9 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
|
|||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts new instance of JedisPool
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
super.start();
|
super.start();
|
||||||
@@ -216,6 +226,9 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
|
|||||||
pool = new JedisPool(config, host, port, timeout, password, database);
|
pool = new JedisPool(config, host, port, timeout, password, database);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops and destroys JedisPool object
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
super.stop();
|
super.stop();
|
||||||
|
|||||||
@@ -302,5 +302,10 @@ input:focus {
|
|||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#version {
|
||||||
|
color: rgba(85,85,85,0.555);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="toolName">Mocked Service</div>
|
<div id="toolName">Mocked Service <span id="version">v0.0.1</span></div>
|
||||||
<div id="itemData">
|
<div id="itemData">
|
||||||
<div id="basicItemData" class="articleHead">Your message</div>
|
<div id="basicItemData" class="articleHead">Your message</div>
|
||||||
<div id="advancedItemData" class="articleHead" style="display: none;">Message id: <span id="mockedMessageId"></span></div>
|
<div id="advancedItemData" class="articleHead" style="display: none;">Message id: <span id="mockedMessageId"></span></div>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -302,5 +302,10 @@ input:focus {
|
|||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#version {
|
||||||
|
color: rgba(85,85,85,0.555);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="toolName">Mocked Service</div>
|
<div id="toolName">Mocked Service <span id="version">v0.0.1</span></div>
|
||||||
<div id="itemData">
|
<div id="itemData">
|
||||||
<div id="basicItemData" class="articleHead">Your message</div>
|
<div id="basicItemData" class="articleHead">Your message</div>
|
||||||
<div id="advancedItemData" class="articleHead" style="display: none;">Message id: <span id="mockedMessageId"></span></div>
|
<div id="advancedItemData" class="articleHead" style="display: none;">Message id: <span id="mockedMessageId"></span></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user