Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 25df750

Browse files
authored
Merge pull request #2 from Making-Sense-Info/v1.0.1
Add check endpoint
2 parents ddbc327 + 2780806 commit 25df750

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010
<groupId>fr.insee</groupId>
1111
<artifactId>trevas-lab</artifactId>
12-
<version>1.0.0</version>
12+
<version>1.1.0</version>
1313
<name>Trevas Lab</name>
1414
<description>VTL API calling Trevas</description>
1515

src/main/java/fr/insee/trevas/lab/controller/TrevasLabController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ public class TrevasLabController {
4444
@Autowired
4545
private ObjectMapper objectMapper;
4646

47+
@GetMapping("check")
48+
public ResponseEntity<String> check() {
49+
try (SparkSession sparkSession = sparkEngine.buildSparkSession()) {
50+
if (sparkSession != null && !sparkSession.sparkContext().isStopped()) {
51+
return ResponseEntity.ok("Spark Session is available and running.");
52+
} else {
53+
return ResponseEntity.status(500).body("Spark Session is not available.");
54+
}
55+
} catch (Exception e) {
56+
return ResponseEntity.status(500).body("Error checking Spark Session: " + e.getMessage());
57+
}
58+
}
59+
4760
@PostMapping("/connect")
4861
public ResponseEntity<EditVisualize> getDataFromConnector(
4962
Authentication auth,

src/main/java/fr/insee/trevas/lab/service/SparkEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class SparkEngine {
3636
@Autowired
3737
private ObjectMapper objectMapper;
3838

39-
private SparkSession buildSparkSession() {
39+
public SparkSession buildSparkSession() {
4040
SparkConf conf = Utils.loadSparkConfig(System.getenv("SPARK_CONF_DIR"));
4141
conf.set("spark.driver.allowMultipleContexts", "true");
4242
// Note: all the dependencies are required for deserialization.

0 commit comments

Comments
 (0)