gdp / lang / js / README.md @ master
History | View | Annotate | Download (6.66 KB)
1 | 60c6eafe | Christopher Brooks | JavaScript Global Data Plane access application programs and support libraries |
---|---|---|---|
2 | ============================================================================== |
||
3 | 5f4144b2 | Christopher Brooks | |
4 | 60c6eafe | Christopher Brooks | The Global Data Plane (GDP) is a middleware that provides a |
5 | data-centric glue for swarm applications. The basic primitive is that |
||
6 | of a secure single-writer append-only log stored on potentially |
||
7 | untrusted distributed infrastructure. Logs natively support a |
||
8 | publish-subscribe mode, making GDP a communication tool. At the same |
||
9 | time, data in a GDP log can be stored for long-term in a |
||
10 | fault-tolerant manner, thus making it an ideal tool for data-storage. |
||
11 | |||
12 | For more information about GDP, see the following publications: |
||
13 | - [Toward a Global Data Infrastructure](http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=7436637) |
||
14 | - [The Cloud is Not Enough: Saving IoT from the Cloud](https://www.terraswarm.org/pubs/518.html) |
||
15 | |||
16 | This package provides a JavaScript interface to the GDP. |
||
17 | 5f4144b2 | Christopher Brooks | |
18 | Resources |
||
19 | 60c6eafe | Christopher Brooks | --------- |
20 | * [https://gdp.cs.berkeley.edu](https://gdp.cs.berkeley.edu) |
||
21 | 5f4144b2 | Christopher Brooks | * [GDP API documentation](https://docs.google.com/document/d/1MdJ47NEfUQdJlTyAXwotZp8aJbXchRIi3VgwOz4LWuU/edit?usp=sharing) |
22 | * [Discussion of the GDP JS interface](http://www.terraswarm.org/swarmos/wiki/Main/GDPJavaScriptInterface) |
||
23 | |||
24 | 60c6eafe | Christopher Brooks | See also apps/README.txt. |
25 | |||
26 | Installation |
||
27 | ------------ |
||
28 | The libs/ directory contains shared libraries for Darwin, RHEL and |
||
29 | Ubuntu. RHEL and Ubuntu libraries are needed because of issues with |
||
30 | libgdp need libcrypto and libcrypto needing different versions of |
||
31 | libssl. |
||
32 | |||
33 | 45e498cc | Christopher Brooks | Note that the GDP shared library included in this module requires |
34 | other packages. To install the other packages, run |
||
35 | |||
36 | ./adm/gdp-setup.sh |
||
37 | |||
38 | 60c6eafe | Christopher Brooks | A modern version of npm is required, where modern is not npm 1.3.6. |
39 | |||
40 | We create a local `node_modules/` directory to make it easier to |
||
41 | describe the installation process. In practice, `npm` will install |
||
42 | in the `node_modules/` directory that is above the current directory. |
||
43 | |||
44 | mkdir node_modules |
||
45 | |||
46 | Install using npm: |
||
47 | |||
48 | npm install @terraswarm/gdp |
||
49 | |||
50 | e45215fd | Christopher Brooks | Ignore messages about "ENOENT: no such file or directory, open 'xxx/package.json'". |
51 | To remove them, see [npm-autoint](https://www.npmjs.com/package/npm-autoinit). |
||
52 | |||
53 | 60c6eafe | Christopher Brooks | Try out a test: |
54 | |||
55 | npm install mocha |
||
56 | cd node_modules/@terraswarm/gdp |
||
57 | 8b8120ec | Christopher Brooks | ../../mocha/bin/mocha -t 4000 test/mocha |
58 | 60c6eafe | Christopher Brooks | |
59 | What the test does is create a new log, write a string to it and then |
||
60 | read back the string from the log. |
||
61 | |||
62 | Issues |
||
63 | ------ |
||
64 | * The functions that are exported are funky. |
||
65 | ** The read_gcl_records() and write_gcl_records() functions take too many arguments and open and close the log each time |
||
66 | * Subscription via a callback is not yet supported. |
||
67 | 5f4144b2 | Christopher Brooks | |
68 | Files |
||
69 | ----- |
||
70 | 60c6eafe | Christopher Brooks | * Makefile: Recursive make for gdpjs/ and apps/. |
71 | Currently, apps/ does not build anything. |
||
72 | 5f4144b2 | Christopher Brooks | |
73 | 0153b908 | Christopher Brooks | * README.md: This file. Also, see README's in our subdirectories. |
74 | 5f4144b2 | Christopher Brooks | |
75 | 60c6eafe | Christopher Brooks | * apps/: JavaScript standalone applications programs. In particular, apps/writer-test.js |
76 | 5f4144b2 | Christopher Brooks | and apps/reader-test.js - both hand translations of corresponding gdp/apps/ |
77 | C programs. These should also provide good examples of access to GDP from |
||
78 | 60c6eafe | Christopher Brooks | Node.js JavaScript. Run with Node.js. See apps/README.txt. |
79 | 5f4144b2 | Christopher Brooks | |
80 | 0153b908 | Christopher Brooks | * adm/: The libgdp shared library depends on libevent2 and other libraries. |
81 | To install the necessary libraries, run adm/gdp-setup.sh. |
||
82 | 5f4144b2 | Christopher Brooks | |
83 | 60c6eafe | Christopher Brooks | * gdpjs/: JavaScript and C support libraries. Has a local Makefile that does build things. |
84 | 5f4144b2 | Christopher Brooks | |
85 | c5113e6f | Christopher Brooks | * libs/: Running make in gdpjs/ populates the libs/ directory. If $PTII |
86 | is set, then shared libraries for other platforms are copied from $PTII/lib. |
||
87 | 5f4144b2 | Christopher Brooks | |
88 | c5113e6f | Christopher Brooks | * node_modules/: Node.js modules required by these JS programs and |
89 | libraries. Loaded into our source repository via "npm install |
||
90 | <module_name>" . |
||
91 | 5f4144b2 | Christopher Brooks | |
92 | 0153b908 | Christopher Brooks | * test: Mocha test scripts. To run, do: |
93 | npm install mocha |
||
94 | mocha test/mocha |
||
95 | |||
96 | |||
97 | 45e498cc | Christopher Brooks | Updating this module and using those changes with the Node Accessor Host |
98 | ======================================================================== |
||
99 | |||
100 | To make channges visible to the Node Accessor Host, one can either |
||
101 | upload the changes to npm, which requires updating the version number |
||
102 | in package.json or one can install the module locally. |
||
103 | |||
104 | To install the module locally: |
||
105 | |||
106 | cd $PTII/org/terraswarm/accessor/accessors/web/hosts/node |
||
107 | npm install $PTII/vendors/gdp/gdp/lang/js |
||
108 | |||
109 | $PTII/org/terraswarm/accessor/accessors/web/hosts/node/node_modules/@terraswarm/gdp/ |
||
110 | should be created or updated. |
||
111 | |||
112 | After that, one may edit |
||
113 | $PTII/org/terraswarm/accessor/accessors/web/hosts/node/node_modules/@terraswarm/gdp/gdpjs/gdpjs.js, |
||
114 | but don't forget to fold the changes back in to |
||
115 | $PTII/vendors/gdp/gdp/lang/js/gdpjs/gdpjs.js |
||
116 | |||
117 | 0153b908 | Christopher Brooks | Testing using Ptolemy II |
118 | ======================== |
||
119 | If necessary, update $PTII/lib: |
||
120 | |||
121 | cp libs/libgdpjs.1.0.dylib $PTII/lib |
||
122 | 7244e92d | Christopher Brooks | svn commit -m "Updated to gdp0.8.0." $PTII/lib/libgdpjs.1.0.dylib |
123 | 0153b908 | Christopher Brooks | |
124 | Then run the model using Node: |
||
125 | |||
126 | (cd $PTII/org/terraswarm/accessor/accessors/web/gdp/test/auto; node ../../../hosts/node/nodeHostInvoke.js -timeout 6000 gdp/test/auto/GDPLogCreateAppendReadJS) |
||
127 | |||
128 | The Node Host Composite Accessor creates a log on edu.berkeley.eecs.gdp-01.gdplogd, appends to it and reads from it. |
||
129 | |||
130 | |||
131 | 5f4144b2 | Christopher Brooks | Updating the GDP Version Number |
132 | ============================== |
||
133 | 0153b908 | Christopher Brooks | (This is for the use of maintainers of this node module.) |
134 | 5f4144b2 | Christopher Brooks | |
135 | If the GDP version number in ../../gdp/gdp_version.h changes, the make the following changes: |
||
136 | |||
137 | 1. gdpjs/Makefile: Update: |
||
138 | c5113e6f | Christopher Brooks | # Version of the GDP Library, should match ../../../gdp/Makefile |
139 | GDPLIBMAJVER= 0 |
||
140 | 7244e92d | Christopher Brooks | GDPLIBMINVER= 8 |
141 | 5f4144b2 | Christopher Brooks | |
142 | 2. gdpjs/gdpjs.js: Update |
||
143 | 7244e92d | Christopher Brooks | |
144 | // libcrypto and libssl are different under RHEL vs. Ubuntu, so |
||
145 | // we have different shared libraries for RHEL. |
||
146 | var libgdpPath = '/libs/libgdp.0.8'; |
||
147 | var libgdpjsPath = '/../libs/libgdpjs.1.0'; |
||
148 | try { |
||
149 | var fs = require('fs'); |
||
150 | fs.accessSync('/etc/redhat-release', fs.F_OK); |
||
151 | libgdpPath = '/libs/libgdp.0.8-rhel'; |
||
152 | libgdpjsPath = '/../libs/libgdpjs.1.0-rhel'; |
||
153 | } catch (exception) { |
||
154 | // Not under RHEL |
||
155 | } |
||
156 | 5f4144b2 | Christopher Brooks | |
157 | 3. Update package.json: |
||
158 | 7244e92d | Christopher Brooks | "version": "0.8.0", |
159 | 5f4144b2 | Christopher Brooks | |
160 | 4. Run make all_noavahi |
||
161 | |||
162 | 5a798b38 | Christopher Brooks | Or, see accessors/web/gdp/adm/gdpUpdatePtII.sh in |
163 | the accessors repo. See https://www.icyphy.org/accessors/svn.html |
||
164 | 5f4144b2 | Christopher Brooks | |
165 | c5113e6f | Christopher Brooks | Install the npm @terrswarm/gdp package on the npm server. |
166 | ======================================================== |
||
167 | 0153b908 | Christopher Brooks | (This is for the use of maintainers of this node module.) |
168 | c5113e6f | Christopher Brooks | |
169 | We are using an account named |
||
170 | '[terraswarm](https://www.npmjs.com/~terraswarm)' on the npmjs |
||
171 | repository to manage the @terraswarm/gdp package. |
||
172 | |||
173 | To update the @terraswarm/gdp package on npmjs: |
||
174 | |||
175 | 1. Update libgdp and libep: |
||
176 | 8b8120ec | Christopher Brooks | (cd ../..; make all) |
177 | c5113e6f | Christopher Brooks | 2. Update libgdpjs: |
178 | 60c6eafe | Christopher Brooks | make all |
179 | c5113e6f | Christopher Brooks | 3. Update the patch number in package.json |
180 | 4. Login to npm |
||
181 | npm login |
||
182 | 5f4144b2 | Christopher Brooks | |
183 | c5113e6f | Christopher Brooks | Username: terraswarm |
184 | Password: See ~terra/.npmpass on terra |
||
185 | Email: terraswarm-software@terraswarm.org |
||
186 | 5. Publish: |
||
187 | npm publish --access public |
||
188 | 5f4144b2 | Christopher Brooks |