StefanRRichter commented on a change in pull request #7568: [FLINK-11417] Make 
access to ExecutionGraph single threaded from JobMaster main thread
URL: https://github.com/apache/flink/pull/7568#discussion_r250990420
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/rpc/MainThreadValidatorUtil.java
 ##########
 @@ -44,4 +51,24 @@ public void exitMainThread() {
                
assert(endpoint.currentMainThread.compareAndSet(Thread.currentThread(), null)) :
                                "The RpcEndpoint has concurrent access from " + 
endpoint.currentMainThread.get();
        }
+
+       /**
+        * Returns true iff the current thread is equals to the provided 
expected thread and logs violations.
+        *
+        * @param expected the expected main thread.
+        * @return true iff the current thread is equals to the provided 
expected thread.
+        */
+       public static boolean isRunningInExpectedThread(@Nullable Thread 
expected) {
+               Thread actual = Thread.currentThread();
+               if (expected != actual) {
+                       log.warn("Violation of main thread constraint detected: 
expected <{}> but running in <{}>.",
+                               expected,
+                               actual,
+                               new Exception());
 
 Review comment:
   Yes, and yes ok.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to