async start() { const igniteClient = new IgniteClient(this.onStateChanged.bind(this)); try { const connectionOptions = { 'key' : FS.readFileSync(TLS_KEY_FILE_NAME), 'cert' : FS.readFileSync(TLS_CERT_FILE_NAME), 'ca' : FS.readFileSync(TLS_CA_FILE_NAME) }; await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT). setUserName(USER_NAME). setPassword(PASSWORD). setConnectionOptions(true, connectionOptions)); const cache = (await igniteClient.getOrCreateCache(CACHE_NAME)). setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER). setValueType(ObjectType.PRIMITIVE_TYPE.SHORT_ARRAY); await this.putGetData(cache); await igniteClient.destroyCache(CACHE_NAME); } catch (err) { console.log('ERROR: ' + err.message); } finally { igniteClient.disconnect(); } }
async start() { const igniteClient = new IgniteClient(this.onStateChanged.bind(this)); try { await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT)); this._personObjectType = new ComplexObjectType(new Person(), PERSON_TYPE_NAME). setFieldType('id', ObjectType.PRIMITIVE_TYPE.INTEGER); this._personCache = (await igniteClient.getOrCreateCache(CACHE_NAME)). setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER). setValueType(this._personObjectType); this._binaryObjectCache = igniteClient.getCache(CACHE_NAME). setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER); await this.putComplexObjects(); await this.putAllBinaryObjects(); await this.getAllComplexObjects(); await this.getBinaryObjects(); await this.scanQuery(); await igniteClient.destroyCache(CACHE_NAME); } catch (err) { console.log('ERROR: ' + err.message); } finally { igniteClient.disconnect(); } }
// This example demonstrates failover behavior of the client // - configures the client to connect to a set of nodes // - connects to a node // - if connection is broken, the client automatically tries to reconnect to another node // - if no specified nodes are available, stops the client async function connectClient() { const igniteClient = new IgniteClient(onStateChanged); igniteClient.setDebug(true); try { const igniteClientConfiguration = new IgniteClientConfiguration( ENDPOINT1, ENDPOINT2, ENDPOINT3); // connect to Ignite a node await igniteClient.connect(igniteClientConfiguration); } catch (err) { console.log(err.message); } }
async start() { const igniteClient = new IgniteClient(this.onStateChanged.bind(this)); try { await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT)); const cacheCfg = new CacheConfiguration(). setQueryEntities( new QueryEntity(). setValueTypeName('Person'). setFields([ new QueryField('id', 'java.lang.Integer'), new QueryField('firstName', 'java.lang.String'), new QueryField('lastName', 'java.lang.String'), new QueryField('salary', 'java.lang.Double') ])); this._cache = (await igniteClient.getOrCreateCache(PERSON_CACHE_NAME, cacheCfg)). setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER). setValueType(new ComplexObjectType(new Person()). setFieldType('id', ObjectType.PRIMITIVE_TYPE.INTEGER)); await this.generateData(); const sqlCursor = await this._cache.query( new SqlQuery('Person', 'salary > ? and salary <= ?'). setArgs(900, 1600)); console.log('SqlQuery results (salary between 900 and 1600):'); let person; do { person = (await sqlCursor.getValue()).getValue(); console.log(Util.format(' name: %s %s, salary: %d', person.firstName, person.lastName, person.salary)); } while (sqlCursor.hasMore()); await igniteClient.destroyCache(PERSON_CACHE_NAME); } catch (err) { console.log('ERROR: ' + err.message); } finally { igniteClient.disconnect(); } }