edu.vub.at.actors.natives
Class DiscoveryManager

java.lang.Object
  extended byedu.vub.at.actors.natives.DiscoveryManager

public final class DiscoveryManager
extends java.lang.Object

The DiscoveryManager is responsible for coupling subscriptions to corresponding publications.

Author:
tvcutsem

Nested Class Summary
static class DiscoveryManager.Publication
          Small container class that represents an entry in the publications list.
static class DiscoveryManager.Subscription
          Small container class that represents an entry in the subscriptions list.
 
Field Summary
private  java.util.LinkedList publications_
          A list of Publication objects that represent locally exported service objects.
private  java.util.LinkedList subscriptions_
          A list of Subscription objects that represent local subscription handlers.
 
Constructor Summary
DiscoveryManager()
           
 
Method Summary
 void addLocalPublication(DiscoveryManager.Publication pub)
          A new local publication: - is stored locally - is checked against local subscriptions, which fire immediately - is broadcast to all currently connected members (done by VM)
 void addLocalSubscription(DiscoveryManager.Subscription sub)
          A new local subscription: - is stored locally - is checked against local publications, which may cause the subscrption to fire immediately - is broadcast to all currently connected members (done by VM)
private  void checkLocalPublishers(DiscoveryManager.Subscription sub)
          When a new subscription is added locally, it is first checked whether this subscription can already be satisfied by some local publications on this VM (but from different actors)
 void deleteLocalPublication(DiscoveryManager.Publication pub)
          A deleted local publication is simply deleted locally.
 void deleteLocalSubscription(DiscoveryManager.Subscription sub)
          A deleted local subscription is simply deleted locally.
 java.util.Set getAllLocalSubscriptionTopics()
           
 java.util.Set getLocalPublishedServicesMatching(ATStripe topic)
          Returns all local publications matching the given topic.
private  void notify(ATObject handler, ATObject service)
          Performs handler<-apply([ service ])
private  void notifyLocalSubscribers(DiscoveryManager.Publication pub)
          When a new publication is added locally, it is first checked whether this publication can already satisfy some outstanding subscriptions on this VM (but from different actors)
 void notifyOfExternalPublication(ATStripe pubTopic, ATObject remoteService)
          When a remote VM hears the request of the local VM for services it requires, it returns its own matching services, using a CMDJoinServices command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publications_

private final java.util.LinkedList publications_
A list of Publication objects that represent locally exported service objects.


subscriptions_

private final java.util.LinkedList subscriptions_
A list of Subscription objects that represent local subscription handlers.

Constructor Detail

DiscoveryManager

public DiscoveryManager()
Method Detail

addLocalPublication

public void addLocalPublication(DiscoveryManager.Publication pub)
A new local publication: - is stored locally - is checked against local subscriptions, which fire immediately - is broadcast to all currently connected members (done by VM)


deleteLocalPublication

public void deleteLocalPublication(DiscoveryManager.Publication pub)
A deleted local publication is simply deleted locally. No further actions are required because remote VMs do not cache publications.


addLocalSubscription

public void addLocalSubscription(DiscoveryManager.Subscription sub)
A new local subscription: - is stored locally - is checked against local publications, which may cause the subscrption to fire immediately - is broadcast to all currently connected members (done by VM)


deleteLocalSubscription

public void deleteLocalSubscription(DiscoveryManager.Subscription sub)
A deleted local subscription is simply deleted locally. No further actions are required because remote VMs do not cache subscriptions.


getLocalPublishedServicesMatching

public java.util.Set getLocalPublishedServicesMatching(ATStripe topic)
Returns all local publications matching the given topic. This method is used when a remote VM has broadcast a subscription request or when two VMs discover one another.

Returns:
a Set of Packet objects representing the serialized form of objects published under a topic matching the argument topic.

getAllLocalSubscriptionTopics

public java.util.Set getAllLocalSubscriptionTopics()
Returns:
a Set of Packet objects denoting the serialized form of all topics for which a local subscription is still open.

notifyOfExternalPublication

public void notifyOfExternalPublication(ATStripe pubTopic,
                                        ATObject remoteService)
When a remote VM hears the request of the local VM for services it requires, it returns its own matching services, using a CMDJoinServices command. Via this command, the local discovery manager is notified of external matches.

Parameters:
remoteService - the remote service matching the topic

notifyLocalSubscribers

private void notifyLocalSubscribers(DiscoveryManager.Publication pub)
When a new publication is added locally, it is first checked whether this publication can already satisfy some outstanding subscriptions on this VM (but from different actors)


checkLocalPublishers

private void checkLocalPublishers(DiscoveryManager.Subscription sub)
When a new subscription is added locally, it is first checked whether this subscription can already be satisfied by some local publications on this VM (but from different actors)


notify

private void notify(ATObject handler,
                    ATObject service)
Performs handler<-apply([ service ])