ThreadedCluster

class ThreadedCluster @JvmOverloads constructor(threads: Int = processors, parts: Int? = null, flags: Flags = Flags.defaults(), textual: Boolean = false, lends: Boolean = true) : AutoCloseable

A distributed solver on the threads of this JVM: each node (the catalog, each worker) handles its messages one at a time, the nodes in parallel on threads threads. The theory is split into at most parts partitions if given, as many as the workers of the cluster and of the sites it is federated with otherwise (see site); the graph is labelled as the standard solver does with flags. The nodes share the terms of their messages; with textual, every message is written as text by its sender and read by its receiver instead, as between processes (see it.unibo.tuprolog.argumentation.parallel.message.MessageCodec).

Constructors

Link copied to clipboard
constructor(threads: Int = processors, parts: Int? = null, flags: Flags = Flags.defaults(), textual: Boolean = false, lends: Boolean = true)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

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

Link copied to clipboard

The flags of the solver, the initial ones those given: those set apply from the next evaluation on, the graph built anew, the links and the peers of the cluster kept

Link copied to clipboard
val id: String

The identifier of the site of the cluster, as the others know it

Link copied to clipboard

The name of the site of the cluster, as its beacons tell the sites nearby: the name of its host by default

Link copied to clipboard

The sites heard on the local network, not linked to this cluster (see discover)

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 the cluster, on the thread that saw it

Link copied to clipboard

The sites the cluster is federated with

Link copied to clipboard

Whether the sites linking to this cluster must present its code, or the token of a pairing made with it: refused otherwise, and after a few wrong codes from an address its codes are refused for a while

Link copied to clipboard
val site: Site

The site of the cluster, running a worker on each thread: to federate it with others, through its links

Link copied to clipboard

The cluster as a solver of arg2p: any goal, its solutions and their graphs, the answers of queries. The goals of several callers are solved in turn by the catalog, each solved again from its start when another one was solved since its last solution.

Link copied to clipboard

What the federation does, as the cluster knows it: the sites, and the last evaluation it answered (see Site.stats)

Functions

Link copied to clipboard
fun add(clause: String)

Adds clause, as Prolog text, to the theory

Link copied to clipboard
open override fun close()

Closes the links to the other sites, and stops the threads

Link copied to clipboard
fun connect(uri: String, code: String? = null)

Federates the cluster with the site listening at uri (ws://host:port), presenting code if it requires one

Link copied to clipboard
fun discover(beaconPort: Int = Beacons.PORT, requireCode: Boolean = false)

Federates the cluster with the clusters of the local network that discover the others as well, as they come (see Beacons): it listens (on an ephemeral port, if it did not already), and its beacons go to beaconPort. With requireCode (see requiresCode), the clusters heard are nearby alone, linked to once paired by hand (pair), and linked again with no code from then on.

Link copied to clipboard
fun listen(port: Int = 0, host: String = "0.0.0.0"): Int

Accepts the links of other sites (on any platform) over WebSockets, on port of host (an ephemeral port for 0): the port taken

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
fun pair(site: String, code: String)

Links this cluster to site, nearby, presenting code: the two paired, linked again with no code while they run; an Arg2pException if it refuses the code (or no site nearby is site)

Link copied to clipboard
fun reset()

Forgets the theory

Link copied to clipboard
fun serve(pages: (path: String) -> StaticContent?)

Serves pages over plain HTTP on the port the cluster listens on (see WebSocketLinks.pages): the page a GET of a path is answered with, none (null) for a 404

Link copied to clipboard

The arguments for statement, as Prolog text, by label: the evaluations of several callers run in parallel