The Basics of Configiration System -- ConfigNamespace and ConfigOption
2017-03-07 10:48
525 查看
The configuration system is divided to two type, ConfigNamespace and ConfigOption. When the class GraphDatabaseConfiguration is loaded, the class static member consists a configure tree rooted by ROOT_NS.
The Confignamespace does not contain the configure name and value, it only contains the part of the name before the last dot. Take STORAGE_NS for example, it is a sub namespace of ROOT_NS.
The definition of isUmbrella.
That means, if a namespace is umbrella, then user can define subnamespace. You can define a subnamespace in REGISTRATION_NS, but you can not define a namespace in ROOT_NS.
super(parent,name,description) calls the constructor method of ConfigElement.
Method isRoot in class ConfigElement.
ConfigOption
Enumeration Type in ConfigOption.
The definition of managedTypes.
The Confignamespace does not contain the configure name and value, it only contains the part of the name before the last dot. Take STORAGE_NS for example, it is a sub namespace of ROOT_NS.
public static ConfigNamespace ROOT_NS = new ConfigNamespace(null,"root","Root Configuration Namespace for the HugeGraph Graph Database"); public static final ConfigNamespace STORAGE_NS = new ConfigNamespace(ROOT_NS,"storage","Configuration options for the storage backend. Some options are applicable only for certain backends.");
public ConfigNamespace(ConfigNamespace parent, String name, String description) { this(parent,name,description,false); }
public ConfigNamespace(ConfigNamespace parent, String name, String description, boolean isUmbrella) { super(parent,name,description); this.isUmbrella=isUmbrella; }
The definition of isUmbrella.
/** * Wether this namespace is an umbrella namespace, that is, is expects immediate sub-namespaces which are user defined. * @return */ public boolean isUmbrella() { return isUmbrella; }
That means, if a namespace is umbrella, then user can define subnamespace. You can define a subnamespace in REGISTRATION_NS, but you can not define a namespace in ROOT_NS.
public static final ConfigNamespace REGISTRATION_NS = new ConfigNamespace(ROOT_NS,"system-registration", "This is used internally to keep track of open instances.",true);
super(parent,name,description) calls the constructor method of ConfigElement.
public ConfigElement(ConfigNamespace namespace, String name, String description) { this.namespace = namespace; this.name = name; this.description = description; if (namespace!=null) namespace.registerChild(this); }
Method isRoot in class ConfigElement.
public boolean isRoot() { return namespace ==null; }
ConfigOption
public static final ConfigOption<Integer> GRAPHITE_PORT = new ConfigOption<Integer>(METRICS_GRAPHITE_NS,"port", "The port to which Graphite data are sent", ConfigOption.Type.MASKABLE, 2003);
public static final<O> Predicate<O> disallowEmpty(Class<O> clazz) { return new Predicate<O>() { @Override public boolean apply(@Nullable O o) { if (o==null) return false; if (o instanceof String) return StringUtils.isNotBlank((String)o); if (o.getClass().isArray() && (Array.getLength(o)==0 || Array.get(o,0)==null)) return false; if (o instanceof Collection && (((Collection)o).isEmpty() || ((Collection)o).iterator().next()==null)) return false; return true; } }; }
public ConfigOption(ConfigNamespace parent, String name, String description, Type type, Class<O> datatype, O defaultValue, Predicate<O> verificationFct, ConfigOption<?> supersededBy) { super(parent, name, description); Preconditions.checkNotNull(type); Preconditions.checkNotNull(datatype); Preconditions.checkNotNull(verificationFct); this.type = type; this.datatype = datatype; this.defaultValue = defaultValue; this.verificationFct = verificationFct; this.supersededBy = supersededBy; // This constructor tends to get called by static initializers, so log before throwing the IAE if (!ACCEPTED_DATATYPES.contains(datatype)) { String msg = String.format("Datatype %s is not one of %s", datatype, ACCEPTED_DATATYPES_STRING); log.error(msg); throw new IllegalArgumentException(msg); } }
Enumeration Type in ConfigOption.
public enum Type { /** * Once the database has been opened, these configuration options cannot * be changed for the entire life of the database */ FIXED, /** * These options can only be changed for the entire database cluster at * once when all instances are shut down */ GLOBAL_OFFLINE, /** * These options can only be changed globally across the entire database * cluster */ GLOBAL, /** * These options are global but can be overwritten by a local * configuration file */ MASKABLE, /** * These options can ONLY be provided through a local configuration file */ LOCAL; }
The definition of managedTypes.
private static final EnumSet<Type> managedTypes = EnumSet.of(Type.FIXED, Type.GLOBAL_OFFLINE, Type.GLOBAL);
ACCEPTED_DATATYPES = ImmutableSet.of( ConflictAvoidanceMode.class, Duration.class, TimestampProviders.class, Instant.class, Boolean.class, Short.class, Integer.class, Byte.class, Long.class, Float.class, Double.class, String.class, String[].class );
相关文章推荐
- The default keys and values of java system properties
- Basics of the Debian package management system
- A List of No Ratio Trackers, And The Ratio Free System
- windows下python 安装igraph库报错 Cannot find the C core of igraph on this system using pkg-config.的解决
- .NET错误The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework
- Design and Implementation of the Sun Network File System
- Note: Time clocks and the ordering of events in a distributed system
- CXF报错[1 counts of IllegalAnnotationExceptions]and[Two classes have the same XML type name]and[Use @XmlType.name and @XmlType.namespace to assign different names to them]
- The design and Implementation of a Log-Structured File System
- 133.Your database is open and the LISTENER listener is running. The new DBA of the system stops the
- 推荐一篇文章<<Time, Clocks, and the Ordering of Events in a Distributed System>>
- System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list
- Excessive growth of the primary database log mirror and system Performance Monitoring
- Design and Implementation of the Sun Network File System
- “System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 错误
- The tag of<o:p> and the <?xml:namespace prefix = o /> in the html
- Oracle: Benefits and consequences of the NOLOGGING option
- Time, Clocks, and the Ordering of Events in a Distributed System
- 每日一命令(13)free - (Display amount of free and used memory in the system)
- windows下python 安装igraph库报错 Cannot find the C core of igraph on this system using pkg-config.的解决