[
https://issues.apache.org/jira/browse/FLUME-3229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16461933#comment-16461933
]
ASF GitHub Bot commented on FLUME-3229:
---------------------------------------
GitHub user lizhenhuan opened a pull request:
https://github.com/apache/flume/pull/207
fix bug : Flume TAILDIR source lost last line when file upload from windows
https://issues-test.apache.org/jira/browse/FLUME-3229
Fix this issue .
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/lizhenhuan/flume trunk
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flume/pull/207.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #207
----
commit 07c98978ec89c8119bbf833cd384b4ba59be8f10
Author: lizhenhuan <zhenhuan.li@...>
Date: 2018-05-03T04:45:53Z
fix bug : Flume TAILDIR source lost last line when file upload from windows
----
> CounterGroup#counters use ConcurrentHashMap instead of HashMap
> --------------------------------------------------------------
>
> Key: FLUME-3229
> URL: https://issues.apache.org/jira/browse/FLUME-3229
> Project: Flume
> Issue Type: Improvement
> Reporter: yangkun
> Priority: Minor
>
> Currently, The CounterGroup#counters use HashMap, so this class all methods
> use the synchronized, if not use HashMap, change to use ConcurrentHashMap ,
> some methods, for example:
> get(String)、incrementAndGet(String)、addAndGet(String, Long)、set(String,
> Long)、getCounter(String), etc. can remove the synchronized, because they are
> thread safe.This can take a little performance improvement.
> // use ConcurrentHashMap instead of HashMap
> private ConcurrentHashMap<String, AtomicLong> counters;
> public CounterGroup() {
> counters = new ConcurrentHashMap<>();
> }
> // no need use synchronized
> public Long get(String name) {
> return getCounter(name).get();
> }
> // no need use synchronized
> public Long incrementAndGet(String name) {
> return getCounter(name).incrementAndGet();
> }
> // no need use synchronized
> public AtomicLong getCounter(String name) {
> if (!counters.containsKey(name)) {
> // use putIfAbsent method
> counters.putIfAbsent(name, new AtomicLong());
> }
> return counters.get(name);
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]