The Basics of Configiration System -- ConfigNamespace and ConfigOption
来源:互联网 发布:软件著作权 翻译 编辑:程序博客网 时间:2024/06/05 18:25
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.
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 Basics of Configiration System -- ConfigNamespace and ConfigOption
- Basics of the Debian package management system
- The basics of Silvermoon
- The basics of swift
- The Basics of Numpy
- Foundations of Microsoft Expression Web: The Basics and Beyond
- Basics of telnet and http
- Basics of the Unix Philosophy
- Chapter6 The Basics of JavaScript
- Quiz: The basics of C
- The Basics Of Image Filtering
- The Basics of Fresnel Shading
- Sparsity and Some Basics of L1 Regularization
- Sparsity and Some Basics of L1 Regularization
- Sparsity and Some Basics of L1 Regularization
- Sparsity and Some Basics of L1 Regularization
- Sparsity and Some Basics of L1 Regularization
- Sparsity and Some Basics of L1 Regularization
- 关于静态方法与非静态方法的执行效率
- hiho1268 九宫(DFS练习)
- BZOJ 1209([HNOI2004]最佳包裹-三维凸包)
- GAN——LSGANs(最小二乘GAN)
- Solr搜索服务的搭建(Liunx)
- The Basics of Configiration System -- ConfigNamespace and ConfigOption
- java使用递归,非递归方式实现二叉树的三种常见遍历方式
- Java常见异常
- cocos2dx 获取某像素点的rgba值
- 并查集详解
- 【九度OJ】题目1439:Least Common Multiple 解题报告
- js中window和document的宽高
- 经验教训:Ubuntu 14.04上安装Nvidia显卡驱动,无经验者慎行!
- 手把手Maven搭建SpringMVC+Spring+MyBatis框架(超级详细版)