dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches

A class that allows to set JVM system properties and get the values of JVM system properties. More...

#include <System.hpp>

Static Public Member Functions

static bool setProperty (StringParam key, StringParam value)
 Sets the JVM system property indicated by the specified key.
template<typename Properties>
static void setProperties (Properties &&properties)
 Sets the JVM system properties to the Properties argument.
static std::string getProperty (StringParam key)
 Gets the system property indicated by the specified key.
static bool setIsolateArguments (std::vector< std::string > arguments)
 Sets the arguments that the Graal isolate is created with, for example -Dmy.prop=value or -Xmx512m.
static RuntimeStatistics getRuntimeStatistics ()
 Reads the runtime statistics of the Graal isolate of the library and of its process: the heap, the garbage collections, the threads, the CPU time of the process and the uptime.
static std::optional< std::string > getBuildInfo (StringParam key)
 Returns a value that tells how the Graal Native SDK library was built and what runs it: the version of QDS, the vendor of the runtime, the target machine and the garbage collectors (the BUILD_INFO_ keys).

Static Public Attributes

static constexpr char BUILD_INFO_QD_VERSION [] = "qd_version"
 The key of getBuildInfo() for the version of QDS that the Graal Native SDK library is built with, e.g. 3.358.
static constexpr char BUILD_INFO_VENDOR [] = "vendor"
 The key of getBuildInfo() for the vendor and the version of the runtime that the Graal Native SDK library is built with, e.g.
static constexpr char BUILD_INFO_MARCH [] = "march"
 The key of getBuildInfo() for the target machine of the build of the Graal Native SDK library (-march of native-image), e.g.
static constexpr char BUILD_INFO_GC [] = "gc"
 The key of getBuildInfo() for the garbage collectors of the runtime of the Graal Native SDK library, separated by , .

Detailed Description

A class that allows to set JVM system properties and get the values of JVM system properties.

Member Function Documentation

◆ getBuildInfo()

std::optional< std::string > System::getBuildInfo ( StringParam key)
static

Returns a value that tells how the Graal Native SDK library was built and what runs it: the version of QDS, the vendor of the runtime, the target machine and the garbage collectors (the BUILD_INFO_ keys).

A tool records them next to its measurements, as the NetTest summary does (tool.qd_version and tool.build).

An unknown key, also an empty one, is not an error: the result is empty, as it is for a value that the library does not know (BUILD_INFO_MARCH of an iOS library). The values are for display and records: their text may change with the runtime or the build, so a program must not parse them. A newer SDK may add keys: they are read with the same function. The call creates the isolate if it is not created yet.

std::cout << System::getBuildInfo(System::BUILD_INFO_QD_VERSION).value_or("unknown") << '\n';
static constexpr char BUILD_INFO_QD_VERSION[]
The key of getBuildInfo() for the version of QDS that the Graal Native SDK library is built with,...
Definition System.hpp:172
static std::optional< std::string > getBuildInfo(StringParam key)
Returns a value that tells how the Graal Native SDK library was built and what runs it: the version o...
Definition System.cpp:93
Parameters
keyThe key (UTF-8 string), one of the BUILD_INFO_ keys.
Returns
The value (UTF-8 string), or an empty optional.
Exceptions
InvalidArgumentExceptionif the key is not valid UTF-8.
RuntimeExceptionif the Graal Native SDK library does not support the build info (the message names the feature and the version of the library).
JavaExceptionif the Graal Native SDK failed to read the value.
GraalExceptionif the creation of the isolate failed (Isolate arguments) or the library is shut down (dxfcpp::shutdown()).

◆ getProperty()

std::string System::getProperty ( StringParam key)
static

Gets the system property indicated by the specified key.

Parameters
keyThe name of the system property (UTF-8 string).
Returns
The value of a JVM system property (UTF-8 string), or an empty string if the property is not set.
Exceptions
InvalidArgumentExceptionif the key is not valid UTF-8.
GraalExceptionif the creation of the isolate failed (Isolate arguments).

◆ getRuntimeStatistics()

RuntimeStatistics System::getRuntimeStatistics ( )
static

Reads the runtime statistics of the Graal isolate of the library and of its process: the heap, the garbage collections, the threads, the CPU time of the process and the uptime.

A value that the platform or the garbage collector does not give is -1, and the call still succeeds (see RuntimeStatistics).

Reading changes nothing: the counters are cumulative since the isolate started, and the caller computes the change between two calls. The first call initializes the sources and may take some milliseconds: call it once at start-up to take the cost out of a measurement. The call creates the isolate if it is not created yet.

Returns
The runtime statistics.
Exceptions
RuntimeExceptionif the Graal Native SDK library does not support the runtime statistics (the message names the feature and the version of the library).
JavaExceptionif the Graal Native SDK failed to read the statistics.
GraalExceptionif the creation of the isolate failed (Isolate arguments) or the library is shut down (dxfcpp::shutdown()).

◆ setIsolateArguments()

bool System::setIsolateArguments ( std::vector< std::string > arguments)
static

Sets the arguments that the Graal isolate is created with, for example -Dmy.prop=value or -Xmx512m.

Call it before the first call of the library that needs Java; it does not create the isolate itself. A repeated call replaces the arguments, an empty vector clears them. The DXFCPP_ISOLATE_ARGUMENTS environment variable adds arguments after these. The arguments, the variable and the errors: Isolate arguments.

Parameters
argumentsThe isolate arguments (UTF-8 strings).
Returns
true if the arguments are stored; false if the creation of the isolate has already started, then nothing changes.
Exceptions
InvalidArgumentExceptionif an argument contains a NUL character; the stored arguments do not change.

◆ setProperties()

template<typename Properties>
void System::setProperties ( Properties && properties)
inlinestatic

Sets the JVM system properties to the Properties argument.

Template Parameters
PropertiesThe properties' type (std::map, std::unordered_map etc).
Parameters
propertiesThe new system properties.
Exceptions
InvalidArgumentExceptionif a key or a value is not valid UTF-8; the properties before it stay set.
GraalExceptionif the creation of the isolate failed (Isolate arguments).

◆ setProperty()

bool System::setProperty ( StringParam key,
StringParam value )
static

Sets the JVM system property indicated by the specified key.

Parameters
keyThe name of the system property (UTF-8 string).
valueThe value of the system property (UTF-8 string).
Returns
true if the setting of the JVM system property succeeded.
Exceptions
InvalidArgumentExceptionif the key or the value is not valid UTF-8; the property does not change. For DXEndpoint::DXFEED_USER_PROPERTY and DXEndpoint::DXFEED_PASSWORD_PROPERTY the message names the offset, not the bytes of the value.
GraalExceptionif the creation of the isolate failed (Isolate arguments).

Member Data Documentation

◆ BUILD_INFO_MARCH

char System::BUILD_INFO_MARCH[] = "march"
staticconstexpr

The key of getBuildInfo() for the target machine of the build of the Graal Native SDK library (-march of native-image), e.g.

compatibility (the baseline CPU of the architecture) or x86-64-v3. The iOS libraries have no value.

◆ BUILD_INFO_VENDOR

char System::BUILD_INFO_VENDOR[] = "vendor"
staticconstexpr

The key of getBuildInfo() for the vendor and the version of the runtime that the Graal Native SDK library is built with, e.g.

GraalVM CE 25.0.1+8.1.