2828import com .fasterxml .jackson .databind .JsonNode ;
2929
3030import io .openvidu .loadtest .config .LoadTestConfig ;
31+ import io .openvidu .loadtest .exceptions .LoadTestInitializationException ;
3132
3233@ Service
3334public class ElasticSearchClient {
@@ -81,9 +82,11 @@ public void init() {
8182 log .info ("Connection to Elasticsearch established at {}" , elasticsearchHost );
8283 }
8384 } catch (Exception e ) {
84- log .error ("Failed to initialize Elasticsearch client: {}" , e .getMessage ());
85- log .error (
86- "If property 'ELASTICSEARCH_HOST' is defined, then it is mandatory that OpenVidu Load Test is able to connect to it" );
85+ throw new LoadTestInitializationException (
86+ "Connection to Elasticsearch failed at " + loadTestConfig .getElasticsearchHost ()
87+ + " (" + e .getMessage ()
88+ + "). If property 'ELASTICSEARCH_HOST' is defined, then it is mandatory that OpenVidu Load Test is able to connect to it" ,
89+ e );
8790 }
8891 }
8992
@@ -93,11 +96,11 @@ private boolean doPing() {
9396 BooleanResponse response = this .client .ping ();
9497 pingSuccess = response .value ();
9598 } catch (IOException e ) {
96- log . error ( "Connection to Elasticsearch failed at {} ({})" , loadTestConfig . getElasticsearchHost (),
97- e . getMessage ());
98- log . error (
99- " If property 'ELASTICSEARCH_HOST' is defined, then it is mandatory that OpenVidu Load Test is able to connect to it");
100- System . exit ( 1 );
99+ throw new LoadTestInitializationException (
100+ "Connection to Elasticsearch failed at " + loadTestConfig . getElasticsearchHost ()
101+ + " (" + e . getMessage ()
102+ + "). If property 'ELASTICSEARCH_HOST' is defined, then it is mandatory that OpenVidu Load Test is able to connect to it",
103+ e );
101104 }
102105 return pingSuccess ;
103106 }
0 commit comments