[
https://issues.apache.org/jira/browse/KARAF-5885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603397#comment-16603397
]
ASF GitHub Bot commented on KARAF-5885:
---------------------------------------
fpapon closed pull request #41: [KARAF-5885] Upgrade to commons-io 2.6, start
tailing from the end of the file and use an executor service
URL: https://github.com/apache/karaf-decanter/pull/41
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/assembly/src/main/feature/feature.xml
b/assembly/src/main/feature/feature.xml
index 3cada8b..0493b72 100644
--- a/assembly/src/main/feature/feature.xml
+++ b/assembly/src/main/feature/feature.xml
@@ -60,7 +60,7 @@
<feature name="decanter-collector-file" version="${project.version}"
description="Karaf Decanter Log File Collector">
<feature>decanter-common</feature>
- <bundle dependency="true">mvn:commons-io/commons-io/2.4</bundle>
+ <bundle dependency="true">mvn:commons-io/commons-io/2.6</bundle>
<bundle>mvn:org.apache.karaf.decanter.collector/org.apache.karaf.decanter.collector.file/${project.version}</bundle>
</feature>
diff --git a/collector/file/pom.xml b/collector/file/pom.xml
index 8bb1498..b09f800 100644
--- a/collector/file/pom.xml
+++ b/collector/file/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.4</version>
+ <version>2.6</version>
</dependency>
</dependencies>
diff --git
a/collector/file/src/main/java/org/apache/karaf/decanter/collector/file/DecanterTailerListener.java
b/collector/file/src/main/java/org/apache/karaf/decanter/collector/file/DecanterTailerListener.java
index bf5989f..a6db6dd 100644
---
a/collector/file/src/main/java/org/apache/karaf/decanter/collector/file/DecanterTailerListener.java
+++
b/collector/file/src/main/java/org/apache/karaf/decanter/collector/file/DecanterTailerListener.java
@@ -22,6 +22,10 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
import org.apache.commons.io.input.Tailer;
import org.apache.commons.io.input.TailerListenerAdapter;
@@ -56,7 +60,7 @@
* additional properties provided by the user
*/
private Dictionary<String, Object> properties;
- private Tailer tailer;
+ private ExecutorService executorService;
@SuppressWarnings("unchecked")
@Activate
@@ -72,21 +76,21 @@ public void activate(ComponentContext context) throws
ConfigurationException {
String path = (String) properties.get("path");
LOGGER.debug("Starting tail on {}", path);
- tailer = new Tailer(new File(path), this);
- Thread thread = new Thread(tailer, "Log Tailer for " + path);
- thread.start();
+ Tailer tailer = Tailer.create(new File(path), this, 1000, true, true);
+ executorService = Executors.newSingleThreadExecutor();
+ executorService.submit(tailer);
this.type = type;
this.path = path;
}
@Deactivate
public void deactivate() {
- tailer.stop();
+ executorService.shutdownNow();
}
@Override
public void handle(String line) {
- LOGGER.trace("Handle new line in {}", this.path);
+ LOGGER.debug("Handle new line in {}", path);
Map<String, Object> data = new HashMap<>();
data.put("type", type);
data.put("path", path);
@@ -122,20 +126,26 @@ private void addPropertiesTo(Map<String, Object> data) {
@Override
public void handle(Exception e) {
- super.handle(e);
LOGGER.warn("Handle exception on file {}", path, e);
+ super.handle(e);
}
@Override
public void fileNotFound() {
- super.fileNotFound();
LOGGER.warn("File {} is not found", path);
+ super.fileNotFound();
}
@Override
public void fileRotated() {
- super.fileRotated();
LOGGER.debug("File {} rotated", path);
+ super.fileRotated();
+ }
+
+ @Override
+ public void endOfFileReached() {
+ LOGGER.debug("Reached end of file {}", path);
+ super.endOfFileReached();
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Upgrade to commons-io 2.6 and improve Tailer configuration
> ----------------------------------------------------------
>
> Key: KARAF-5885
> URL: https://issues.apache.org/jira/browse/KARAF-5885
> Project: Karaf
> Issue Type: Dependency upgrade
> Components: decanter
> Reporter: Jean-Baptiste Onofré
> Assignee: Jean-Baptiste Onofré
> Priority: Major
> Fix For: decanter-2.1.0
>
>
> {{commons-io}} is used in the file collector. The new 2.6 version brings
> improvements around the threads handling.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)