[GitHub] carbondata pull request #1821: [HOTFIX] Listeners not getting registered to ...

2018-01-19 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/carbondata/pull/1821


---


[GitHub] carbondata pull request #1821: [HOTFIX] Listeners not getting registered to ...

2018-01-18 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1821#discussion_r162273088
  
--- Diff: integration/spark2/src/main/spark2.2/CarbonSessionState.scala ---
@@ -216,6 +216,8 @@ class CarbonSessionStateBuilder(sparkSession: 
SparkSession,
 new CarbonUDFTransformRule,
 new CarbonLateDecodeRule)
 
+  CarbonEnv.initListeners()
--- End diff --

The same, this is moved to CarbonEnv.init


---


[GitHub] carbondata pull request #1821: [HOTFIX] Listeners not getting registered to ...

2018-01-17 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1821#discussion_r162264895
  
--- Diff: 
core/src/main/java/org/apache/carbondata/events/OperationEventListener.java ---
@@ -19,13 +19,29 @@
 /**
  * Event listener interface which describes the possible events
  */
-public interface OperationEventListener {
+public abstract class OperationEventListener {
 
   /**
* Called on a specified event occurrence
*
* @param event
* @param operationContext
*/
-  void onEvent(Event event, OperationContext operationContext) throws 
Exception;
+  protected abstract void onEvent(Event event, OperationContext 
operationContext) throws Exception;
+
+  @Override
+  public boolean equals(Object obj) {
+if (obj == null || !(obj instanceof OperationEventListener)) {
+  return false;
+}
+return getComparisonName().equals(((OperationEventListener) 
obj).getComparisonName());
+  }
+
+  private String getComparisonName() {
+return getClass().getName();
+  }
+
+  @Override public int hashCode() {
--- End diff --

move @Override to previous line


---


[GitHub] carbondata pull request #1821: [HOTFIX] Listeners not getting registered to ...

2018-01-17 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1821#discussion_r162264804
  
--- Diff: integration/spark2/src/main/spark2.1/CarbonSessionState.scala ---
@@ -75,6 +75,8 @@ class CarbonSessionCatalog(
 env
   }
 
+  CarbonEnv.initListeners()
--- End diff --

There is a CarbonEnv.init function, can you put this initialization inside 
that


---


[GitHub] carbondata pull request #1821: [HOTFIX] Listeners not getting registered to ...

2018-01-17 Thread kunal642
Github user kunal642 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1821#discussion_r162052102
  
--- Diff: 
core/src/main/java/org/apache/carbondata/events/OperationListenerBus.java ---
@@ -57,9 +57,9 @@ public OperationListenerBus addListener(Class eventClass,
   OperationEventListener operationEventListener) {
 
 String eventType = eventClass.getName();
-List operationEventListeners = 
eventMap.get(eventType);
+Set operationEventListeners = 
eventMap.get(eventType);
 if (null == operationEventListeners) {
-  operationEventListeners = new CopyOnWriteArrayList<>();
+  operationEventListeners = new CopyOnWriteArraySet<>();
--- End diff --

1) Changed the code to use addIfAbsent method instead of add. This will 
take care of dublicate entries.
2) changed the OperationEventListener interface to abstract class with 
equals and hashcode which will compare the class name.


---