Recent Changes - Search:

Using the RD

Resource Directory (RD)

 

In the Smart Santander system one of the main RD’s tasks is persistent storage of resources available in the system. Resources are described using human/machine readable resource description format. During system bootstrapping, the system topology of a testbed is initialized based on the information from the RD. Whenever the topology changes afterwards, the RD is updated accordingly. Up to date system resources management is provided through the REST based RD interfaces.

  • Resources may be listed using HTTP GET method on the following URL format: <RD_HOST>/rd
  • Access to the specific resource description is available using the following URL format: <RD_HOST>/rd/<RESOURCE_UID>
    • Allowed HTTP methods are GET, POST (for resource creation), PUT (for resource updating) and DELETE (for resource deleting).
  • RD querying is provided through the RLI interface. Querying is performed using HTTP GET on the following URL format: <RD_HOST>/rli?<QUERY>
    • QUERY is encoded as URL parameters.
    • Example: <RD_HOST>/rli?sensor.type=temperature will return resources with sensor type temperature.

RD manages resource “create/update” fields as well as appropriate querying of these fields. This feature facilitates component bootstrapping/restarting. Existing query interface is extended for create/update fields, their values may be specified inthe ‘yyyy-MM-dd HH:mm:ss’ time format or milliseconds since 1.1.1970.

Template based matching in the query interface is introduced. This querying is based on the regular expression usage. Currently template based querying is part of the existing query interface, but this will be moved to the additional querying interface.

Some fields of the resource description are interpreted as a numeric values, which provides a better querying capabilities. This enhancement for example enables location based resource querying like: ..longitude>0. For appropriate TMON integration, several resource fields needs to be interpreted as a values, like device radio power etc.

RD is based on the free form tree based resource description structure. Resource description model is shown on the following figure.


Resource description data model

Resource description example:

	<resource-description>
		<uid>MLAB.smartsantander.eu</uid>
		<created>2013-07-03 15:21:58</created>
		<updated>2013-07-03 15:21:58</updated>
		<resource_type>GATEWAY</resource_type>
		<urnprefix>urn:smartsantander:testbed:</urnprefix>
		<parent_id>testbed.smartsantander.eu</parent_id>
		<ssh_port>22</ssh_port>
		<position>
			<type>OUTDOOR</type>
			<outdoor_coordinates>
				<longitude>-3.80017</longitude>
				<latitude>43.47172</latitude>
			</outdoor_coordinates>
		</position>
	  <is_experiment_gw>true</is_experiment_gw>
	  <is_service_gw>true</is_service_gw>
	  <is_logical_gw>false</is_logical_gw>
	  <node_status>READY</node_status>
	</resource-description>


Parts of the resource description like uid, created, updated are managed by the RD and thus can't be updated by end user.

Querying is performed for elements value in the following format: <RD_HOST>/rli?path=value. Path is relative to the root element dot separated. For example if we need resources with type OUTDOOR qurey is: <RD_HOST>/rli?position.type=OUTDOOR

For easier usage Java RD API library is built. Methods in the RD API are from generic CRUD to the component specific methods like “enable/disable node” etc.

Sample Java RD API library usage:

                RD_API_HTTP rdApi = new RD_API_HTTP(RD_URL);

		// list resources
		List<RDResource> resources = rdApi.getRDResources();

		// a new resource creation
		RDResource res = new RDResource();

		res.setName("resource-description");
		res.setUid(uid);
		RDNode descr = new RDNode(RDNodeValueType.Container, "sensor", null)
			.addChild(new RDNode(RDNodeValueType.String, "type", "temperature"))
			.addChild(new RDNode(RDNodeValueType.String, "unit", "celsius"));

		res.addChild(descr);
		res.addChild(descr);

		// resource publishing
		rdApi.addResource(res);

		// resource updating
		rdApi. updateResource(newResource, uid);

		// resource deleting
		rdApi.deleteResource(uid);

		// resource querying
		List<RDResource> resLookup = rdApi.lookupRD("sensor.type=Temperature");
Edit - History - Print - Recent Changes - Search
Page last modified on July 23, 2013, at 11:44 AM