1 import com.fasterxml.jackson.core.type.TypeReference;
2 import com.fasterxml.jackson.databind.ObjectMapper;
3 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
4 import config.Configuration;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
8 import java.io.InputStream;
10 import java.util.HashMap;
14 public class Orchestrator {
16 private static Logger logger = LoggerFactory.getLogger(Orchestrator.class);
18 public void init(String configYamlFile){
20 parseConfigYaml(configYamlFile);
23 private void parseConfigYaml(String configYaml) {
25 URL fileUrl = getClass().getResource(configYaml);
27 System.out.println("::: Config file missing!!! :::");
30 Configuration conf = new Configuration();
31 ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
32 String realConfigYaml = configYaml;
34 if (!realConfigYaml.startsWith("/")) {
35 realConfigYaml = "/" + configYaml;
37 Map<String, Object> configs;
38 try (InputStream is = getClass().getResourceAsStream(realConfigYaml)) {
39 TypeReference<HashMap<String, Object>> typeRef
40 = new TypeReference<HashMap<String, Object>>() {
42 configs = mapper.readValue(is, typeRef);
45 } catch (Exception e) {
46 logger.error(e.getMessage());