XROAD
Конфигурирование ноды

Основная конфигурация

Каждая нода должна иметь xml конфигурацию и соотвествующую ей схему валидации xsd Пример:

robot1.xml:

<?xml version="1.0"?>
<config>
<node
log_level="debug"
/>
</config>

robot1.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="node.xsd"/>
<xs:element name="config">
<xs:complexType>
<xs:sequence>
<xs:element name="node" type="node_type" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Корневым тэгом должен быть всегда тэг <config>, который, в свою очередь, должен содержать обязательный тэг <node>, полное описание которого можно найти в node.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="common.xsd"/>
<xs:simpleType name="log_level_type">
<xs:restriction base="xs:string">
<xs:pattern value="trace|debug|info|notice|warning|error"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="node_status_type">
<xs:restriction base="xs:string">
<xs:pattern value="online|offline|DEAD"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="alarm_type">
<xs:restriction base="xs:string">
<xs:pattern value="(all|none|(error|warning|notice)(\s*,\s*(error|warning|notice))*)"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="node_name_type">
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:maxLength value="32" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="group_name_type">
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:maxLength value="32" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="config_name_type">
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:maxLength value="32" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="logger_name_type">
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:maxLength value="32" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="posix_queue_link_type">
<xs:attribute name="msgsize_max" type="non_zero_integer_type" default="2048" use="optional" />
<xs:attribute name="max_msg" type="non_zero_integer_type" default="10000" use="optional"/>
</xs:complexType>
<xs:complexType name="shm_link_type">
<xs:attribute name="size" type="non_zero_integer_type" default="10485760" use="optional" />
</xs:complexType>
<xs:complexType name="node_type">
<xs:sequence>
<xs:element name="link" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="posix_queue" type="posix_queue_link_type"/>
<xs:element name="shm_queue" type="shm_link_type"/>
</xs:choice>
<xs:element name="preopen" minOccurs="0" maxOccurs="1" >
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="0" maxOccurs="unbounded" >
<xs:complexType>
<xs:attribute name="id" type="non_zero_integer_type" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="flush" type="xs:boolean" default="false" use="optional"/>
<xs:attribute name="read_count" type="xs:integer" default="-1" use="optional" /> <!-- count of read messages at once, -1 - all messages read at once -->
</xs:complexType>
</xs:element>
<xs:element name="loggers" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="logger" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="logger_name_type" use="required"/>
<xs:attribute name="log_level" type="log_level_type" use="optional"/>
<xs:attribute name="alarm" type="alarm_type" default="error,notice" use="optional"/>
<xs:attribute name="display_name" type="logger_name_type" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dll_map" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="fn" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="non_empty_string_type" use="required"/>
<xs:attribute name="map_to" type="non_empty_string_type" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="wait_timeout_ms" type="xs:integer" default="-1" use="optional" />
<xs:attribute name="log_level" type="log_level_type" default="info" use="optional" />
<xs:attribute name="log_rotate" type="xs:boolean" default="true" use="optional" />
<xs:attribute name="log_buffer_size" type="non_zero_integer_type" default="1048576" use="optional" />
<xs:attribute name="log_thread_cpus" type="xs:string" default="" use="optional" />
<xs:attribute name="log_thread_timeout_ms" type="xs:integer" default="10" use="optional" />
<xs:attribute name="redirect_io" type="xs:boolean" default="false" use="optional" />
<xs:attribute name="alarm" type="alarm_type" default="error,notice" use="optional" />
<xs:attribute name="dll" type="non_empty_string_type" default="${XROAD_ROOT_DIR}/lib/libdll.so" use="optional" />
</xs:complexType>
</xs:schema>

тэг <node>, может содержит следующие атрибуты:

  • wait_timeout_ms - необязательный. Определяет время ожидания событий для xroad_node_receive. Если равен -1, то ожидание бесконечно.
  • log_level - необязательный. Определяет уровень логирования для логгера по умолчанию. По молчанию info
  • log_rotate - необязательный. Определяет нужно ли создавать новый лог файл при смене даты в 00:00. По умолчанию включено
  • log_buffer_size - необязательный. Определяет размер буфера thread логгера, если он используется
  • log_thread_cpus - необязательный. Определяет маску CPU для thread логгера
  • log_thread_timeout_ms - необязательный. Определяет поллинг таймаут для thread логгера
  • redirect_io - необязательный. Определяет нужно ли перенаправлять потоки в stdout, stderr в файл. Если включено, то в рабочей директории ноды создаются файлы stdout, stderr в которые будет вестись запись. По умолчанию выключено.
  • alarm - устаревший аттрибут теперь используется alaram_filter.
  • alarm_filter - необязательный. Определяет типы сообщений по которым будут сгенерированы алармы, по умолчанию error, notice.
  • dll - необязательный. Определяет путь к библиотеке роутинга. По умолчанию config/libdll.so

Конфигурация логгеров

Помимо всего, в <node> можно конфигурировать логгеры создаваемые при помощи xroad_logger_get метода:

<?xml version="1.0"?>
<config>
<node log_level="debug">
<loggers>
<logger name="mdata" log_level="error" alarm="true" />
<logger name="order" log_level="trace" alarm="false" display_name="ord" />
</loggers>
</node>
<mdata_engine/>
<app mdata_instr="SBER.TQBR" order_instr="SBER.TQBR" account="S01-00000F00" client_code="1" />
</config>

В строках 4-7 задается конфигурация логгеров mdata и order. Каждый из логгеров имеет свой уровень логирования, устанавливает послылать алармы или нет. Каждому логгеру так же можно определить display_name, т.е. это имя которое будет записано в лог файл вместо имени самого логгера. Все атрибуты кроме name опциональны. В таком случае, берутся параметры основного логгера.