Title: AgentOS Kernel
1AgentOS Kernel
2Topics
31.AgentOS Kernel Overview
AgentOS Kernel Overview
41.1. AgentOS Kernel Functionality
AgentOS kernel Overview
- Provides access to system services
- directory service, registry, etc ( to be
discussed in service model). - Enables network-wide communication between agents
- allows syn/asyn message sending, active/passive
message receiving, etc (to be discussed in event
model). - Monitors network connection
- accepts agents from other nodes over the AgentOS
network (to be discussed in Kernel class).
51.2. Kernel Structure
AgentOS kernel Overview
61.3. Kernel Components
AgentOS kernel Overview
- Classes required to run the AgentOS kernel
- AgentOS Class
- to start the AgentOS kernels functionality ( to
be discussed in the demonstration). - Kernel Class
- responsible for providing access to system
services and the system-wide event exchange. - ServiceEnum Class
- responsible for managing the list of available
services, and creates instances of service
providers as agents request them. - Eventpool Class
- Provides a communication mechanism between agents
within the same node.
7Topics
82. Kernel Class
- Loaded by the AgentOS class to start the AgentOS
kernel services. - Functions
- starts the event pool to allow message exchange
between agents. - loads the service agents.
- accepts agents migrating from other nodes.
92.1. Kernel Class Definition
Kernel Class
- Member Variables
- protected AgentOSConfig m_theConfig
- The instance of an AgentOSConfig class used in
AgentOS - protected ServiceEnum m_theServEnum
- The global ServiceEnum object
- protected ServerSocket m_sockListener
- The server socket used to listen to clients
- protected ThreadGroup m_tgSysContext
- Thread group of all system contexts
- protected ThreadGroup m_tgAgentContext
- Thread group of all normal contexts
- protected EventPool eventPool
- The instance of the event pool.
102.1. Kernel Class Definition
Kernel Class
- Member Functions
- public Kernel()
- Setup the event pool.
- boolean initOS (AgentOSConfig Config)
- Setup ListernerSocket to allow incomming
connections. - void run()
- continuously waits for agents migrating from
other nodes. - public void startAgent(URL agentURL) throws
Exception - Starts an incoming agent.
- boolean setupListenerSocket()
- Creates a ServerSocket instance used to listen
to clients (agents).
112.2. Kernel Class Implementation
Kernel Class
- The constructor of the Kernel class will start
the EventPool to handling message exchange among
agents - public Kernel()
-
- super("kernel thread")
- //start the event pool here
- eventPool new EventPool()
-
122.2. Kernel Class Implementation
Kernel Class
- Initialize the kernel by loading the services and
setting up the socket listener -
- public boolean initOS(AgentOSConfig config)
- m_theConfig config
- m_theServEnum m_theConfig.m_seServices
- // set up the socket to listen to
clients - setupListenerSocket()
- // load the standard services into
their agent contexts - loadServices()
- return true
-
132.2. Kernel Class Implementation
Kernel Class
- Run the Kernel thread
- public void run()
- while (true)
- // waiting for agents migrating from other
nodes - Socket sockClient m_sockListener.accept()
- //create the agent on this node
- ContextLoader cl new ContextLoader(this,
null, sockClient) - //start the agent on this node
- cl.start()
-
-
142.2. Kernel Class Implementation
Kernel Class
- Other Functions
- public void startAgent(URL agentURL) throws
Exception - //create context using the agent class
- AgentContext context new AgentContext(this,ag
entURL) - context.initAgent()
- context.start()
-
- public int getPort()
- return m_theConfig.m_nPort
-
152.2. Kernel Class Implementation
Kernel Class
- Other Functions
- protected boolean loadServices()
- return true // Currently not handling services
-
- protected boolean setupListenerSocket()
- m_sockListener new
ServerSocket(m_theConfig.m_nPort)
16Topics
173. Service Model
- Defines the way that agents can request services
- Three components
- ServiceEnum Class
- manages the services available on the node
- service implementers (under construction)
- special agents that provide services to other
agents - must register to the ServiceEnum to be accessed
by other agents - service providers (under construction)
- interfaces between serving agents and requesting
agents - Each service implementer class exposes its
services through one service provider interface.
183.1. ServiceEnum Class
Services Model
- Manages the list of services available on the
system. - standard services basic services provided by the
kernel, such as directory service, registry
service. - Extended services other services.
- Keeps track of the service implementers that have
been instantiated. - Creates an instance of the corresponding service
provider when an agent requests the service of a
service implementer.
193.1.1. ServiceEnum Class Definition
Services Model
- Member Variables
- protected final String strDefExtServiceCount
"0" - protected final String strDefStdServiceRoot
"stdservices" - protected final String strDefExtServiceRoot
"extservices" - default values for the number of services, root
directory to find standard and extended services. - protected int m_nExtServiceCount
- protected int m_nStdServiceCount
- number of extended and standard services.
- protected String m_strExtServiceRoot
- protected String m_strStdServiceRoot
- the root directory to find extended and standard
services. - protected String m_strStdServices
"Directory", "Registry", "RunningList", -
"HistoryList", "NodeNeighbor", - the name of standard services.
- int m_nTotalServiceCount 0
- The count of all registered services standard
and extended. - protected Vector m_vecServices null
- The list of ServiceInfo objects one for each
registered service.
203.1.1. ServiceEnum Class Definition
Services Model
- Member Functions
- public boolean loadServiceList(Properties p)
- Loads in the service list from the configuration
info. - p is a Properties object containing the set up
information specified in the configuration file. - protected boolean addExtService(String strInfo,
int nIndex) - Adds an extended service with given the
information and index. - strInfo contains information on the service as
specified in the configuration file. - nIndex the index at which the service is to be
stored.
213.1.2. ServiceEnum Class Implementation
Services Model
- Add a service to the kernel
- protected boolean addExtService(String strInfo,
int nIndex) - //get the name of the service
- int nIndexSep strInfo.indexOf(',')
- String strName strInfo.substring(0,
nIndexSep) - //determine if the service should be loaded when
kernel start - String strRequired strInfo.substring(nInde
xSep1, nIndexSep2) - int fRequired Integer.parseInt(strRequired
) - //store the information in a data structure
- ServiceInfo s new ServiceInfo(strName,
fRequired, ServiceInfo.SERVICEEXT) - //add this service to the service list
- m_vecServices.insertElementAt(s, nIndex
m_nStdServiceCount) - return true
-
22ServiceInfo Class
Services Model
- Stores the information related to each service
- Member Variables
- public final static int SERVICESTD 0
- public final static int SERVICEEXT 1
- protected String m_strName
- Name assigned to the service - used in
determining package file name - protected boolean m_fRequired
- If required the service is loaded at AgentOS
startup otherwise loaded on a need basis. - protected int m_nServiceType
- The type of service - standard or extended
- public int m_nInstanceID
- public AgentOSInstance m_instance
- The creation instance for the service implementor
agent.
233.2. Service Implementer
Services Model
- Implemented as an agent.
- Implements the actual services in its member
functions . - Provides its functionality by responding to
events received from service providers. - Loaded from local file system only, not through
network transfer. - Has a relaxed security model
- allowed more access to the file system (write,
delete, etc.). - Not mobile
- does not migrate from one node to another.
- Has both a human readable name and an unique
AgentOSID (to be discussed ).
243.3. Service Provider
Services Model
- An interface for agents to access services of the
service implementers. - A corresponding service provider accompanies each
service implementer. - Transform agent requests into events
understandable by their respective implementers. - Agents can not access the service implementer
directly. - potential benefits.
253.3.1. Service Provider Interfaces
Services Model
- Each service implementer must implement at least
the services defined in the following two
interfaces - Interface 1 services to be accessed by ordinary
agents. - public interface IServiceProvider
-
- // get information on the service
- public AgentOSID getServiceID()
- public String getServiceName()
- public boolean isExtendedService()
-
263.3.2. Service Provider Implementation
Services Model
- Interface 2 services to be accessed by system
components (such as the ServiceEnum object) - public interface IServiceProviderSys
-
- // get the IServiceProvider implementation
- public IServiceProvider getIServiceProvider()
- // set the service implementer id
- public setImplementerInstance(AgentOSInstanceID
theImplementer) -
273.4. Impementer / Provider Model Benefits
Services Model
- More secure without direct access by agents
- avoid breaches such as block of service (through
monopolizing by an agents) and corruption of data
(through illegal service requests). - Better module isolation
- an agent only needs the service provider, not the
implementer, at the time of compilation. - Favors transaction oriented services
- otherwise, a single service implementer has to
maintain a state for each agent that is using the
service.
283.5. Create a Service - Step 1
Services Model
- Create a new service provider by extending the
IServiceProvider interface. - Declare the functions that will be implemented.
- Do not implement the functions.
- Example create an IDirectoryServiceProvider
- public interface IDirectoryServiceProvider
extends IServiceProvider -
- // methods specific to the Directory Service.
- Method_A(...)
- Method_B(...)
-
293.5. Create a Service - Step 2
Services Model
- Create a new service implementer which implements
the functions defined in the service provider. - Implement the functions defined in the service
provider. - Example create a DirectoryServiceProvider
- public class DirectoryServiceProvider implements
IDirectoryServiceProvider,
IServiceProviderSys - // implement the methods in IDirectoryServiceProv
ider - // and IServiceProviderSys
- Method_A()
- Method_B()
- ...
303.6. Standard Services(to be constructed)
Services Model
- Services provided by the AgnetOS kernel
- AgentOSID Generator IAgentOSIDGenServiceProvider,
"AgentOS.AgentOSIDGen" - Provides agents with the ability to create new
unique identifiers. This can be used in creating
new agents by agents themselves. - Registry IRegistryServiceProvider,
"AgentOS.Registry" - The Registry Service provides access to the
registry, which is a list of categorized agents.
- RunningList IRunningListServiceProvider,
"AgentOS.RunningList" - The RunningList Service provides a list of agents
currently active on the node. This enables agents
to discover other agents to communicate with
(using events).
313.6. Standard Services(to be constructed)
Services Model
- History IHistoryServiceProvider,
"AgentOS.History" - Provide a listing of agents that have been
activated on the node, and their source node and
their destination node, if the agent had migrated
. - The History can be used in conjunction with the
Running List to implement an efficient agent
search algorithm. - Directory IDirectoryServiceProvider,
"AgentOS.Directory" - The Directory is a list of all active agents
within the AgentOS network. - The Directory Service can search the AgentOS
network for a specified agent. - Agents can communicate with other agents
regardless of their location.
323.6. Standard Services(to be constructed)
Services Model
- Agent Package Factory IAgentPkgFactoryServiceProv
ider, "AgentOS.AgentPkgFactory" - Allows agents to create new agent packages from
Java source code. - Node Information IAgentOSNodeInfoServiceProvider,
"AgentOS.NodeInfo" - Provides means for agents to query their current
location. - It allows access to standard system information
such as the type of operating system , user name,
and to AgentOS specific information such as the
list of neighboring nodes etc.
33Topics
344. Event Model (under construction)
- Allows communication between
- Agents
- Service providers and their respective service
implementers. - Communication between agents on the same node
- The event is sent to and fetched from an event
pool by using event API of the AgentContext. - Communication between agents on different nodes
- The AgentContext of the source agent send an
Event agent to the node of the destination agent. - The Event agent exchanges information with the
destination agent though event pool. - The Event agent returns back to the source agent
and pass the message back to the source agent
through event pool.
354.1. Event Sending
Event Model
- Two modes
- Synchronous the event source is suspended until
the event listener responds to the event - Asynchronous the event source continues
execution, while the event is delivered and
processed by the event listener. - The Event can be send to a certain agent, or
broadcast to a set of agents.
364.2. Event Listening
Event Model
- Two modes
- Active the event listener requests an event of
specified type, and remains blocked until the
event arrives. - Passive the event listener informs the event
pool of its interest in a certain kind of event,
and passes a callback function that the event
pool can invoke when that event happens.
374.3. Event Model Advantages
Event Model
- Uniform
- allows communication between agents on the same
node and across nodes using the same API and same
agent code. - Scalable
- different modes for different purposes.
- Flexible
- allows agents to define the format of the
messages used.
384.4 Eventpool Class
Event Model
- Each AgentOS system contains a single EventPool.
- The EventPool provides both message broadcasting
and point-to-point communication among agents
within the same node. - The EventPool supports multiple forms of
event-based communication as discussed. - It relies on the unique identification to
identify each agent in the network.
394.4.1. Eventpool Class Description
Event Model
- Member Variables
- private PublicForum publicForum
- the messages here are for all agents
- private Hashtable privateForums
- a list of private forums for two agents to
exchange messages - Member Functions
- public EventPool()
- create a public and a hash table to store
private forums - public PublicForum getPublicForum()
- return the instance of the public forum
- public PrivateForum createPrivateForum(int
session) - create a private forum on request
- public PrivateForum getPrivateForum(int session)
- get the private forum specified by the session
number
404.4.2. Eventpool Class Implementation
Event Model
- Eventpool Constructor
- create a public forum
- create a hash table to store private forums
- public EventPool()
-
- //create a public forum
- publicForum new PublicForum()
- //create a hash table to store the list of
private forums - privateForums new Hashtable()
-
414.4.2. Eventpool Class Implementation
Event Model
- Create a private forum with a given session
number for message exchange between two agents. - public PrivateForum createPrivateForum(int
session) - //create a private forum
- PrivateForum pf new PrivateForum(session)
- //put this forum into the hash table
- Integer i new Integer(session)
- privateForums.put(i, pf)
- return pf
-
424.4.2. Eventpool Class Implementation
Event Model
- Get the public forum
- public PublicForum getPublicForum()
-
- return publicForum
-
- Get the private forum with a certain session
number - public PrivateForum getPrivateForum(int session)
- Integer i new Integer(session)
- // return the private forum with the given
session number - return (PrivateForum)privateForums.get(i)
43Topics
445. Unique Naming Space
Unique Naming Scheme
- Provide unique identifiers for both static
objects (such as agent classes) and active
objects (such as instances of agents) in the
AgentOS network. - This uniqueness is achieved using two
identifiers - AgentOSID
- a static ID that is assigned to static objects
when they are created. - AgentInstanceID
- a dynamic ID that is assigned to dynamic objects
when they are created.
455.1. AgentOSID Class
Unique Naming Scheme
- Creates globally unique identifiers --AgentOSID
- The AgentOSID guarantees uniqueness of all static
objects. - It is generated using a combination of a hash
code that is unique to each Java Virtual Machine,
a network address, a time stamp and a sequential
counter (represented in hexadecimal number
format).
465.2. AgentInstanceID Class
Unique Naming Scheme
- Creates globally unique identifiers
--AgentInstanceID - Guarantees the uniqueness of dynamic objects and
is assigned on a per-instance basis. - It is based on static AgentOSID, the network
address of the node where the object was first
created and the time of creation. - The AgentInstaceID guarantees the uniqueness of
dynamic objects - multiple instances of the same static ID result
in different instance IDs.