public void build ( final String ... args ) { if ( args != null ) { final CmdLineParser parser = new CmdLineParser ( this , ParserProperties . defaults ( ) . withUsageWidth ( 80 ) ) ; try { parser . parseArgument ( args ) ; } catch ( final CmdLineException e ) { throw new ClusterRunnerException ( "Failed to parse args: " + Strings . arrayToDelimitedString ( args , " " ) ) ; } } if ( basePath == null ) { try { basePath = Files . createTempDirectory ( "es-cluster" ) . toAbsolutePath ( ) . toString ( ) ; } catch ( final IOException e ) { throw new ClusterRunnerException ( "Could not create $ES_HOME." , e ) ; } } final Path esBasePath = Paths . get ( basePath ) ; createDir ( esBasePath ) ; final String [ ] types = moduleTypes == null ? MODULE_TYPES : moduleTypes . split ( "," ) ; for ( final String moduleType : types ) { Class < ? extends Plugin > clazz ; try { clazz = Class . forName ( moduleType ) . asSubclass ( Plugin . class ) ; pluginList . add ( clazz ) ; } catch ( final ClassNotFoundException e ) { logger . debug ( moduleType + " is not found." , e ) ; } } if ( pluginTypes != null ) { for ( final String value : pluginTypes . split ( "," ) ) { final String pluginType = value . trim ( ) ; if ( pluginType . length ( ) > 0 ) { Class < ? extends Plugin > clazz ; try { clazz = Class . forName ( pluginType ) . asSubclass ( Plugin . class ) ; pluginList . add ( clazz ) ; } catch ( final ClassNotFoundException e ) { throw new ClusterRunnerException ( pluginType + " is not found." , e ) ; } } } } print ( "Cluster Name: " + clusterName ) ; print ( "Base Path: " + basePath ) ; print ( "Num Of Node: " + numOfNode ) ; for ( int i = 0 ; i < numOfNode ; i ++ ) { execute ( i + 1 ) ; } }
Create and start Elasticsearch cluster with arguments .