Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The YangSerializerRegistry interface provides 2 API's:

Code Block
languagejava
titleTo register a new serializer or overwrite if the serializer for a particular data format already exists.
Code Block
void registerSerializer(YANGSerializer serializer)
Code Block
languagejava
titleTo unregister the specified serializer

...

void unregisterSerializer(YANGSerializer serializer)

 

2) Model Registry 

This API is used by schema aware application to register YANG model. Example:L3VPN application and also live compiler.

Example: When L3VPN application wants to register L3VPN service model it has to extend the AbstractYangModelRegistrator which allows the application to attach endpoints to the respective service model.

Code Block
languagejava
titleCode Snippet

...

public class L3VpnModelRegistrator extends AbstractYangModelRegistrator

...

 {
    /**

...

     * Creates L3VPN model registrator.

     */

    public L3VpnModelRegistrator() {

...


     * Creates L3VPN model registrator.
     */
    public L3VpnModelRegistrator() {
        super(IetfL3VpnSvc.class, getAppInfo());

...

    }

...


    }
    private static Map<YangModuleId, AppModuleInfo> getAppInfo()

...

 {
        Map<YangModuleId, AppModuleInfo> appInfo = new HashMap<>();

...


        appInfo.put(new DefaultYangModuleId("ietf-inet-types", "2013-00-15"),

...


                    new DefaultAppModuleInfo(IetfInetTypes.class, null));

...


        appInfo.put(new DefaultYangModuleId("ietf-l3vpn-svc", "2016-00-30"),

...


                    new DefaultAppModuleInfo(IetfL3VpnSvc.class, null));

...


        appInfo.put(new DefaultYangModuleId("ietf-yang-types", "2013-00-15"),

...


                    new DefaultAppModuleInfo(IetfYangTypes.class, null));

...


        appInfo.put(new DefaultYangModuleId("l3vpn-svc-ext", "2016-00-30"),

...


                    new DefaultAppModuleInfo(L3VpnSvcExt.class, null));

...


        return ImmutableMap.copyOf(appInfo);

...


    }
}

...

 

The YangModelRegistry interface provides the following methods: 

Code Block
languagejava
titleRegister a new model with parameters specifying any additional information provided by the application.

...

void registerModel(ModelRegistrationParam param)

 

 

Code Block
languagejava
titleUnregister the specified model with parameters specifying any addtional information provided by the applciation.

...

 void unregisterModel(ModelRegistrationParam param) 

 

3) Runtime Service 

It is a service for encoding and decoding between internal and external model representation.

...

Also protocols like NETCONF will have decorations around the input stream which will be reported back to protocol in output. Produced annotations will be in order of pre-order traversal.
=>CompositeData

 

Code Block
languagejava
CompositeData decode(CompositeStream external, RuntimeContext context)

 

 

The encode method encodes the internal in-memory representation of a configuration model to an external representation consumable from the resulting input stream.Resource identifier in composite data will get encoded to resource data stream.

...

Also protocols like NETCONF would like to provide additional decorations for the node. The decoration should be in pre-order traversal order. =>CompositeStream

 

Code Block
languagejava
CompositeStream encode(CompositeData internal, RuntimeContext context)

 

4) ModelConverter Service 

Model converter provides a mechanism for converting between DataNode and Model Object instances. It is capable of constructing model POJO objects from the DataNode,including any augmentations which may be present in the DataNode structure and creating immutable tree structure from a given POJO. This API mainly gives the following methods:
//

 

Code Block
languagejava
titleProduces a mutable POJO backed by the specified data node

...

ModelObject createModel(DataNode)

...

 

 

 

Code Block
languagejava
titleProduces an immutable tree structure rooted at the returned DataNode using the supplied model POJO object

...

DataNode createDataNode(ModelObject)

 

5) SchemaContext Provider 

It returns an entity that provides schema context corresponding to a given resource identifier.  //

Code Block
languagejava
titleIf the model is not registered the implementation returns null else it returns schema context corresponding to a given resource identifier.

...

SchemaContext getSchemaContext(ResourceId id)

 

Helper Utils

  • Runtime Helper

    Represents utility for runtime.These utilities can be used by the application to get the YANG model for the application and also it can be used by the runtime to get the YANG Node for the given YANG model.

    Examples API's :1.

     

    Code Block
    languagejava
    titleTo obtain YANG model for given generated class:
    =>YANGModel
     YANGModel getModel(Class<?> aClass)
    2.
    Code Block
    languagejava
    titleTo get YANG node for given YANG model
    =>Set<YANGNode>
     Set<YANGNode> getNodes(YANGModel model)
    3.
    Code Block
    languagejava
    titleTo get interface class name of the schema node
    =>String
     String getInterfaceClassName(YANGSchemaNode schemaNode)

     

  • Serializer Helper

    These set of utilities are used by Serializer to build the data node and resource identifier without obtaining schema.

    Example API's:1.

    ResourceId
    Code Block
    languagejava
    titleTo add to resource identifier builder used by applications which are not aware about the schema name association with key's value.This api will also carry out necessary schema related validations.
    =>
     ResourceId.Builder addToResourceId(ResourceId.Builder builder, String name, String namespace, List<String> value)
    2.
    Code Block
    languagejava
    title
    To add a data node to a given data node builder. This API will also carry out necessary schema related validations.
    =>
    Builder addDataNode(Builder builder, String name, String namespace, String value, DataNode.Type type)
    3.
    Code Block
    languagejava
    title
    To get the resource identifier for a given data node. This API will be used by serializer to obtain the resource identifier in the scenario when an annotation is associated with a given data node.
    =>
    ResourceId getResourceId(Builder builder)

...

Use Case Scenarios Of YANG Runtime

...