Navigation


Tutorials


General concept

Computation is represented by set of agents, which can create new agents and send results to each other. Agent is an object, which means that it has a state and behaviour. Agents' broker is a component which manages the agents - it mediates in sending agents and results. Agents make their computations on workers, which make their resources accessible to agents. Among the resources are services. At the moment there are two services: caching results in RAM and making operations on agents' broker.

Every agent is unambiguously identified by identifying string (identString). In agents' broker, there can be only one agent with given identifying string at the same time.

Defining parallel computing in this framework lies mainly in dividing computations to pieces of computation, represented by agents. These pieces can be defined statically (we know how many agents there are from the beginning) or dynamically (agents can create new agents).

Description

AgentBroker interface describes agents' broker service, typically implemented by queues' broker. The interface is divided into two subinterfaces in order to differentiate in what way the broker is used. Available operations are: transaction service, sending an agent with possible priority, fetching an agent, sending results produced by this agent and receiving results produced for this agent.

CacheService interface describes caching of results service. The results can be any Java objects and they are identified by any Java object assuming correct implementation of hashCode(). Possible implementations: storing cache as hashmap in worker's memory, using distributed-cache server in memcached style.

Abstract class Agent describes an agent and provides default implementation of strings, which unambiguously identify the agents, and implementation of storing references to services required by agent: AgentManager and CacheService. Agent uses CacheService to remember the results of computations/database readouts. However, it has to be noticed, that one CacheService can be used by multiple agents. Agent uses AgentManager to:

  • send subagent
  • send results of his own computations and/or his continuation.
  • receive the subagents' results.

Agent is created by a constructor Agent(String identString). If identString equals null, then the constructor creates proper identifying string (returned by getIdentString() method). Default implementation of identifying strings uses UUID generator. Alternatively, string can be passed (e.g. may originate from another agent, the continuation of which we implement).

Worker is the class representing "the place of computation", without any public methods. Worker uses AgentBroker to fetch agents, injects them proper implementations of AgentBroker and CacheService, and finally activates the agent - execute() method.

Workers' launching

Default worker is implemented in class pl.gasps.ab.workers.WorkerSingleThreaded. Function main of that class uses spring context in order to fetch implementation of services defined for HOG (Higher Order GASPS).

In case of launching other algorithms than HOG (Higher Order GASPS), the class has to be instanced, proper services have to be injected (with set... methods), and run() method must be executed.

In order to initialize computations you have to send initial agents to the agents' broker.

UmlDoc