Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
function IdentifiedEntryProcessor(value) {
// Constructor function
}
IdentifiedEntryProcessor.prototype.readData = function (inp) {
};
IdentifiedEntryProcessor.prototype.writeData = function (outp) {
};
IdentifiedEntryProcessor.prototype.getFactoryId = function () {
return 1;
};
IdentifiedEntryProcessor.prototype.getClassId = function () {
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var HazelcastClient = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
var cfg = new Config.ClientConfig();
cfg.listeners.addLifecycleListener(function (state) {
console.log('Lifecycle Event >>> ' + state);
});
HazelcastClient.newHazelcastClient(cfg).then(function (hazelcastClient) {
hazelcastClient.shutdown();
});
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config.ClientConfig;
var UsernamePasswordCredentials = require('./user_pass_cred').UsernamePasswordCredentials;
var UsernamePasswordCredentialsFactory = require('./user_pass_cred_factory').UsernamePasswordCredentialsFactory;
var readerClientConfig = new Config();
readerClientConfig.serializationConfig.portableFactories[1] = new UsernamePasswordCredentialsFactory();
readerClientConfig.customCredentials = new UsernamePasswordCredentials('reader', 'password2', '127.0.0.1');
Client.newHazelcastClient(readerClientConfig).then(function (readerClient) {
console.log('Reader client connected');
var readerMap;
return readerClient.getMap('importantReaderMap').then(function (map) {
console.log('Reader can create a map');
readerMap = map;
return readerMap.get('someKey');
* Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Config = require('hazelcast-client').Config;
var HazelcastClient = require('hazelcast-client').Client;
var cfg = new Config.ClientConfig();
cfg.networkConfig.sslConfig.enabled = true;
HazelcastClient.newHazelcastClient(cfg).then(function (client) {
console.log('This client is authenticated using SSL.');
client.shutdown();
});
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
var Predicates = require('hazelcast-client').Predicates;
var HazelcastJsonValue = require('hazelcast-client').HazelcastJsonValue;
var JsonStringDeserializationPolicy = require('hazelcast-client').JsonStringDeserializationPolicy;
var config = new Config.ClientConfig();
config.serializationConfig.jsonStringDeserializationPolicy = JsonStringDeserializationPolicy.NO_DESERIALIZATION;
Client.newHazelcastClient(config).then(function(hz) {
var map;
return hz.getMap('employees').then(function(mp) {
map = mp;
var employees = [
{ name: 'Alice', age: 35 },
{ name: 'Andy', age: 22},
{ name: 'Bob', age: 37 }
];
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
function Employee(id, name) {
this.id = id;
this.name = name;
}
Employee.prototype.readData = function (input) {
this.id = input.readInt();
this.name = input.readUTF();
};
Employee.prototype.writeData = function (output) {
output.writeInt(this.id);
output.writeUTF(this.name);
};
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
function createConfig() {
var cfg = new Config.ClientConfig();
var nearCacheConfig = new Config.NearCacheConfig();
cfg.nearCacheConfigs['nearCachedMap'] = nearCacheConfig;
cfg.properties['hazelcast.client.statistics.enabled'] = true;
cfg.properties['hazelcast.client.statistics.period.seconds'] = 2;
return cfg;
}
Client.newHazelcastClient(createConfig()).then(function (client) {
var ncMap;
return client.getMap('nearCachedMap').then(function (map) {
ncMap = map;
return ncMap.put('key1', 'value1');
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* JSON serialization is not capable if handling circular references.
* We will use Mousse serializer to serialize our self referring objects.
*/
var mousse = require('mousse');
var Client = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
var cfg = new Config.ClientConfig();
cfg.serializationConfig.globalSerializer = {
mousseSerialize: mousse.serialize,
mousseDeserialize: mousse.deserialize,
getId: function () {
return 10;
},
write: function (out, obj) {
out.writeUTF(this.mousseSerialize(obj))
},
read: function (inp) {
var representation = inp.readUTF();
return this.mousseDeserialize(representation).then(function (obj) {
return obj;
});
}
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var Predicates = require('hazelcast-client').Predicates;
var Config = require('hazelcast-client').Config;
function User(username, age, active) {
this.username = username;
this.age = age;
this.active = active;
}
User.prototype.readPortable = function (reader) {
this.username = reader.readUTF('username');
this.age = reader.readInt('age');
this.active = reader.readBoolean('active');
};
User.prototype.writePortable = function (writer) {
writer.writeUTF('username', this.username);
writer.writeInt('age', this.age);
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Client = require('hazelcast-client').Client;
var ClientConfig = require('hazelcast-client').Config.ClientConfig;
var fs = require('fs');
var Path = require('path');
function createClientConfigWithSSLOpts(key, cert, ca) {
var sslOpts = {
servername: 'Hazelcast-Inc',
rejectUnauthorized: true,
ca: fs.readFileSync(Path.join(__dirname, ca)),
key: fs.readFileSync(Path.join(__dirname, key)),
cert: fs.readFileSync(Path.join(__dirname, cert))
};
var cfg = new ClientConfig();
cfg.networkConfig.sslOptions = sslOpts;
cfg.networkConfig.connectionAttemptLimit = 1000;