Package org.yamcs
Class YamcsServer
java.lang.Object
org.yamcs.YamcsServer
Yamcs server together with the global instances
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommandOption(CommandOption option) Registers the system-wide availability of aCommandOption.voidvoidaddConfigurationList(ConfigScope scope, String key, Spec spec) voidaddConfigurationSection(String key, Spec spec) Add the definition of an additional configuration section to the root Yamcs spec (yamcs.yaml).voidaddConfigurationSection(ConfigScope scope, String key, Spec spec) Add the definition of an additional configuration section to a particular configuration type<T extends YamcsService>
voidaddGlobalService(String name, Class<T> serviceClass, YConfiguration args) voidaddInstance(String name, InstanceMetadata metadata, boolean offline, YConfiguration config) Creates a new yamcs instance.voidaddInstanceTemplate(Template template) voidaddReadyListener(ReadyListener readyListener) Register a listener that will be called when Yamcs has fully started.createInstance(String name, String templateName, Map<String, Object> templateArgs, Map<String, String> labels, Map<String, Object> customMetadata) Create a new instance based on a template.Returns the command options registered to this instance.Returns the main Yamcs configurationgetConfigurationLists(ConfigScope scope) getCrashHandler(String yamcsInstance) <T extends YamcsService>
TgetGlobalService(Class<T> serviceClass) Returns the global service matching the specified class.getGlobalService(String serviceName) <T extends YamcsService>
List<T>getGlobalServices(Class<T> serviceClass) getGlobalServiceWithConfig(String serviceName) Deprecated.getInstance(String yamcsInstance) static List<YamcsServerInstance>getInstanceTemplate(String name) getProcessor(String yamcsInstance, String processorName) byte[]static YamcsServerThe serverId has to be unique among Yamcs servers connected to eachother.<T extends YamcsService>
TgetService(String yamcsInstance, Class<T> serviceClass) Returns the service matching the specified class.<T extends YamcsService>
List<T>getServices(String yamcsInstance, Class<T> serviceClass) getSpec()Returns the configuration specification for the config returned bygetConfig().static TimeServicegetTimeService(String yamcsInstance) Returns the time service for a given instancebooleanstatic booleanhasInstance(String instance) booleanhasInstanceTemplate(String template) static voidinitServices(String instance, List<ServiceWithConfig> services) booleanReturns true when Yamcs is shutting down.static voidvoidvoidvoidremoveInstance(String instanceName) restartInstance(String instanceName) Restarts a yamcs instance.voidsetBucketManager(BucketManager bucketManager) Intended for unit tests only.static voidsetMockupTimeService(TimeService timeService) voidshutDown()voidstart()voidstartGlobalService(String serviceName) startInstance(String instanceName) Start the instance.static voidstartServices(List<ServiceWithConfig> serviceList) Starts the specified list of services.stopInstance(String instanceName) Stop the instance (it will be offline after this)void
-
Field Details
-
CFG_CRASH_HANDLER_KEY
- See Also:
-
GLOBAL_INSTANCE
- See Also:
-
SERVICE_STOP_GRACE_TIME
public static final int SERVICE_STOP_GRACE_TIMEDuring shutdown, allow services this number of seconds for stopping- See Also:
-
-
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:
ValidationExceptionInitException
-
startServices
Starts the specified list of services.- Parameters:
serviceList- list of service configurations- Throws:
ConfigurationException
-
shutDown
public void shutDown() -
hasInstance
-
hasInstanceTemplate
-
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
Registers the system-wide availability of aCommandOption. 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
Linkthat 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
Returns the command options registered to this instance. -
hasCommandOption
-
getCommandOption
-
addCommandOptionListener
-
removeCommandOptionListener
-
getConfig
Returns the main Yamcs configuration -
getSpec
Returns the configuration specification for the config returned bygetConfig(). -
restartInstance
Restarts a yamcs instance.- Parameters:
instanceName- the name of the instance- Returns:
- the newly created instance
- Throws:
IOException
-
stopInstance
Stop the instance (it will be offline after this)- Parameters:
instanceName- the name of the instance- Returns:
- the instance
- Throws:
IOException
-
removeInstance
- Throws:
IOException
-
startInstance
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
-
getBucketManager
-
setBucketManager
Intended for unit tests only. -
getPluginManager
-
addConfigurationSection
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 configspec- the specification of this configuration section.
-
addConfigurationSection
Add the definition of an additional configuration section to a particular 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 configspec- the specification of this configuration section.
-
addConfigurationList
-
getConfigurationSections
-
getConfigurationLists
-
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 instancemetadata- 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 configconfig- 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, throws IOExceptionString> labels, Map<String, Object> customMetadata) Create a new instance based on a template.- Parameters:
name- the name of the instancetemplateName- the name of an available templatetemplateArgs- arguments to use while processing the templatelabels- labels associated to this instancecustomMetadata- 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, throws IOExceptionString> labels) - Throws:
IOException
-
getInstances
-
getInstance
-
getInstanceTemplates
-
getInstanceTemplate
-
getTimeService
Returns the time service for a given instance -
getSecurityStore
-
getGlobalServices
-
getGlobalServiceWithConfig
-
getService
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
-
setMockupTimeService
-
getGlobalService
-
getGlobalService
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
-
startGlobalService
public void startGlobalService(String serviceName) throws ConfigurationException, ValidationException, InitException -
getCrashHandler
-
getGlobalCrashHandler
-
getConfigDirectory
-
getDataDirectory
-
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
-
addReadyListener
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
- Returns:
- the (singleton) server
-
main
-
prepareStart
-
validateMainConfiguration
- Throws:
ValidationException
-
start
- Throws:
IOExceptionPluginException
-
isShuttingDown
public boolean isShuttingDown()Returns true when Yamcs is shutting down. -
addInstanceTemplate
-
addGlobalServicesAndInstances
-
getProcessor
-
getThreadPoolExecutor
-