Class FailureProcess

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc
    Direct Known Subclasses:
    SingleFailureEvent, TimeBasedFailure

    public abstract class FailureProcess
    extends SchedulingElement
    A FailureProcess causes FailureNotices to be sent to a ResourceUnit. If the user supplies an initial starting time random variable then, it will be used to start the process at that time for each replication of the simulation. If no initial starting time random variable is supplied, then the process will not be started automatically and the user should use the start() methods to start the process at the appropriate time. Starting the process causes the first failure to occur at the specified start time and for it to last for the provided duration. When the process is started the first failure event is scheduled. If the process is not started then no first event is scheduled. Implementors of sub-classes are responsible for suspending, resuming, and stopping the process by implementing the suspendProcess(), resumeProcess(), and stopProcess() methods.

    Once the failure process has been started it cannot be started again (until the next replication). Once the failure process has been stopped, it cannot be started again (until the next replication). A FailureProcess is associated with one ResourceUnit.

    • Constructor Detail

      • FailureProcess

        public FailureProcess​(ResourceUnit resourceUnit,
                              RandomIfc duration)
        The process will not be started automatically.
        Parameters:
        resourceUnit - the resourceUnit
        duration - governs the duration of the FailureNotices
      • FailureProcess

        public FailureProcess​(ResourceUnit resourceUnit,
                              RandomIfc duration,
                              java.lang.String name)
        The process will not be started automatically.
        Parameters:
        resourceUnit - the resourceUnit
        duration - governs the duration of the FailureNotices
      • FailureProcess

        public FailureProcess​(ResourceUnit resourceUnit,
                              RandomIfc duration,
                              RandomIfc initialStartTimeRV)
        Parameters:
        resourceUnit - the resourceUnit, may not be null
        duration - governs the duration of the FailureNotices, may not be null
        initialStartTimeRV - used to specify the time of the start of the process, if the process is to be started automatically at the beginning of each replication. May be null.
      • FailureProcess

        public FailureProcess​(ResourceUnit resourceUnit,
                              RandomIfc duration,
                              RandomIfc initialStartTimeRV,
                              java.lang.String name)
        Parameters:
        resourceUnit - the resourceUnit, may not be null
        duration - governs the duration of the FailureNotices, may not be null
        initialStartTimeRV - used to specify the time of the start of the process, if the process is to be started automatically at the beginning of each replication. May be null.
        name - the name of the FailureProcess
    • Method Detail

      • addFailureProcessListener

        public final void addFailureProcessListener​(FailureProcessListenerIfc listener)
        Adds a listener to react to FailureProcess state changes
        Parameters:
        listener - the listener to add
      • removeFailureProcessListener

        public final void removeFailureProcessListener​(FailureProcessListenerIfc listener)
        Removes the listener from the FailureProcess
        Parameters:
        listener - the listener to remove
      • getPriority

        public final int getPriority()
        Returns:
        the priority of the generated FailureNotices
      • setPriority

        public final void setPriority​(int priority)
        Parameters:
        priority - the priority of the generated FailureNotices
      • getFailureDelayOption

        public final boolean getFailureDelayOption()
        The default option is true
        Returns:
        returns true if the FailureNotices made by this FailureElement can be delayed if the ResourceUnit it is sent to is busy
      • setFailureDurationTimeInitialRandomSource

        public final void setFailureDurationTimeInitialRandomSource​(RandomIfc d)
        Sets the failure duration distribution
        Parameters:
        d - the distribution
      • getAutoStartProcessOption

        public final boolean getAutoStartProcessOption()
        The default is false
        Returns:
        true if failure process will start automatically upon initialization
      • turnOffAutoStartProcessOption

        public final void turnOffAutoStartProcessOption()
        Causes the auto starting of the process to be turned off. This indicates that the process should not use the initial start time if it was supplied. Thus, a start time may be supplied but not used.
      • turnOnAutoStartProcessOption

        public final void turnOnAutoStartProcessOption​(RandomIfc startTime)
        Setting an initial start time indicates to the failure process that it should automatically start using the supplied time at the beginning of each replication.
        Parameters:
        startTime - the time that the process should start at the beginning of each simulation, must not be null
      • getInitialStartTimeRV

        protected final java.util.Optional<RandomVariable> getInitialStartTimeRV()
        Since supplying an initial starting time is optional, it may be null.
        Returns:
        the random variable that computes the value of the initial start time (if present)
      • getFailureDurationRV

        protected final RandomVariable getFailureDurationRV()
        Returns:
        the random variable representing the duration
      • getInitialStartTimeValue

        public final double getInitialStartTimeValue()
        If the initial start time random variable is set then this method should return the starting time of the event. If the initial start time is not set, this method returns Double.NaN. If the initial start time random variable is set, then this method is used when initializing the failure process to set the start time of the process to the value returned from this method.
        Returns:
        returns the value of the initial start time or Double.NaN if the initial start time was not specified.
      • getDurationValue

        public final double getDurationValue()
        Used for getting the value of the duration within createFailureNotice(). All notices will use the values returned from this method
        Returns:
        the value of the duration, which may be random
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called
        Overrides:
        initialize in class ModelElement
      • createFailureNotice

        protected final FailureNotice createFailureNotice()
        Should be used in implementations of sendFailureNotice()
        Returns:
        creates a FailureNotice
      • getStartEvent

        protected final java.util.Optional<JSLEvent> getStartEvent()
        If the process has not been started yet then the start event may be null
        Returns:
        the event that is scheduled to start the process
      • stop

        public final void stop()
        Stops the failure process. Once the failure process is stopped, the the process cannot be restarted. The process can be stopped from the running or suspended states.
      • start

        public final void start​(double time)
        This method starts the process by scheduling the first event to occur at getTime() + time.

        If the failure process has already been started then an IllegalStateException is thrown. The process must be started to be able to send failure notices. The failure process can only be started once per replication. The process can only be started from the created state.

      • start

        public final void start()
        Start the process at the current time. In other words in getTime() + 0.0 into the future.
      • start

        public final void start​(GetValueIfc value)
        Causes the failure process to start at getTime() + value.getValue().
        Parameters:
        value - the GetValueIfc object that should be used get the value of the starting time
      • suspend

        public final void suspend()
        Tells the process to suspend the generation of FailureNotices. Once suspended, resume() can be used to continue the generation of FailureNotices. Suspending the generation of FailureNotices should cause no new FailureNotices to be sent. The process can only be suspended from the running state.
      • resume

        public final void resume()
        Tells the process to resume the generation of FailureNotices. Once resumed, suspend() can be used to pause the generation of new FailureNotices. Resuming the generation of FailureNotices should allow the process to continue sending notices if resumption of the process is permitted. The process can only be resumed from the suspended state.
      • getResourceUnit

        protected final ResourceUnit getResourceUnit()
        Returns:
        the resource unit attached to this failure process
      • failureNoticeActivated

        protected abstract void failureNoticeActivated​(FailureNotice fn)
        When a FailureNotice is made active, this method is called. Called from FailureNotice.CreatedState or FailureNotice.DelayedState when activate() is called. A FailureNotice is activated from ResourceUnit when scheduling the end of failure for the generated FailureNotice using ResourceUnit's scheduleEndOfFailure(FailureNotice failureNotice). If the FailureNotice is not delayed then it is activated immediately upon the ResourceUnit receiving the failure notice. If the FailureNotice is delayed, then after the delay it is activated This can be used to react to the notices becoming active. A FailureNotice becoming active means that the failure has started (taking down the resource unit).
        Parameters:
        fn - the failure notice
      • failureNoticeDelayed

        protected abstract void failureNoticeDelayed​(FailureNotice fn)
        When a FailureNotice is delayed, this method is called. This can be used to react to the notice becoming delayed.
        Parameters:
        fn - the failure notice
      • failureNoticeIgnored

        protected abstract void failureNoticeIgnored​(FailureNotice fn)
        When a FailureNotice is ignored, this method is called. This can be used to react to the notice becoming ignored.
        Parameters:
        fn - the failure notice
      • failureNoticeCompleted

        protected abstract void failureNoticeCompleted​(FailureNotice fn)
        When a FailureNotice is completed, this method is called. This can be used to react to the notice becoming completed.
        Parameters:
        fn - the failure notice
      • suspendProcess

        protected abstract void suspendProcess()
        Performs work associated with suspending the process
      • stopProcess

        protected abstract void stopProcess()
        Performs work associated with stopping the process
      • resumeProcess

        protected abstract void resumeProcess()
        Performs work to resume the process.
      • notifyFailureProcessListeners

        protected final void notifyFailureProcessListeners​(FailureNotice fn)
        Used internally to notify failure process listeners of state changes: start, stop, failure, suspend, resume
      • fail

        protected final void fail()
        Use this method to cause FailureNotices to be sent. This method properly checks the state of the process before sending.
      • signalFailure

        protected void signalFailure()
        Implement this method signal ResourceUnits via FailureNotices This method is called by fail() which properly checks the state of the process before signalling
      • isRunning

        public final boolean isRunning()
        Returns:
        true if the failure process is in the running state
      • isCreated

        public final boolean isCreated()
        Returns:
        true if the failure process is in the created state
      • isSuspended

        public final boolean isSuspended()
        Returns:
        true if the failure process is in the suspended state
      • isStopped

        public final boolean isStopped()
        Returns:
        true if the failure process is in the running state
      • scheduleStartOfProcess

        protected final void scheduleStartOfProcess​(double time)
        Performs the work to start the failure process. Schedules the first event
        Parameters:
        time - the time that the process should be scheduled to start, must be not be negative
      • cancelStartEvent

        protected final void cancelStartEvent()
        If the start event has been scheduled, then cancel it
      • unCancelStartEvent

        protected final void unCancelStartEvent()
        Uncancels the start event
      • resourceUnitStateChange

        protected final void resourceUnitStateChange()
        This method is called by ResourceUnit when a state change has occurred. It calls the resourceUnitXtoY() methods to allow sub-classes to specialize the behavior associated with a state change on a ResourceUnit.
      • resourceUnitInactiveToIdle

        protected void resourceUnitInactiveToIdle()
      • resourceUnitInactiveToInactive

        protected void resourceUnitInactiveToInactive()
      • resourceUnitInactiveToFailed

        protected void resourceUnitInactiveToFailed()
      • resourceUnitInactiveToBusy

        protected void resourceUnitInactiveToBusy()
      • resourceUnitBusyToBusy

        protected void resourceUnitBusyToBusy()
      • resourceUnitBusyToFailed

        protected void resourceUnitBusyToFailed()
      • resourceUnitBusyToInactive

        protected void resourceUnitBusyToInactive()
      • resourceUnitBusyToIdle

        protected void resourceUnitBusyToIdle()
      • resourceUnitFailedToBusy

        protected void resourceUnitFailedToBusy()
      • resourceUnitFailedToFailed

        protected void resourceUnitFailedToFailed()
      • resourceUnitFailedToInactive

        protected void resourceUnitFailedToInactive()
      • resourceUnitFailedToIdle

        protected void resourceUnitFailedToIdle()
      • resourceUnitIdleToBusy

        protected void resourceUnitIdleToBusy()
      • resourceUnitIdleToFailed

        protected void resourceUnitIdleToFailed()
      • resourceUnitIdleToInactive

        protected void resourceUnitIdleToInactive()
      • resourceUnitIdleToIdle

        protected void resourceUnitIdleToIdle()