forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Too many issues to fix in one PR, add a class that is used where we rely on notifying on same thread to at least have visibility.
- Loading branch information
1 parent
41c54e1
commit 7722a9e
Showing
8 changed files
with
78 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
server/src/main/java/org/elasticsearch/action/support/UnsafePlainActionFuture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.support; | ||
|
||
import org.elasticsearch.common.util.concurrent.EsExecutors; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* An unsafe future. You should not need to use this for new code, rather you should be able to convert that code to be async | ||
* or use a clear hierarchy of thread pool executors around the future. | ||
* | ||
* This future is unsafe, since it allows notifying the future on the same thread pool executor that it is being waited on. This | ||
* is a common deadlock scenario, since all threads may be waiting and thus no thread may be able to complete the future. | ||
*/ | ||
public class UnsafePlainActionFuture<T> extends PlainActionFuture<T> { | ||
|
||
private final String unsafeExecutor; | ||
|
||
public UnsafePlainActionFuture(String unsafeExecutor) { | ||
Objects.requireNonNull(unsafeExecutor); | ||
this.unsafeExecutor = unsafeExecutor; | ||
} | ||
|
||
@Override | ||
boolean allowedExecutors(Thread thread1, Thread thread2) { | ||
return super.allowedExecutors(thread1, thread2) || unsafeExecutor.equals(EsExecutors.executorName(thread1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters