Package fr.gouv.vitam.common
Class ServerIdentity
java.lang.Object
fr.gouv.vitam.common.ServerIdentity
- All Implemented Interfaces:
ServerIdentityInterface
Server Identity containing ServerName, ServerRole, Global PlatformId
This is a private Common.
By default this class is initialized with default values:
One should initialize its server instance by calling:
Role could be a multiple, noted as role1_role2_role3.
Usage:
NOTE for developers:
This is a private Common.
By default this class is initialized with default values:
- ServerName: hostname or UnknownHostname if not found
- ServerRole: UnknownRole
- ServerId: partial MAC ADDRESS as integer
- SiteId : 0
One should initialize its server instance by calling:
ServerIdentity serverIdentity = ServerIdentity.getInstance(); serverIdentity.setName(name).setRole(role).setPlatformId(platformId); or ServerIdentity.getInstance().setFromMap(map); or ServerIdentity.getInstance().setFromPropertyFile(file);Where name, role and platformID comes from a configuration file for instance.
Role could be a multiple, noted as role1_role2_role3.
Usage:
ServerIdentity serverIdentity = ServerIdentity.getInstance(); String name = serverIdentity.getName(); String role = serverIdentity.getRole(); int platformId = serverIdentity.getPlatformId();Main usages are for:
- GUID for PlatformId
- Logger and Logbook: for all
NOTE for developers:
- Do not add LOGGER there
- Do not modify directly serverId attribute . Use setServerId
- Do not modify directly siteId attribute . Use setSiteId
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Map key for setFromMapstatic class
Implementation of ServerIdentityConfiguration Interface -
Method Summary
Modifier and TypeMethodDescriptionfinal int
static final ServerIdentity
final String
final String
final String
getName()
final String
getRole()
final int
final int
final ServerIdentity
setFromMap
(Map<String, Object> map) Assign the ServerIdentity from a Map where Key are elements from MAP_KEYNAME.final ServerIdentity
setFromPropertyFile
(File propertiesFile) Assign the ServerIdentity from a Property file where Key are elements from MAP_KEYNAME.final ServerIdentity
setFromYamlFile
(File yamlFile) Assign the ServerIdentity from a Yaml file where Key are elements from MAP_KEYNAME.final ServerIdentity
final ServerIdentity
final ServerIdentity
setServerId
(int serverId) The PlatformId is a unique name per site (each of the 3 sites of Vitam should have a different id).final ServerIdentity
setSiteId
(int siteId) Set the SideID
-
Method Details
-
getLoggerMessagePrepend
- Specified by:
getLoggerMessagePrepend
in interfaceServerIdentityInterface
- Returns:
- the Logger Message prepend
-
getJsonIdentity
- Returns:
- the Json representation of the ServerIdentity
-
getInstance
- Returns:
- the current instance of ServerIdentity
-
setFromPropertyFile
Assign the ServerIdentity from a Property file where Key are elements from MAP_KEYNAME.
Other keys are ignored. Illegal values are ignored.- Parameters:
propertiesFile
- file- Returns:
- this
- Throws:
FileNotFoundException
- if the property file is not found
-
setFromYamlFile
Assign the ServerIdentity from a Yaml file where Key are elements from MAP_KEYNAME.
Other keys are ignored. Illegal values are ignored.- Parameters:
yamlFile
- file- Returns:
- this
- Throws:
FileNotFoundException
- if the Yaml file is not found
-
setFromMap
Assign the ServerIdentity from a Map where Key are elements from MAP_KEYNAME.
Other keys are ignored. Illegal values are ignored.- Parameters:
map
- the map from which the values are to be set- Returns:
- this
- Throws:
IllegalArgumentException
- map null
-
getName
- Specified by:
getName
in interfaceServerIdentityInterface
- Returns:
- the name of the Server
-
setName
- Parameters:
name
- the name of the Server to set- Returns:
- this
- Throws:
IllegalArgumentException
- name null
-
getRole
- Specified by:
getRole
in interfaceServerIdentityInterface
- Returns:
- the role of the Server
-
setRole
- Parameters:
role
- the role of the Server to set- Returns:
- this
- Throws:
IllegalArgumentException
- role
-
getGlobalPlatformId
public final int getGlobalPlatformId()- Specified by:
getGlobalPlatformId
in interfaceServerIdentityInterface
- Returns:
- the global uniq Id of the server (global along all sites)
-
setServerId
The PlatformId is a unique name per site (each of the 3 sites of Vitam should have a different id).- Parameters:
serverId
- the platformId of the Vitam Platform to set- Returns:
- this
- Throws:
IllegalArgumentException
- platformId < 0
-
getServerId
public final int getServerId()- Specified by:
getServerId
in interfaceServerIdentityInterface
- Returns:
- the uniq Id of the Server
-
getSiteId
public final int getSiteId()- Specified by:
getSiteId
in interfaceServerIdentityInterface
- Returns:
- the siteID
-
setSiteId
Set the SideID- Parameters:
siteId
- the siteId to set- Returns:
- this
-