-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6163 from entur/raptor_application_integration
Remove unwanted dependencies in Raptor code
- Loading branch information
Showing
17 changed files
with
157 additions
and
71 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
41 changes: 41 additions & 0 deletions
41
application/src/main/java/org/opentripplanner/raptor/api/request/RaptorEnvironment.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,41 @@ | ||
package org.opentripplanner.raptor.api.request; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* The raptor environment provides a few hooks and integration points to the caller. The default | ||
* implementation will work just fine, override to adjust Raptor to the calling application. | ||
*/ | ||
public interface RaptorEnvironment { | ||
Runnable NOOP = () -> {}; | ||
|
||
/** | ||
* Use the timeout-hook to register a callback from Raptor. The hook is called periodically to | ||
* check if a time-out is reached. The hook should then exit with an exception handled by the | ||
* caller. Raptor does not have blocking method calls so just calling {@link Thread#interrupt()} | ||
* will not terminate the Raptor search. | ||
*/ | ||
default Runnable timeoutHook() { | ||
return NOOP; | ||
} | ||
|
||
/** | ||
* Raptor has support for running a few things in parallel. If Raptor catches an | ||
* {@link InterruptedException}, Raptor will convert the checked exception to an unchecked | ||
* exception. The default is {@link RuntimeException}. Override this method to map | ||
* {@link InterruptedException} to your prefered runtime exception. | ||
*/ | ||
default RuntimeException mapInterruptedException(InterruptedException e) { | ||
return new RuntimeException(e); | ||
} | ||
|
||
/** | ||
* Inject a thread pool into Raptor to run part of the raptor search in parallel. If no | ||
* thread pool is provided, then Raptor runs everything in the caller thread. | ||
*/ | ||
@Nullable | ||
default ExecutorService threadPool() { | ||
return null; | ||
} | ||
} |
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
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
Oops, something went wrong.