infinispan 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.eslintrc +25 -0
  2. package/Jenkinsfile-release +5 -3
  3. package/documentation/asciidoc/stories/assembly_client_usage_examples.adoc +2 -8
  4. package/documentation/asciidoc/stories/{assembly_configuration.adoc → assembly_installation_configuration.adoc} +6 -4
  5. package/documentation/asciidoc/titles/js_client.asciidoc +1 -0
  6. package/documentation/asciidoc/titles/stories.adoc +1 -2
  7. package/documentation/asciidoc/topics/attributes/community-attributes.adoc +2 -1
  8. package/documentation/asciidoc/topics/attributes/downstream-attributes.adoc +0 -2
  9. package/documentation/asciidoc/topics/code_examples/authentication-digest.js +3 -2
  10. package/documentation/asciidoc/topics/code_examples/authentication-external.js +3 -2
  11. package/documentation/asciidoc/topics/code_examples/authentication-oauthbearer.js +3 -2
  12. package/documentation/asciidoc/topics/code_examples/authentication-plain.js +3 -2
  13. package/documentation/asciidoc/topics/code_examples/authentication-scram.js +3 -2
  14. package/documentation/asciidoc/topics/code_examples/await-single-entries.js +1 -1
  15. package/documentation/asciidoc/topics/code_examples/conditional-operations.js +7 -1
  16. package/documentation/asciidoc/topics/code_examples/connection-multiple-servers.js +5 -1
  17. package/documentation/asciidoc/topics/code_examples/data-types.js +2 -2
  18. package/documentation/asciidoc/topics/code_examples/ephemeral-data.js +11 -6
  19. package/documentation/asciidoc/topics/code_examples/hello-world.js +13 -1
  20. package/documentation/asciidoc/topics/code_examples/key-value-converter.js +3 -4
  21. package/documentation/asciidoc/topics/code_examples/multiple-entries.js +13 -2
  22. package/documentation/asciidoc/topics/code_examples/queries.js +92 -0
  23. package/documentation/asciidoc/topics/code_examples/register-event-listener.js +8 -4
  24. package/documentation/asciidoc/topics/code_examples/sample-script-execute.js +6 -1
  25. package/documentation/asciidoc/topics/code_examples/single-entries.js +13 -2
  26. package/documentation/asciidoc/topics/proc_configuring_connections.adoc +8 -9
  27. package/documentation/asciidoc/topics/proc_installing_clients.adoc +23 -5
  28. package/documentation/asciidoc/topics/ref_client_usage.adoc +128 -0
  29. package/lib/codec.js +153 -2
  30. package/lib/infinispan.js +87 -57
  31. package/lib/io.js +14 -8
  32. package/lib/protocols.js +129 -4
  33. package/lib/protostream/message-wrapping.proto +134 -0
  34. package/lib/protostream/query.proto +122 -0
  35. package/lib/sasl/bitops.js +5 -7
  36. package/lib/sasl/factory.js +71 -0
  37. package/lib/utils.js +1 -1
  38. package/memory-profiling/helper.js +9 -0
  39. package/memory-profiling/infinispan_memory_many_get.js +1 -3
  40. package/memory-profiling/infinispan_memory_one_get.js +6 -4
  41. package/package.json +10 -12
  42. package/run-servers.sh +1 -1
  43. package/smoke-tests.sh +1 -0
  44. package/spec/codec_spec.js +7 -7
  45. package/spec/configs/infinispan-clustered.xml +17 -14
  46. package/spec/configs/infinispan-ssl.xml +25 -22
  47. package/spec/configs/infinispan-xsite-EARTH.xml +17 -14
  48. package/spec/configs/infinispan-xsite-MOON.xml +14 -11
  49. package/spec/configs/infinispan.xml +22 -13
  50. package/spec/protostream_spec.js +237 -0
  51. package/spec/utils/testing.js +1 -3
  52. package/types/README.md +91 -0
  53. package/types/index.d.ts +868 -0
  54. package/.jshintrc +0 -14
  55. package/documentation/asciidoc/stories/assembly_getting_started.adoc +0 -11
  56. package/documentation/asciidoc/topics/community-attributes.adoc +0 -10
  57. package/documentation/asciidoc/topics/downstream-attributes.adoc +0 -10
  58. package/documentation/asciidoc/topics/proc_executing_scripts.adoc +0 -16
  59. package/documentation/asciidoc/topics/proc_registering_event_listeners.adoc +0 -31
  60. package/documentation/asciidoc/topics/proc_using_async_await.adoc +0 -23
  61. package/documentation/asciidoc/topics/proc_using_conditional_operations.adoc +0 -7
  62. package/documentation/asciidoc/topics/proc_working_ephemeral_data.adoc +0 -7
  63. package/documentation/asciidoc/topics/proc_working_multiple_entries.adoc +0 -7
  64. package/documentation/asciidoc/topics/proc_working_single_entries_statistics.adoc +0 -7
  65. package/documentation/asciidoc/topics/ref_basic_usage.adoc +0 -8
package/.eslintrc ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "root":true,
3
+ "env": {
4
+ "es6": true,
5
+ "node": true
6
+ },
7
+ "parserOptions": {
8
+ "ecmaVersion": 2022,
9
+ "sourceType": "module"
10
+ },
11
+ "rules": {
12
+ "standard/no-callback-literal": "off",
13
+ "arrow-spacing": "error",
14
+ "arrow-parens": ["error", "as-needed"],
15
+ "arrow-body-style": ["error", "as-needed"],
16
+ "prefer-template": "error",
17
+ "no-unused-vars": ["warn", {
18
+ "argsIgnorePattern": "^_$|^e$|^reject$|^resolve$"
19
+ }],
20
+ "valid-jsdoc": "error",
21
+ "require-jsdoc": "warn",
22
+ "semi": ["error", "always"],
23
+ "quotes": ["error", "single", { "allowTemplateLiterals": true }]
24
+ }
25
+ }
@@ -24,7 +24,7 @@ pipeline {
24
24
 
25
25
  stage('Install release package') {
26
26
  steps {
27
- nodejs(nodeJSInstallationName: 'Node 14') {
27
+ nodejs(nodeJSInstallationName: 'Node 18') {
28
28
  sh 'rm -drf node_modules/'
29
29
  sh 'npm config ls'
30
30
  sh 'npm install'
@@ -35,10 +35,12 @@ pipeline {
35
35
 
36
36
  stage('Release') {
37
37
  steps {
38
- nodejs(nodeJSInstallationName: 'Node 14') {
38
+ nodejs(nodeJSInstallationName: 'Node 18') {
39
39
  withCredentials([string(credentialsId: 'npmauthtoken', variable: 'NPM_AUTH_TOKEN')]) {
40
40
  sh './set-npm-auth-token.sh'
41
41
  }
42
+ sh "git status"
43
+ sh "git diff"
42
44
  sh "npm-release ${version}"
43
45
  }
44
46
  }
@@ -46,7 +48,7 @@ pipeline {
46
48
 
47
49
  stage('Generate JS API docs and upload') {
48
50
  steps {
49
- nodejs(nodeJSInstallationName: 'Node 14') {
51
+ nodejs(nodeJSInstallationName: 'Node 18') {
50
52
  sh './node_modules/.bin/jsdoc lib/*.js'
51
53
  sh 'mv out apidocs'
52
54
  sh 'mkdir 1.0'
@@ -1,15 +1,9 @@
1
1
  [id='client-usage-examples']
2
2
  :context: client-usage-examples
3
3
  = Using {hr_js} clients
4
- This section provides code examples that show you how to use {hr_js} clients to perform various operations.
4
+ Take a look at some examples for using the {hr_js} client with {brandname}.
5
5
 
6
- include::{topics}/proc_working_single_entries_statistics.adoc[leveloffset=+1]
7
- include::{topics}/proc_using_conditional_operations.adoc[leveloffset=+1]
8
- include::{topics}/proc_working_multiple_entries.adoc[leveloffset=+1]
9
- include::{topics}/proc_working_ephemeral_data.adoc[leveloffset=+1]
10
- include::{topics}/proc_registering_event_listeners.adoc[leveloffset=+1]
11
- include::{topics}/proc_executing_scripts.adoc[leveloffset=+1]
12
- include::{topics}/proc_using_async_await.adoc[leveloffset=+1]
6
+ include::{topics}/ref_client_usage.adoc[leveloffset=+1]
13
7
 
14
8
  // Restore the parent context.
15
9
  ifdef::parent-context[:context: {parent-context}]
@@ -1,8 +1,10 @@
1
- [id='client-configuration']
2
- :context: client-configuration
3
- = Configuring {hr_js} clients
4
- Configure {hr_js} clients to connect to {brandname} Server, use different media types for keys and values, and adjust levels for log messages.
1
+ [id='install-configure']
2
+ :context: install-configure
3
+ = Installing and configuring {hr_js} clients
4
+ Ensure your system meets requirements before installing the {hr_js} client.
5
+ You can then configure {hr_js} clients to connect to {brandname} Server, use different media types for keys and values, and customize logging.
5
6
 
7
+ include::{topics}/proc_installing_clients.adoc[leveloffset=+1]
6
8
  include::{topics}/proc_configuring_connections.adoc[leveloffset=+1]
7
9
  include::{topics}/proc_configuring_connections_xsite.adoc[leveloffset=+2]
8
10
  include::{topics}/proc_switching_clusters.adoc[leveloffset=+2]
@@ -9,6 +9,7 @@ include::{topics}/attributes/community-attributes.adoc[]
9
9
  //Downstream
10
10
  //include::{topics}/attributes/downstream-attributes.adoc[]
11
11
  //:downstream:
12
+ //:rhdg-install-npmrepo:
12
13
 
13
14
  //Title attributes
14
15
  :toc2:
@@ -1,6 +1,5 @@
1
1
  //Reference user stories or topics.
2
2
  //Please review authoring guidelines in the Contributors Guide.
3
3
 
4
- include::{stories}/assembly_getting_started.adoc[leveloffset=+1]
5
- include::{stories}/assembly_configuration.adoc[leveloffset=+1]
4
+ include::{stories}/assembly_installation_configuration.adoc[leveloffset=+1]
6
5
  include::{stories}/assembly_client_usage_examples.adoc[leveloffset=+1]
@@ -3,6 +3,7 @@
3
3
 
4
4
  :doc_home: https://infinispan.org/documentation/
5
5
  :download_url: https://infinispan.org/hotrod-clients
6
- :js_api_docs: https://docs.jboss.org/infinispan/hotrod-clients/javascript/1.0/apidocs/
6
+ :node_docs: https://docs.jboss.org/infinispan/hotrod-clients/javascript/1.0/apidocs/
7
7
  :server_docs: https://infinispan.org/docs/stable/titles/server/server.html
8
8
  :code_tutorials: https://github.com/infinispan/infinispan-simple-tutorials/
9
+ :query_docs: https://infinispan.org/docs/stable/titles/query/query.html
@@ -1,4 +1,2 @@
1
1
  :brandname: Data Grid
2
2
  :hr_js: Hot Rod JS
3
-
4
- :js_api_docs: https://access.redhat.com/webassets/avalon/d/red-hat-data-grid/8.2/node/
@@ -1,5 +1,6 @@
1
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'},
2
- {
1
+ var connected = infinispan.client(
2
+ {port: 11222, host: '127.0.0.1'},
3
+ {
3
4
  authentication: {
4
5
  enabled: true,
5
6
  saslMechanism: 'DIGEST-MD5',
@@ -1,5 +1,6 @@
1
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'},
2
- {
1
+ var connected = infinispan.client(
2
+ {port: 11222, host: '127.0.0.1'},
3
+ {
3
4
  authentication: {
4
5
  enabled: true,
5
6
  saslMechanism: 'EXTERNAL'
@@ -1,5 +1,6 @@
1
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'},
2
- {
1
+ var connected = infinispan.client(
2
+ {port: 11222, host: '127.0.0.1'},
3
+ {
3
4
  authentication: {
4
5
  enabled: true,
5
6
  saslMechanism: 'OAUTHBEARER',
@@ -1,5 +1,6 @@
1
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'},
2
- {
1
+ var connected = infinispan.client(
2
+ {port: 11222, host: '127.0.0.1'},
3
+ {
3
4
  authentication: {
4
5
  enabled: true,
5
6
  saslMechanism: 'PLAIN',
@@ -1,5 +1,6 @@
1
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'},
2
- {
1
+ var connected = infinispan.client(
2
+ {port: 11222, host: '127.0.0.1'},
3
+ {
3
4
  authentication: {
4
5
  enabled: true,
5
6
  saslMechanism: 'SCRAM-SHA-1',
@@ -21,7 +21,7 @@ async function test() {
21
21
  let stats = await client.stats();
22
22
  console.log('Number of stores: ' + stats.stores);
23
23
  console.log('Number of cache hits: ' + stats.hits);
24
- console.log('All stats: ' + JSON.stringify(stats, null, " "));
24
+ console.log('All statistics: ' + JSON.stringify(stats, null, " "));
25
25
 
26
26
  await client.disconnect();
27
27
  }
@@ -1,6 +1,11 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'});
3
+ var connected = infinispan.client(
4
+ {port: 11222, host: '127.0.0.1'}
5
+ {
6
+ // Configure client connections with authentication and encryption here.
7
+ }
8
+ );
4
9
 
5
10
  connected.then(function (client) {
6
11
 
@@ -18,6 +23,7 @@ connected.then(function (client) {
18
23
  var clientGetMetaForReplace = showReplace.then(
19
24
  function() { return client.getWithMetadata('cond'); });
20
25
 
26
+ // Call the getWithMetadata method to retrieve the value and its metadata.
21
27
  var clientReplaceWithVersion = clientGetMetaForReplace.then(
22
28
  function(entry) {
23
29
  console.log('getWithMetadata(cond)=' + JSON.stringify(entry));
@@ -1,7 +1,11 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
3
  var connected = infinispan.client(
4
- [{port: 11322, host: '127.0.0.1'}, {port: 11222, host: '127.0.0.1'}]);
4
+ [{port: 11322, host: '127.0.0.1'}, {port: 11222, host: '127.0.0.1'}]
5
+ {
6
+ // Configure client connections with authentication and encryption here.
7
+ }
8
+ );
5
9
 
6
10
  connected.then(function (client) {
7
11
 
@@ -1,8 +1,8 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
3
  var connected = infinispan.client(
4
- {port: 11222, host: '127.0.0.1'}
5
- , {
4
+ {port: 11222, host: '127.0.0.1'},
5
+ {
6
6
  dataFormat : {
7
7
  keyType: 'application/json',
8
8
  valueType: 'application/json'
@@ -1,6 +1,11 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'});
3
+ var connected = infinispan.client(
4
+ {port: 11222, host: '127.0.0.1'}
5
+ {
6
+ // Configure client connections with authentication and encryption here.
7
+ }
8
+ );
4
9
 
5
10
  connected.then(function (client) {
6
11
 
@@ -8,26 +13,26 @@ connected.then(function (client) {
8
13
 
9
14
  var clientGetMetaAndSize = clientPutExpiry.then(
10
15
  function() {
11
- // Compute getWithMetadata and size in parallel
16
+ // Compute getWithMetadata and size in parallel.
12
17
  return Promise.all([client.getWithMetadata('expiry'), client.size()]);
13
18
  });
14
19
 
15
20
  var showGetMetaAndSize = clientGetMetaAndSize.then(
16
21
  function(values) {
17
- console.log('before expiration:');
22
+ console.log('Before expiration:');
18
23
  console.log('getWithMetadata(expiry)=' + JSON.stringify(values[0]));
19
24
  console.log('size=' + values[1]);
20
25
  });
21
26
 
22
27
  var clientContainsAndSize = showGetMetaAndSize.then(
23
28
  function() {
24
- sleepFor(1100); // Sleep to force expiration
29
+ sleepFor(1100); // Sleep to force expiration.
25
30
  return Promise.all([client.containsKey('expiry'), client.size()]);
26
31
  });
27
32
 
28
33
  var showContainsAndSize = clientContainsAndSize.then(
29
34
  function(values) {
30
- console.log('after expiration:');
35
+ console.log('After expiration:');
31
36
  console.log('containsKey(expiry)=' + values[0]);
32
37
  console.log('size=' + values[1]);
33
38
  });
@@ -43,5 +48,5 @@ connected.then(function (client) {
43
48
 
44
49
  function sleepFor(sleepDuration){
45
50
  var now = new Date().getTime();
46
- while(new Date().getTime() < now + sleepDuration){ /* do nothing */ }
51
+ while(new Date().getTime() < now + sleepDuration){ /* Do nothing. */ }
47
52
  }
@@ -1,8 +1,20 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
3
  // Connect to {brandname} Server.
4
+ // Use an existing cache named "myCache".
4
5
  var connected = infinispan.client(
5
- {port: 11222, host: '127.0.0.1'}, {cacheName: 'myCache'});
6
+ {port: 11222, host: '127.0.0.1'},
7
+ {
8
+ cacheName: 'myCache',
9
+ clientIntelligence: 'BASIC',
10
+ authentication: {
11
+ enabled: true,
12
+ saslMechanism: 'DIGEST-MD5',
13
+ userName: 'username',
14
+ password: 'changeme'
15
+ }
16
+ }
17
+ );
6
18
 
7
19
  connected.then(function (client) {
8
20
 
@@ -11,7 +11,7 @@ var connected = infinispan.client(
11
11
  );
12
12
 
13
13
  connected.then(function (client) {
14
-
14
+ // Include the remote event converter to avoid unnecessary roundtrips.
15
15
  var opts = {
16
16
  converterFactory : {
17
17
  name: "key-value-with-previous-converter-factory"
@@ -22,9 +22,8 @@ connected.then(function (client) {
22
22
 
23
23
  var clientAddListeners = clientAddListenerCreate.then(
24
24
  function(listenerId) {
25
- // Multiple callbacks can be associated with a single client-side listener.
26
- // This is achieved by registering listeners with the same listener id
27
- // as shown in the example below.
25
+ // Associate multiple callbacks with a single client-side listener.
26
+ // To do this, register listeners with the same listener ID.
28
27
  var clientAddListenerModify =
29
28
  client.addListener('modify', logEvent("Modified"), {opts, listenerId: listenerId});
30
29
 
@@ -1,6 +1,17 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'});
3
+ var connected = infinispan.client(
4
+ {port: 11222, host: '127.0.0.1'},
5
+ {
6
+ cacheName: 'myCache',
7
+ authentication: {
8
+ enabled: true,
9
+ saslMechanism: 'DIGEST-MD5',
10
+ userName: 'username',
11
+ password: 'changeme'
12
+ }
13
+ }
14
+ );
4
15
 
5
16
  connected.then(function (client) {
6
17
  var data = [
@@ -25,7 +36,7 @@ connected.then(function (client) {
25
36
  var showIterated = clientIterator.then(
26
37
  function(it) {
27
38
  function loop(promise, fn) {
28
- // Simple recursive loop over iterator's next() call
39
+ // Simple recursive loop over the iterator's next() call.
29
40
  return promise.then(fn).then(function (entry) {
30
41
  return entry.done
31
42
  ? it.close().then(function () { return entry.value; })
@@ -0,0 +1,92 @@
1
+ const infinispan = require('infinispan');
2
+ const protobuf = require('protobufjs');
3
+ // This example uses async/await paradigma
4
+ (async function () {
5
+ // User data protobuf definition
6
+ const cacheValueProtoDef = `package awesomepackage;
7
+ /**
8
+ * @TypeId(1000044)
9
+ */
10
+ message AwesomeUser {
11
+ required string name = 1;
12
+ required int64 age = 2;
13
+ required bool isVerified =3;
14
+ }`
15
+ try {
16
+ // Creating clients for two caches:
17
+ // - ___protobuf_metadata for registering .proto file
18
+ // - queryCache for user data
19
+ const connectProp = { port: 11222, host: '127.0.0.1' };
20
+ const commonOpts = {
21
+ version: '3.0',
22
+ authentication: {
23
+ enabled: true,
24
+ saslMechanism: 'DIGEST-MD5',
25
+ userName: 'admin',
26
+ password: 'pass'
27
+ }
28
+ };
29
+ const protoMetaClientOps = {
30
+ cacheName: '___protobuf_metadata',
31
+ dataFormat: { keyType: "text/plain", valueType: "text/plain" }
32
+ }
33
+ const clientOps = {
34
+ dataFormat: { keyType: "text/plain", valueType: "application/x-protostream" },
35
+ cacheName: 'queryCache'
36
+ }
37
+ var protoMetaClient = await infinispan.client(connectProp, Object.assign(commonOpts, protoMetaClientOps));
38
+ var client = await infinispan.client(connectProp, Object.assign(commonOpts, clientOps));
39
+
40
+ // Registering protobuf definition on server
41
+ await protoMetaClient.put("awesomepackage/AwesomeUser.proto", cacheValueProtoDef);
42
+
43
+ // Registering protobuf definition on protobufjs
44
+ const root = protobuf.parse(cacheValueProtoDef).root;
45
+ const AwesomeUser = root.lookupType(".awesomepackage.AwesomeUser");
46
+ client.registerProtostreamRoot(root);
47
+ client.registerProtostreamType(".awesomepackage.AwesomeUser", 1000044);
48
+
49
+ // Cleanup and populating the cache
50
+ await client.clear();
51
+ for (let i = 0; i < 10; i++) {
52
+ const payload = { name: "AwesomeName" + i, age: i, isVerified: (Math.random() < 0.5) };
53
+ const message = AwesomeUser.create(payload);
54
+ console.log("Creating entry:", message);
55
+ await client.put(i.toString(), message)
56
+ }
57
+ // Run the query
58
+ const queryStr = `select u.name,u.age from awesomepackage.AwesomeUser u where u.age<20 order by u.name asc`;
59
+ console.log("Running query:", queryStr);
60
+ const query = await client.query({ queryString: queryStr });
61
+ console.log("Query result:");
62
+ console.log(query);
63
+ } catch (err) {
64
+ handleError(err);
65
+ } finally {
66
+ if (client) {
67
+ await client.disconnect();
68
+ }
69
+ if (protoMetaClient) {
70
+ await protoMetaClient.disconnect();
71
+ }
72
+ }
73
+ })();
74
+
75
+ function handleError(err) {
76
+ if (err.message.includes("'queryCache' not found")) {
77
+ console.log('*** ERROR ***');
78
+ console.log(`*** This example needs a cache 'queryCache' with the following config:
79
+ {
80
+ "local-cache": {
81
+ "statistics": true,
82
+ "encoding": {
83
+ "key": {
84
+ "media-type": "text/plain"
85
+ },
86
+ "value": {
87
+ "media-type": "application/x-protostream"
88
+ }}}}`)
89
+ } else {
90
+ console.log(err);
91
+ }
92
+ }
@@ -1,6 +1,11 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'});
3
+ var connected = infinispan.client(
4
+ {port: 11222, host: '127.0.0.1'}
5
+ {
6
+ // Configure client connections with authentication and encryption here.
7
+ }
8
+ );
4
9
 
5
10
  connected.then(function (client) {
6
11
 
@@ -8,9 +13,8 @@ connected.then(function (client) {
8
13
 
9
14
  var clientAddListeners = clientAddListenerCreate.then(
10
15
  function(listenerId) {
11
- // Multiple callbacks can be associated with a single client-side listener.
12
- // This is achieved by registering listeners with the same listener id
13
- // as shown in the example below.
16
+ // Associate multiple callbacks with a single client-side listener.
17
+ // To do this, register listeners with the same listener ID.
14
18
  var clientAddListenerModify =
15
19
  client.addListener('modify', onModify, {listenerId: listenerId});
16
20
 
@@ -1,7 +1,12 @@
1
1
  var infinispan = require('infinispan');
2
2
  var readFile = Promise.denodeify(require('fs').readFile);
3
3
 
4
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'});
4
+ var connected = infinispan.client(
5
+ {port: 11222, host: '127.0.0.1'}
6
+ {
7
+ // Configure client connections with authentication and encryption here.
8
+ }
9
+ );
5
10
 
6
11
  connected.then(function (client) {
7
12
 
@@ -1,6 +1,17 @@
1
1
  var infinispan = require('infinispan');
2
2
 
3
- var connected = infinispan.client({port: 11222, host: '127.0.0.1'});
3
+ var connected = infinispan.client(
4
+ {port: 11222, host: '127.0.0.1'},
5
+ {
6
+ cacheName: 'myCache',
7
+ authentication: {
8
+ enabled: true,
9
+ saslMechanism: 'DIGEST-MD5',
10
+ userName: 'username',
11
+ password: 'changeme'
12
+ }
13
+ }
14
+ );
4
15
 
5
16
  connected.then(function (client) {
6
17
 
@@ -25,7 +36,7 @@ connected.then(function (client) {
25
36
  function(stats) {
26
37
  console.log('Number of stores: ' + stats.stores);
27
38
  console.log('Number of cache hits: ' + stats.hits);
28
- console.log('All stats: ' + JSON.stringify(stats, null, " "));
39
+ console.log('All statistics: ' + JSON.stringify(stats, null, " "));
29
40
  });
30
41
 
31
42
  return showStats.finally(
@@ -2,6 +2,14 @@
2
2
  = Configuring {brandname} connections
3
3
  Configure {hr_js} clients to connect to {brandname} Server.
4
4
 
5
+ If you add multiple server addresses to the configuration, the {hr_js} client loops through them until it finds a node to which it can connect.
6
+
7
+ However, you only need to add one {brandname} Server address for the client to receive the entire cluster topology.
8
+ If the {hr_js} client connects to a single server instance that is a member of a cluster, the client gets the address information for all nodes.
9
+
10
+ Because {hr_js} clients are topology aware, if a connection to one {brandname} Server breaks, the client retries any incomplete operations on other nodes in the cluster.
11
+ Likewise, if client listener that is registered on one {brandname} Server fails or leaves the cluster, the client transparently migrates the listener registration to another node in the cluster so that it can continue receiving events.
12
+
5
13
  .Prerequisites
6
14
 
7
15
  * Install the {hr_js} client.
@@ -15,12 +23,3 @@ Configure {hr_js} clients to connect to {brandname} Server.
15
23
  ----
16
24
  include::code_examples/connection-multiple-servers.js[]
17
25
  ----
18
-
19
- The preceding configuration example includes connection details for two servers.
20
- When you add multiple server addresses to the configuration, the {hr_js} client loops through them until it finds a node to which it can connect.
21
-
22
- However, you only need to add one {brandname} Server address for the client to receive the entire cluster topology.
23
- If the {hr_js} client connects to a single server instance that is a member of a cluster, the client gets the address information for all nodes.
24
-
25
- Because {hr_js} clients are topology aware, if a connection to one {brandname} Server breaks, the client retries any incomplete operations on other nodes in the cluster.
26
- Likewise, if client listener that is registered on one {brandname} Server fails or leaves the cluster, the client transparently migrates the listener registration to another node in the cluster so that it can continue receiving events.
@@ -22,19 +22,37 @@ endif::downstream[]
22
22
  ifdef::community[]
23
23
  * Install the `infinispan` client as follows:
24
24
  +
25
- [source,bash,options="nowrap",subs=attributes+]
25
+ [source,options="nowrap",subs=attributes+]
26
26
  ----
27
- $ npm i infinispan
27
+ npm install infinispan
28
28
  ----
29
29
  endif::community[]
30
30
 
31
31
  //Downstream content
32
- ifdef::downstream[]
32
+ ifdef::rhdg-install-npmrepo[]
33
+ . Add the Red Hat repository to your NPM configuration.
34
+ +
35
+ You can use the `npm config` command or add the following to an `.npmrc` file in your project:
36
+ +
37
+ [source,options="nowrap",subs=attributes+]
38
+ ----
39
+ @redhat:registry=https://npm.registry.redhat.com
40
+ registry=https://registry.npmjs.org/
41
+ ----
42
+
43
+ . Install the {hr_js} client as follows:
44
+ +
45
+ [source,options="nowrap",subs=attributes+]
46
+ ----
47
+ npm install @redhat/infinispan
48
+ ----
49
+ endif::rhdg-install-npmrepo[]
50
+ ifdef::rhdg-install-package[]
33
51
  . Download and extract the `redhat-datagrid-<version>-nodejs-client.zip` from the {portal}.
34
52
  . Install the `tgz` package from the extracted directory as in the following example:
35
53
  +
36
54
  [source,bash,options="nowrap",subs=attributes+]
37
55
  ----
38
- $ npm install /path/to/redhat-datagrid-<version>-nodejs-client/infinispan-<version>.tgz
56
+ npm install /path/to/redhat-datagrid-<version>-nodejs-client/infinispan-<version>.tgz
39
57
  ----
40
- endif::downstream[]
58
+ endif::rhdg-install-package[]