Site

class Site(scheduler: Scheduler, workers: Int?, parts: Int? = null, flags: Flags = Flags.defaults(), lends: Boolean = true, textual: Boolean = false, introducible: Boolean = false, val id: String = newId()) : LinkListener

An instance of the distributed solver, on any platform: a catalog for a theory of its own, the workers it runs on scheduler (at most workers for a graph, null for no limit), and its peers, other sites on the links its transports give it (see Link), on this machine or another, whatever their platform.

The graph of its theory is built by its workers and by those its peers lend (if they do, see lends): the theory is split into as many parts as they can run together, or into parts if given, the parts placed on the sites in proportion to their workers. The nodes of the site share the terms of their messages, written as text only towards other sites (or always, with textual). A graph is built anew if a site running some of its workers leaves while it is built, or a link its messages went through closes; the workers it ran for a site that left are dropped.

A site may have delegates, sites working for it alone (the threads of a JS runtime, see delegate): it offers their workers with its own, and runs the workers it is given on them as well, its delegates reaching the other sites through it.

Sites opening links of their own (introducible, as browsers over WebRTC) are introduced to each other by the sites they are both linked to, which carry what they need to open the link (signal).

A site may require a code of the sites linking to it (requiresCode): one presenting it is paired with it, and presents the token of their pairing instead from then on, linked again with no code while the two run; one presenting another is refused, and after a few wrong codes from an address its codes are refused for a while.

Each graph built is a session of its site: the workers of a session, wherever they run, only hear from those of the same session, so that nothing of a graph given up reaches the next one.

The catalog of the site evaluates the statements of its clients (solve) and solves their goals as the standard solver does (see it.unibo.tuprolog.argumentation.parallel.cluster.ClusterSolver); stats tells what the federation does, as the site knows it.

Constructors

Link copied to clipboard
constructor(scheduler: Scheduler, workers: Int?, parts: Int? = null, flags: Flags = Flags.defaults(), lends: Boolean = true, textual: Boolean = false, introducible: Boolean = false, id: String = newId())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The code the sites linking to this one present, if it requires one: four digits, random

Link copied to clipboard

The flags of the solver of the catalog: those set apply from the next evaluation on, the graph built anew

Link copied to clipboard
val id: String
Link copied to clipboard

The name of the site, as its beacons tell the sites nearby (see Beacons)

Link copied to clipboard

The sites heard on the local network (see Beacons) that are not peers of this one

Link copied to clipboard
var onIntroduced: (site: String) -> Unit?

Called with a site opening links of its own this one is introduced to, if it opens such links as well

Link copied to clipboard
var onNearbyChanged: () -> Unit?

Called whenever the sites heard on the local network change

Link copied to clipboard
var onPeersChanged: () -> Unit?

Called whenever a site joins or leaves the peers of this one

Link copied to clipboard
var onSignal: (from: String, payload: String) -> Unit?

Called with what a site sent this one to open a link of their own (see signal)

Link copied to clipboard

The sites paired with this one (one presented the code of the other): linked again with no code while they run

Link copied to clipboard

The sites this one is federated with, its delegates included

Link copied to clipboard

Whether the sites linking to this one must present its code, or the token of a pairing made with it: refused otherwise. Its delegates and the links it opens are not checked.

Link copied to clipboard

What the federation does, as this site knows it: itself, its peers, the sites it reaches through them (those introduced to it, and those running workers of a graph it runs some of), and the last evaluation it answered

Functions

Link copied to clipboard
fun add(clause: String)

Adds clause, as Prolog text, to the theory

Link copied to clipboard
open override fun closed(link: Link)
Link copied to clipboard
fun delegate(link: Link)

link, just opened, leads to a delegate of this site: the site offers its workers, and runs workers on them

Link copied to clipboard
fun load(theory: String)

Replaces the theory with theory, as Prolog text

Link copied to clipboard

A new code, the one before refused from now on (the pairings made stay)

Link copied to clipboard
open override fun opened(link: Link)
Link copied to clipboard
open override fun received(link: Link, frame: String)
Link copied to clipboard
fun reset()

Forgets the theory

Link copied to clipboard
fun signal(to: String, payload: String)

Sends payload to to, a peer or a site this one was introduced to, to open a link of their own

Link copied to clipboard
fun solve(statement: String, reply: (EvaluationResponse) -> Unit)

Evaluates statement, as Prolog text: reply is given the arguments for it by label

Link copied to clipboard
fun stop()

Stops what the catalog evaluates for the clients of this site: their evaluations end at once, as stopped, and the graph being built for them is given up (the resolution under way interrupted, where it can be); the next ones are answered as before. Nothing is done if none is under way.