IKernelConfiguration

A list on a table, van Gogh

The kernel configuration service is the first service when starting the kernel. It establishes the node ID, reads the configuration from the various sources, and initializes the preferences and logging.

Get the kernel configuration

The service is fetched as a singleton from the service registry:

final IKernelConfiguration kc = CServiceRegistry.getInstance()
                                                .getService(IKernelConfiguration.class);

As always, make sure that the service starter of your package has a dependency on the IKernelConfiguration to ensure that the service already exists.

Name of the configuration

The name of the configuration. This name is usually the node ID, but it can be different. For example, the node ID of client nodes is often wildcarded, which is replaced with a random string to ensure unique node IDs. To avoid creating a configuration for each start of the client, this name is used for the configuration.

@NotNull String getName();

The type of node

You can get the type of node here.

@NotNull ETypeOfNode getTypeOfNode();

The node address

This method returns the node ID and the segment ID as the node address.

@NotNull CNodeAddress getNodeAddress();

The base path

If the base path is not configured, the current directory becomes the base directory. The base directory is important for the automatic determination of other directories. Thus, in the absence of explicit path specifications for config, storage, and log paths, corresponding subdirectories of the base directory are assumed.

@NotNull Path getBasePath();

The storage path

The storage directory is the directory where the node or plugins can store data. If no storage path is specified, the "storage" directory in the base path is assumed.

@NotNull Path getStoragePath();

The configuration path

The configuration directory is the directory where the node can find configuration files. If no storage path is specified, the "storage" directory in the base path is assumed.

@NotNull Path getConfigurationPath();

Start time of the node

Here the start time of the node is returned.

@NotNull LocalDateTime getStartTime();

License ID

The license ID is returned. A license ID is always necessary and available from sillysky for a fee.
If the node is operated non-commercially, the license ID "02abaff4-0b09-11e7-9850-6c626defb9c0" must be used.
The validity of the license can be checked at any time via the license check on this homepage.

@NotNull UUID getLicense();

The node description

The description of the node can be determined here.

@NotNull String getDescription();

Vendor

Here the provider of the node software is returned, usually sillysky .

@NotNull String getVendor();

The version of the kernel

The version of the kernel JAR can be read out in this way:

@NotNull CVersion getKernelVersion();

Preferences

The current configuration is stored in a hierarchical database using the JAVA Preference module. There are a number of methods for access.

The preferences are stored in hierarchical nodes. There are two subtrees: the SYSTEM nodes and the USER nodes. nyssr.net uses only the USER preferences. Preferences can be specified in absolute paths. For a node "XXX" in nyssr.net, the base node is "sillysky/nodes/XXX". This preference node is returned by the following method:

@NotNull Preferences getUserRoot();

A module "MMM" in the node "XXX" then has its own preference node. The path is "sillysky/nodes/XXX/MMM" and is returned by this method.

@NotNull Preferences getPreferences(@NotNull String aConfigurationName);

// usage:
final Preferences pref = kernelConfiguration.getPreferences("MMM");

If you want to use string properties, it is possible via the following method. It returns all properties of the desired module "MMM". Properties in sub-nodes are not taken into account.

@NotNull CStringProperties getSystemProperties(@NotNull String aConfigurationName);

// usage:
final CStringProperties sp = kernelConfiguration.getSystemProperties("MMM");

For a given preference node, you can also have all key-value pairs returned as StringProperties.

@NotNull CStringProperties readProperties(@NotNull Preferences aPreferences) throws BackingStoreException;

This method returns the names of all stored configurations.

@NotNull Collection<String> getConfigurationNames() throws BackingStoreException;

Completion of an address

Since the kernel configuration has the current node ID and the segment ID, you can have an incomplete target address supplemented by these.

@NotNull CTargetAddress completeAddress(@NotNull CTargetAddress aAddress);

nyssr.net - Innovative Distributed System