org.modeshape.jcr.bus

## Class ClusteredRepositoryChangeBus

- java.lang.Object
- - org.modeshape.jcr.bus.ClusteredRepositoryChangeBus

- All Implemented Interfaces:
    ChangeBus, ChangeSetListener, Observable

      @ThreadSafe
      public final class ClusteredRepositoryChangeBus
      extends Object
      implements ChangeBus

  Implementation of a `ChangeBus` which can run in a cluster, via JGroups. This bus wraps around another bus, to which it delegates all "local" processing of events.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `ClusteredRepositoryChangeBus.Listener`
    `protected class` | `ClusteredRepositoryChangeBus.ObjectInputStreamWithClassLoader` ObjectInputStream extension that allows a different class loader to be used when resolving types.
    `protected class` | `ClusteredRepositoryChangeBus.Receiver`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RepositoryConfiguration.Clustering` | `clusteringConfiguration` The clustering configuration
    `protected ChangeBus` | `delegate` The wrapped standalone bus to which standard bus operations are delegated
    `protected AtomicBoolean` | `isOpen` Flag that dictates whether this bus has connected to the cluster.
    `protected static Logger` | `LOGGER`
    `protected AtomicBoolean` | `multipleAddressesInCluster` Flag that dictates whether there are multiple participants in the cluster; if not, then the changes are propagated only to the local observers.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClusteredRepositoryChangeBus(RepositoryConfiguration.Clustering clusteringConfiguration, ChangeBus delegate, String processId)` Creates a new clustered repository bus

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ChangeSet` | `deserialize(byte[] data)`
    `boolean` | `hasObservers()` Checks if there are any observers registered with the bus.
    `protected void` | `logReceivedOperation(ChangeSet changeSet)`
    `protected void` | `logSendOperation(ChangeSet changeSet)`
    `void` | `notify(ChangeSet changeSet)` Notifies a listener of the given changes.
    `boolean` | `register(ChangeSetListener observer)` Register the supplied observer.
    `protected byte[]` | `serialize(ChangeSet changes)`
    `void` | `shutdown()` Shuts down the change bus, closing and clearing resources created during `ChangeBus.start()`
    `void` | `start()` Starts up the change bus.
    `boolean` | `unregister(ChangeSetListener observer)` Unregister the supplied observer.

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

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

- - ### Field Detail

    - #### LOGGER

          protected static final Logger LOGGER

    - #### delegate

          protected final ChangeBus delegate

      The wrapped standalone bus to which standard bus operations are delegated

    - #### isOpen

          protected final AtomicBoolean isOpen

      Flag that dictates whether this bus has connected to the cluster.

    - #### multipleAddressesInCluster

          protected final AtomicBoolean multipleAddressesInCluster

      Flag that dictates whether there are multiple participants in the cluster; if not, then the changes are propagated only to the local observers.

    - #### clusteringConfiguration

          protected final RepositoryConfiguration.Clustering clusteringConfiguration

      The clustering configuration

  - ### Constructor Detail

    - #### ClusteredRepositoryChangeBus

          public ClusteredRepositoryChangeBus(RepositoryConfiguration.Clustering clusteringConfiguration,
                                      ChangeBus delegate,
                                      String processId)

      Creates a new clustered repository bus
      Parameters:
        `clusteringConfiguration` - the bus configuration
        `delegate` - the local bus to which changes will be delegated
        `processId` - the id of the process which started this bus

  - ### Method Detail

    - #### start

          public void start()
                     throws Exception

      Description copied from interface: `ChangeBus`
      Starts up the change bus.
      Specified by:
        `start` in interface `ChangeBus`
      Throws:
        `Exception` - if anything unexpected fails during startup.

    - #### hasObservers

          public boolean hasObservers()

      Description copied from interface: `ChangeBus`
      Checks if there are any observers registered with the bus.
      Specified by:
        `hasObservers` in interface `ChangeBus`
      Returns:
        `true` if there are any registered observers, `false` otherwise

    - #### shutdown

          public void shutdown()

      Description copied from interface: `ChangeBus`
      Shuts down the change bus, closing and clearing resources created during `ChangeBus.start()`
      Specified by:
        `shutdown` in interface `ChangeBus`

    - #### notify

          public void notify(ChangeSet changeSet)

      Description copied from interface: `ChangeSetListener`
      Notifies a listener of the given changes.
      Specified by:
        `notify` in interface `ChangeSetListener`
      Parameters:
        `changeSet` - a `non-null` `ChangeSet`

    - #### logSendOperation

          protected final void logSendOperation(ChangeSet changeSet)

    - #### logReceivedOperation

          protected final void logReceivedOperation(ChangeSet changeSet)

    - #### register

          public boolean register(ChangeSetListener observer)

      Description copied from interface: `Observable`
      Register the supplied observer. This method does nothing if the observer reference is null.
      Specified by:
        `register` in interface `Observable`
      Parameters:
        `observer` - the observer to be added; may be null
      Returns:
        true if the observer was added, or false if the observer was null, if the observer was already registered, or if the observer could not be added

    - #### unregister

          public boolean unregister(ChangeSetListener observer)

      Description copied from interface: `Observable`
      Unregister the supplied observer. This method does nothing if the observer reference is null.
      Specified by:
        `unregister` in interface `Observable`
      Parameters:
        `observer` - the observer to be removed; may not be null
      Returns:
        true if the observer was removed, or false if the observer was null or if the observer was not registered on this source

    - #### serialize

          protected byte[] serialize(ChangeSet changes)
                              throws Exception

      Throws:
        `Exception`

    - #### deserialize

          protected ChangeSet deserialize(byte[] data)
                                   throws Exception

      Throws:
        `Exception`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.