Page tree

Versions Compared

Key

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

...

  • SubjectFactory ties a subject to its subject key, and generates objects that represent the subject.

    Example: the factory that generates ConnectPoints is instantiated as:

    Code Block
    languagejava
    public static final SubjectFactory<ConnectPoint> CONNECT_POINT_SUBJECT_FACTORY =
        new SubjectFactory<ConnectPoint>(ConnectPoint.class, "ports") {
            @Override
            public ConnectPoint createSubject(String key) {
                return ConnectPoint.deviceConnectPoint(key);
            }
        };

    meaning that the key for the JSON field containing port information is keyed on string “ports”, and the factory can create ConnectPoints from a “deviceId:port” string (the argument to createSubject).

  • ConfigFactory ties a subject to its config and config key, and generates Configs.

    Example: The ConfigFactory for OpticalPortConfig is defined as:

    Code Block
    languagejava
    // ConfigFactory<S, C extends Config<S>>
    new ConfigFactory<ConnectPoint, OpticalPortConfig>(CONNECT_POINT_SUBJECT_FACTORY,
                                                       OpticalPortConfig.class,
                                                       "optical") {
        @Override
        public OpticalPortConfig createConfig() {
            return new OpticalPortConfig();
        }
    }

    indicating that this ConfigFactory can generate OpticalPortConfigs, and the configuration information for a given optical port can be fetched from the subsystem’s manager using its associated subject (a ConnectPoint in this case). In the JSON structure, the key “basic” can be used to fetch out the values set by the OpticalPortConfig.

...

The relationship between the subject, config, subject key, and config key are summarized by the following JSON tree:

Code Block
languagetext
{
    subject key 1 : {
        subject 1 : {
            config key 1 : {
                attr1 : value1,
                attr2 : value2,
                ...
            },
            config key 2 : {
                ...
            }
        },
        subject 2 : {
          ...
    },
    subject key 2 {
    ...
}

...

For example, a configuration for the device identified by the ID (subject) of:0000ffffffffff0a might look like the following:

Code Block
languagetext
{
   "devices" : {
      "of:0000ffffffffff0a" : {
          "basic": {
              "driver": "linc-oe",
              "type": "ROADM",
              "latitude": 33.8,
              "name": "ATL-S10",
              "longitude": -84.1
          }
      }
   }
}

...

Indeed, if you were to take a look at BasicDeviceConfig and its superclass, you will find all of the fields within the “basic” clause above defined in those two classes.

...

Making objects configurable

The network configuration subsystem can be used to configure arbitrary network objects. For an object to be configurable through this subsystem, you must implement the components described in Components. Some things to note are:

  • SubjectFactory implementations belong in SubjectFactories. While you may want to use an existing factory for your subject of choice, you may want to implement a new SubjectFactory in addition to an existing one if a different key/creation technique is required for a subject.

  • ConfigFactory must be registered with the NetworkConfigManager. Adding a ConfigFactory to BasicNetworkConfigs will cause it to be registered when the subsystem starts up. Alternatively, you may manually invoke NetworkConfigManager.registerConfigFactory() from the application:

    Code Block
    languagejava
    // in the application:
    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
    protected NetworkConfigRegistry registry;
    
    private ConfigFactory configFactory =
            new ConfigFactory(SubjectFactories.FOO_SUBJECT_FACTORY, FooConfig.class, "foo") {
        @Override
        public FooConfig createConfig() {
            return new FooConfig();
        }
    };
    
    public void register() {
        registry.registerConfigFactory(configFactory);
    }
  • ConfigOperators enforce an order of precedence on information depending on their source. As a general rule, the configs supplied by this subsystem override information supplied by providers.

Using the service from applications

As with other services, the two primary ways that an application can use the network configuration subsystem are:

...