edu.ucsb.nceas.metacat.dataone.hazelcast

## Class HazelcastService

- java.lang.Object
- - edu.ucsb.nceas.metacat.shared.BaseService
  - - edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService

- All Implemented Interfaces:
    com.hazelcast.core.EntryListener<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>, com.hazelcast.core.ItemListener<org.dataone.service.types.v1.Identifier>, com.hazelcast.core.LifecycleListener, com.hazelcast.core.MembershipListener, java.util.EventListener

      public class HazelcastService
      extends BaseService
      implements com.hazelcast.core.EntryListener<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>, com.hazelcast.core.MembershipListener, com.hazelcast.core.LifecycleListener, com.hazelcast.core.ItemListener<org.dataone.service.types.v1.Identifier>

  The Hazelcast service enables Metacat as a Hazelcast cluster member

- - ### Field Summary

    - ### Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `_serviceName`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doRefresh()` Refresh the Hazelcast service by restarting it
    `void` | `entryAdded(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)` Implement the EntryListener interface for Hazelcast, reponding to entry added events in the hzSystemMetadata map.
    `void` | `entryEvicted(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)` Implement the EntryListener interface for Hazelcast, reponding to entry evicted events in the hzSystemMetadata map.
    `void` | `entryRemoved(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)` Implement the EntryListener interface for Hazelcast, reponding to entry removed events in the hzSystemMetadata map.
    `void` | `entryUpdated(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)` Implement the EntryListener interface for Hazelcast, reponding to entry updated events in the hzSystemMetadata map.
    `com.hazelcast.core.HazelcastInstance` | `getHazelcastInstance()`
    `com.hazelcast.core.ISet<org.dataone.service.types.v1.Identifier>` | `getIdentifiers()` Get the identifiers set
    `com.hazelcast.core.IMap<org.dataone.service.types.v1.Identifier,edu.ucsb.nceas.metacat.common.index.event.IndexEvent>` | `getIndexEventMap()` Get the index event map
    `com.hazelcast.core.IMap<org.dataone.service.types.v1.Identifier,edu.ucsb.nceas.metacat.common.index.IndexTask>` | `getIndexQueue()` Get the index queue
    `static HazelcastService` | `getInstance()` Get the instance of the HazelcastService that has been instantiated, or instantiate one if it has not been already.
    `java.util.concurrent.locks.Lock` | `getLock(java.lang.String identifier)`
    `com.hazelcast.core.IMap<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>` | `getSystemMetadataMap()` Get the system metadata map
    `void` | `init()` Initializes the Hazelcast service
    `void` | `itemAdded(com.hazelcast.core.ItemEvent<org.dataone.service.types.v1.Identifier> event)` Respond to itemAdded events on the hzMissingIdentifiers Set.
    `void` | `itemRemoved(com.hazelcast.core.ItemEvent<org.dataone.service.types.v1.Identifier> event)` Respond to itemRemoved events on the hzMissingIdentifiers Set
    `void` | `memberAdded(com.hazelcast.core.MembershipEvent event)` When there is missing SystemMetadata on the local member, we retrieve it from the shared map and add it to the local backing store for safe keeping.
    `void` | `memberRemoved(com.hazelcast.core.MembershipEvent event)`
    `boolean` | `refreshable()` Indicate whether or not this service is refreshable.
    `void` | `refreshSystemMetadataEntry(java.lang.String guid)` When Metacat changes the underlying store, we need to refresh the in-memory representation of it.
    `void` | `resynchInThread()`
    `void` | `stateChanged(com.hazelcast.core.LifecycleEvent event)` In cases where this cluster is paused, we want to check that the local store accurately reflects the shared SystemMetadata map
    `void` | `stop()` Stop the HazelcastService.

    - ### Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `refresh`

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

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

- - ### Method Detail

    - #### getInstance

          public static HazelcastService getInstance()

      Get the instance of the HazelcastService that has been instantiated, or instantiate one if it has not been already.
      Returns:
        hazelcastService - The instance of the hazelcast service

    - #### init

          public void init()
                    throws ServiceException

      Initializes the Hazelcast service
      Throws:
        `ServiceException`

    - #### getSystemMetadataMap

          public com.hazelcast.core.IMap<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> getSystemMetadataMap()

      Get the system metadata map
      Parameters:
        `identifier` - - the identifier of the object as a string
      Returns:
        systemMetadata - the hazelcast map of system metadata

    - #### getIdentifiers

          public com.hazelcast.core.ISet<org.dataone.service.types.v1.Identifier> getIdentifiers()

      Get the identifiers set
      Returns:
        identifiers - the set of unique DataONE identifiers in the cluster

    - #### getIndexQueue

          public com.hazelcast.core.IMap<org.dataone.service.types.v1.Identifier,edu.ucsb.nceas.metacat.common.index.IndexTask> getIndexQueue()

      Get the index queue
      Returns:
        the set of SystemMetadata to be indexed

    - #### getIndexEventMap

          public com.hazelcast.core.IMap<org.dataone.service.types.v1.Identifier,edu.ucsb.nceas.metacat.common.index.event.IndexEvent> getIndexEventMap()

      Get the index event map
      Returns:
        indexEventMap - the hazelcast map of index events

    - #### refreshSystemMetadataEntry

          public void refreshSystemMetadataEntry(java.lang.String guid)

      When Metacat changes the underlying store, we need to refresh the in-memory representation of it.
      Parameters:
        `guid` -

    - #### getLock

          public java.util.concurrent.locks.Lock getLock(java.lang.String identifier)

    - #### refreshable

          public boolean refreshable()

      Indicate whether or not this service is refreshable.
      Specified by:
        `refreshable` in class `BaseService`
      Returns:
        refreshable - the boolean refreshable status

    - #### stop

          public void stop()
                    throws ServiceException

      Stop the HazelcastService. When stopped, the service will no longer respond to requests.
      Specified by:
        `stop` in class `BaseService`
      Throws:
        `ServiceException`

    - #### getHazelcastInstance

          public com.hazelcast.core.HazelcastInstance getHazelcastInstance()

    - #### doRefresh

          protected void doRefresh()
                            throws ServiceException

      Refresh the Hazelcast service by restarting it
      Specified by:
        `doRefresh` in class `BaseService`
      Throws:
        `ServiceException`

    - #### entryAdded

          public void entryAdded(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)

      Implement the EntryListener interface for Hazelcast, reponding to entry added events in the hzSystemMetadata map. Evaluate the entry and create CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
      Specified by:
        `entryAdded` in interface `com.hazelcast.core.EntryListener<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>`
      Parameters:
        `event` - - The EntryEvent that occurred

    - #### entryEvicted

          public void entryEvicted(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)

      Implement the EntryListener interface for Hazelcast, reponding to entry evicted events in the hzSystemMetadata map. Evaluate the entry and create CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
      Specified by:
        `entryEvicted` in interface `com.hazelcast.core.EntryListener<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>`
      Parameters:
        `event` - - The EntryEvent that occurred

    - #### entryRemoved

          public void entryRemoved(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)

      Implement the EntryListener interface for Hazelcast, reponding to entry removed events in the hzSystemMetadata map. Evaluate the entry and create CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
      Specified by:
        `entryRemoved` in interface `com.hazelcast.core.EntryListener<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>`
      Parameters:
        `event` - - The EntryEvent that occurred

    - #### entryUpdated

          public void entryUpdated(com.hazelcast.core.EntryEvent<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata> event)

      Implement the EntryListener interface for Hazelcast, reponding to entry updated events in the hzSystemMetadata map. Evaluate the entry and create CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
      Specified by:
        `entryUpdated` in interface `com.hazelcast.core.EntryListener<org.dataone.service.types.v1.Identifier,org.dataone.service.types.v2.SystemMetadata>`
      Parameters:
        `event` - - The EntryEvent that occurred

    - #### resynchInThread

          public void resynchInThread()

    - #### memberAdded

          public void memberAdded(com.hazelcast.core.MembershipEvent event)

      When there is missing SystemMetadata on the local member, we retrieve it from the shared map and add it to the local backing store for safe keeping.
      Specified by:
        `memberAdded` in interface `com.hazelcast.core.MembershipListener`

    - #### memberRemoved

          public void memberRemoved(com.hazelcast.core.MembershipEvent event)

      Specified by:
        `memberRemoved` in interface `com.hazelcast.core.MembershipListener`

    - #### stateChanged

          public void stateChanged(com.hazelcast.core.LifecycleEvent event)

      In cases where this cluster is paused, we want to check that the local store accurately reflects the shared SystemMetadata map
      Specified by:
        `stateChanged` in interface `com.hazelcast.core.LifecycleListener`
      Parameters:
        `event` -

    - #### itemAdded

          public void itemAdded(com.hazelcast.core.ItemEvent<org.dataone.service.types.v1.Identifier> event)

      Respond to itemAdded events on the hzMissingIdentifiers Set. Uses a distributed ILock to try to prevent multiple put calls on hzSystemMetadata
      Specified by:
        `itemAdded` in interface `com.hazelcast.core.ItemListener<org.dataone.service.types.v1.Identifier>`
      Parameters:
        `pid` - the identifier of the event

    - #### itemRemoved

          public void itemRemoved(com.hazelcast.core.ItemEvent<org.dataone.service.types.v1.Identifier> event)

      Respond to itemRemoved events on the hzMissingIdentifiers Set
      Specified by:
        `itemRemoved` in interface `com.hazelcast.core.ItemListener<org.dataone.service.types.v1.Identifier>`
      Parameters:
        `pid` - the identifier of the event

Copyright © 2020 Regents of the University of California. All Rights Reserved.