Skip to content
Xi Software Request an evaluation

Clustering Xi-Text Printers

Patterns, classes and networked hosts, so a job is printed by whichever printer is in service

Xi-TextXi-Textnetworkingprintersspaddspchangesphaltsplistspstart

Several printers, on one host or on several, can print one body of work, so that a job is printed while any of them is out of service. Xi-Text does this with printer name patterns, class codes and networked hosts, and this article says how to set it up.

A job names a set of printers, and any idle member prints it

The printer a job is submitted to is a pattern. * matches any run of characters, ? one character and [a-c] one character in the range; letters match in either case. A job submitted with

spr -P 'acct-*' -f a4 invoice.txt

is printed by any printer whose name begins acct-. A job submitted with no printer is printed by any printer.

The scheduler gives a job to a printer when all of these hold:

  • the printer is idle;
  • the printer's name matches the job's pattern;
  • the printer's form type, up to its suffix, is the job's form type;
  • the printer's class code and the job's class code have a letter in common;
  • the job's size is within the printer's size range.

Every idle printer that meets them takes the next job that meets them, so a job to acct-* with four idle members is printed by one of the four and the next such job by another. The members share the work; one of them out of service leaves three.

Class codes group printers whatever their names

A class code is a set of letters, given as letters and ranges: A, AB, A-D. A printer is given its class code when it is added (spadd -C) and can be given another with spchange -C. A job is given its class code with spr -C; without the option it carries the submitting user's class code. The job's class code is reduced to the letters it shares with the user's own, so a user can only direct a job at printers within their class.

A class code groups printers whose names have nothing in common, and keeps apart printers whose names match the same pattern: acct-1 in class A and acct-2 in class B each take only jobs of their own class, whatever pattern the job names.

Printers on other hosts are members of the set

With a network licence, every host in the hosts file shares its jobs and its printers with the others. A job submitted on one host is printed on another host's printer when that printer is idle and matches it; the printing host proposes, the host holding the job confirms, and the job is printed there.

Hosts are entered with hostedit into /etc/xi/text-hosts, or into the file named by the HOSTFILE setting in /etc/xi/textconfig. Each entry carries the host's name, whether to probe it before connecting, whether the connection is made at start-up or by spconn, and the connection timeout. The hosts keep their connections alive with regular messages, and a host that stops answering within its timeout is treated as gone.

A printer is visible to the other hosts when it is marked network-wide, which is the state spadd -w gives it. spadd -s, or spchange -s on a halted printer, marks it local-only; spchange -w makes it network-wide again.

A printer that fails returns its job to the queue

A printer whose device stops answering goes to offline; a printer whose setup or network program fails goes to error. In either state the job it was printing is returned to the queue, and any other idle printer that matches the job prints it. The failed printer shows its state and the reason in splist and spq, and is started again with spstart once the device is back.

A host that stops answering takes its printers out of the set, and the jobs those printers were printing return to the queue on the hosts that hold them. A job is held on the host it was submitted on; when that host is out of service its jobs are printed when it returns.

The scheduler runs a program when a printer fails

When a printer on the local host goes to offline or error, the scheduler runs the program named by the SPPTRMSGS environment variable, with three arguments: the printer's name, its device and its description. The program is run with the scheduler's environment, which carries no PATH, so it names its own.

The scheduler is started by the xitext service, so the variable is set in a drop-in for the unit:

systemctl edit xitext
[Service]
Environment=SPPTRMSGS=/usr/local/sbin/ptr-alert

followed by a restart of the service. The program is run once for each failure; what it does is the site's choice. The following program brings a standby printer into service when a primary fails, so that the standby takes work only while a primary is down:

#!/bin/sh
# ptr-alert: called by the Xi-Text scheduler with printer, device, description.
PATH=/usr/local/bin:/usr/bin:/bin
export PATH
case "$1" in
acct-1|acct-2)
    spstart acct-standby
    ;;
esac
logger -t xitext "printer $1 ($2) needs attention: $3"

The standby is halted again with sphalt acct-standby when the primary is started.

Jobs arriving over the network

rspr -Q host submits from a machine that runs the Xi-Text client, and names the host that is to hold the job. Jobs arriving by LPD are received by xtlpd on the host it runs on, so each host that is to accept them runs its own receiver.

What to do

Build the set

  1. Give the printers names with a common prefix: acct-1, acct-2 on the first host, acct-3, acct-4 on the second.

  2. Add each on its own host with the same form type and class code, network-wide:

    bash spadd -w -C A -N -l 192.0.2.21 -D 'Accounts laser 1' acct-1 a4

    Ptrinstall creates the printer's setup files; spadd on its own adds the record.

  3. Enter each host in the other's hosts file with hostedit, and start Xi-Text on both.

  4. Start the printers with spstart, and confirm with splist on either host that all four show idle.

Submit to the set

Give the pattern as the printer, with the form type the printers carry:

spr -P 'acct-*' -f a4 invoice.txt

Users whose jobs always go to the set are given the pattern as their default printer with spuser, and then submit with no -P option.

Confirm the behaviour

  1. Halt one member with sphalt acct-1, submit a job to the pattern, and confirm with sqlist that it is printed by another member.
  2. Stop Xi-Text on one host with sstop, submit a job on the other to the pattern, and confirm that it is printed on the host that is up.
  3. Disconnect a printer's device while it is printing, and confirm with splist that it shows offline and with sqlist that the job is printed by another member. Reconnect the device and spstart the printer.

Managing Xi-Text Printer States and Operations

The eight states a printer can be in, what moves it between them, and the commands and spq keys that drive it

Diagnosing and Clearing the Xi-Text Printer error State

What puts a printer into error, the messages Xi-Text writes when it happens, and the one command that starts it again

All articles · Release notes · Contact support