DVDRPDispatcher (Siena 2.0.4 API Documentation)
Date: 2015-05-17

siena

## Class DVDRPDispatcher

- java.lang.Object
- - siena.HierarchicalDispatcher
  - - siena.DVDRPDispatcher

- All Implemented Interfaces:
    java.lang.Runnable, Siena

      public class DVDRPDispatcher
      extends HierarchicalDispatcher
      implements Siena, java.lang.Runnable

  implementation of a Siena-DV/DRP event notification service. This is an implementation of a Siena DV/DRP event notification service (it extends `HierarchicalDispatcher`). A `DVDRPDispatcher` can serve as a Siena event service for local (same Java VM) clients as well as remote clients. A `DVDRPDispatcher`s can also be combined in a distributed architecture with other dispatchers. Every dispatcher can be connected to a neighbor dispatcher, thereby forming a generic network topology. The network of dispatchers is assembled incrementally and can be modified by issuing configuration requests to a dispatcher.

  A `DVDRPDispatcher` uses a `PacketReceiver` to receive notifications, subscriptions and unsubscriptions from external clients and from its neighbor dispatcher. In order to receive and process external requests, a `DVDRPDispatcher` can either use a pool of internal threads, or it can use users' threads. See `HierarchicalDispatcher.DefaultThreadCount`, `setReceiver(PacketReceiver)`, and `setReceiver(PacketReceiver, int)`

  See Also:
    `Siena`, `ThinClient`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `chokePeriod`
    `static long` | `DEFAULT_DVDISPATCH_PERIOD`
    `static int` | `DEFAULT_MAX_COST`
    `static int` | `DEFAULT_TTL_FOR_RECOVERY`
    `static int` | `DEFAULT_TTL_FOR_UDV`
    `static int` | `DEFAULT_WAIT_FOR_REROUTE`
    `protected DistanceVector` | `distanceVector`
    `long` | `dvDispatchPeriod`
    `protected DistanceVector` | `fwTable`
    `protected DVHeartbeat` | `heartbeat`
    `protected PredicatesTable` | `predFwTable`
    `protected PredicatesTable` | `predicates`
    `java.lang.Object` | `predicatesFWDLock`
    `java.lang.Object` | `predicatesUpdateLock`
    `protected java.util.Timer` | `timer`
    `protected DistanceVector` | `updatedDV`
    `protected PredicatesTable` | `updatedPredicates`

    - ### Fields inherited from class siena.HierarchicalDispatcher

      `cleanup_max_r, cleanup_max_t, cleanup_rounds, cleanup_time, contacts, DefaultThreadCount, ifmanager, listener, master, master_interface, matchers, MaxFailedConnectionsDuration, MaxFailedConnectionsNumber, my_identity, sff, sffTable, sndbuf, spkt, storeFileName, subscriptions, subscriptionsMap`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DVDRPDispatcher()`
    `DVDRPDispatcher(java.lang.String id)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanUpDVEntry(byte[] destId)`
    `protected void` | `configure(siena.SENPPacket req)`
    `void` | `doDiscovery()`
    `protected void` | `handleDRP(siena.SENPPacket req)` This method is invoked each time a DRP request is received.
    `protected void` | `handlePAD(siena.SENPPacket req)`
    `protected void` | `handleUDV(siena.SENPPacket req)`
    `protected void` | `partitionRecipients(siena.SENPPacket req)` Partitions the list of recipients of a DRP package and forwards the package accordingly.
    `protected void` | `partitionRecipientsAnyCast(siena.SENPPacket req)` Partitions the list of recipients of a DRP package and forwards the package accordingly.
    `protected void` | `processRequest(siena.SENPPacket req)`
    `protected void` | `publish(siena.SENPPacket req)`
    `void` | `queueDistanceVector(byte[] destination, int priority)` Adds a package addressed to a subscriber containing the whole local distance vector to the queue of outgoing DV packages consumed by `DispatcherThread`.
    `void` | `recomputeLocalPredicates()`
    `void` | `rerouteDRPPacket(siena.SENPPacket req)`
    `void` | `setChoke(int chokePeriod)`
    `void` | `setHeartbeat(long heartbeat)`
    `void` | `setReceiver(PacketReceiver r)` sets the packet receiver for this server.
    `void` | `setReceiver(PacketReceiver r, int threads)` sets the packet receiver for this server.
    `void` | `shutdown()` Stops the server instance
    `void` | `startHeartbeat()`
    `protected void` | `subscribe(Filter f, siena.Subscriber s, siena.SENPPacket req)`
    `protected void` | `subscribe(siena.SENPPacket req)`
    `protected void` | `unsubscribe(Filter f, siena.Subscriber s, siena.SENPPacket req)`
    `protected void` | `updateDistanceVector(DistanceVector update)` This method is invoked by a single thread 'DVHeartbeat.chocke' seconds after an update to the network topology
    `protected void` | `updatePredicates(PredicatesTable update)` This method is invoked by a single thread 'DVHeartbeat.choke' seconds after an update to the predicates in the network (including local)

    - ### Methods inherited from class siena.HierarchicalDispatcher

      `advertise, clearSubscriptions, getIdentity, getMaster, getReceiver, initStore, loadSubscriptions, map_subscriber, map, processOneRequest, publish, resume, resume, resumeMaster, run, saveSubscriptions, setDefaultPacketSenderFactory, setMaster, setPacketSenderFactory, setStoreRefreshCounter, setStoreRefreshTimeout, subscribe, subscribe, suspend, suspend, suspendMaster, unadvertise, unadvertise, unsubscribe, unsubscribe, unsubscribe, unsubscribe, updateFWTable`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface siena.Siena

      `advertise, publish, resume, subscribe, subscribe, suspend, unadvertise, unadvertise, unsubscribe, unsubscribe, unsubscribe`

    - ### Methods inherited from interface java.lang.Runnable

      `run`

- - ### Field Detail

    - #### DEFAULT_WAIT_FOR_REROUTE

          public static int DEFAULT_WAIT_FOR_REROUTE

    - #### DEFAULT_TTL_FOR_UDV

          public static int DEFAULT_TTL_FOR_UDV

    - #### DEFAULT_TTL_FOR_RECOVERY

          public static int DEFAULT_TTL_FOR_RECOVERY

    - #### DEFAULT_MAX_COST

          public static int DEFAULT_MAX_COST

    - #### DEFAULT_DVDISPATCH_PERIOD

          public static long DEFAULT_DVDISPATCH_PERIOD

    - #### dvDispatchPeriod

          public long dvDispatchPeriod

    - #### chokePeriod

          public int chokePeriod

    - #### distanceVector

          protected DistanceVector distanceVector

    - #### updatedDV

          protected DistanceVector updatedDV

    - #### predicates

          protected PredicatesTable predicates

    - #### updatedPredicates

          protected PredicatesTable updatedPredicates

    - #### fwTable

          protected DistanceVector fwTable

    - #### predFwTable

          protected PredicatesTable predFwTable

    - #### timer

          protected java.util.Timer timer

    - #### predicatesUpdateLock

          public java.lang.Object predicatesUpdateLock

    - #### predicatesFWDLock

          public java.lang.Object predicatesFWDLock

    - #### heartbeat

          protected DVHeartbeat heartbeat

  - ### Constructor Detail

    - #### DVDRPDispatcher

          public DVDRPDispatcher()

    - #### DVDRPDispatcher

          public DVDRPDispatcher(java.lang.String id)

  - ### Method Detail

    - #### startHeartbeat

          public void startHeartbeat()

      Overrides:
        `startHeartbeat` in class `HierarchicalDispatcher`

    - #### doDiscovery

          public void doDiscovery()

    - #### processRequest

          protected void processRequest(siena.SENPPacket req)

      Overrides:
        `processRequest` in class `HierarchicalDispatcher`

    - #### handleUDV

          protected void handleUDV(siena.SENPPacket req)

      Parameters:
        `req` -

    - #### updateDistanceVector

          protected void updateDistanceVector(DistanceVector update)

      This method is invoked by a single thread 'DVHeartbeat.chocke' seconds after an update to the network topology

    - #### updatePredicates

          protected void updatePredicates(PredicatesTable update)

      This method is invoked by a single thread 'DVHeartbeat.choke' seconds after an update to the predicates in the network (including local)

    - #### handlePAD

          protected void handlePAD(siena.SENPPacket req)

    - #### shutdown

          public void shutdown()

      Stops the server instance
      Specified by:
        `shutdown` in interface `Siena`
      Overrides:
        `shutdown` in class `HierarchicalDispatcher`
      See Also:
        `HierarchicalDispatcher.setReceiver(PacketReceiver)`, `HierarchicalDispatcher.setMaster(String)`

    - #### queueDistanceVector

          public void queueDistanceVector(byte[] destination,
                                 int priority)

      Adds a package addressed to a subscriber containing the whole local distance vector to the queue of outgoing DV packages consumed by `DispatcherThread`.
      Parameters:
        `destination` - the Subscriber to which the DV will be sent
        `priority` - the priority of the message in the queue (1 high, 2 low)
      See Also:
        `DispatcherThread`

    - #### rerouteDRPPacket

          public void rerouteDRPPacket(siena.SENPPacket req)

    - #### publish

          protected void publish(siena.SENPPacket req)

      Overrides:
        `publish` in class `HierarchicalDispatcher`

    - #### handleDRP

          protected void handleDRP(siena.SENPPacket req)

      This method is invoked each time a DRP request is received. The request is eventually forwarded to local subscribers or neighbor servers
      Parameters:
        `req` - the DRP request *
      See Also:
        `SENPPacket`

    - #### partitionRecipients

          protected void partitionRecipients(siena.SENPPacket req)

      Partitions the list of recipients of a DRP package and forwards the package accordingly.
      Parameters:
        `req` - the DRP package whose recipients have to be partitioned
      See Also:
        `SENPPacket`

    - #### partitionRecipientsAnyCast

          protected void partitionRecipientsAnyCast(siena.SENPPacket req)

      Partitions the list of recipients of a DRP package and forwards the package accordingly.
      Parameters:
        `req` - the DRP package whose recipients have to be partitioned
      See Also:
        `SENPPacket`

    - #### configure

          protected void configure(siena.SENPPacket req)

      Overrides:
        `configure` in class `HierarchicalDispatcher`

    - #### unsubscribe

          protected void unsubscribe(Filter f,
                         siena.Subscriber s,
                         siena.SENPPacket req)

      Overrides:
        `unsubscribe` in class `HierarchicalDispatcher`

    - #### recomputeLocalPredicates

          public void recomputeLocalPredicates()

    - #### subscribe

          protected void subscribe(Filter f,
                       siena.Subscriber s,
                       siena.SENPPacket req)
                            throws SienaException

      Overrides:
        `subscribe` in class `HierarchicalDispatcher`
      Throws:
        `SienaException`

    - #### cleanUpDVEntry

          public void cleanUpDVEntry(byte[] destId)

    - #### setHeartbeat

          public void setHeartbeat(long heartbeat)

    - #### setChoke

          public void setChoke(int chokePeriod)

      Overrides:
        `setChoke` in class `HierarchicalDispatcher`

    - #### setReceiver

          public void setReceiver(PacketReceiver r,
                         int threads)

      Description copied from class: `HierarchicalDispatcher`
      sets the packet receiver for this server. A packet receiver accepts notifications, subscriptions, and other requests on some communication channel. `setReceiver` will shut down any previously activated receiver for this dispatcher. This method does not guarantee a transactional switch to a new receiver. This means that some requests might get lost while the server has closed the old port and before it reopens the new port.
      Overrides:
        `setReceiver` in class `HierarchicalDispatcher`
      Parameters:
        `r` - the packet receiver
        `threads` - is the number of threads associated with the receiver, and therefore to the whole server. A positive value causes this dispatcher to create threads. A value of 0 causes the dispatcher not to create any thread, In this case, the application must explicitly call `HierarchicalDispatcher.processOneRequest()`.
      See Also:
        `HierarchicalDispatcher.shutdown()`, `HierarchicalDispatcher.setMaster(String)`

    - #### setReceiver

          public void setReceiver(PacketReceiver r)

      Description copied from class: `HierarchicalDispatcher`
      sets the packet receiver for this server. A packet receiver accepts notifications, subscriptions, and other requests on some communication channel. `setReceiver` will shut down any previously activated receiver for this dispatcher. This method does not guarantee a transactional switch to a new receiver. This means that some requests might get lost while the server has closed the old port and before it reopens the new port.

      This method simply calls `HierarchicalDispatcher.setReceiver(PacketReceiver, int)` using `HierarchicalDispatcher.DefaultThreadCount` as a default value.

      Overrides:
        `setReceiver` in class `HierarchicalDispatcher`
      Parameters:
        `r` - is the receiver
      See Also:
        `HierarchicalDispatcher.shutdown()`, `HierarchicalDispatcher.setReceiver(PacketReceiver, int)`

    - #### subscribe

          protected void subscribe(siena.SENPPacket req)
                            throws InvalidSenderException,
                                   SienaException

      Overrides:
        `subscribe` in class `HierarchicalDispatcher`
      Throws:
        `InvalidSenderException`
        `SienaException`

Copyright © 2000-2005 University of Colorado.
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga