forked from vipshop/vjtools
-
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.
vipshop#149 vjmap最多运行15分钟,超时后退出并建议用户更改模式
- Loading branch information
1 parent
ec7e257
commit 2bcab4c
Showing
4 changed files
with
35 additions
and
3 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
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
22 changes: 22 additions & 0 deletions
22
vjmap/src/main/java/com/vip/vjtools/vjmap/utils/TimeController.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,22 @@ | ||
package com.vip.vjtools.vjmap.utils; | ||
|
||
/** | ||
* 最多等待15分钟,超时后打印当前结果并退出,建议用户使用live参数 | ||
*/ | ||
public class TimeController { | ||
|
||
long start = System.currentTimeMillis(); | ||
|
||
// 15 minutes | ||
long maxTime = Long.parseLong(System.getProperty("vjmap.timeout", String.valueOf(60 * 1000 * 15))); | ||
|
||
public void checkTimedOut() { | ||
if (System.currentTimeMillis() - start > maxTime) { | ||
throw new TimeoutException(); | ||
} | ||
} | ||
|
||
public static class TimeoutException extends RuntimeException { | ||
|
||
} | ||
} |