Installing and Running Doradus : Embedding Doradus In Another Application : DoradusServer.startEmbedded()

DoradusServer.startEmbedded()
This method returns as soon as all internal services are initialized and started. In addition to runtime arguments (like main()), this method accepts a second String[] that specifies optional services. Example:
String[] args = new String[] {"-restport", "5711"};
String[] services = new String[] {OLAPService.class.getName()};
DoradusServer.startEmbedded(args, services); // returns when services are started
The services parameter overrides the doradus.yaml file parameter default_services, starting only the given optional services. The example above starts Doradus with the OLAP storage service. But the REST, Task Manager, and other optional services are not initialized. Note that Doradus always initializes the DB and Schema services, which are required. See the doradus.yaml file default_services option for a description of optional services that may be requested.
The services parameter must include full package name of each service. At least one storage service must be initialized otherwise startEmbedded() will throw a RuntimeException. If multiple storage services are provided, the first one becomes the default for new applications created via the embedded Doradus instance that do not explicitly declare a storage service.
Although startEmbedded() returns when all requested and requires services have started, a service may not be immediately ready to use. For example, the internal database service is not ready until a connection to Cassandra is established. Until it does, the schema service and all storage services also will not be ready. To ensure that a needed service is ready to use, the application can call the waitForFullService() method. For example, to wait for the OLAPService to be ready:
OLAPService.instance().waitForFullSerice(); // wait until OLAP is ready.
Note that multiple Doradus instances can be launched for the same Cassandra cluster with different service sets. For example, a bulk load application could embed Doradus, initializing only the storage service that it requires, while another standalone instance of Doradus can be executed with full services.
When Doradus is started with the startEmbedded() method, it returns as soon as all requested services are initialized and running. Doradus can be gracefully shutdown by calling the shutDown method. Example:
DoradusServer.shutDown(); // gracefully shutdown and return
Alternatively, Doradus can be gracefully shutdown and terminate the JVM process by calling stopServer. Example:
DordusServer.stopServer(null); // gracefully shutdown and call System.exit()
The parameter passed to stopServer() is a String[], but it is ignored.