Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BkTimetable wrong design #211

Closed
yegor256 opened this issue Apr 27, 2015 · 21 comments
Closed

BkTimetable wrong design #211

yegor256 opened this issue Apr 27, 2015 · 21 comments

Comments

@yegor256
Copy link
Owner

I think that current design of BkTimetable is too complex, that's why the unit test is very difficult to understand. I would refactor it and simplify. I would do it like this:

final class BkTimeable {
  Back back;
  long latency;
  Thread monitor;
  Map<Target, Long> threads; // thread and start time
  public BkTimeable(Back back, long msec) {
    //...
  }
}

Just one ctor, nothing else.

Current unit tests are absolutely wrong. They don't test the class, but instead test its interaction with encapsulated elements. It's against the idea of OOP. Let's remove current tests and create a simple integration test, which will run a server (like it's done in FtCLITest) and make sure the request is interrupted in a few seconds.

@yegor256 yegor256 changed the title BkTim BkTimetable wrong design Apr 27, 2015
@yegor256 yegor256 added the bug label Apr 27, 2015
@dmzaytsev
Copy link
Contributor

@yegor256 @davvd please assign this task to me

@yegor256
Copy link
Owner Author

@davvd assign @dmzaytsev to this task pls

@dmzaytsev
Copy link
Contributor

@yegor256 should I use Thread instance instead ScheduledExecutorService ? something like this

new Thread(new Runnable() {
    @Override
        public void run() {
            while (true) {
                // look for expired threads and interrupt them
               Thread.sleep();
            }
).start();

@davvd
Copy link

davvd commented Apr 27, 2015

@yegor256 I will find a developer for the task soon...

@davvd davvd added this to the 1.0 milestone Apr 27, 2015
@davvd
Copy link

davvd commented Apr 27, 2015

@yegor256 milestone set to 1.0 (correct me if I am wrong)

@davvd
Copy link

davvd commented Apr 27, 2015

@yegor256 thanks a lot for reporting, 15 mins added to your acc, pmt ID 000-e27c2164

@davvd
Copy link

davvd commented Apr 27, 2015

@davvd assign @dmzaytsev to this task pls

@yegor256 OK @dmzaytsev please go ahead, this task is yours

@yegor256
Copy link
Owner Author

@dmzaytsev yes, that's how I would do this, with while(true) and TimeUnit.SECONDS.sleep(1L)

@dmzaytsev
Copy link
Contributor

@yegor256 We have some problems when using BkTimeable with BkParallel. BkTimeable catches the current thread, but BkParallel creates a new thread which unknown for BkTimeable. We need to change call order for them.

Also I suggest to break BkTimeable into two classes Watcher and BkTimeable.
So FtCLI code will look something like this

    final Front front = new FtBasic (
                 new BkParallel (
                  new BkTimeable (
                     new Watcher.Base (this.options.maxLatency ()),
                     new BkSafe (new BkBasic (tks))
                  )
                 this.options.threads ()
             )
             this.options.port ()
         );

This will allow to use the single watcher for the whole application if we have several listeners.
What do you think about the suggestion?

dmzaytsev added a commit to dmzaytsev/takes that referenced this issue Apr 28, 2015
rewritten the unit test
@dmzaytsev
Copy link
Contributor

@davvd the PR #216 for the task is ready for review
@yegor256 if you accept the suggestion, I will do it later

@yegor256
Copy link
Owner Author

@dmzaytsev I didn't get the idea of watcher... why do we need to make it visible/changeable outside of BkTimeable?

@dmzaytsev
Copy link
Contributor

@yegor256 Idea of watcher is sharing one watcher between many thread catchers. In case if we use multiple instances of Front(listen different ports). But this is rare case. I think it is not required.

@yegor256
Copy link
Owner Author

@dmzaytsev yes, it's over-engineering. let's keep it simple

dmzaytsev added a commit to dmzaytsev/takes that referenced this issue Apr 30, 2015
dmzaytsev added a commit to dmzaytsev/takes that referenced this issue Apr 30, 2015
dmzaytsev added a commit to dmzaytsev/takes that referenced this issue Apr 30, 2015
@dmzaytsev
Copy link
Contributor

@yegor256 the PR #216 has been merged. Could you close the task please ? Or let me know why the delivery not accepted

@yegor256
Copy link
Owner Author

@dmzaytsev looks perfect now, thanks!

yegor256 pushed a commit that referenced this issue Apr 30, 2015
@dmzaytsev
Copy link
Contributor

@yegor256 you are welcome :)

@davvd
Copy link

davvd commented May 2, 2015

@elenavolokhova please, let us know what do you think about this ticket, according to our QA rules

@elenavolokhova
Copy link

@davvd Quality is good.

@davvd
Copy link

davvd commented May 4, 2015

@davvd Quality is good.

@elenavolokhova thanks for the review

@davvd
Copy link

davvd commented May 6, 2015

@davvd Quality is good.

@elenavolokhova thank you, good quality is always good :)

@davvd
Copy link

davvd commented May 9, 2015

@dmzaytsev I added 10 mins to @elenavolokhova (for QA review) in transaction 56854433

Thanks a lot, I just topped your account for 30 mins, transaction ID 56854444, total time was 80 hours and 28 mins

+30 added to your rating, at the moment it is: +1212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants