Package org.yamcs

Class YamcsServer

java.lang.Object
org.yamcs.YamcsServer

public class YamcsServer extends Object
Yamcs server together with the global instances
  • Field Details

  • Constructor Details

    • YamcsServer

      public YamcsServer()
  • Method Details

    • initServices

      public static void initServices(String instance, List<ServiceWithConfig> services) throws InitException
      Throws:
      InitException
    • addGlobalService

      public <T extends YamcsService> void addGlobalService(String name, Class<T> serviceClass, YConfiguration args) throws ValidationException, InitException
      Throws:
      ValidationException
      InitException
    • startServices

      public static void startServices(List<ServiceWithConfig> serviceList) throws ConfigurationException
      Starts the specified list of services.
      Parameters:
      serviceList - list of service configurations
      Throws:
      ConfigurationException
    • 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)
    • getCommandOption

      public CommandOption getCommandOption(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
    • removeInstance

      public void removeInstance(String instanceName) throws IOException
      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
    • getPluginManager

      public PluginManager getPluginManager()
    • 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.
    • getConfigurationSections

      public Map<String,Spec> getConfigurationSections(ConfigScope scope)
    • 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
    • reconfigureInstance

      public YamcsServerInstance reconfigureInstance(String name, Map<String,Object> templateArgs, Map<String,String> labels) throws IOException
      Throws:
      IOException
    • getInstances

      public static List<YamcsServerInstance> getInstances()
    • getInstance

      public YamcsServerInstance getInstance(String yamcsInstance)
    • getInstanceTemplates

      public Set<Template> getInstanceTemplates()
    • getInstanceTemplate

      public Template getInstanceTemplate(String name)
    • getTimeService

      public static TimeService getTimeService(String yamcsInstance)
      Returns the time service for a given instance
    • getSecurityStore

      public SecurityStore getSecurityStore()
    • getGlobalServices

      public List<ServiceWithConfig> getGlobalServices()
    • getGlobalServiceWithConfig

      public ServiceWithConfig getGlobalServiceWithConfig(String serviceName)
    • getService

      public <T extends YamcsService> T getService(String yamcsInstance, Class<T> serviceClass)
      Returns the service matching the specified class.

      This method requires that there be only one matching service, else it will throw an exception.

      Returns:
      The matching singleton service, else null.
      Throws:
      IllegalStateException - There is more than one matching service.
    • getServices

      public <T extends YamcsService> List<T> getServices(String yamcsInstance, Class<T> serviceClass)
    • setMockupTimeService

      public static void setMockupTimeService(TimeService timeService)
    • getGlobalService

      public YamcsService getGlobalService(String serviceName)
    • getGlobalService

      public <T extends YamcsService> T getGlobalService(Class<T> serviceClass)
      Returns the global service matching the specified class.

      This method requires that there be only one matching service, else it will throw an exception.

      Returns:
      The matching singleton service, else null.
      Throws:
      IllegalStateException - There is more than one matching service.
    • getGlobalServices

      public <T extends YamcsService> List<T> getGlobalServices(Class<T> serviceClass)
    • startGlobalService

      public void startGlobalService(String serviceName) throws ConfigurationException, ValidationException, InitException
      Throws:
      ConfigurationException
      ValidationException
      InitException
    • getCrashHandler

      public CrashHandler getCrashHandler(String yamcsInstance)
    • getGlobalCrashHandler

      public CrashHandler getGlobalCrashHandler()
    • getConfigDirectory

      public Path getConfigDirectory()
    • getDataDirectory

      public Path getDataDirectory()
    • getIncomingDirectory

      @Deprecated public Path getIncomingDirectory()
      Deprecated.
      Path of the Yamcs incoming directory. This global option is deprecated. Links that need an incoming directory, should read this information directly from that link's configuration.
    • 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)
    • prepareStart

      public void prepareStart() throws ValidationException, IOException, InitException
      Throws:
      ValidationException
      IOException
      InitException
    • validateMainConfiguration

      public void validateMainConfiguration() throws ValidationException
      Throws:
      ValidationException
    • start

      public void start() throws PluginException
      Throws:
      PluginException
    • isShuttingDown

      public boolean isShuttingDown()
      Returns true when Yamcs is shutting down.
    • addInstanceTemplate

      public void addInstanceTemplate(Template template)
    • addGlobalServicesAndInstances

      public void addGlobalServicesAndInstances() throws IOException, ValidationException, InitException
      Throws:
      IOException
      ValidationException
      InitException
    • getProcessor

      public Processor getProcessor(String yamcsInstance, String processorName)
    • getThreadPoolExecutor

      public ScheduledThreadPoolExecutor getThreadPoolExecutor()