[
https://issues.apache.org/jira/browse/HDDS-692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666520#comment-16666520
]
Nanda kumar commented on HDDS-692:
----------------------------------
[~horzsolt2006], sorry for the delay in response.
{quote}I'm not sure if I understand you wrt giving the actual task to the
Progressbar thread.
{quote}
RandomKeyGenerator Line:253 - {{progressBar.start(task)}}, here {{task}} is the
actual runnable which starts/submits the job to ExecutorService. We are passing
the actual job to ProgressBar.
In case of {{RandomKeyGenerator}}, we use ExecutorService to run the tasks in
parallel. If someone uses ProgressBar who doesn't use ExecutorService,
ProgressBar will be the one who will be running the job.
{quote}In its public void start(Runnable task) the task parameter used as a
functional interface, it doesn't actually start a thread..
{quote}
Actually, {{public void start(Runnable task)}} method is the one which runs the
job. It doesn't create a new Thread to run, but runs the job in the same Thread.
{code:java}
public void start(Runnable task) {
startTime = System.nanoTime();
try {
progressBar.start();
task.run(); -----> This will run the job.
} catch (Exception e) {
exception = true;
}
}
{code}
We should not pass {{Runnable}} as an argument to {{ProgressBar}} class.
ProgressBar should take a {{Supplier<Long>}} which will return a Long value.
This is how ProgressBar APIs should look.
{code:java}
public class ProgressBar {
/**
* Constructs the ProgressBar instance.
*
* @param stream The stream to print
* @param maxValue The max value
* @param currentValue current value supplier
*/
public ProgressBar(PrintStream stream, Long maxValue, Supplier<Long>
currentValue) {
...
// Create new progress bar task (runnable)
...
}
/**
* Starts the ProgressBar in a new Thread.
* This is a non blocking call.
*/
public void start() {
...
// Start the progress bar task
...
}
/**
* Graceful shutdown, waits for the progress bar to complete.
* This is a blocking call.
*/
public void shutdown() {
...
// Wait for the progress bar task to complete
...
}
/**
* Terminates the progress bar.
* This doesn't wait for the progress bar to complete.
*/
public void terminate() {
...
// Terminate the progress bar task
...
}
}
{code}
{quote}Sorry for my newbie questions, I'm just getting familiar with the code
now.
{quote}
No issues :) If I have confused you more, we can get on a call to discuss this.
> Use the ProgressBar class in the RandomKeyGenerator freon test
> --------------------------------------------------------------
>
> Key: HDDS-692
> URL: https://issues.apache.org/jira/browse/HDDS-692
> Project: Hadoop Distributed Data Store
> Issue Type: Bug
> Reporter: Elek, Marton
> Assignee: Zsolt Horvath
> Priority: Major
> Attachments: HDDS-692.001.patch
>
>
> HDDS-443 provides a reusable progress bar to make it easier to add more freon
> tests, but the existing RandomKeyGenerator test
> (hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java)
> still doesn't use it.
> It would be good to switch to use the new progress bar there.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]