Introduction

This document covers the following topics:


Natural Subprogram Server Concept

A Natural Subprogram Server is a multi-user, multi-tasking application. It can host Natural sessions for multiple users and execute their requests concurrently.

The concept is based on the "serverized" Natural runtime system. Its architecture comprises a server front-end stub (NATRNPI subprogram server stub) that uses the Natural front-end to dispatch Natural sessions and to execute subprograms within these sessions.

The architecture basically consists of:

  • Front-end stub

    The NATRNPI stub is launched to initialize a Natural Subprogram Server. It listens for incoming requests and initializes a Natural session for executing the subprogram.

  • Front-end

    The front-end is called (together with the Natural runtime system) by the front-end stub for session initialization/termination and request execution.

  • Gateway module

    The NATGWNPI module provides for interaction between the Natural runtime system and the front-end stub. NATGWNPI is already included in the Natural nucleus and is called by the Natural runtime system to exchange the necessary request data.

  • Natural driver

    Natural is driven by the Natural Driver, NATOS / NATOSL.

    Note
    NATOSL is an extension of NATOS that supports IBM's Language Environment (LE). LE allows different programming languages to be used within a single application. Because the server is implemented in C and requires LE, the Natural front end must always include both NATOS and NATOSL.

  • Server monitor

    A monitor task allows the administrator to control the server activities and to terminate the entire server, etc.

NATRNPI Front-end Stub

NATRNPI is a multi-user and multi-tasking front-end stub, and it is launched to initialize a Natural Subprogram Server.

This document covers the following topics:

Stub Description

The task executing the server initialization, TMain, is the main listener which waits for incoming requests from the Natural OpenAPI Server. It owns a session directory to manage multiple clients (users) and their corresponding remote Natural sessions. TMain has the task to accept all incoming requests and to dispatch them to other subtasks (TWork). The process is as follows:

  • First, the Natural OpenAPI Server connects to TMain to establish a connection.

  • Next, TMain inserts the client into its session directory, attaches a new TWork subtask, and passes the connection to TWork.

  • TWork initializes a new Natural session, processes the request, replies the result to the client, terminates the Natural session, and terminates itself.

Each request is stateless. For each request, a separate Natural session is started. However, the session initialization is accelerated by cloning new sessions from a master session. At server initialization, a master session is initialized and kept in a user-independent state. For a new session, the master is just copied and connected with the user-ID of the request.

Worker Pool

It is expensive to create a new worker task for each request. It is possible to keep created workers in a pool to reuse them for successive requests. If the configuration variable WORKER_DELAY is set to a value greater than zero, a worker waits after request execution for the defined time in seconds. The worker pool automatically adjusts its size based on the server’s workload. When there are many parallel requests, the pool grows to handle the increased load. As the workload decreases, the pool shrinks accordingly.

Natural System Variables Used

Within a Natural OpenAPI Server session, the following Natural system variables are used:

  • *TPSYS contains SERVSTUB.

  • *DEVICE contains BATCH.

  • *SERVER-TYPE contains CALLNAT.

Natural I/O Handling

The called subprogram must not do any screen-io. If a screen-io happens, the server dumps the content of the screen to its trace file and cancels the screen-io.

Front-end

The Natural front-end required for a Natural Subprogram Server is a Natural batch front-end driver, which should be LE enabled. See sample installation jobs for details.

Gateway Module

The NATGWNPI gateway module is already included in the Natural nucleus.

Server Monitor

To enable the administrator to monitor the status of the Natural Subprogram Server, a monitor task is provided and is automatically initialized at server startup. Using the monitor commands, the administrator can control the server activities, terminate the entire server, etc. For more information, see Natural API Server > Natural Subprogram Server on z/OS > Operation > Monitoring the Natural API Server > Monitor Communication.

Product Interaction

The following graphic illustrates the interaction of the Natural OpenAPI Server with a Natural Subprogram Server.

Interaction of             Natural OpenAPI Server with Natural Subprogram Server

  1. Natural OpenAPI Server (the client) gets a REST call. It converts it into a proprietary protocol and sends it to the Natural Subprogram Server using the port number specified with the Natural OpenAPI Server.

  2. The Natural Subprogram Server initializes (clones) a Natural session using the Natural front-end you have specified with FRONTEND_NAME, the Natural Subprogram Server configuration parameter. In this example is NATOS.