Skip to content

Commit

Permalink
+ removed writer level buffer
Browse files Browse the repository at this point in the history
+ added front and back buffer capacities configurations on entire service level
  • Loading branch information
q3769 committed May 1, 2023
1 parent 9dce75e commit 63633ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import elf4j.engine.service.BufferingWriterThread;
import elf4j.engine.service.LogServiceManager;
import elf4j.engine.service.WriterThread;
import elf4j.engine.service.util.PropertiesUtils;
import elf4j.engine.service.writer.BufferedStandardOutput;
import elf4j.engine.service.writer.LogWriter;
import elf4j.util.InternalLogger;
Expand All @@ -45,7 +46,6 @@
*/
@ToString
public class RefreshableLogServiceConfiguration implements LogServiceConfiguration, Refreshable {
private static final String UNDEFINED_INT = "0";
private final Map<NativeLogger, Boolean> loggerConfigurationCache = new ConcurrentHashMap<>();
private final PropertiesLoader propertiesLoader;
private boolean noop;
Expand Down Expand Up @@ -117,13 +117,8 @@ private void parseConfigurations(@Nullable Properties properties) {
}
this.callerLevelRepository = CallerLevelRepository.from(properties);
this.writerRepository = WriterRepository.from(properties);
this.writerThread =
new BufferingWriterThread(Integer.parseInt(properties.getProperty("buffer.front", UNDEFINED_INT)
.replace("_", "")
.replace(",", "")));
this.writerThread = new BufferingWriterThread(PropertiesUtils.getAsInt("buffer.front", properties));
this.standardOutputBufferCapacity =
new BufferedStandardOutput(Integer.parseInt(properties.getProperty("buffer.back", UNDEFINED_INT)
.replace("_", "")
.replace(",", "")));
new BufferedStandardOutput(PropertiesUtils.getAsInt("buffer.back", properties));
}
}
13 changes: 13 additions & 0 deletions src/main/java/elf4j/engine/service/util/PropertiesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*/
public class PropertiesUtils {

private static final String UNDEFINED_INT = "0";

private PropertiesUtils() {
}

Expand Down Expand Up @@ -72,4 +74,15 @@ public static List<Map<String, String>> getPropertiesGroupOfType(String type, @N
.map(name -> getChildProperties(name, properties))
.collect(Collectors.toList());
}

/**
* @param name
* full key in properties
* @param properties
* to look up in
* @return int value in specified properties, default to 0 if missing
*/
public static int getAsInt(String name, @NonNull Properties properties) {
return Integer.parseInt(properties.getProperty(name, UNDEFINED_INT).replace("_", "").replace(",", ""));
}
}

0 comments on commit 63633ae

Please sign in to comment.