org.jgroups.service
Class AbstractService
java.lang.Object
org.jgroups.service.AbstractService
- MembershipListener
public abstract class AbstractService
extends java.lang.Object
AbstractService
is a superclass for all service implementations.
Each service has two communication channels: one for inter-service
communication with group memebership enabled, and one for client communication
witout group membership. This allows creation of full featured services with
replication and load balancing and light-weight clients that can call service
methods by sending specific messages.
- Roman Rokytskyy (rrokytskyy@acm.org)
void | block() - This method is called when service is supposed to stop sending messages
to channel until new view is installed.
|
Address | getAddress() - Get address of this service in service group.
|
String | getName() - Get name of this service.
|
boolean | isBlocked() - This method returns
true if inter-service communication
processes should temporarily stop sending messages to service channel.
|
boolean | isCoordinator() - Check if this service is a coordinator of service group.
|
protected void | setMessageListener(MessageListener listener) - Set message listener for service message channel.
|
void | start() - Start standalone thread that will run until explicitly stopped.
|
void | stop() - Stop standalone thread started with
start() method.
|
void | suspect(Address suspectedMember) - This method is called when a member of service group is suspected to
be failed.
|
void | viewAccepted(View view) - This method is called when new view is installed.
|
void | waitOnBlocked() - Stop current thread's execution until inter-service channel is unblocked.
|
blockMonitor
protected Object blockMonitor
blocked
protected boolean blocked
clientChannel
protected Channel clientChannel
members
protected LinkedList members
runThread
protected boolean runThread
serviceChannel
protected Channel serviceChannel
threadMonitor
protected Object threadMonitor
AbstractService
public AbstractService(Channel serviceChannel,
Channel clientChannel)
Main constructor to create services. It creates instance of service
class, registers
PullPushAdapter
for inter-service channel and
tries to retrive initial service state.
serviceChannel
- instance of Channel
class that will be
used for inter-service communication. This channel must provide group
membership service and reliable group multicast.clientChannel
- instance of Channel
class that will be used
for client-service communication. This channel should provide reliable
group multicast and unicast, but specific service implementation might
put weaker requirements.
block
public void block()
This method is called when service is supposed to stop sending messages
to channel until new view is installed. Services that use inter-service
communication should respect this method.
- block in interface MembershipListener
getAddress
public Address getAddress()
Get address of this service in service group.
getName
public String getName()
Get name of this service. Name of the service determines service type,
but not an instance. Instance of the service is uniquely determined
by
getAddress()
value.
- name of this service.
isBlocked
public boolean isBlocked()
This method returns true
if inter-service communication
processes should temporarily stop sending messages to service channel.
isCoordinator
public boolean isCoordinator()
Check if this service is a coordinator of service group.
true
if this service is a coordinator of service
group.
setMessageListener
protected void setMessageListener(MessageListener listener)
Set message listener for service message channel.
start
public void start()
Start standalone thread that will run until explicitly stopped. This
allows running this service as standalone process.
stop
public void stop()
Stop standalone thread started with start()
method. If no thread
were started this method does nothing.
suspect
public void suspect(Address suspectedMember)
This method is called when a member of service group is suspected to
be failed.
- suspect in interface MembershipListener
viewAccepted
public void viewAccepted(View view)
This method is called when new view is installed. We make local copy
of view members. If any other information is needed, it can be accessed
via getChannel()
method.
- viewAccepted in interface MembershipListener
view
- new view that was accepted.
waitOnBlocked
public void waitOnBlocked()
throws InterruptedException
Stop current thread's execution until inter-service channel is unblocked.
This is a service method to simplify development of channel management
in subclasses.
Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.