Class SemaphoreProcessor

All Implemented Interfaces:
ValueProcessor

public class SemaphoreProcessor extends MemoryValueProcessor
Semaphore is a processor which acts as remote process semaphore: it allows only one remote process ID to be registered as active. Remote process sets own ID as string to the semaphore. If semaphore is free, this means string value is empty, it will accept the ID for a minute. Process will host semaphore as long as it will reset it's ID before expires. Setting semaphore to empty string will release semaphore. Process, which ID is set on semaphore, is being allowed to access some resource. Before a process can access such a resource, it must check the semaphore and proceed only if semaphore accepted it's ID.
Author:
igor@scictrl.com
  • Constructor Details

    • SemaphoreProcessor

      public SemaphoreProcessor()

      Constructor for SemaphoreProcessor.

  • Method Details

    • configure

      public void configure(Record record, org.apache.commons.configuration.HierarchicalConfiguration config)
      Configures the internals of value processor, provides reference to parent record and to configuration with root inside processor tag. Parent record is not yet initialized, so does not have reference to Database, the Database reference will be available during activate call.
      Specified by:
      configure in interface ValueProcessor
      Overrides:
      configure in class MemoryValueProcessor
      Parameters:
      record - the parent record.
      config - configuration with room inside processor tag.
    • _setValue

      protected boolean _setValue(Object value, gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status, boolean notify, boolean force)
      Internal set: sets new value to this processor. It checks if it is fixed, it never sets fixed value. Fires value update event only if value was changes and notify is true. If force is true, then updates value and fires notify, if notify is true, even if value was not changed. If the value is not an array it tries to convert it to a single element array. Updates timestamp. If required fires notify event.
      Overrides:
      _setValue in class MemoryValueProcessor
      Parameters:
      value - value to be set
      severity - the severity to be used together with the value update. If null no alarm update is fired.
      status - the status to be used together with the value update. If null no alarm update is fired.
      notify - if true fire notify event if value was change, false suppresses events
      force - if true it will update value and timestamp even if there is not new value and proceeds with notify
      Returns:
      true if value was updated, regardless if based on difference or force
    • process

      public void process()
      Called by Database in interval set by the trigger parameter in milliseconds. Not called if trigger in 0.
      Specified by:
      process in interface ValueProcessor
      Overrides:
      process in class AbstractValueProcessor