apache / apache/accumulo

Investigate replacing long+TimeUnit with Duration in more places

Open
#4,361 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
1.2k
Forks
487
Avg merge
4d 5h
Merged PRs (30d)
13

Description

**Is your feature request related to a problem? Please describe.**
No problem. It seems like a nice improvement to replace methods that accept a long and a `TimeUnit` with a single `Duration` parameter.

Looking through the code I see the following methods that have this pattern of long+TimeUnit:
EDIT: crossed out ones that we shouldnt change
* ~~ScannerBase.setTimeout(long timeOut, TimeUnit timeUnit)~~
* ~~ScannerBase.setBatchTimeout(long timeOut, TimeUnit timeUnit)~~
* ~~BatchWriterConfig.setMaxLatency(long maxLatency, TimeUnit timeUnit)~~
* ~~BatchWriterConfig.setTimeout(long timeout, TimeUnit timeUnit)~~
* ~~ConditionalWriterConfig.setTimeout(long timeout, TimeUnit timeUnit)~~
* ~~DelegationTokenConfig.setTokenLifetime(long lifetime, TimeUnit unit)~~
* TabletLogger.suspended(KeyExtent extent, HostAndPort server, long time, TimeUnit timeUnit, int numWalogs)
* ThreadPools.createFixedThreadPool(int numThreads, long timeOut, TimeUnit units, final String name, boolean emitThreadPoolMetrics)
* ThreadPools.createThreadPool
* ~~MiniAccumuloCluster.stopProcessWithTimeout(final Process proc, long timeout, TimeUnit unit)~~
* TestTicker.advance(final long value, final TimeUnit units)

There is a good chance that a lot of these should stay as they are or are not worth looking into but it seems like this could be a good improvement for some. I think each would need to be investigated to see how these values are used and if there are reasons why we might want to avoid `Duration`.

Contributor guide

Open the contributing guide

Research direction

Review the remaining candidates in TabletLogger.suspended, ThreadPools.createFixedThreadPool/createThreadPool, and TestTicker.advance, starting with their current callers and how the timeout values are used. Done means identifying which methods should use Duration, documenting reasons to keep the others unchanged, and updating affected callers and tests where a conversion is justified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.