http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/browser.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/browser.js b/modules/web-console/src/main/js/serve/browser.js deleted file mode 100644 index 8a6d33e..0000000 --- a/modules/web-console/src/main/js/serve/browser.js +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -/** - * Module interaction with browsers. - */ -module.exports = { - implements: 'browser-manager', - inject: ['require(lodash)', 'require(socket.io)', 'agent-manager', 'configure'] -}; - -module.exports.factory = (_, socketio, agentMgr, configure) => { - const _errorToJson = (err) => { - return { - message: err.message || err, - code: err.code || 1 - }; - }; - - return { - attach: (server) => { - const io = socketio(server); - - configure.socketio(io); - - io.sockets.on('connection', (socket) => { - const user = socket.request.user; - - const demo = socket.request._query.IgniteDemoMode === 'true'; - - const accountId = () => user._id; - - // Return available drivers to browser. - socket.on('schemaImport:drivers', (cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.availableDrivers()) - .then((drivers) => cb(null, drivers)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Return schemas from database to browser. - socket.on('schemaImport:schemas', (preset, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => { - const jdbcInfo = {user: preset.user, password: preset.password}; - - return agent.metadataSchemas(preset.jdbcDriverJar, preset.jdbcDriverClass, preset.jdbcUrl, jdbcInfo); - }) - .then((schemas) => cb(null, schemas)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Return tables from database to browser. - socket.on('schemaImport:tables', (preset, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => { - const jdbcInfo = {user: preset.user, password: preset.password}; - - return agent.metadataTables(preset.jdbcDriverJar, preset.jdbcDriverClass, preset.jdbcUrl, jdbcInfo, - preset.schemas, preset.tablesOnly); - }) - .then((tables) => cb(null, tables)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Return topology command result from grid to browser. - socket.on('node:topology', (attr, mtr, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.topology(demo, attr, mtr)) - .then((clusters) => cb(null, clusters)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Close query on node. - socket.on('node:query:close', (queryId, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.queryClose(demo, queryId)) - .then(() => cb()) - .catch((err) => cb(_errorToJson(err))); - }); - - // Execute query on node and return first page to browser. - socket.on('node:query', (cacheName, pageSize, query, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => { - if (query === null) - return agent.scan(demo, cacheName, pageSize); - - return agent.fieldsQuery(demo, cacheName, query, pageSize); - }) - .then((res) => cb(null, res)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Fetch next page for query and return result to browser. - socket.on('node:query:fetch', (queryId, pageSize, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.queryFetch(demo, queryId, pageSize)) - .then((res) => cb(null, res)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Execute query on node and return full result to browser. - socket.on('node:query:getAll', (cacheName, query, cb) => { - // Set page size for query. - const pageSize = 1024; - - agentMgr.findAgent(accountId()) - .then((agent) => { - const firstPage = query === null ? agent.scan(demo, cacheName, pageSize) - : agent.fieldsQuery(demo, cacheName, query, pageSize); - - const fetchResult = (acc) => { - if (acc.last) - return acc; - - return agent.queryFetch(demo, acc.queryId, pageSize) - .then((res) => { - acc.items = acc.items.concat(res.items); - - acc.last = res.last; - - return fetchResult(acc); - }); - }; - - return firstPage - .then(fetchResult); - }) - .then((res) => cb(null, res)) - .catch((err) => cb(_errorToJson(err))); - }); - - // Return cache metadata from all nodes in grid. - socket.on('node:cache:metadata', (cacheName, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.metadata(demo, cacheName)) - .then((caches) => { - let types = []; - - const _compact = (className) => { - return className.replace('java.lang.', '').replace('java.util.', '').replace('java.sql.', ''); - }; - - const _typeMapper = (meta, typeName) => { - const maskedName = _.isEmpty(meta.cacheName) ? '<default>' : meta.cacheName; - - let fields = meta.fields[typeName]; - - let columns = []; - - for (const fieldName in fields) { - if (fields.hasOwnProperty(fieldName)) { - const fieldClass = _compact(fields[fieldName]); - - columns.push({ - type: 'field', - name: fieldName, - clazz: fieldClass, - system: fieldName === '_KEY' || fieldName === '_VAL', - cacheName: meta.cacheName, - typeName, - maskedName - }); - } - } - - const indexes = []; - - for (const index of meta.indexes[typeName]) { - fields = []; - - for (const field of index.fields) { - fields.push({ - type: 'index-field', - name: field, - order: index.descendings.indexOf(field) < 0, - unique: index.unique, - cacheName: meta.cacheName, - typeName, - maskedName - }); - } - - if (fields.length > 0) { - indexes.push({ - type: 'index', - name: index.name, - children: fields, - cacheName: meta.cacheName, - typeName, - maskedName - }); - } - } - - columns = _.sortBy(columns, 'name'); - - if (!_.isEmpty(indexes)) { - columns = columns.concat({ - type: 'indexes', - name: 'Indexes', - cacheName: meta.cacheName, - typeName, - maskedName, - children: indexes - }); - } - - return { - type: 'type', - cacheName: meta.cacheName || '', - typeName, - maskedName, - children: columns - }; - }; - - for (const meta of caches) { - const cacheTypes = meta.types.map(_typeMapper.bind(null, meta)); - - if (!_.isEmpty(cacheTypes)) - types = types.concat(cacheTypes); - } - - return cb(null, types); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // Fetch next page for query and return result to browser. - socket.on('node:visor:collect', (evtOrderKey, evtThrottleCntrKey, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.collect(demo, evtOrderKey, evtThrottleCntrKey)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // Swap backups specified caches on specified node and return result to browser. - socket.on('node:cache:swap:backups', (nid, cacheNames, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.cacheSwapBackups(demo, nid, cacheNames)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // Reset metrics specified cache on specified node and return result to browser. - socket.on('node:cache:reset:metrics', (nid, cacheName, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.cacheResetMetrics(demo, nid, cacheName)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // Clear specified cache on specified node and return result to browser. - socket.on('node:cache:clear', (nid, cacheName, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.cacheClear(demo, nid, cacheName)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // Start specified cache and return result to browser. - socket.on('node:cache:start', (nids, near, cacheName, cfg, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.cacheStart(demo, nids, near, cacheName, cfg)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // Stop specified cache on specified node and return result to browser. - socket.on('node:cache:stop', (nid, cacheName, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.cacheStop(demo, nid, cacheName)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - - // Ping node and return result to browser. - socket.on('node:ping', (taskNid, nid, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.ping(demo, taskNid, nid)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // GC node and return result to browser. - socket.on('node:gc', (nids, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.gc(demo, nids)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - // GC node and return result to browser. - socket.on('node:thread:dump', (nid, cb) => { - agentMgr.findAgent(accountId()) - .then((agent) => agent.threadDump(demo, nid)) - .then((data) => { - if (data.finished) - return cb(null, data.result); - - cb(_errorToJson(data.error)); - }) - .catch((err) => cb(_errorToJson(err))); - }); - - const count = agentMgr.addAgentListener(user._id, socket); - - socket.emit('agent:count', {count}); - }); - - // Handle browser disconnect event. - io.sockets.on('disconnect', (socket) => - agentMgr.removeAgentListener(socket.client.request.user._id, socket) - ); - } - }; -};
http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/config/settings.json.sample ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/config/settings.json.sample b/modules/web-console/src/main/js/serve/config/settings.json.sample deleted file mode 100644 index 94dd9f7..0000000 --- a/modules/web-console/src/main/js/serve/config/settings.json.sample +++ /dev/null @@ -1,26 +0,0 @@ -{ - "server": { - "port": 3000, - "ssl": false, - "key": "serve/keys/test.key", - "cert": "serve/keys/test.crt", - "keyPassphrase": "password" - }, - "mongoDB": { - "url": "mongodb://localhost/console" - }, - "agent-server": { - "port": 3001, - "ssl": false, - "key": "serve/keys/test.key", - "cert": "serve/keys/test.crt", - "keyPassphrase": "password" - }, - "smtp": { - "service": "", - "username": "Apache Ignite Web Console", - "sign": "Kind regards,<br>Apache Ignite Team", - "email": "", - "password": "" - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/configure.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/configure.js b/modules/web-console/src/main/js/serve/configure.js deleted file mode 100644 index 9671d66..0000000 --- a/modules/web-console/src/main/js/serve/configure.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -/** - * Module for configuration express and websocket server. - */ -module.exports = { - implements: 'configure', - inject: ['require(morgan)', 'require(cookie-parser)', 'require(body-parser)', - 'require(express-session)', 'require(connect-mongo)', 'require(passport)', 'require(passport.socketio)', 'settings', 'mongo'] -}; - -module.exports.factory = function(logger, cookieParser, bodyParser, session, connectMongo, passport, passportSocketIo, settings, mongo) { - const _sessionStore = new (connectMongo(session))({mongooseConnection: mongo.connection}); - - return { - express: (app) => { - app.use(logger('dev', { - skip: (req, res) => res.statusCode < 400 - })); - - app.use(cookieParser(settings.sessionSecret)); - - app.use(bodyParser.json({limit: '50mb'})); - app.use(bodyParser.urlencoded({limit: '50mb', extended: true})); - - app.use(session({ - secret: settings.sessionSecret, - resave: false, - saveUninitialized: true, - unset: 'destroy', - cookie: { - expires: new Date(Date.now() + settings.cookieTTL), - maxAge: settings.cookieTTL - }, - store: _sessionStore - })); - - app.use(passport.initialize()); - app.use(passport.session()); - - passport.serializeUser(mongo.Account.serializeUser()); - passport.deserializeUser(mongo.Account.deserializeUser()); - - passport.use(mongo.Account.createStrategy()); - }, - socketio: (io) => { - const _onAuthorizeSuccess = (data, accept) => { - accept(null, true); - }; - - const _onAuthorizeFail = (data, message, error, accept) => { - accept(null, false); - }; - - io.use(passportSocketIo.authorize({ - cookieParser, - key: 'connect.sid', // the name of the cookie where express/connect stores its session_id - secret: settings.sessionSecret, // the session_secret to parse the cookie - store: _sessionStore, // we NEED to use a sessionstore. no memorystore please - success: _onAuthorizeSuccess, // *optional* callback on success - read more below - fail: _onAuthorizeFail // *optional* callback on fail/error - read more below - })); - } - }; -}; http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/mail.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/mail.js b/modules/web-console/src/main/js/serve/mail.js deleted file mode 100644 index 2c67276..0000000 --- a/modules/web-console/src/main/js/serve/mail.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -/** - * Module for send email. - */ -module.exports = { - implements: 'mail', - inject: ['require(nodemailer)', 'settings'] -}; - -module.exports.factory = function(nodemailer, settings) { - return { - /** - * Send mail to user. - * - * @param {Account} user - * @param {String} subject - * @param {String} html - * @param {String} sendErr - * @throws {Error} - * @return {Promise} - */ - send: (user, subject, html, sendErr) => { - const transporter = { - service: settings.smtp.service, - auth: { - user: settings.smtp.email, - pass: settings.smtp.password - } - }; - - if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '') - throw new Error('Failed to send email. SMTP server is not configured. Please ask webmaster to setup SMTP server!'); - - const mailer = nodemailer.createTransport(transporter); - - const sign = settings.smtp.sign ? `<br><br>--------------<br>${settings.smtp.sign}<br>` : ''; - - const mail = { - from: settings.smtp.address(settings.smtp.username, settings.smtp.email), - to: settings.smtp.address(`${user.firstName} ${user.lastName}`, user.email), - subject, - html: html + sign - }; - - return new Promise((resolve, reject) => { - mailer.sendMail(mail, (err) => { - if (err) - return reject(sendErr ? new Error(sendErr) : err); - - resolve(user); - }); - }); - } - }; -}; http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/mongo.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/mongo.js b/modules/web-console/src/main/js/serve/mongo.js deleted file mode 100644 index 8fb0a20..0000000 --- a/modules/web-console/src/main/js/serve/mongo.js +++ /dev/null @@ -1,676 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -/** - * Module mongo schema. - */ -module.exports = { - implements: 'mongo', - inject: ['require(mongoose-deep-populate)', 'require(passport-local-mongoose)', 'settings', 'ignite_modules/mongo:*'] -}; - -module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, pluginMongo) { - const mongoose = require('mongoose'); - - // Use native promises - mongoose.Promise = global.Promise; - - const deepPopulate = deepPopulatePlugin(mongoose); - - // Connect to mongoDB database. - mongoose.connect(settings.mongoUrl, {server: {poolSize: 4}}); - - const Schema = mongoose.Schema; - const ObjectId = mongoose.Schema.Types.ObjectId; - const result = { connection: mongoose.connection }; - - result.ObjectId = ObjectId; - - // Define Account schema. - const AccountSchema = new Schema({ - firstName: String, - lastName: String, - email: String, - company: String, - country: String, - lastLogin: Date, - admin: Boolean, - token: String, - resetPasswordToken: String - }); - - // Install passport plugin. - AccountSchema.plugin(passportMongo, { - usernameField: 'email', limitAttempts: true, lastLoginField: 'lastLogin', - usernameLowerCase: true - }); - - // Configure transformation to JSON. - AccountSchema.set('toJSON', { - transform: (doc, ret) => { - return { - _id: ret._id, - email: ret.email, - firstName: ret.firstName, - lastName: ret.lastName, - company: ret.company, - country: ret.country, - admin: ret.admin, - token: ret.token, - lastLogin: ret.lastLogin - }; - } - }); - - // Define Account model. - result.Account = mongoose.model('Account', AccountSchema); - - // Define Space model. - result.Space = mongoose.model('Space', new Schema({ - name: String, - owner: {type: ObjectId, ref: 'Account'}, - demo: {type: Boolean, default: false}, - usedBy: [{ - permission: {type: String, enum: ['VIEW', 'FULL']}, - account: {type: ObjectId, ref: 'Account'} - }] - })); - - // Define Domain model schema. - const DomainModelSchema = new Schema({ - space: {type: ObjectId, ref: 'Space', index: true}, - caches: [{type: ObjectId, ref: 'Cache'}], - queryMetadata: {type: String, enum: ['Annotations', 'Configuration']}, - kind: {type: String, enum: ['query', 'store', 'both']}, - databaseSchema: String, - databaseTable: String, - keyType: String, - valueType: String, - keyFields: [{ - databaseFieldName: String, - databaseFieldType: String, - javaFieldName: String, - javaFieldType: String - }], - valueFields: [{ - databaseFieldName: String, - databaseFieldType: String, - javaFieldName: String, - javaFieldType: String - }], - fields: [{name: String, className: String}], - aliases: [{field: String, alias: String}], - indexes: [{ - name: String, - indexType: {type: String, enum: ['SORTED', 'FULLTEXT', 'GEOSPATIAL']}, - fields: [{name: String, direction: Boolean}] - }], - demo: Boolean - }); - - // Define model of Domain models. - result.DomainModel = mongoose.model('DomainModel', DomainModelSchema); - - // Define Cache schema. - const CacheSchema = new Schema({ - space: {type: ObjectId, ref: 'Space', index: true}, - name: String, - clusters: [{type: ObjectId, ref: 'Cluster'}], - domains: [{type: ObjectId, ref: 'DomainModel'}], - cacheMode: {type: String, enum: ['PARTITIONED', 'REPLICATED', 'LOCAL']}, - atomicityMode: {type: String, enum: ['ATOMIC', 'TRANSACTIONAL']}, - - backups: Number, - memoryMode: {type: String, enum: ['ONHEAP_TIERED', 'OFFHEAP_TIERED', 'OFFHEAP_VALUES']}, - offHeapMaxMemory: Number, - startSize: Number, - swapEnabled: Boolean, - - evictionPolicy: { - kind: {type: String, enum: ['LRU', 'FIFO', 'SORTED']}, - LRU: { - batchSize: Number, - maxMemorySize: Number, - maxSize: Number - }, - FIFO: { - batchSize: Number, - maxMemorySize: Number, - maxSize: Number - }, - SORTED: { - batchSize: Number, - maxMemorySize: Number, - maxSize: Number - } - }, - - rebalanceMode: {type: String, enum: ['SYNC', 'ASYNC', 'NONE']}, - rebalanceBatchSize: Number, - rebalanceBatchesPrefetchCount: Number, - rebalanceOrder: Number, - rebalanceDelay: Number, - rebalanceTimeout: Number, - rebalanceThrottle: Number, - - cacheStoreFactory: { - kind: { - type: String, - enum: ['CacheJdbcPojoStoreFactory', 'CacheJdbcBlobStoreFactory', 'CacheHibernateBlobStoreFactory'] - }, - CacheJdbcPojoStoreFactory: { - dataSourceBean: String, - dialect: { - type: String, - enum: ['Generic', 'Oracle', 'DB2', 'SQLServer', 'MySQL', 'PostgreSQL', 'H2'] - } - }, - CacheJdbcBlobStoreFactory: { - connectVia: {type: String, enum: ['URL', 'DataSource']}, - connectionUrl: String, - user: String, - dataSourceBean: String, - dialect: { - type: String, - enum: ['Generic', 'Oracle', 'DB2', 'SQLServer', 'MySQL', 'PostgreSQL', 'H2'] - }, - initSchema: Boolean, - createTableQuery: String, - loadQuery: String, - insertQuery: String, - updateQuery: String, - deleteQuery: String - }, - CacheHibernateBlobStoreFactory: { - hibernateProperties: [String] - } - }, - storeKeepBinary: Boolean, - loadPreviousValue: Boolean, - readThrough: Boolean, - writeThrough: Boolean, - - writeBehindEnabled: Boolean, - writeBehindBatchSize: Number, - writeBehindFlushSize: Number, - writeBehindFlushFrequency: Number, - writeBehindFlushThreadCount: Number, - - invalidate: Boolean, - defaultLockTimeout: Number, - atomicWriteOrderMode: {type: String, enum: ['CLOCK', 'PRIMARY']}, - writeSynchronizationMode: {type: String, enum: ['FULL_SYNC', 'FULL_ASYNC', 'PRIMARY_SYNC']}, - - sqlEscapeAll: Boolean, - sqlSchema: String, - sqlOnheapRowCacheSize: Number, - longQueryWarningTimeout: Number, - sqlFunctionClasses: [String], - snapshotableIndex: Boolean, - statisticsEnabled: Boolean, - managementEnabled: Boolean, - readFromBackup: Boolean, - copyOnRead: Boolean, - maxConcurrentAsyncOperations: Number, - nearCacheEnabled: Boolean, - nearConfiguration: { - nearStartSize: Number, - nearEvictionPolicy: { - kind: {type: String, enum: ['LRU', 'FIFO', 'SORTED']}, - LRU: { - batchSize: Number, - maxMemorySize: Number, - maxSize: Number - }, - FIFO: { - batchSize: Number, - maxMemorySize: Number, - maxSize: Number - }, - SORTED: { - batchSize: Number, - maxMemorySize: Number, - maxSize: Number - } - } - }, - demo: Boolean - }); - - // Install deep populate plugin. - CacheSchema.plugin(deepPopulate, { - whitelist: ['domains'] - }); - - // Define Cache model. - result.Cache = mongoose.model('Cache', CacheSchema); - - const IgfsSchema = new Schema({ - space: {type: ObjectId, ref: 'Space', index: true}, - name: String, - clusters: [{type: ObjectId, ref: 'Cluster'}], - affinnityGroupSize: Number, - blockSize: Number, - streamBufferSize: Number, - dataCacheName: String, - metaCacheName: String, - defaultMode: {type: String, enum: ['PRIMARY', 'PROXY', 'DUAL_SYNC', 'DUAL_ASYNC']}, - dualModeMaxPendingPutsSize: Number, - dualModePutExecutorService: String, - dualModePutExecutorServiceShutdown: Boolean, - fragmentizerConcurrentFiles: Number, - fragmentizerEnabled: Boolean, - fragmentizerThrottlingBlockLength: Number, - fragmentizerThrottlingDelay: Number, - ipcEndpointConfiguration: { - type: {type: String, enum: ['SHMEM', 'TCP']}, - host: String, - port: Number, - memorySize: Number, - tokenDirectoryPath: String - }, - ipcEndpointEnabled: Boolean, - maxSpaceSize: Number, - maximumTaskRangeLength: Number, - managementPort: Number, - pathModes: [{path: String, mode: {type: String, enum: ['PRIMARY', 'PROXY', 'DUAL_SYNC', 'DUAL_ASYNC']}}], - perNodeBatchSize: Number, - perNodeParallelBatchCount: Number, - prefetchBlocks: Number, - sequentialReadsBeforePrefetch: Number, - trashPurgeTimeout: Number, - secondaryFileSystemEnabled: Boolean, - secondaryFileSystem: { - uri: String, - cfgPath: String, - userName: String - }, - colocateMetadata: Boolean, - relaxedConsistency: Boolean - }); - - // Define IGFS model. - result.Igfs = mongoose.model('Igfs', IgfsSchema); - - // Define Cluster schema. - const ClusterSchema = new Schema({ - space: {type: ObjectId, ref: 'Space', index: true}, - name: String, - localHost: String, - discovery: { - localAddress: String, - localPort: Number, - localPortRange: Number, - addressResolver: String, - socketTimeout: Number, - ackTimeout: Number, - maxAckTimeout: Number, - networkTimeout: Number, - joinTimeout: Number, - threadPriority: Number, - heartbeatFrequency: Number, - maxMissedHeartbeats: Number, - maxMissedClientHeartbeats: Number, - topHistorySize: Number, - listener: String, - dataExchange: String, - metricsProvider: String, - reconnectCount: Number, - statisticsPrintFrequency: Number, - ipFinderCleanFrequency: Number, - authenticator: String, - forceServerMode: Boolean, - clientReconnectDisabled: Boolean, - kind: {type: String, enum: ['Vm', 'Multicast', 'S3', 'Cloud', 'GoogleStorage', 'Jdbc', 'SharedFs', 'ZooKeeper']}, - Vm: { - addresses: [String] - }, - Multicast: { - multicastGroup: String, - multicastPort: Number, - responseWaitTime: Number, - addressRequestAttempts: Number, - localAddress: String, - addresses: [String] - }, - S3: { - bucketName: String - }, - Cloud: { - credential: String, - credentialPath: String, - identity: String, - provider: String, - regions: [String], - zones: [String] - }, - GoogleStorage: { - projectName: String, - bucketName: String, - serviceAccountP12FilePath: String, - serviceAccountId: String, - addrReqAttempts: String - }, - Jdbc: { - initSchema: Boolean - }, - SharedFs: { - path: String - }, - ZooKeeper: { - curator: String, - zkConnectionString: String, - retryPolicy: { - kind: {type: String, enum: ['ExponentialBackoff', 'BoundedExponentialBackoff', 'UntilElapsed', - 'NTimes', 'OneTime', 'Forever', 'Custom']}, - ExponentialBackoff: { - baseSleepTimeMs: Number, - maxRetries: Number, - maxSleepMs: Number - }, - BoundedExponentialBackoff: { - baseSleepTimeMs: Number, - maxSleepTimeMs: Number, - maxRetries: Number - }, - UntilElapsed: { - maxElapsedTimeMs: Number, - sleepMsBetweenRetries: Number - }, - NTimes: { - n: Number, - sleepMsBetweenRetries: Number - }, - OneTime: { - sleepMsBetweenRetry: Number - }, - Forever: { - retryIntervalMs: Number - }, - Custom: { - className: String - } - }, - basePath: String, - serviceName: String, - allowDuplicateRegistrations: Boolean - } - }, - atomicConfiguration: { - backups: Number, - cacheMode: {type: String, enum: ['LOCAL', 'REPLICATED', 'PARTITIONED']}, - atomicSequenceReserveSize: Number - }, - binaryConfiguration: { - idMapper: String, - nameMapper: String, - serializer: String, - typeConfigurations: [{ - typeName: String, - idMapper: String, - nameMapper: String, - serializer: String, - enum: Boolean - }], - compactFooter: Boolean - }, - caches: [{type: ObjectId, ref: 'Cache'}], - clockSyncSamples: Number, - clockSyncFrequency: Number, - deploymentMode: {type: String, enum: ['PRIVATE', 'ISOLATED', 'SHARED', 'CONTINUOUS']}, - discoveryStartupDelay: Number, - igfsThreadPoolSize: Number, - igfss: [{type: ObjectId, ref: 'Igfs'}], - includeEventTypes: [String], - managementThreadPoolSize: Number, - marshaller: { - kind: {type: String, enum: ['OptimizedMarshaller', 'JdkMarshaller']}, - OptimizedMarshaller: { - poolSize: Number, - requireSerializable: Boolean - } - }, - marshalLocalJobs: Boolean, - marshallerCacheKeepAliveTime: Number, - marshallerCacheThreadPoolSize: Number, - metricsExpireTime: Number, - metricsHistorySize: Number, - metricsLogFrequency: Number, - metricsUpdateFrequency: Number, - networkTimeout: Number, - networkSendRetryDelay: Number, - networkSendRetryCount: Number, - communication: { - listener: String, - localAddress: String, - localPort: Number, - localPortRange: Number, - sharedMemoryPort: Number, - directBuffer: Boolean, - directSendBuffer: Boolean, - idleConnectionTimeout: Number, - connectTimeout: Number, - maxConnectTimeout: Number, - reconnectCount: Number, - socketSendBuffer: Number, - socketReceiveBuffer: Number, - messageQueueLimit: Number, - slowClientQueueLimit: Number, - tcpNoDelay: Boolean, - ackSendThreshold: Number, - unacknowledgedMessagesBufferSize: Number, - socketWriteTimeout: Number, - selectorsCount: Number, - addressResolver: String - }, - connector: { - enabled: Boolean, - jettyPath: String, - host: String, - port: Number, - portRange: Number, - idleTimeout: Number, - idleQueryCursorTimeout: Number, - idleQueryCursorCheckFrequency: Number, - receiveBufferSize: Number, - sendBufferSize: Number, - sendQueueLimit: Number, - directBuffer: Boolean, - noDelay: Boolean, - selectorCount: Number, - threadPoolSize: Number, - messageInterceptor: String, - secretKey: String, - sslEnabled: Boolean, - sslClientAuth: Boolean, - sslFactory: String - }, - peerClassLoadingEnabled: Boolean, - peerClassLoadingLocalClassPathExclude: [String], - peerClassLoadingMissedResourcesCacheSize: Number, - peerClassLoadingThreadPoolSize: Number, - publicThreadPoolSize: Number, - swapSpaceSpi: { - kind: {type: String, enum: ['FileSwapSpaceSpi']}, - FileSwapSpaceSpi: { - baseDirectory: String, - readStripesNumber: Number, - maximumSparsity: Number, - maxWriteQueueSize: Number, - writeBufferSize: Number - } - }, - systemThreadPoolSize: Number, - timeServerPortBase: Number, - timeServerPortRange: Number, - transactionConfiguration: { - defaultTxConcurrency: {type: String, enum: ['OPTIMISTIC', 'PESSIMISTIC']}, - defaultTxIsolation: {type: String, enum: ['READ_COMMITTED', 'REPEATABLE_READ', 'SERIALIZABLE']}, - defaultTxTimeout: Number, - pessimisticTxLogLinger: Number, - pessimisticTxLogSize: Number, - txSerializableEnabled: Boolean, - txManagerFactory: String - }, - sslEnabled: Boolean, - sslContextFactory: { - keyAlgorithm: String, - keyStoreFilePath: String, - keyStoreType: String, - protocol: String, - trustStoreFilePath: String, - trustStoreType: String, - trustManagers: [String] - }, - rebalanceThreadPoolSize: Number, - attributes: [{name: String, value: String}], - collision: { - kind: {type: String, enum: ['Noop', 'PriorityQueue', 'FifoQueue', 'JobStealing', 'Custom']}, - PriorityQueue: { - parallelJobsNumber: Number, - waitingJobsNumber: Number, - priorityAttributeKey: String, - jobPriorityAttributeKey: String, - defaultPriority: Number, - starvationIncrement: Number, - starvationPreventionEnabled: Boolean - }, - FifoQueue: { - parallelJobsNumber: Number, - waitingJobsNumber: Number - }, - JobStealing: { - activeJobsThreshold: Number, - waitJobsThreshold: Number, - messageExpireTime: Number, - maximumStealingAttempts: Number, - stealingEnabled: Boolean, - stealingAttributes: [{name: String, value: String}], - externalCollisionListener: String - }, - Custom: { - class: String - } - }, - failoverSpi: [{ - kind: {type: String, enum: ['JobStealing', 'Never', 'Always', 'Custom']}, - JobStealing: { - maximumFailoverAttempts: Number - }, - Always: { - maximumFailoverAttempts: Number - }, - Custom: { - class: String - } - }], - logger: { - kind: {type: 'String', enum: ['Log4j2', 'Null', 'Java', 'JCL', 'SLF4J', 'Log4j', 'Custom']}, - Log4j2: { - level: {type: String, enum: ['OFF', 'FATAL', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE', 'ALL']}, - path: String - }, - Log4j: { - mode: {type: String, enum: ['Default', 'Path']}, - level: {type: String, enum: ['OFF', 'FATAL', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE', 'ALL']}, - path: String - }, - Custom: { - class: String - } - } - }); - - // Install deep populate plugin. - ClusterSchema.plugin(deepPopulate, { - whitelist: [ - 'caches', - 'caches.domains', - 'igfss' - ] - }); - - // Define Cluster model. - result.Cluster = mongoose.model('Cluster', ClusterSchema); - - result.ClusterDefaultPopulate = ''; - - // Define Notebook schema. - const NotebookSchema = new Schema({ - space: {type: ObjectId, ref: 'Space', index: true}, - name: String, - expandedParagraphs: [Number], - paragraphs: [{ - name: String, - query: String, - editor: Boolean, - result: {type: String, enum: ['none', 'table', 'bar', 'pie', 'line', 'area']}, - pageSize: Number, - timeLineSpan: String, - hideSystemColumns: Boolean, - cacheName: String, - chartsOptions: {barChart: {stacked: Boolean}, areaChart: {style: String}}, - rate: { - value: Number, - unit: Number - } - }] - }); - - // Define Notebook model. - result.Notebook = mongoose.model('Notebook', NotebookSchema); - - result.handleError = function(res, err) { - // TODO IGNITE-843 Send error to admin - res.status(err.code || 500).send(err.message); - }; - - /** - * Query for user spaces. - * - * @param userId User ID. - * @param {Boolean} demo Is need use demo space. - * @returns {Promise} - */ - result.spaces = function(userId, demo) { - return result.Space.find({owner: userId, demo: !!demo}).lean().exec(); - }; - - /** - * Extract IDs from user spaces. - * - * @param userId User ID. - * @param {Boolean} demo Is need use demo space. - * @returns {Promise} - */ - result.spaceIds = function(userId, demo) { - return result.spaces(userId, demo) - .then((spaces) => spaces.map((space) => space._id)); - }; - - // Registering the routes of all plugin modules - for (const name in pluginMongo) { - if (pluginMongo.hasOwnProperty(name)) - pluginMongo[name].register(mongoose, deepPopulate, result); - } - - return result; -}; http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/admin.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/admin.js b/modules/web-console/src/main/js/serve/routes/admin.js deleted file mode 100644 index 3c2e728..0000000 --- a/modules/web-console/src/main/js/serve/routes/admin.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -module.exports = { - implements: 'admin-routes', - inject: ['require(lodash)', 'require(express)', 'settings', 'mail', 'mongo'] -}; - -module.exports.factory = function(_, express, settings, mail, mongo) { - return new Promise((factoryResolve) => { - const router = new express.Router(); - - /** - * Get list of user accounts. - */ - router.post('/list', (req, res) => { - - Promise.all([ - mongo.Space.aggregate([ - {$match: {demo: false}}, - {$lookup: {from: 'clusters', localField: '_id', foreignField: 'space', as: 'clusters'}}, - {$lookup: {from: 'caches', localField: '_id', foreignField: 'space', as: 'caches'}}, - {$lookup: {from: 'domainmodels', localField: '_id', foreignField: 'space', as: 'domainmodels'}}, - {$lookup: {from: 'igfs', localField: '_id', foreignField: 'space', as: 'igfs'}}, - {$project: { - owner: 1, - clusters: {$size: '$clusters'}, - models: {$size: '$domainmodels'}, - caches: {$size: '$caches'}, - igfs: {$size: '$igfs'} - }} - ]).exec(), - mongo.Account.find({}).sort('firstName lastName').lean().exec() - ]) - .then((values) => { - const counters = _.keyBy(values[0], 'owner'); - const accounts = values[1]; - - return accounts.map((account) => { - account.counters = _.omit(counters[account._id], '_id', 'owner'); - - return account; - }); - }) - .then((users) => res.json(users)) - .catch((err) => mongo.handleError(res, err)); - }); - - // Remove user. - router.post('/remove', (req, res) => { - const userId = req.body.userId; - - mongo.Account.findByIdAndRemove(userId).exec() - .then((user) => { - res.sendStatus(200); - - return mongo.spaceIds(userId) - .then((spaceIds) => Promise.all([ - mongo.Cluster.remove({space: {$in: spaceIds}}).exec(), - mongo.Cache.remove({space: {$in: spaceIds}}).exec(), - mongo.DomainModel.remove({space: {$in: spaceIds}}).exec(), - mongo.Igfs.remove({space: {$in: spaceIds}}).exec(), - mongo.Notebook.remove({space: {$in: spaceIds}}).exec(), - mongo.Space.remove({owner: userId}).exec() - ])) - .then(() => user) - .catch((err) => console.error(`Failed to cleanup spaces [user=${user.username}, err=${err}`)); - }) - .then((user) => - mail.send(user, 'Your account was deleted', - `Hello ${user.firstName} ${user.lastName}!<br><br>` + - `You are receiving this email because your account for <a href="http://${req.headers.host}">${settings.smtp.username}</a> was removed.`, - 'Account was removed, but failed to send email notification to user!') - ) - .catch((err) => mongo.handleError(res, err)); - }); - - // Save user. - router.post('/save', (req, res) => { - const params = req.body; - - mongo.Account.findByIdAndUpdate(params.userId, {admin: params.adminFlag}).exec() - .then(() => res.sendStatus(200)) - .catch((err) => mongo.handleError(res, err)); - }); - - // Become user. - router.get('/become', (req, res) => { - mongo.Account.findById(req.query.viewedUserId).exec() - .then((viewedUser) => { - req.session.viewedUser = viewedUser; - - res.sendStatus(200); - }) - .catch(() => res.sendStatus(404)); - }); - - // Revert to your identity. - router.get('/revert/identity', (req, res) => { - req.session.viewedUser = null; - - return res.sendStatus(200); - }); - - factoryResolve(router); - }); -}; - http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/agent.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/agent.js b/modules/web-console/src/main/js/serve/routes/agent.js deleted file mode 100644 index 48ec131..0000000 --- a/modules/web-console/src/main/js/serve/routes/agent.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -module.exports = { - implements: 'agent-routes', - inject: ['require(lodash)', 'require(express)', 'require(fs)', 'require(jszip)', 'settings', 'agent-manager'] -}; - -/** - * @param _ - * @param express - * @param fs - * @param JSZip - * @param settings - * @param {AgentManager} agentMgr - * @returns {Promise} - */ -module.exports.factory = function(_, express, fs, JSZip, settings, agentMgr) { - return new Promise((resolveFactory) => { - const router = new express.Router(); - - /* Get grid topology. */ - router.get('/download/zip', (req, res) => { - const latest = agentMgr.supportedAgents.latest; - - if (_.isEmpty(latest)) - return res.status(500).send('Missing agent zip on server. Please ask webmaster to upload agent zip!'); - - const agentFld = latest.fileName.substr(0, latest.fileName.length - 4); - const agentZip = latest.fileName; - const agentPathZip = latest.filePath; - - // Read a zip file. - fs.readFile(agentPathZip, (errFs, data) => { - if (errFs) - return res.download(agentPathZip, agentZip); - - // Set the archive name. - res.attachment(agentZip); - - JSZip.loadAsync(data) - .then((zip) => { - const prop = []; - - const host = req.hostname.match(/:/g) ? req.hostname.slice(0, req.hostname.indexOf(':')) : req.hostname; - - prop.push('tokens=' + req.user.token); - prop.push('server-uri=' + (settings.agent.SSLOptions ? 'https' : 'http') + '://' + host + ':' + settings.agent.port); - prop.push('#Uncomment following options if needed:'); - prop.push('#node-uri=http://localhost:8080'); - prop.push('#driver-folder=./jdbc-drivers'); - - zip.file(agentFld + '/default.properties', prop.join('\n')); - - zip.generateAsync({type: 'nodebuffer', platform: 'UNIX'}) - .then((buffer) => res.send(buffer)); - }); - }); - }); - - resolveFactory(router); - }); -}; http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/caches.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/caches.js b/modules/web-console/src/main/js/serve/routes/caches.js deleted file mode 100644 index ed1f257..0000000 --- a/modules/web-console/src/main/js/serve/routes/caches.js +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -module.exports = { - implements: 'caches-routes', - inject: ['require(lodash)', 'require(express)', 'mongo'] -}; - -module.exports.factory = function(_, express, mongo) { - return new Promise((factoryResolve) => { - const router = new express.Router(); - - /** - * Get spaces and caches accessed for user account. - * - * @param req Request. - * @param res Response. - */ - router.post('/list', (req, res) => { - const result = {}; - let spaceIds = []; - - // Get owned space and all accessed space. - mongo.spaces(req.currentUserId(), req.header('IgniteDemoMode')) - .then((spaces) => { - result.spaces = spaces; - spaceIds = spaces.map((space) => space._id); - - return mongo.Cluster.find({space: {$in: spaceIds}}).sort('name').lean().exec(); - }) - .then((clusters) => { - result.clusters = clusters; - - return mongo.DomainModel.find({space: {$in: spaceIds}}).sort('name').lean().exec(); - }) - .then((domains) => { - result.domains = domains; - - return mongo.Cache.find({space: {$in: spaceIds}}).sort('name').lean().exec(); - }) - .then((caches) => { - result.caches = caches; - - res.json(result); - }) - .catch((err) => mongo.handleError(res, err)); - }); - - /** - * Save cache. - */ - router.post('/save', (req, res) => { - const params = req.body; - const clusters = params.clusters; - const domains = params.domains; - - mongo.Cache.findOne({space: params.space, name: params.name}).exec() - .then((existingCache) => { - const cacheId = params._id; - - if (existingCache && cacheId !== existingCache._id.toString()) - return res.status(500).send('Cache with name: "' + existingCache.name + '" already exist.'); - - if (cacheId) { - return mongo.Cache.update({_id: cacheId}, params, {upsert: true}).exec() - .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec()) - .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {multi: true}).exec()) - .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec()) - .then(() => mongo.DomainModel.update({_id: {$nin: domains}}, {$pull: {caches: cacheId}}, {multi: true}).exec()) - .then(() => res.send(cacheId)); - } - - return (new mongo.Cache(params)).save() - .then((cache) => - mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cache._id}}, {multi: true}).exec() - .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cache._id}}, {multi: true}).exec()) - .then(() => res.send(cache._id)) - ); - }) - .catch((err) => mongo.handleError(res, err)); - }); - - /** - * Remove cache by ._id. - */ - router.post('/remove', (req, res) => { - const params = req.body; - const cacheId = params._id; - - mongo.Cluster.update({caches: {$in: [cacheId]}}, {$pull: {caches: cacheId}}, {multi: true}).exec() - .then(() => mongo.DomainModel.update({caches: {$in: [cacheId]}}, {$pull: {caches: cacheId}}, {multi: true}).exec()) - .then(() => mongo.Cache.remove(params).exec()) - .then(() => res.sendStatus(200)) - .catch((err) => mongo.handleError(res, err)); - }); - - /** - * Remove all caches. - */ - router.post('/remove/all', (req, res) => { - mongo.spaceIds(req.currentUserId(), req.header('IgniteDemoMode')) - .then((spaceIds) => - mongo.Cluster.update({space: {$in: spaceIds}}, {caches: []}, {multi: true}).exec() - .then(() => mongo.DomainModel.update({space: {$in: spaceIds}}, {caches: []}, {multi: true}).exec()) - .then(() => mongo.Cache.remove({space: {$in: spaceIds}}).exec()) - ) - .then(() => res.sendStatus(200)) - .catch((err) => mongo.handleError(res, err)); - }); - - factoryResolve(router); - }); -}; - http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/clusters.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/clusters.js b/modules/web-console/src/main/js/serve/routes/clusters.js deleted file mode 100644 index 9d13990..0000000 --- a/modules/web-console/src/main/js/serve/routes/clusters.js +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -module.exports = { - implements: 'clusters-routes', - inject: ['require(lodash)', 'require(express)', 'mongo'] -}; - -module.exports.factory = function(_, express, mongo) { - return new Promise((factoryResolve) => { - const router = new express.Router(); - - /** - * Get spaces and clusters accessed for user account. - * - * @param req Request. - * @param res Response. - */ - router.post('/list', (req, res) => { - const result = {}; - let spaceIds = []; - let domains = {}; - - mongo.spaces(req.currentUserId(), req.header('IgniteDemoMode')) - .then((spaces) => { - result.spaces = spaces; - spaceIds = spaces.map((space) => space._id); - - return mongo.DomainModel.find({space: {$in: spaceIds}}).lean().exec(); - }) - .then((_domains) => { - domains = _domains.reduce((map, obj) => { - map[obj._id] = obj; - - return map; - }, {}); - - return mongo.Cache.find({space: {$in: spaceIds}}).sort('name').lean().exec(); - }) - .then((caches) => { - _.forEach(caches, (cache) => { - cache.domains = _.map(cache.domains, (domainId) => domains[domainId]); - }); - - result.caches = caches; - - return mongo.Igfs.find({space: {$in: spaceIds}}).sort('name').lean().exec(); - }) - .then((igfss) => { - result.igfss = igfss; - - return mongo.Cluster.find({space: {$in: spaceIds}}).sort('name').deepPopulate(mongo.ClusterDefaultPopulate).lean().exec(); - }) - .then((clusters) => { - result.clusters = clusters; - - res.json(result); - }) - .catch((err) => mongo.handleError(res, err)); - }); - - /** - * Save cluster. - */ - router.post('/save', (req, res) => { - const params = req.body; - const caches = params.caches; - const igfss = params.igfss; - - mongo.Cluster.findOne({space: params.space, name: params.name}).exec() - .then((existingCluster) => { - const clusterId = params._id; - - if (existingCluster && clusterId !== existingCluster._id.toString()) - throw new Error('Cluster with name: "' + existingCluster.name + '" already exist.'); - - if (clusterId) { - return mongo.Cluster.update({_id: clusterId}, params, {upsert: true}).exec() - .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec()) - .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec()) - .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec()) - .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec()) - .then(() => res.send(clusterId)); - } - - return (new mongo.Cluster(params)).save() - .then((cluster) => - mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: cluster._id}}, {multi: true}).exec() - .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: cluster._id}}, {multi: true}).exec()) - .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: cluster._id}}, {multi: true}).exec()) - .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: cluster._id}}, {multi: true}).exec()) - .then(() => res.send(cluster._id)) - ); - }) - .catch((err) => mongo.handleError(res, err)); - }); - - /** - * Remove cluster by ._id. - */ - router.post('/remove', (req, res) => { - const params = req.body; - const clusterId = params._id; - - mongo.Cache.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec() - .then(() => mongo.Igfs.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec()) - .then(() => mongo.Cluster.remove(params).exec()) - .then(() => res.sendStatus(200)) - .catch((err) => mongo.handleError(res, err)); - }); - - /** - * Remove all clusters. - */ - router.post('/remove/all', (req, res) => { - // Get owned space and all accessed space. - mongo.spaceIds(req.currentUserId(), req.header('IgniteDemoMode')) - .then((spaceIds) => mongo.Cache.update({space: {$in: spaceIds}}, {clusters: []}, {multi: true}).exec() - .then(() => mongo.Igfs.update({space: {$in: spaceIds}}, {clusters: []}, {multi: true}).exec()) - .then(() => mongo.Cluster.remove({space: {$in: spaceIds}}).exec()) - ) - .then(() => res.sendStatus(200)) - .catch((err) => mongo.handleError(res, err)); - }); - - factoryResolve(router); - }); -}; http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/demo.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/demo.js b/modules/web-console/src/main/js/serve/routes/demo.js deleted file mode 100644 index dd47eb9..0000000 --- a/modules/web-console/src/main/js/serve/routes/demo.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -'use strict'; - -// Fire me up! - -module.exports = { - implements: 'demo-routes', - inject: [ - 'require(lodash)', - 'require(express)', - 'settings', - 'mongo', - 'require(./demo/domains.json)', - 'require(./demo/caches.json)', - 'require(./demo/igfss.json)', - 'require(./demo/clusters.json)' - ] -}; - -module.exports.factory = (_, express, settings, mongo, domains, caches, igfss, clusters) => { - return new Promise((factoryResolve) => { - const router = new express.Router(); - - /** - * Reset demo configuration. - */ - router.post('/reset', (req, res) => { - mongo.spaces(req.user._id, true) - .then((spaces) => { - if (spaces.length) { - const spaceIds = spaces.map((space) => space._id); - - return Promise.all([ - mongo.Cluster.remove({space: {$in: spaceIds}}).exec(), - mongo.Cache.remove({space: {$in: spaceIds}}).exec(), - mongo.DomainModel.remove({space: {$in: spaceIds}}).exec(), - mongo.Igfs.remove({space: {$in: spaceIds}}).exec() - ]).then(() => spaces[0]); - } - - return new mongo.Space({name: 'Demo space', owner: req.user._id, demo: true}).save(); - }) - .then((space) => { - return Promise.all(_.map(clusters, (cluster) => { - const clusterDoc = new mongo.Cluster(cluster); - - clusterDoc.space = space._id; - - return clusterDoc.save(); - })); - }) - .then((clusterDocs) => { - return _.map(clusterDocs, (cluster) => { - const addCacheToCluster = (cacheDoc) => cluster.caches.push(cacheDoc._id); - const addIgfsToCluster = (igfsDoc) => cluster.igfss.push(igfsDoc._id); - - if (cluster.name.endsWith('-caches')) { - const cachePromises = _.map(caches, (cacheData) => { - const cache = new mongo.Cache(cacheData); - - cache.space = cluster.space; - cache.clusters.push(cluster._id); - - return cache.save() - .then((cacheDoc) => { - const domainData = _.find(domains, (item) => - item.databaseTable === cacheDoc.name.slice(0, -5).toUpperCase()); - - if (domainData) { - const domain = new mongo.DomainModel(domainData); - - domain.space = cacheDoc.space; - domain.caches.push(cacheDoc._id); - - return domain.save() - .then((domainDoc) => { - cacheDoc.domains.push(domainDoc._id); - - return cacheDoc.save(); - }); - } - - return cacheDoc; - }); - }); - - return Promise.all(cachePromises) - .then((cacheDocs) => { - _.forEach(cacheDocs, addCacheToCluster); - - return cluster.save(); - }); - } - - if (cluster.name.endsWith('-igfs')) { - return Promise.all(_.map(igfss, (igfs) => { - const igfsDoc = new mongo.Igfs(igfs); - - igfsDoc.space = cluster.space; - igfsDoc.clusters.push(cluster._id); - - return igfsDoc.save(); - })) - .then((igfsDocs) => { - _.forEach(igfsDocs, addIgfsToCluster); - - return cluster.save(); - }); - } - }); - }) - .then(() => res.sendStatus(200)) - .catch((err) => res.status(500).send(err.message)); - }); - - factoryResolve(router); - }); -}; - http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/demo/caches.json ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/demo/caches.json b/modules/web-console/src/main/js/serve/routes/demo/caches.json deleted file mode 100644 index f7a8690..0000000 --- a/modules/web-console/src/main/js/serve/routes/demo/caches.json +++ /dev/null @@ -1,87 +0,0 @@ -[ - { - "name": "CarCache", - "cacheMode": "PARTITIONED", - "atomicityMode": "ATOMIC", - "readThrough": true, - "writeThrough": true, - "sqlFunctionClasses": [], - "cacheStoreFactory": { - "kind": "CacheJdbcPojoStoreFactory", - "CacheJdbcPojoStoreFactory": { - "dataSourceBean": "dsH2", - "dialect": "H2" - } - }, - "domains": [], - "clusters": [] - }, - { - "name": "ParkingCache", - "cacheMode": "PARTITIONED", - "atomicityMode": "ATOMIC", - "readThrough": true, - "writeThrough": true, - "sqlFunctionClasses": [], - "cacheStoreFactory": { - "kind": "CacheJdbcPojoStoreFactory", - "CacheJdbcPojoStoreFactory": { - "dataSourceBean": "dsH2", - "dialect": "H2" - } - }, - "domains": [], - "clusters": [] - }, - { - "name": "CountryCache", - "cacheMode": "PARTITIONED", - "atomicityMode": "ATOMIC", - "readThrough": true, - "writeThrough": true, - "sqlFunctionClasses": [], - "cacheStoreFactory": { - "kind": "CacheJdbcPojoStoreFactory", - "CacheJdbcPojoStoreFactory": { - "dataSourceBean": "dsH2", - "dialect": "H2" - } - }, - "domains": [], - "clusters": [] - }, - { - "name": "DepartmentCache", - "cacheMode": "PARTITIONED", - "atomicityMode": "ATOMIC", - "readThrough": true, - "writeThrough": true, - "sqlFunctionClasses": [], - "cacheStoreFactory": { - "kind": "CacheJdbcPojoStoreFactory", - "CacheJdbcPojoStoreFactory": { - "dataSourceBean": "dsH2", - "dialect": "H2" - } - }, - "domains": [], - "clusters": [] - }, - { - "name": "EmployeeCache", - "cacheMode": "PARTITIONED", - "atomicityMode": "ATOMIC", - "readThrough": true, - "writeThrough": true, - "sqlFunctionClasses": [], - "cacheStoreFactory": { - "kind": "CacheJdbcPojoStoreFactory", - "CacheJdbcPojoStoreFactory": { - "dataSourceBean": "dsH2", - "dialect": "H2" - } - }, - "domains": [], - "clusters": [] - } -] http://git-wip-us.apache.org/repos/asf/ignite/blob/6af6560a/modules/web-console/src/main/js/serve/routes/demo/clusters.json ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/serve/routes/demo/clusters.json b/modules/web-console/src/main/js/serve/routes/demo/clusters.json deleted file mode 100644 index 014b519..0000000 --- a/modules/web-console/src/main/js/serve/routes/demo/clusters.json +++ /dev/null @@ -1,50 +0,0 @@ -[ - { - "name": "cluster-igfs", - "connector": { - "noDelay": true - }, - "communication": { - "tcpNoDelay": true - }, - "igfss": [], - "caches": [], - "binaryConfiguration": { - "compactFooter": true, - "typeConfigurations": [] - }, - "discovery": { - "kind": "Multicast", - "Multicast": { - "addresses": ["127.0.0.1:47500..47510"] - }, - "Vm": { - "addresses": ["127.0.0.1:47500..47510"] - } - } - }, - { - "name": "cluster-caches", - "connector": { - "noDelay": true - }, - "communication": { - "tcpNoDelay": true - }, - "igfss": [], - "caches": [], - "binaryConfiguration": { - "compactFooter": true, - "typeConfigurations": [] - }, - "discovery": { - "kind": "Multicast", - "Multicast": { - "addresses": ["127.0.0.1:47500..47510"] - }, - "Vm": { - "addresses": ["127.0.0.1:47500..47510"] - } - } - } -]
