|
1 | | -package cws.k8s.scheduler; |
2 | | - |
3 | | -import jakarta.annotation.PostConstruct; |
4 | | -import lombok.extern.slf4j.Slf4j; |
5 | | -import org.springframework.beans.factory.annotation.Autowired; |
6 | | -import org.springframework.boot.SpringApplication; |
7 | | -import org.springframework.boot.autoconfigure.SpringBootApplication; |
8 | | -import org.springframework.boot.info.BuildProperties; |
9 | | - |
10 | | -import java.text.DateFormat; |
11 | | -import java.text.SimpleDateFormat; |
12 | | -import java.util.Date; |
13 | | - |
14 | | -@SpringBootApplication |
15 | | -@Slf4j |
16 | | -public class Main { |
17 | | - |
18 | | - private final BuildProperties buildProperties; |
19 | | - |
20 | | - Main( @Autowired BuildProperties buildProperties ) { |
21 | | - this.buildProperties = buildProperties; |
22 | | - } |
23 | | - |
24 | | - public static void main(String[] args) { |
25 | | - if( System.getenv( "SCHEDULER_NAME" ) == null || System.getenv( "SCHEDULER_NAME" ).isEmpty() ){ |
26 | | - throw new IllegalArgumentException( "Please define environment variable: SCHEDULER_NAME" ); |
27 | | - } |
28 | | - SpringApplication.run(Main.class, args); |
29 | | - } |
30 | | - |
31 | | - @PostConstruct |
32 | | - private void logVersion() { |
33 | | - DateFormat format = new SimpleDateFormat("dd/MM/yy-HH:mm:ss"); |
34 | | - final long buildDate = Long.parseLong( buildProperties.get( "time" ) ); |
35 | | - Date date = new Date( buildDate ); |
36 | | - final String dateString = format.format( date ); |
37 | | - final String version = buildProperties.getVersion(); |
38 | | - String[] text = { |
39 | | - "", |
40 | | - "Common Workflow Scheduler for Kubernetes " + version + " (" + dateString + ")", |
41 | | - "", |
42 | | - "If you use the Common Workflow Scheduler for research purposes, please cite the following:", |
43 | | - "Lehmann Fabian, Jonathan Bader, Friedrich Tschirpke, Lauritz Thamsen, and Ulf Leser.", |
44 | | - "\"How Workflow Engines Should Talk to Resource Managers: A Proposal for a Common Workflow", |
45 | | - "Scheduling Interface.\" In 2023 IEEE/ACM 23rd International Symposium on Cluster, Cloud and", |
46 | | - "Internet Computing (CCGrid). Bangalore, India, 2023.", |
47 | | - "" |
48 | | - }; |
49 | | - |
50 | | - int longest = 0; |
51 | | - for ( String s : text ) { |
52 | | - if ( s.length() > longest ) { |
53 | | - longest = s.length(); |
54 | | - } |
55 | | - } |
56 | | - |
57 | | - String info = "=".repeat( longest + 6 ) + "\n"; |
58 | | - for ( String s : text ) { |
59 | | - info += "= " + s + " ".repeat( longest - s.length() ) + " =\n"; |
60 | | - } |
61 | | - info += "=".repeat( longest + 6 ) + "\n"; |
62 | | - |
63 | | - log.info( "\n\n\n" + info + "\n" ); |
64 | | - |
65 | | - } |
66 | | - |
67 | | -} |
| 1 | +package cws.k8s.scheduler; |
| 2 | + |
| 3 | +import jakarta.annotation.PostConstruct; |
| 4 | +import lombok.extern.slf4j.Slf4j; |
| 5 | +import org.jetbrains.annotations.NotNull; |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; |
| 7 | +import org.springframework.boot.SpringApplication; |
| 8 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 9 | +import org.springframework.boot.info.BuildProperties; |
| 10 | + |
| 11 | +import java.text.DateFormat; |
| 12 | +import java.text.SimpleDateFormat; |
| 13 | +import java.util.Date; |
| 14 | + |
| 15 | +@SpringBootApplication |
| 16 | +@Slf4j |
| 17 | +public class Main { |
| 18 | + |
| 19 | + private final BuildProperties buildProperties; |
| 20 | + |
| 21 | + Main( @Autowired BuildProperties buildProperties ) { |
| 22 | + this.buildProperties = buildProperties; |
| 23 | + } |
| 24 | + |
| 25 | + public static void main(String[] args) { |
| 26 | + if( System.getenv( "SCHEDULER_NAME" ) == null || System.getenv( "SCHEDULER_NAME" ).isEmpty() ){ |
| 27 | + throw new IllegalArgumentException( "Please define environment variable: SCHEDULER_NAME" ); |
| 28 | + } |
| 29 | + SpringApplication.run(Main.class, args); |
| 30 | + } |
| 31 | + |
| 32 | + @PostConstruct |
| 33 | + private void logVersion() { |
| 34 | + DateFormat format = new SimpleDateFormat("dd/MM/yy-HH:mm:ss"); |
| 35 | + final long buildDate = Long.parseLong( buildProperties.get( "time" ) ); |
| 36 | + Date date = new Date( buildDate ); |
| 37 | + final String dateString = format.format( date ); |
| 38 | + final String[] text = getMessage( dateString ); |
| 39 | + |
| 40 | + int longest = 0; |
| 41 | + for ( String s : text ) { |
| 42 | + if ( s.length() > longest ) { |
| 43 | + longest = s.length(); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + String info = "=".repeat( longest + 6 ) + "\n"; |
| 48 | + for ( String s : text ) { |
| 49 | + info += "= " + s + " ".repeat( longest - s.length() ) + " =\n"; |
| 50 | + } |
| 51 | + info += "=".repeat( longest + 6 ) + "\n"; |
| 52 | + |
| 53 | + log.info( "\n\n\n" + info + "\n" ); |
| 54 | + |
| 55 | + } |
| 56 | + |
| 57 | + private String @NotNull [] getMessage( String dateString ) { |
| 58 | + final String version = buildProperties.getVersion(); |
| 59 | + String[] text = { |
| 60 | + "", |
| 61 | + "Common Workflow Scheduler for Kubernetes " + version + " (" + dateString + ")", |
| 62 | + "", |
| 63 | + "If you use the Common Workflow Scheduler for research purposes, please cite the following:", |
| 64 | + "Lehmann Fabian, Jonathan Bader, Friedrich Tschirpke, Lauritz Thamsen, and Ulf Leser.", |
| 65 | + "\"How Workflow Engines Should Talk to Resource Managers: A Proposal for a Common Workflow", |
| 66 | + "Scheduling Interface.\" In 2023 IEEE/ACM 23rd International Symposium on Cluster, Cloud and", |
| 67 | + "Internet Computing (CCGrid). Bangalore, India, 2023.", |
| 68 | + "" |
| 69 | + }; |
| 70 | + return text; |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments