You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@fluo.apache.org by keith-turner <gi...@git.apache.org> on 2017/05/04 23:24:23 UTC

[GitHub] incubator-fluo issue #829: Observers implemented as lambdas showing up multi...

GitHub user keith-turner opened an issue:

    https://github.com/apache/incubator-fluo/issues/829

    Observers implemented as lambdas showing up multiple times in metrics

    With the changes for #816 observers implemented as lambdas end with different names on different nodes in metrics.
    
    ![screenshot from 2017-05-04 19-17-12](https://cloud.githubusercontent.com/assets/1268739/25728667/935d8ea4-30fe-11e7-87f6-351716f88c61.png)


----

----


---
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] incubator-fluo issue #829: Observers implemented as lambdas showing up multi...

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

    https://github.com/apache/incubator-fluo/issues/829
  
    I did some research to see if these numbers generated for lambdas are stable w.r.t to a compiled class files.  From what I read online, it seems they are not.  The first number (before the slash) seems to be runtime encounter order and I have not been able to find out what the second number represents.
    
    I ran simple test to prove to myself that the first number is encounter order.
    
    ```java
    public class Test {
      
      public static Runnable getL1(){
        return () -> System.out.println("foo");
      }
      
      public static Runnable getL2(){
        return () -> System.out.println("bar");
      }
      
      public static void main(String[] args) {
        System.out.println(getL1().getClass().getSimpleName());
        System.out.println(getL2().getClass().getSimpleName());
        
        System.out.println(getL1().getClass().getSimpleName());
        System.out.println(getL2().getClass().getSimpleName());
      }
    }
    ```
    
    The program above prints 
    
    ```
    Test$$Lambda$1/834600351
    Test$$Lambda$2/1418481495
    Test$$Lambda$1/834600351
    Test$$Lambda$2/1418481495
    ```
    
    In the program below I change the order of the first two prints so that the class name returned by `getL2()` is printed first.
    
    ```java
    public class Test {
      
      public static Runnable getL1(){
        return () -> System.out.println("foo");
      }
      
      public static Runnable getL2(){
        return () -> System.out.println("bar");
      }
      
      public static void main(String[] args) {
        System.out.println(getL2().getClass().getSimpleName());
        System.out.println(getL1().getClass().getSimpleName());
        
        System.out.println(getL1().getClass().getSimpleName());
        System.out.println(getL2().getClass().getSimpleName());
      }
    }
    ```
    
    The program above prints
    
    ```
    Test$$Lambda$1/834600351
    Test$$Lambda$2/1418481495
    Test$$Lambda$2/1418481495
    Test$$Lambda$1/834600351
    ```
    
    This shows that a lambda at the same position in source code can end up with different classnames on different processes depending on the encounter order.


---
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] incubator-fluo issue #829: Observers implemented as lambdas showing up multi...

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

    https://github.com/apache/incubator-fluo/issues/829
  
    One option for solving this is to use the column name in metrics instead of the classname.  I discussed this offline with @ctubbsii and he suggested letting the user specify a name.  This made me thing that the new ObserverRegistry should have a Fluent interface (it currently has two methods that take a bunch of arguments).  @ctubbsii suggested the following method names for the fluent interface.
    
    ```java
    ObserverRegistry or;
    or.observer(...).named(...).forColumn(...).withWeakNotifications().register();
    or.observer(...).forColumn(...).withWeakNotifications().register();
    ```
    
    We discussed that the `named(...)` method could be optional and it would fall back to the column name if that was not used.  The advantage of allowing the user to optionally specify a name is that the column name may not always be something that is human readable.


---
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] incubator-fluo issue #829: Observers implemented as lambdas showing up multi...

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

    https://github.com/apache/incubator-fluo/issues/829


---
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] incubator-fluo issue #829: Observers implemented as lambdas showing up multi...

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

    https://github.com/apache/incubator-fluo/issues/829
  
    Things are much better after this change 
    
    ![image](https://cloud.githubusercontent.com/assets/1268739/25965473/174c9a28-3656-11e7-93f1-1a227841d518.png)



---
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] incubator-fluo issue #829: Observers implemented as lambdas showing up multi...

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

    https://github.com/apache/incubator-fluo/issues/829
  
    I have been playing around with the idea of making the observer registry fluent.  I realized its nice to have the observer come last for the case when the observer is a multi-line lambda.  To make the observer come last, I am thinking of using the following method names.
    
    ```java
    ObserverRegistry obsRegistry;
    obsRegistry.forColumn(col1, NotificationType.STRONG).useObserver((tx,row,col) -> {
      //multi-line observer
    });
    
    //register an observer with an alias used for metrics and possibly logging
    ObserverRegistry obsRegistry;
    obsRegistry.forColumn(col2, NotificationType.WEAK).aliasedAs("foo42").useObserver((tx,row,col) -> {
      //multi-line observer
    });
    
    ```


---
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.
---