Andrew Brown | e96c16d | 2015-02-21 15:44:42 -0800 | [diff] [blame] | 1 | # jndn-utils |
| 2 | |
| 3 | This project is a collection of tools to simplify synchronous and asynchronous data transfer over the NDN network. It relies on the [NDN Protocol](https://named-data.net) and its associated [client library](https://github.com/named-data/jndn). |
| 4 | |
| 5 | ## Install |
| 6 | With Maven, add the following to your POM: |
| 7 | ``` |
| 8 | <dependency> |
| 9 | <groupId>com.intel.jndn.utils</groupId> |
| 10 | <artifactId>jndn-utils</artifactId> |
| 11 | <version>RELEASE</version> <!-- or a specific version --> |
| 12 | </dependency> |
| 13 | ``` |
| 14 | |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 15 | ## Build |
| 16 | |
| 17 | To build, run `mvn install` in the cloned directory. Additionally, you may want |
| 18 | to run integration tests by running the `nfd-integration-tests` profile with |
| 19 | a running NFD instance (see [pom.xml](https://github.com/01org/jndn-utils/blob/master/pom.xml) for more details); |
| 20 | |
Andrew Brown | e96c16d | 2015-02-21 15:44:42 -0800 | [diff] [blame] | 21 | ## Use |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 22 | |
| 23 | This library provides `Client`, `Server` and `Repository` interfaces. These |
| 24 | are implemented in their respective `impl` packages and require Java 8. |
| 25 | |
| 26 | Use a `SimpleClient` or `AdvancedClient` (provides segmentation, retries, and streaming) |
| 27 | to retrieve data from the network. For example: |
Andrew Brown | e96c16d | 2015-02-21 15:44:42 -0800 | [diff] [blame] | 28 | ``` |
andrewsbrown | 7fff867 | 2015-04-07 09:24:17 -0700 | [diff] [blame] | 29 | // retrieve a single Data packet synchronously, will block until complete |
Andrew Brown | ec84305 | 2016-09-02 21:26:06 -0700 | [diff] [blame] | 30 | Data singleData = SimpleClient.getDefault().getSync(face, prefix); |
andrewsbrown | 7fff867 | 2015-04-07 09:24:17 -0700 | [diff] [blame] | 31 | |
Andrew Brown | ec84305 | 2016-09-02 21:26:06 -0700 | [diff] [blame] | 32 | // retrieve segmented Data packets (i.e. with a last Component containing a segment number and a valid FinalBlockId) by prefix |
| 33 | CompletableFuture<Data> segmentedData = AdvancedClient.getDefault().getAsync(face, prefix); |
andrewsbrown | 20ccfdd | 2015-04-07 09:34:31 -0700 | [diff] [blame] | 34 | ``` |
andrewsbrown | 7fff867 | 2015-04-07 09:24:17 -0700 | [diff] [blame] | 35 | |
andrewsbrown | 20ccfdd | 2015-04-07 09:34:31 -0700 | [diff] [blame] | 36 | Use `SimpleServer` or `SegmentedServer` to serve data on the network. For example: |
| 37 | ``` |
andrewsbrown | 7fff867 | 2015-04-07 09:24:17 -0700 | [diff] [blame] | 38 | // segment and serve Data packet under a specific prefix |
| 39 | RepositoryServer server = new SegmentedServer(face, prefix); |
| 40 | server.serve(largeDataPacket); // call face.processEvents() in an event loop |
| 41 | |
andrewsbrown | 20ccfdd | 2015-04-07 09:34:31 -0700 | [diff] [blame] | 42 | // add signatures; this pipeline stage will sign each Data packet prior to being encoded for transport |
andrewsbrown | 7fff867 | 2015-04-07 09:24:17 -0700 | [diff] [blame] | 43 | server.addPipelineStage(new SigningStage(keyChain, signingCertificateName)); |
Andrew Brown | e96c16d | 2015-02-21 15:44:42 -0800 | [diff] [blame] | 44 | ``` |
| 45 | |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 46 | For the full API, see the [Javadoc](http://01org.github.io/jndn-utils/). |
| 47 | |
| 48 | ## Logging |
| 49 | |
| 50 | `jndn-utils` uses Java's default logging utilities (see http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html). Most messages are logged with the FINER or FINEST status; one way to change this is to add a `logging.properties` file in the classpath with the following lines: |
| 51 | ``` |
| 52 | handlers=java.util.logging.ConsoleHandler |
| 53 | .level=FINEST |
| 54 | java.util.logging.ConsoleHandler.level=FINEST |
| 55 | ``` |
andrewsbrown | 7fff867 | 2015-04-07 09:24:17 -0700 | [diff] [blame] | 56 | |
Andrew Brown | e96c16d | 2015-02-21 15:44:42 -0800 | [diff] [blame] | 57 | ## License |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 58 | Copyright © 2015, Intel Corporation. |
andrewsbrown | 4feb2da | 2015-03-03 16:05:29 -0800 | [diff] [blame] | 59 | |
| 60 | This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU Lesser General Public License, version 3, as published by the Free Software Foundation. |
| 61 | |
| 62 | This program is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU Lesser General Public License](https://github.com/01org/jndn-utils/blob/master/LICENSE) for more details. |