public class NetricsEmbedded
extends java.lang.Object
A copy of the TIBCO Patterns server can be run within the Java VM, avoiding the need for a separate external process. This is called the "embedded" server. (This is not available on all platforms, see the release notes for the list of platforms on which the embedded server is available.) The exact same Java API is used to communicate with the embedded server as with an external server. However, just like an external server, the embedded server must be started before it is used and should be shutdown after all use is completed. There is only ONE embedded server within a single JVM. This class provides static methods for starting and stopping the embedded server.
The standard procedure for using the embedded server is as follows:
NetricsEmbeddedSettings embedded_settings = new NetricsEmbeddedSettings() ;
// set your options here. E.g.
embedded_settings.consoleLogFilename = "embedded_server.log" ;
// to avoid crashing the JVM it is recommended a memory limit be set.
embedded_settings.maxTableMemory = 100000 ; // ~100M
// other settings as desired...
// set the directory where the embedded server library resides.
// (The embedded server library is found in the same bin directory
// as the TIBCO Patterns server executable.)
File embedded_lib = new File("/home/tibco/Patterns/versionserver/bin") ;
// start the embedded server.
try {
NetricsEmbedded.initialize(embedded_settings, embedded_lib) ;
} catch (NetricsException ne) {
// Handle exception
}
// Create a connection to the embedded server.
NetricsConMgr con_mgr = new NetricsConMgr() ;
con_mgr.setEmbeddedMode(true) ;
NetricsServerInterface nsi = con_mgr.newConnection() ;
// Now use the interface as you would any interface to a server...
A few things to note about the embedded server:
shutdown
method should be used.
| Constructor and Description |
|---|
NetricsEmbedded() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
initialize(NetricsEmbeddedSettings settings,
java.io.File libDir)
Initialize and start the TIBCO Patterns Embedded server.
|
static int |
shutdown()
Shut down the TIBCO Patterns Embedded Server.
|
public static boolean initialize(NetricsEmbeddedSettings settings, java.io.File libDir) throws NetricsException
This call is used to initialize and start the embedded TIBCO Patterns server. This must be called before attempting to use the embedded server. If the embedded server is not initialized by this command all attempts to communicate with the embedded server will throw a NetricsException.
If the embedded server is already initialized and running this command does nothing except increment the initialization count. This implies the initialization settings can't be changed dynamically after the server is started. To change the settings the server must be shutdown (destroying all tables and saved data), and restarted.
An equal number of shutdown methods as initialize methods
must be called to shut down the server. This behavior is similar to that of
recursive locks.
settings - the initialization settings for the Embedded server. These are
analogous to the command line options of the standard server. If null
is passed in the default options are used. The default options are the
same as for the standard server except the use of parallel loads is
turned off.libDir - this is the full path name for the directory where the embedded server
library resides. Note this is the directory and not the library file.
The library name is "TIB_tps_embedded". The library file name
is determined by the run time platform. On Linux it would be
"libTIB_tps_embedded.so", on Windows it would be
"TIB_tps_embedded.dll". The library is searched for in this directory.
If this is null the standard system library path is searched.NetricsException - if the library cannot be loaded, or if the Embedded server
initialization failed.public static int shutdown()
throws NetricsException
This shuts down the TIBCO Patterns embedded server. Shutting down the embedded server destroys all loaded data such as: tables, thesauri, Learn models and character maps. All memory used by the server is freed. (Note: this may not shrink the JVM process size as memory is only returned to the heap, the heap manager may or may not return it to the OS.)
An equal number of shutdown calls as initialize
calls must be made before the embedded server is actually shut down.
NetricsException - if shutdown encountered an internal error.