protected void initNode ( ) { /** * quick fix for integration tests. if hosts property set to "embedded" then a local node is start. * maven dependencies need to be defined correctly for this to work */ ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { // Need to use the classloader for Elasticsearch to pick up the property files when // running in an OSGi environment Thread . currentThread ( ) . setContextClassLoader ( TransportClient . class . getClassLoader ( ) ) ; final Properties properties = new Properties ( ) ; try { InputStream stream = null ; if ( System . getProperties ( ) . containsKey ( "jboss.server.config.dir" ) ) { File file = new File ( System . getProperty ( "jboss.server.config.dir" ) + File . separatorChar + HAWKULAR_ELASTICSEARCH_PROPERTIES ) ; stream = new FileInputStream ( file ) ; } else { stream = this . getClass ( ) . getResourceAsStream ( File . separatorChar + HAWKULAR_ELASTICSEARCH_PROPERTIES ) ; } properties . load ( stream ) ; stream . close ( ) ; } catch ( IOException e ) { log . log ( Level . SEVERE , "Failed to load elasticsearch properties" , e ) ; } node = NodeBuilder . nodeBuilder ( ) . settings ( ImmutableSettings . settingsBuilder ( ) . put ( properties ) ) . node ( ) ; node . start ( ) ; client = node . client ( ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( cl ) ; } if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Initialized Elasticsearch node=" + node + " client=" + client ) ; } }
This method initializes the node .