You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by jinmingjian <gi...@git.apache.org> on 2017/02/27 03:44:04 UTC

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

GitHub user jinmingjian opened a pull request:

    https://github.com/apache/flink/pull/3420

    [FLINK-4422] Convert all time interval measurements to System.nanoTime() - flink-connector-kafka-0.8

    Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
    If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html).
    In addition to going through the list, please provide a meaningful description of your changes.
    
    - [x ] General
      - The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
      - The pull request addresses only one issue
      - Each commit in the PR has a meaningful commit message (including the JIRA id)
    
    - [ ] Documentation
      - Documentation has been added for new functionality
      - Old documentation affected by the pull request has been updated
      - JavaDoc for public methods has been added
    
    - [ x] Tests & Build
      - Functionality added by the pull request is covered by tests
      - `mvn clean verify` has been executed successfully locally or a Travis build has passed


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jinmingjian/flink FLINK-4422-3

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/3420.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 #3420
    
----
commit 4df15f1334748926dca55fa690220ffbbc4aee40
Author: Jin Mingjian <ji...@gmail.com>
Date:   2017-02-27T03:40:05Z

    [FLINK-4422] Convert all time interval measurements to System.nanoTime() - flink-connector-kafka-0.8

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103481121
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/ClosableBlockingQueue.java ---
    @@ -355,13 +355,13 @@ public E getElementBlocking(long timeoutMillis) throws InterruptedException {
     			throw new IllegalArgumentException("invalid timeout");
     		}
     		
    -		final long deadline = System.currentTimeMillis() + timeoutMillis;
    +		final long deadline = System.nanoTime() + timeoutMillis * 1_000_000L;
    --- End diff --
    
    I think it is nice to have the arguments as either milliseconds, or as `long value, TimeUnit unit`. That is the unofficial standard in Java which most users implicitly assume.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103492897
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/ClosableBlockingQueue.java ---
    @@ -355,13 +355,13 @@ public E getElementBlocking(long timeoutMillis) throws InterruptedException {
     			throw new IllegalArgumentException("invalid timeout");
     		}
     		
    -		final long deadline = System.currentTimeMillis() + timeoutMillis;
    +		final long deadline = System.nanoTime() + timeoutMillis * 1_000_000L;
    --- End diff --
    
    Good points! Lets leave it as `timeoutMillis` then.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #3420: [FLINK-4422] Convert all time interval measurements to Sy...

Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on the issue:

    https://github.com/apache/flink/pull/3420
  
    @jinmingjian thanks for addressing my comments. Minus Stephan's comment, looks good on my side.
    Once that's fixed, +1 to merge.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by jinmingjian <gi...@git.apache.org>.
Github user jinmingjian commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103195631
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/KillerWatchDog.java ---
    @@ -42,12 +42,12 @@
     	@SuppressWarnings("deprecation")
     	@Override
     	public void run() {
    -		final long deadline = System.currentTimeMillis() + timeout;
    +		final long deadline = System.nanoTime() + timeout * 1_000_000L;
     		long now;
     
    -		while (toKill.isAlive() && (now = System.currentTimeMillis()) < deadline) {
    +		while (toKill.isAlive() && (now = System.nanoTime()) < deadline) {
     			try {
    -				toKill.join(deadline - now);
    +				toKill.join( ( deadline - now ) / 1_000_000L );
    --- End diff --
    
    good catch:)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by jinmingjian <gi...@git.apache.org>.
Github user jinmingjian commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103627979
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/KillerWatchDog.java ---
    @@ -42,12 +42,12 @@
     	@SuppressWarnings("deprecation")
     	@Override
     	public void run() {
    -		final long deadline = System.currentTimeMillis() + timeout;
    +		final long deadline = System.nanoTime() + timeout * 1_000_000L;
     		long now;
     
    -		while (toKill.isAlive() && (now = System.currentTimeMillis()) < deadline) {
    +		while (toKill.isAlive() && (now = System.nanoTime()) < deadline) {
     			try {
    -				toKill.join(deadline - now);
    +				toKill.join((deadline - now) / 1_000_000L);
    --- End diff --
    
    thanks for pointing this, my mistake for ignoring the API of Thread#join:) I proposed a simple move of rounding.
    
    It is found that the Thread#join is using the System.currentTimeMillis(). So the fix may be not  as strong as we expected. The better may be that we do not fix KillerWatchDog because the "last resort" codes already there.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103182219
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/ClosableBlockingQueue.java ---
    @@ -355,13 +355,13 @@ public E getElementBlocking(long timeoutMillis) throws InterruptedException {
     			throw new IllegalArgumentException("invalid timeout");
     		}
     		
    -		final long deadline = System.currentTimeMillis() + timeoutMillis;
    +		final long deadline = System.nanoTime() + timeoutMillis * 1_000_000L;
    --- End diff --
    
    Can we just change the argument to `timeoutNanos`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103181679
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/KillerWatchDog.java ---
    @@ -42,12 +42,12 @@
     	@SuppressWarnings("deprecation")
     	@Override
     	public void run() {
    -		final long deadline = System.currentTimeMillis() + timeout;
    +		final long deadline = System.nanoTime() + timeout * 1_000_000L;
     		long now;
     
    -		while (toKill.isAlive() && (now = System.currentTimeMillis()) < deadline) {
    +		while (toKill.isAlive() && (now = System.nanoTime()) < deadline) {
     			try {
    -				toKill.join(deadline - now);
    +				toKill.join( ( deadline - now ) / 1_000_000L );
    --- End diff --
    
    nit: I don't think we usually have spaces after braces like this here.
    There isn't an agreed codestyle for this, but I think we can remove the spaces to be consistent with other parts of the code.
    
    Will fix will merging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #3420: [FLINK-4422] Convert all time interval measurements to Sy...

Posted by jinmingjian <gi...@git.apache.org>.
Github user jinmingjian commented on the issue:

    https://github.com/apache/flink/pull/3420
  
    another way is to modify the API to pass timeInNano. But considering all references are named with test*. I suggest the conservative fix.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #3420: [FLINK-4422] Convert all time interval measurements to Sy...

Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on the issue:

    https://github.com/apache/flink/pull/3420
  
    Thanks for the fix @jinmingjian. LGTM, merging the PRs now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by jinmingjian <gi...@git.apache.org>.
Github user jinmingjian commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103196536
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/ClosableBlockingQueue.java ---
    @@ -355,13 +355,13 @@ public E getElementBlocking(long timeoutMillis) throws InterruptedException {
     			throw new IllegalArgumentException("invalid timeout");
     		}
     		
    -		final long deadline = System.currentTimeMillis() + timeoutMillis;
    +		final long deadline = System.nanoTime() + timeoutMillis * 1_000_000L;
    --- End diff --
    
    We can. But as an API, a ton of invocations in tests will come to change. Are you ready for review? :smiley_cat: And from practices, it is uncommon to use nano sec time unit in API except for performance/benchmark in that it is usual too small.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103861044
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/KillerWatchDog.java ---
    @@ -42,12 +42,12 @@
     	@SuppressWarnings("deprecation")
     	@Override
     	public void run() {
    -		final long deadline = System.currentTimeMillis() + timeout;
    +		final long deadline = System.nanoTime() + timeout * 1_000_000L;
     		long now;
     
    -		while (toKill.isAlive() && (now = System.currentTimeMillis()) < deadline) {
    +		while (toKill.isAlive() && (now = System.nanoTime()) < deadline) {
     			try {
    -				toKill.join(deadline - now);
    +				toKill.join((deadline - now) / 1_000_000L);
    --- End diff --
    
    I think the fix is fine. The rounding will result in the originally used millisecond precision anyway.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/3420


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #3420: [FLINK-4422] Convert all time interval measurement...

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3420#discussion_r103481458
  
    --- Diff: flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/KillerWatchDog.java ---
    @@ -42,12 +42,12 @@
     	@SuppressWarnings("deprecation")
     	@Override
     	public void run() {
    -		final long deadline = System.currentTimeMillis() + timeout;
    +		final long deadline = System.nanoTime() + timeout * 1_000_000L;
     		long now;
     
    -		while (toKill.isAlive() && (now = System.currentTimeMillis()) < deadline) {
    +		while (toKill.isAlive() && (now = System.nanoTime()) < deadline) {
     			try {
    -				toKill.join(deadline - now);
    +				toKill.join((deadline - now) / 1_000_000L);
    --- End diff --
    
    This can round down to `0`, which translates to "wait infinitely`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---