Package org.yamcs

Class YamcsServer


  • public class YamcsServer
    extends Object
    Yamcs server together with the global instances
    • Constructor Detail

      • YamcsServer

        public YamcsServer()
    • Method Detail

      • shutDown

        public void shutDown()
      • hasInstance

        public static boolean hasInstance​(String instance)
      • hasInstanceTemplate

        public boolean hasInstanceTemplate​(String template)
      • getServerId

        public String getServerId()
        The serverId has to be unique among Yamcs servers connected to eachother.

        It is used to distinguish the data generated by one particular server.

        Returns:
      • getSecretKey

        public byte[] getSecretKey()
      • addCommandOption

        @Experimental
        public void addCommandOption​(CommandOption option)
        Registers the system-wide availability of a CommandOption. Command options represent additional arguments that commands may require, but that are not used by Yamcs in building telecommand binary.

        An example use case would be a custom TC Link that may support additional arguments for controlling its behaviour.

        While not enforced we recommend to call this method from a Plugin.onLoad(YConfiguration) hook as this will avoid registering an option multiple times (attempts to do so would generate an error).

        Parameters:
        option - the new command option.
      • getCommandOptions

        public Collection<CommandOption> getCommandOptions()
        Returns the command options registered to this instance.
      • hasCommandOption

        public boolean hasCommandOption​(String id)
      • getConfig

        public YConfiguration getConfig()
        Returns the main Yamcs configuration
      • getSpec

        public Spec getSpec()
        Returns the configuration specification for the config returned by getConfig().
      • restartInstance

        public YamcsServerInstance restartInstance​(String instanceName)
                                            throws IOException
        Restarts a yamcs instance.
        Parameters:
        instanceName - the name of the instance
        Returns:
        the newly created instance
        Throws:
        IOException
      • stopInstance

        public YamcsServerInstance stopInstance​(String instanceName)
                                         throws IOException
        Stop the instance (it will be offline after this)
        Parameters:
        instanceName - the name of the instance
        Returns:
        the instance
        Throws:
        IOException
      • startInstance

        public YamcsServerInstance startInstance​(String instanceName)
                                          throws IOException
        Start the instance. If the instance is already started, do nothing. If the instance is FAILED, restart the instance If the instance is OFFLINE, rename the <instance>.yaml.offline to <instance>.yaml and start the instance
        Parameters:
        instanceName - the name of the instance
        Returns:
        the instance
        Throws:
        IOException
      • addConfigurationSection

        public void addConfigurationSection​(String key,
                                            Spec spec)
        Add the definition of an additional configuration section to the root Yamcs spec (yamcs.yaml).
        Parameters:
        key - the name of this section. This represent a direct subkey of the main app config
        spec - the specification of this configuration section.
      • addConfigurationSection

        public void addConfigurationSection​(ConfigScope scope,
                                            String key,
                                            Spec spec)
        Add the definition of an additional configuration section to a particulat configuration type
        Parameters:
        scope - the scope where this section belongs. When using file-based configuration this can be thought of as the type of the configuration file.
        key - the name of this section. This represent a direct subkey of the main app config
        spec - the specification of this configuration section.
      • addInstance

        public YamcsServerInstance addInstance​(String name,
                                               InstanceMetadata metadata,
                                               boolean offline,
                                               YConfiguration config)
        Creates a new yamcs instance. If the instance already exists an IllegalArgumentException is thrown
        Parameters:
        name - the name of the new instance
        metadata - the metadata associated to this instance (labels or other attributes)
        offline - if true, the instance will be created offline and it does not need a config
        config - the configuration for this instance (equivalent of yamcs.instance.yaml)
        Returns:
        the newly created instance
      • createInstance

        public YamcsServerInstance createInstance​(String name,
                                                  String templateName,
                                                  Map<String,​Object> templateArgs,
                                                  Map<String,​String> labels,
                                                  Map<String,​Object> customMetadata)
                                           throws IOException
        Create a new instance based on a template.
        Parameters:
        name - the name of the instance
        templateName - the name of an available template
        templateArgs - arguments to use while processing the template
        labels - labels associated to this instance
        customMetadata - custom metadata associated with this instance.
        Returns:
        the newly create instance
        Throws:
        IOException - when a disk operation failed
      • getInstanceTemplates

        public Set<Template> getInstanceTemplates()
      • getInstanceTemplate

        public Template getInstanceTemplate​(String name)
      • getTimeService

        public static TimeService getTimeService​(String yamcsInstance)
      • setMockupTimeService

        public static void setMockupTimeService​(TimeService timeService)
      • getGlobalServices

        public <T extends YamcsServiceList<T> getGlobalServices​(Class<T> serviceClass)
      • getGlobalCrashHandler

        public CrashHandler getGlobalCrashHandler()
      • getConfigDirectory

        public Path getConfigDirectory()
      • getDataDirectory

        public Path getDataDirectory()
      • getIncomingDirectory

        public Path getIncomingDirectory()
      • getCacheDirectory

        public Path getCacheDirectory()
      • addReadyListener

        public void addReadyListener​(ReadyListener readyListener)
        Register a listener that will be called when Yamcs has fully started. If you register a listener after Yamcs has already started, your callback will not be executed.
      • getServer

        public static YamcsServer getServer()
        Returns:
        the (singleton) server
      • main

        public static void main​(String[] args)
      • addInstanceTemplate

        public void addInstanceTemplate​(Template template)