File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
agent/src/main/java/agent
ecs-firelens/src/main/java Expand file tree Collapse file tree 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");
6565logger. flush();
6666
6767// 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 );
6969```
7070
7171## API
Original file line number Diff line number Diff line change 77import software .amazon .cloudwatchlogs .emf .model .DimensionSet ;
88import software .amazon .cloudwatchlogs .emf .model .Unit ;
99
10+ import java .util .concurrent .ExecutionException ;
11+ import java .util .concurrent .TimeoutException ;
1012import java .util .concurrent .TimeUnit ;
1113
1214public class App {
1315
14- public static void main (String [] args ) {
16+ public static void main (String [] args ) throws ExecutionException , InterruptedException , TimeoutException {
1517 DefaultEnvironment environment = new DefaultEnvironment (EnvironmentConfigurationProvider .getConfig ());
1618 emitMetric (environment );
1719 emitMetric (environment );
1820 emitMetric (environment );
19- environment .getSink ().shutdown ().orTimeout (360_000L , TimeUnit .MILLISECONDS );
21+ environment .getSink ().shutdown ().get (360_000L , TimeUnit .MILLISECONDS );
2022 }
2123
2224 private static void emitMetric (Environment environment ) {
Original file line number Diff line number Diff line change 2828import java .io .IOException ;
2929import java .io .OutputStream ;
3030import java .net .InetSocketAddress ;
31+ import java .util .concurrent .ExecutionException ;
32+ import java .util .concurrent .TimeoutException ;
3133import java .util .concurrent .TimeUnit ;
3234
3335public class App {
@@ -48,7 +50,16 @@ public static void main(String[] args) throws Exception {
4850 private static void registerShutdownHook () {
4951 // https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/
5052 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+
5263 System .exit (0 );
5364 });
5465 }
You can’t perform that action at this time.
0 commit comments