File tree 3 files changed +17
-4
lines changed
agent/src/main/java/agent
ecs-firelens/src/main/java
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ logger.putProperty("RequestId", "422b1569-16f6-4a03-b8f0-fe3fd9b100f8");
65
65
logger. flush();
66
66
67
67
// flush the sink, waiting up to 10s before giving up
68
- environment. getSink(). shutdown(). orTimeout (10_000L , TimeUnit . MILLISECONDS );
68
+ environment. getSink(). shutdown(). get (10_000L , TimeUnit . MILLISECONDS );
69
69
```
70
70
71
71
## API
Original file line number Diff line number Diff line change 7
7
import software .amazon .cloudwatchlogs .emf .model .DimensionSet ;
8
8
import software .amazon .cloudwatchlogs .emf .model .Unit ;
9
9
10
+ import java .util .concurrent .ExecutionException ;
11
+ import java .util .concurrent .TimeoutException ;
10
12
import java .util .concurrent .TimeUnit ;
11
13
12
14
public class App {
13
15
14
- public static void main (String [] args ) {
16
+ public static void main (String [] args ) throws ExecutionException , InterruptedException , TimeoutException {
15
17
DefaultEnvironment environment = new DefaultEnvironment (EnvironmentConfigurationProvider .getConfig ());
16
18
emitMetric (environment );
17
19
emitMetric (environment );
18
20
emitMetric (environment );
19
- environment .getSink ().shutdown ().orTimeout (360_000L , TimeUnit .MILLISECONDS );
21
+ environment .getSink ().shutdown ().get (360_000L , TimeUnit .MILLISECONDS );
20
22
}
21
23
22
24
private static void emitMetric (Environment environment ) {
Original file line number Diff line number Diff line change 28
28
import java .io .IOException ;
29
29
import java .io .OutputStream ;
30
30
import java .net .InetSocketAddress ;
31
+ import java .util .concurrent .ExecutionException ;
32
+ import java .util .concurrent .TimeoutException ;
31
33
import java .util .concurrent .TimeUnit ;
32
34
33
35
public class App {
@@ -48,7 +50,16 @@ public static void main(String[] args) throws Exception {
48
50
private static void registerShutdownHook () {
49
51
// https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/
50
52
Signal .handle (new Signal ("TERM" ), sig -> {
51
- env .getSink ().shutdown ().orTimeout (1_000L , TimeUnit .MILLISECONDS );
53
+ try {
54
+ env .getSink ().shutdown ().get (1_000L , TimeUnit .MILLISECONDS );
55
+ } catch (InterruptedException | ExecutionException | TimeoutException e ) {
56
+ if (e instanceof InterruptedException ) {
57
+ Thread .currentThread ().interrupt ();
58
+ }
59
+
60
+ e .printStackTrace ();
61
+ }
62
+
52
63
System .exit (0 );
53
64
});
54
65
}
You can’t perform that action at this time.
0 commit comments