Icon Configuring and Starting the Engine

Configuring the Engine
As already discussed in the Architecture topic, the TEDBEngine component represents the engine in ElevateDB. The following information will show how to configure the engine for use as a client engine in an application or as an server engine. The TEDBEngine EngineType property controls whether the engine is behaving as a local engine or a server engine.

Information The TEDBEngine component must be inactive (Active=False) when modifying any of the configuration properties.

Character Set
The TEDBEngine CharacterSet property specifies which character set, ANSI or Unicode, to use for reading and writing the configuration file and all databases and tables. This property defaults to a value that matches the default string type used by the current compiler. For example, with Delphi XE the default string type is a Unicode string, so this property will default to csUnicode when used with Delphi XE. This setting can be overridden on a per-session basis by modifying the TEDBSession CharacterSet property.

Configuration Path
The TEDBEngine ConfigMemory and ConfigPath properties specify where the engine should look for the configuration file to use for the application, if running as a client engine, or the server, if running as a server engine. The configuration file is used to store the information in the Configuration database in ElevateDB. If the ConfigMemory property is set to True, then the configuration file will be "virtual" and stored in the process memory. If the ConfigMemory property is False and the path specified for the ConfigPath property does not exist, then an error will be raised when the engine is started (Active=True). If the path exists, but the configuration file does not exist in the path, then the ElevateDB engine will create the configuration file as necessary.

Information It is very important that you do not have more than one instance of the ElevateDB engine using different configuration files (including mixing virtual and non-virtual configuration files) and accessing the same database(s). Doing so will cause locking errors. All instances of the ElevateDB engine must use the same type of configuration file (virtual or disk-based) and, if disk-based, the same configuration file if they will be accessing the same database(s).

Temporary Tables Path
The TEDBEngine TempTablesPath property controls where ElevateDB creates any temporary tables that are required for storing query result sets. By default, the TempTablesPath property is set to the user-specific temporary tables path for the operating system.

Engine Signature
The TEDBEngine Signature property controls the engine signature for the engine. The default engine signature is "edb_signature". The engine signature in ElevateDB is used to "stamp" all configuration files, catalog files, table files, backup files, update files, and streams created by the engine so that only an engine with the same signature can open them or access them afterwards. If an engine does attempt to access an existing table, backup file, update file, or stream with a different signature than that of the table, backup file, update file, or stream, an EEDBError exception will be raised. The error that is raised when the access fails due to an invalid engine signature is 100 (EDB_ERROR_VALIDATE).

Also, if the EngineType property is set to etClient, the engine signature is used to stamp all requests sent from a remote session to an ElevateDB Server. If the ElevateDB Server is not using the same engine signature, then the requests will be treated as invalid and rejected by the ElevateDB Server. If the EngineType property is set to etServer, the engine signature is used to stamp all responses sent from the ElevateDB Server to any remote session. If the remote session is not using the same engine signature then the requests will be treated as invalid and rejected by the ElevateDB Server. In summary, both the remote sessions and the ElevateDB Server must be using the same engine signature or else communications between the two will be impossible.

Information It is important to note that ElevateDB can always open any file that is stamped with the default signature, as well as communicate with any ElevateDB Server using the default signature, even if the engine signature has been changed to use a custom signature. Therefore, it is important that one make sure that the engine signature is changed *before* any files are created that one wants to be stamped with the custom engine signature.

Encryption Password
You can use the EncryptionPassword property to modify the encryption password used by ElevateDB for all file encryption purposes. ElevateDB uses this password for all configuration, database catalog (for encrypted catalogs), and table files (for encrypted tables) encryption. The default encryption password is 'elevatesoft'.

ElevateDB uses the Blowfish block cipher encryption algorithm with 128-bit MD5 hash keys for encryption. Please see the Encryption topic for more information.

Licensed Sessions
You can specify that a certain maximum number of concurrent licensed sessions be allowed by modifying the TEDBEngine LicensedSessions property. The default value for this property is 4096 sessions. Setting this property to a lower figure will allow no more than the specified number of sessions to concurrently access the same configuration.

Buffered File I/O
You can specify whether to enable buffered file I/O in ElevateDB by modifying the TEDBEngine BufferedFileIO property. The default value for this property is False. If you enable buffered file I/O, you can use the BufferedFileIOSettings and BufferedFileIOFlushInterval properties to control how the buffered file I/O behaves.

The following is an example of how the buffered file I/O could be configured:

Engine.BufferedFileIO:=True;
with Engine.BufferedFileIOSettings do
   begin
   { Lock files don't use buffering }
   Add('"*EDBConfig.EDBLck",1,1,0,False');
   Add('"*EDBDatabase.EDBLck",1,1,0,False');
   { Configuration and catalog files:
     64KB block size
     4MB buffer size
     0-second flush age (always write any dirty buffers during flush checks)
     Always force flush to disk call in OS }
   Add('"*EDBDatabase.EDBCfg",64,4,0,True');
   Add('"*EDBDatabase.EDBCat",64,4,0,True');
   { Smaller database table files:
     64KB block size
     32MB buffer size
     120-second flush age
     Don't force flush to disk call in OS }
   Add('"*Customer.EDBTbl",64,32,120,False');
   Add('"*Customer.EDBIdx",64,32,120,False');
   Add('"*Customer.EDBBlb",64,32,120,False');
   { Larger database table files:
     64KB block size
     128MB-256MB buffer sizes
     120-second flush age
     Don't force flush to disk call in OS }
   Add('"*Orders.EDBTbl",64,128,120,False');
   Add('"*Orders.EDBIdx",64,256,120,False');
   Add('"*Orders.EDBBlb",64,256,120,False');
   end;

Please see the Buffering and Caching topic in the SQL manual for more information on buffered file I/O in ElevateDB.

File Names and Extensions
The following file customziations can be made for the engine:

FileDescription
Configuration FileThe ConfigName property determines the root name (without extension) used by the engine for the configuration file. The extension used for the configuration file is determined by the ConfigExtension property. The location of the configuration file is determined by the ConfigPath property.
Configuration Lock FileThe ConfigName property determines the root name (without extension) used by the engine for the configuration lock file. The extension used for the configuration lock file is determined by the LockExtension property. The location of the configuration lock file is determined by the ConfigPath property, and the configuration lock file is hidden, by default.
Configuration Log FileThe ConfigName property determines the root name (without extension) used by the engine for the configuration log file. The extension used for the configuration log file is determined by the LogExtension property. The location of the configuration log file is determined by the ConfigPath property. The maximum size of the log file can be controlled via the MaxLogFileSize property. Log entries are added to the log in a circular fashion, meaning that once the maximum log file size ia reached, ElevateDB will start re-using the oldest log entries for new log entries. The default value is 1048576 bytes. Which types of logged events are recorded in the log can be controlled by the LogCategories property. By default, all categories of events are logged (Information, Warning, or Error).

Warning It is very important that all applications accessing the same configuration file use the same maximum log file size for the configuration log file. Using different values can result in log entries being prematurely overwritten or appearing "out-of-order" when viewing the log entries via the LogEvents Table.
Catalog FileThe CatalogName property determines the root name (without extension) used by the engine for all database catalog files. The extension used for the catalog files is determined by the CatalogExtension property. The location of the catalog file is determined by the path designated for the applicable database when the database was created. Please see the Creating, Altering, or Dropping Configuration Objects topic for more information.
Catalog Lock FileThe CatalogName property determines the root name (without extension) used by the engine for the database catalog lock files. The extension used for a catalog lock file is determined by the LockExtension property. The location of a catalog lock file is determined by the path designated for the applicable database when the database was created, and a catalog lock file is hidden, by default. Please see the Creating, Altering, or Dropping Configuration Objects topic for more information.
Backup FileThe BackupExtension property determines the extension used for all backup files created by ElevateDB. Please see the Backing Up and Restoring Databases topic for more information.
Update FileThe UpdateExtension property determines the extension used for all update files created by ElevateDB. Please see the Saving Updates To and Loading Updates From Databases topic for more information.
Table FilesThe TableExtension determines the extension used for all table files used by ElevateDB, the TableIndexExtension determines the extension used for all table index files, the TableBlobExtension determines the extension used for all table BLOB files, and the TablePublishExtension determines the extension used for all table publish files. Every table in an ElevateDB database has at least a table file and a table index file. If the table contains BLOB columns, then it will also have a table BLOB file. If the table is published, then it will also have a table publish file. The location of the table files is determined by the path designated for the applicable database when the database was created. Please see the Creating, Altering, or Dropping Configuration Objects topic for more information.

Server Configuration
There are no extra steps required in order to use the TEDBEngine component in ElevateDB as a client engine since the default value of the EngineType property is etClient. However, in order to use the TEDBEngine component in ElevateDB as an ElevateDB Server you will need to make some property changes before starting the engine.

The TEDBEngine component has several key properties that are used to configure the ElevateDB Server, which are described below in order of importance:

PropertyDescription
EngineTypeIn order to start the TEDBEngine component as an ElevateDB Server, you must set this property to etServer.
ServerNameThis property is used to identify the ElevateDB Server to external clients once they have connected to the ElevateDB Server. The default value is "EDBSrvr".
ServerDescriptionThis property is used in conjunction with the ServerName property to give more information about the ElevateDB Server to external clients once they have connected to the ElevateDB Server. The default value is "ElevateDB Server".
ServerAddressThis property specifies the IP address that the ElevateDB Server should bind to when listening for incoming connections from remote sessions. The default value is blank (""), which specifies that the ElevateDB Server should bind to all available IP addresses.
ServerPortThis property specifies the port that the ElevateDB Server should bind to when listening for incoming connections from remote sessions. The default value is 12010.
ServerThreadCacheSizeThis property specifies the number of threads that the ElevateDB Server should actively cache for connections. When a thread is terminated in the server it will be added to this thread cache until the number of threads cached reaches this property value. This allows the ElevateDB Server to re-use the threads from the cache instead of having to constantly create/destroy the threads as needed, which can improve the performance of the ElevateDB Server if there are many connections and disconnections occurring. The default value is 10.
ServerEncryptionPasswordThis property specifies the encryption password used by the ElevateDB Server for encrypting all communications with remote sessions. The default encryption password is 'elevatesoft'.

ElevateDB uses the Blowfish block cipher encryption algorithm with 128-bit MD5 hash keys for encryption. Please see the Encryption topic for more information.
ServerEncryptedOnlyThis property specifies whether all incoming connections from remote sessions should be encrypted or not. If this property is set to True, then all incoming connections to the ElevateDB Server that are not encrypted will be rejected with the error code 1105 (EDB_ERROR_ENCRYPTREQ). The default value is False.

Information If you intend to use encrypted connections to an ElevateDB Server over a public network then you should always use a different ServerEncryptionPassword from the default password.
ServerSessionTimeoutThis property specifies how long the server engine should wait for a request from a connected remote session before it disconnects the session. This is done to keep the number of concurrent connections at a minimum. Once a session has been disconnected by the server engine, the session is then considered to be "dead" until either the remote session reconnects to the session in the server, or the server removes the session according to the parameters specified by the ServerDeadSessionInterval,ServerDeadSessionExpiration, or ServerMaxDeadSessions properties (see below). A remote session may enable pinging via the TEDBSession RemotePing property in order to prevent the server engine from disconnecting the remote session due to the ServerSessionTimeout property.

The default value for this property is 180 seconds, or 3 minutes.
ServerDeadSessionIntervalThis property controls how often the server engine will poll the disconnected sessions to see if any need to be removed according to the ServerDeadSessionExpiration, or ServerMaxDeadSessions properties (see below). The default value is 30 seconds.
ServerDeadSessionExpirationThis property controls how long a session can exist in the server in a disconnected, or "dead", state before the server engine removes the session. This is done to prevent a situation where "dead" sessions accumulate from client applications whose network connections were permanently interrupted.

Information If all of the remote sessions accessing the server are using pinging via the TEDBSession RemotePing property, then you should set this property to the minimum value of 10 seconds so that sessions are removed as soon as they stop pinging the server.

The default value for this property is 300 seconds, or 5 minutes.
ServerMaxDeadSessionsThis property controls how many "dead" sessions can accumulate in the server before the server engine begins to remove them immediately, irrespective of the ServerDeadSessionExpiration property above. If the ServerMaxDeadSessions property is exceeded, then the server engine removes the "dead" sessions in oldest-to-youngest order until the number of "dead" sessions is at or under the ServerMaxDeadSessions property setting. The default value for this property is 64.
ServerAuthorizedAddressesThis property controls which IP addresses are authorized to access the server. This is commonly referred to as a "white list". There is no limit to the number of addresses that can be specified, and the IP address entries may contain the asterisk (*) wildcard character to represent any portion of an address.
ServerBlockedAddressesThis property controls which IP addresses are not allowed to access the server. This is commonly referred to as a "black list". There is no limit to the number of addresses that can be specified, and the IP address entries may contain the asterisk (*) wildcard character to represent any portion of an address.
ServerRunJobsThis property controls whether the server engine is allowed to schedule and run jobs that are defined in the Configuration database. If this property is set to True (the default), then the ServerJobCategory property below determines which category of jobs that the server will schedule and run.
ServerJobCategoryThis property controls which job category the server will schedule and run if the ServerRunJobs property is set to True. This property can contain any value, and the default value is blank (''), which indicates that the server engine can run all job categories. A job category is assigned to each job when it is created via the CREATE JOB DDL statement.
OnServerSessionEventAttach an event handler for this event in order to take certain actions when a remote session connects, reconnects, logs in, logs out, or disconnects from the server.
ServerTraceThis property controls whether the server will trigger the OnServerTrace event for every request and response to/from the server.

Warning Do not enable this property in production without being aware of the consequences. Enabling this property can result in a significant amount of overhead, depending upon how the OnServerTrace event is handled. In the ElevateDB Server project that is provided with ElevateDB (see below), enabling this property will generate a large number of trace files that can easily consume large amounts of disk space on a busy server.

ElevateDB comes with a default GUI ElevateDB Server project for Delphi called edbsrvr.dpr (Windows only). You can examine the source code of these projects to see how you would go about setting up a TEDBEngine component as an ElevateDB Server in a project. Both of these projects are also provided in compiled form with ElevateDB. You can find these servers in the \servers\edbsrvr subdirectories under the main ElevateDB installation directory, and you can find the source code to these servers in the \source subdirectory under each server's directory.

Starting the Engine
Once you have configured the engine using the above information, starting the engine is quite simple. All you need to do is set the Active property to True. The following shows an example of how one might configure and start an ElevateDB Server using the default global Engine function in the edbcomps unit (Delphi and Lazarus) or edbcomps header file (C++):

with Engine do
   begin
   ConfigPath:='\MyApplication';
   ServerName:='MyTestServer';
   ServerDescription:='My Test Server';
   { Only listen on this IP address }
   ServerAddress:='192.168.0.1';
   Active:=True;
   end;

Information You can use the TEDBEngine BeforeStart event to configure the TEDBEngine component before it is started. Likewise, you can use the AfterStart, BeforeStop, and AfterStop events to respond to the engine being started or stopped.
Image