Class ScheduledProcessStartTools

java.lang.Object
de.aristaflow.adept2.core.eventmanager.ScheduledProcessStartTools

public final class ScheduledProcessStartTools extends Object
Converts scheduled process starts between ScheduledProcessStart and their form in the configuration of an event manager, checks the entries of a batch write of them, and reads, records and removes their state there. The configuration holds a static and a runtime layer of starts, the keys of the runtime layer carrying the prefix RTConf. in addition. Each layer lists the names of its starts in ScheduledStarts.Instances, and the start of the name n has the keys ScheduledStarts.n.property of these properties:
  • Start: the first due time, required: an ISO-8601 date-time, or a local date-time with T or a blank between date and time and optional seconds, in the zone of the server or followed by a zone after a blank or in brackets, its ID, its offset or a name read in the locales of the agent, e. g. 2026-10-01 06:00 MEZ.
  • Period: an ISO-8601 duration or period which is not negative; without it or with a zero period, the start is due once.
  • FixedRate: whether the period counts from the previous due time rather than from the end of the previous instance, required with a period other than zero.
  • OverlapAllowed, MissedStartCaughtUp and RetryCount: the start policies, by default false, true and 0.
  • TemplateID or ProcessType: the ID of the template of which instances are started or the process type of whose latest template they are started, exactly one of them.
  • Input.parameter: the typed text form of the value of the input parameter, for each input parameter with a value; a string value keeps no leading or trailing white space.
  • Enabled: whether the start is enabled, by default true.
  • Comment: the comment on the start.
  • Overridable: in the static layer only, whether a runtime start of the same name may override the start, by default false.
  • LastTimeEvent and LastInstance: the state of the start, which the runtime configuration holds without the prefix RTConf., so that it lies beside the keys of the static layer.

A start with a key in the runtime layer is read wholly from the runtime layer, otherwise wholly from the static layer, and it is refused if it has another key there than these. Values are read as they are stored, so that a variable in a value stays text, and of a value which an unescaped comma splits, the first part counts; written values have a comma and a backslash escaped by a backslash. A parameter name stands in its key as it is: since a start name contains no dot, the parameter name is everything after Input..

The starts of template statuses have no form in the configuration, only their state, which lies under their names: TemplateStarts. followed by the ID of the start, a name which differs from that of every configured start, since that contains no dot. Besides LastTimeEvent and LastInstance, the state of such a start holds Removed, the time its source has been removed while the state is kept, and Period and FixedRate, the period of its schedule and whether it is a fixed rate, both absent for a start due once, so that the state can expire once no source holds the start.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The property of the comment on a start.
    static final String
    The property stating whether a start is enabled.
    The execution states which end an instance.
    static final String
    The property stating whether the period of a start counts from the previous due time.
    static final String
    The property of the input values of a start, followed by the name of an input parameter.
    static final String
    The property stating whether a start catches up missed due times.
    static final String
    The property stating whether a start allows overlapping instances.
    static final String
    The property of a static start stating whether a runtime start may override it.
    static final String
    The property of the period of a start.
    static final String
    The first segment of the keys of the starts.
    static final String
    The property of the process type of a start.
    static final String
    The property of the number of retries of a start.
    static final String
    The property of the first due time of a start.
    static final String
    The key of the list of the names of the starts in the static layer.
    static final String
    The property of the ID of the template of a start.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Checks the form of the designated name of a start: it is not empty, not Instances, the last segment of the key of a list of names, neither begins nor ends with a blank, since the list of names would drop it, contains neither a comma nor a dot nor a slash, and has at most 212 characters, so that no key of a property of the start in the runtime layer has more than 255 characters.
    static void
    Checks whether the designated entry of a batch write may be written into the runtime layer of the configuration of an event manager: its key is the key of the list of the names in the runtime layer or a key of a start there, it has at most 255 characters, and its value has at most 4000 characters, a comma and a backslash escaped by a backslash counted, and contains no ${, since reading the value as a string would resolve it as a variable.
    static Map<String,String>
    Gets the entries which write the designated start into the runtime layer of the designated configuration through the batch write of an event manager, setConfigurationValues: every key of the start with its value, the empty string for every other key the start has in the runtime layer, so that the batch write deletes it, and the list of the names in the runtime layer with the name of the start.
    static Map<String,String>
    Gets the entries which remove the start of the designated name from the runtime layer of the designated configuration through the batch write of an event manager, setConfigurationValues: the empty string for every key the start has in the runtime layer, so that the batch write deletes it, and the list of the names in the runtime layer without the name.
    static List<String>
    Gets the keys of the runtime layer of the designated configuration which a batch write of an event manager changes: the key of the list of the names in the runtime layer and, for every start of both layers which a runtime start may override, the keys of its properties in the runtime layer.
    static Boolean
    Gets whether the period of the schedule of the start of a template status of the designated name counts from the previous due time rather than from the end of the previous instance, from its state in the designated configuration.
    static UUID
    Gets the ID of the instance which the last successful trigger of the start of the designated name has started, from its state in the designated configuration.
    static Instant
    Gets the last due time for which the start of the designated name has raised an event, or the time it has been registered or enabled or its schedule has been changed if it has raised none since, from its state in the designated configuration.
    Gets the names of the starts in the static layer of the designated configuration which do not allow a runtime start to override them, although the runtime layer holds a start of their name: it lists the name or has a key of a start of the name.
    Gets the names of the starts of both layers of the designated configuration, those of the static layer and then those of the runtime layer, each once.
    Gets the period of the schedule of the start of a template status of the designated name from its state in the designated configuration.
    static Instant
    Gets the time at which the source of the start of a template status of the designated name has been removed while its state is kept, from its state in the designated configuration.
    static String
    Gets the name of the start of which the designated key is a key in the runtime layer of the configuration of an event manager.
    Gets the names of the starts in the runtime layer of the designated configuration, each once and in the order of their list.
    Gets the names of the configured starts which have state in the designated configuration, each once.
    Gets the names of the starts in the static layer of the designated configuration, each once and in the order of their list.
    static String
    Gets the name of the start of a template status of the designated ID, which identifies the start in an event manager and in its state: TemplateStarts. followed by the ID.
    Gets the names of the starts of template statuses which have state in the designated configuration, each once.
    static boolean
    Gets whether a runtime start may override the start of the designated name in the static layer of the designated configuration, which it may not unless the static start states so.
    static boolean
    Gets whether the designated name is that of a start of a template status, as getTemplateStartName(UUID) builds it, rather than that of a configured start, which contains no dot.
    parse(Configuration conf, String name, ProcessModelFactory factory, Locale locale, Logger logger)
    Reads the start of the designated name from the designated configuration, wholly from the runtime layer if the start has a key there, otherwise wholly from the static layer.
    static void
    Removes the last time event of the start of the designated name from its state in the designated configuration, while its last instance stays.
    static void
    Removes the removal time of the start of a template status of the designated name from its state in the designated configuration, since a source of the start is registered again.
    static void
    Removes the state of the start of the designated name from the designated configuration: its last time event and its last instance, and for a start of a template status also its removal time, its period and whether this is a fixed rate.
    static void
    setLastInstance(Configuration conf, String name, UUID instanceID)
    Records the instance of the designated ID as the last instance of the start of the designated name in its state in the designated configuration, which writes it into its runtime layer.
    static void
    Records the designated time as the last time event of the start of the designated name in its state in the designated configuration, which writes it into its runtime layer.
    static void
    setPeriod(Configuration conf, String name, TimeSchedule schedule)
    Records the period of the designated schedule of the start of a template status of the designated name and whether it is a fixed rate in its state in the designated configuration, which writes them into its runtime layer, or removes both from the state if the schedule has no period.
    static void
    Records the designated time as the removal time of the start of a template status of the designated name in its state in the designated configuration, which writes it into its runtime layer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • getStaticNames

      public static Collection<String> getStaticNames(Configuration conf)
      Gets the names of the starts in the static layer of the designated configuration, each once and in the order of their list.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The names of the starts in the static layer of the designated configuration. This will never be null.
    • getRuntimeNames

      public static Collection<String> getRuntimeNames(Configuration conf)
      Gets the names of the starts in the runtime layer of the designated configuration, each once and in the order of their list.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The names of the starts in the runtime layer of the designated configuration. This will never be null.
    • getNames

      public static Collection<String> getNames(Configuration conf)
      Gets the names of the starts of both layers of the designated configuration, those of the static layer and then those of the runtime layer, each once.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The names of the starts of both layers of the designated configuration. This will never be null.
    • getLockedNames

      public static Collection<String> getLockedNames(Configuration conf) throws ConfigurationException
      Gets the names of the starts in the static layer of the designated configuration which do not allow a runtime start to override them, although the runtime layer holds a start of their name: it lists the name or has a key of a start of the name.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The names of the static starts which do not allow the runtime start of their name. This will never be null.
      Throws:
      ConfigurationException - If such a static start states whether a runtime start may override it in another form than a boolean, a ConfigurationException naming the start and the key will be thrown.
    • isOverridable

      public static boolean isOverridable(Configuration conf, String name) throws ConfigurationException
      Gets whether a runtime start may override the start of the designated name in the static layer of the designated configuration, which it may not unless the static start states so.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the static start. This must not be null.
      Returns:
      Whether a runtime start may override the static start of the designated name.
      Throws:
      ConfigurationException - If the static start states it in another form than a boolean, a ConfigurationException naming the start and the key will be thrown.
    • parse

      public static ScheduledProcessStart parse(Configuration conf, String name, ProcessModelFactory factory, Locale locale, Logger logger) throws ConfigurationException
      Reads the start of the designated name from the designated configuration, wholly from the runtime layer if the start has a key there, otherwise wholly from the static layer. The keys are read under the read lock of the configuration, so that a write through it is read completely or not at all.

      The first due time is read in the zone of the server unless it names a zone, and the name of a zone in the chain of locales from the designated one through the default locale of the JVM. If the locales read the name as zones with different rules from the first due time on, the zone of the first is taken and a warning is logged, and a name which no locale knows refuses the start.

      The start is refused if it has a key there which is none of the keys of a start, so that a misspelt key does not change the start unnoticed, if a key has a value of the wrong form, a negative period or retry count included, if it lacks its first due time, if it states both or neither of template ID and process type, or if it has a period other than zero without stating whether the period is a fixed rate. Its name is refused if it is empty or Instances, begins or ends with a blank or contains a comma, a dot or a slash, and if a key of the start in the runtime layer would have more than 255 characters, so that every start fits the runtime layer: a name has at most 212 characters, and a name and a parameter name together at most 225.

      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start which to read. This must not be null.
      factory - The factory creating the time schedule and the scheduled start of the start. This must not be null.
      locale - The locale in which to read the name of the zone of the first due time first, usually that of the agent of the event manager. This must not be null.
      logger - The logger which to warn of a name of a zone which the locales read as zones with different rules. This must not be null.
      Returns:
      The start of the designated name. This will never be null.
      Throws:
      ConfigurationException - If the start of the designated name is refused, a ConfigurationException naming the start and the key will be thrown.
    • format

      public static Map<String,String> format(Configuration conf, ScheduledProcessStart start) throws ConversionException
      Gets the entries which write the designated start into the runtime layer of the designated configuration through the batch write of an event manager, setConfigurationValues: every key of the start with its value, the empty string for every other key the start has in the runtime layer, so that the batch write deletes it, and the list of the names in the runtime layer with the name of the start. Every property is written, a default value as well, the period and whether it is a fixed rate only for a start with a period, and the comment only for a start with one; a value has a comma and a backslash escaped by a backslash. If the static layer has a start of the same name, it is thereby overridden.
      Parameters:
      conf - The configuration of an event manager, which provides the keys of the start in the runtime layer and the list of names there. This must not be null.
      start - The start which to write. This must not be null.
      Returns:
      The entries which write the designated start into the runtime layer, by their keys. This will never be null.
      Throws:
      ConversionException - If an input value of the designated start has no typed text form, a ConversionException naming the start and the input parameter will be thrown.
    • formatRemoval

      public static Map<String,String> formatRemoval(Configuration conf, String name)
      Gets the entries which remove the start of the designated name from the runtime layer of the designated configuration through the batch write of an event manager, setConfigurationValues: the empty string for every key the start has in the runtime layer, so that the batch write deletes it, and the list of the names in the runtime layer without the name. If the static layer has a start of the same name, it is thereby restored.
      Parameters:
      conf - The configuration of an event manager, which provides the keys of the start in the runtime layer and the list of names there. This must not be null.
      name - The name of the start which to remove. This must not be null.
      Returns:
      The entries which remove the start of the designated name from the runtime layer, by their keys. This will never be null.
    • getRuntimeName

      public static String getRuntimeName(String key)
      Gets the name of the start of which the designated key is a key in the runtime layer of the configuration of an event manager.
      Parameters:
      key - The key of which to get the name of the start. This must not be null.
      Returns:
      The name of the start of which the designated key is a key in the runtime layer or null if it is none, as the key of the list of the names in the runtime layer is.
    • checkName

      public static void checkName(String name) throws ConfigurationException
      Checks the form of the designated name of a start: it is not empty, not Instances, the last segment of the key of a list of names, neither begins nor ends with a blank, since the list of names would drop it, contains neither a comma nor a dot nor a slash, and has at most 212 characters, so that no key of a property of the start in the runtime layer has more than 255 characters. The key of an input value, which holds the name of its input parameter as well, is checked when the start is read and as an entry of a batch write.
      Parameters:
      name - The name of the start. This must not be null.
      Throws:
      ConfigurationException - If the designated name does not have the form of the name of a start, a ConfigurationException naming it will be thrown.
    • checkRuntimeEntry

      public static void checkRuntimeEntry(String key, String value) throws ConfigurationException
      Checks whether the designated entry of a batch write may be written into the runtime layer of the configuration of an event manager: its key is the key of the list of the names in the runtime layer or a key of a start there, it has at most 255 characters, and its value has at most 4000 characters, a comma and a backslash escaped by a backslash counted, and contains no ${, since reading the value as a string would resolve it as a variable.
      Parameters:
      key - The key of the entry. This must not be null.
      value - The value of the entry, the empty string deleting the key. This must not be null.
      Throws:
      ConfigurationException - If the designated entry may not be written, a ConfigurationException naming the key will be thrown.
    • getChangeableKeys

      public static List<String> getChangeableKeys(Configuration conf)
      Gets the keys of the runtime layer of the designated configuration which a batch write of an event manager changes: the key of the list of the names in the runtime layer and, for every start of both layers which a runtime start may override, the keys of its properties in the runtime layer. The keys of its input values are accepted beyond them, since they are named after the input parameters of its template.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The keys of the runtime layer which a batch write changes. This will never be null.
    • getLastTimeEvent

      public static Instant getLastTimeEvent(Configuration conf, String name) throws ConfigurationException
      Gets the last due time for which the start of the designated name has raised an event, or the time it has been registered or enabled or its schedule has been changed if it has raised none since, from its state in the designated configuration.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start. This must not be null.
      Returns:
      The last time event of the start of the designated name or null if its state has none.
      Throws:
      ConfigurationException - If the state holds it in another form than a date, a ConfigurationException naming the start and the key will be thrown.
    • getLastInstance

      public static UUID getLastInstance(Configuration conf, String name) throws ConfigurationException
      Gets the ID of the instance which the last successful trigger of the start of the designated name has started, from its state in the designated configuration.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start. This must not be null.
      Returns:
      The ID of the last instance of the start of the designated name or null if its state has none.
      Throws:
      ConfigurationException - If the state holds it in another form than a UUID, a ConfigurationException naming the start and the key will be thrown.
    • setLastTimeEvent

      public static void setLastTimeEvent(Configuration conf, String name, Instant time)
      Records the designated time as the last time event of the start of the designated name in its state in the designated configuration, which writes it into its runtime layer.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start. This must not be null.
      time - The last time event of the start. This must not be null.
      Throws:
      ConfigurationRuntimeException - If the runtime layer fails to store the time, a ConfigurationRuntimeException will be thrown.
    • setLastInstance

      public static void setLastInstance(Configuration conf, String name, UUID instanceID)
      Records the instance of the designated ID as the last instance of the start of the designated name in its state in the designated configuration, which writes it into its runtime layer.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start. This must not be null.
      instanceID - The ID of the last instance of the start. This must not be null.
      Throws:
      ConfigurationRuntimeException - If the runtime layer fails to store the ID, a ConfigurationRuntimeException will be thrown.
    • removeLastTimeEvent

      public static void removeLastTimeEvent(Configuration conf, String name)
      Removes the last time event of the start of the designated name from its state in the designated configuration, while its last instance stays. The start then counts its due times from its next registration.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start. This must not be null.
      Throws:
      ConfigurationRuntimeException - If the runtime layer fails to remove the last time event, a ConfigurationRuntimeException will be thrown.
    • removeState

      public static void removeState(Configuration conf, String name)
      Removes the state of the start of the designated name from the designated configuration: its last time event and its last instance, and for a start of a template status also its removal time, its period and whether this is a fixed rate.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start. This must not be null.
      Throws:
      ConfigurationRuntimeException - If the runtime layer fails to remove the state, a ConfigurationRuntimeException will be thrown.
    • getStateNames

      public static Collection<String> getStateNames(Configuration conf)
      Gets the names of the configured starts which have state in the designated configuration, each once.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The names of the configured starts which have state in the designated configuration. This will never be null.
    • getTemplateStartName

      public static String getTemplateStartName(UUID id)
      Gets the name of the start of a template status of the designated ID, which identifies the start in an event manager and in its state: TemplateStarts. followed by the ID.
      Parameters:
      id - The ID of the start, its key in the template status. This must not be null.
      Returns:
      The name of the start of a template status of the designated ID. This will never be null.
    • isTemplateStartName

      public static boolean isTemplateStartName(String name)
      Gets whether the designated name is that of a start of a template status, as getTemplateStartName(UUID) builds it, rather than that of a configured start, which contains no dot.
      Parameters:
      name - The name of a start. This must not be null.
      Returns:
      Whether the designated name is that of a start of a template status.
    • getTemplateStateNames

      public static Collection<String> getTemplateStateNames(Configuration conf)
      Gets the names of the starts of template statuses which have state in the designated configuration, each once.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      Returns:
      The names of the starts of template statuses which have state in the designated configuration. This will never be null.
    • getRemovalTime

      public static Instant getRemovalTime(Configuration conf, String name) throws ConfigurationException
      Gets the time at which the source of the start of a template status of the designated name has been removed while its state is kept, from its state in the designated configuration.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start of a template status. This must not be null.
      Returns:
      The removal time of the start of the designated name or null if its state has none, as while its source is registered.
      Throws:
      ConfigurationException - If the state holds it in another form than a date, a ConfigurationException naming the start and the key will be thrown.
      IllegalArgumentException - If the designated name is not that of a start of a template status, an IllegalArgumentException will be thrown.
    • setRemovalTime

      public static void setRemovalTime(Configuration conf, String name, Instant time)
      Records the designated time as the removal time of the start of a template status of the designated name in its state in the designated configuration, which writes it into its runtime layer.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start of a template status. This must not be null.
      time - The time at which the source of the start has been removed. This must not be null.
      Throws:
      IllegalArgumentException - If the designated name is not that of a start of a template status, an IllegalArgumentException will be thrown.
      ConfigurationRuntimeException - If the runtime layer fails to store the time, a ConfigurationRuntimeException will be thrown.
    • removeRemovalTime

      public static void removeRemovalTime(Configuration conf, String name)
      Removes the removal time of the start of a template status of the designated name from its state in the designated configuration, since a source of the start is registered again.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start of a template status. This must not be null.
      Throws:
      IllegalArgumentException - If the designated name is not that of a start of a template status, an IllegalArgumentException will be thrown.
      ConfigurationRuntimeException - If the runtime layer fails to remove the removal time, a ConfigurationRuntimeException will be thrown.
    • getPeriod

      public static TemporalAmount getPeriod(Configuration conf, String name) throws ConfigurationException
      Gets the period of the schedule of the start of a template status of the designated name from its state in the designated configuration.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start of a template status. This must not be null.
      Returns:
      The period of the start of the designated name or null if its state has none, as for a start due once.
      Throws:
      ConfigurationException - If the state holds it in another form than an ISO-8601 duration or period, a ConfigurationException naming the start and the key will be thrown.
      IllegalArgumentException - If the designated name is not that of a start of a template status, an IllegalArgumentException will be thrown.
    • getFixedRate

      public static Boolean getFixedRate(Configuration conf, String name) throws ConfigurationException
      Gets whether the period of the schedule of the start of a template status of the designated name counts from the previous due time rather than from the end of the previous instance, from its state in the designated configuration.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start of a template status. This must not be null.
      Returns:
      Whether the period of the start of the designated name is a fixed rate or null if its state does not state it, as for a start due once.
      Throws:
      ConfigurationException - If the state holds it in another form than a boolean, a ConfigurationException naming the start and the key will be thrown.
      IllegalArgumentException - If the designated name is not that of a start of a template status, an IllegalArgumentException will be thrown.
    • setPeriod

      public static void setPeriod(Configuration conf, String name, TimeSchedule schedule)
      Records the period of the designated schedule of the start of a template status of the designated name and whether it is a fixed rate in its state in the designated configuration, which writes them into its runtime layer, or removes both from the state if the schedule has no period.
      Parameters:
      conf - The configuration of an event manager. This must not be null.
      name - The name of the start of a template status. This must not be null.
      schedule - The schedule of the start. This must not be null.
      Throws:
      IllegalArgumentException - If the designated name is not that of a start of a template status, an IllegalArgumentException will be thrown.
      ConfigurationRuntimeException - If the runtime layer fails to store or remove the period or whether it is a fixed rate, a ConfigurationRuntimeException will be thrown.