This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema, | |
bcrypt = require('bcrypt'), | |
SALT_WORK_FACTOR = 10, | |
// these values can be whatever you want - we're defaulting to a | |
// max of 5 attempts, resulting in a 2 hour lock | |
MAX_LOGIN_ATTEMPTS = 5, | |
LOCK_TIME = 2 * 60 * 60 * 1000; | |
var UserSchema = new Schema({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parsed options: | |
{ nThreads: 32, fileSizeMB: 1000, r: true, mmf: true } | |
creating test file size:1000MB ... | |
testing... | |
new thread, total running : 1 | |
67 ops/sec | |
110 ops/sec | |
184 ops/sec | |
167 ops/sec | |
174 ops/sec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#inserting documents | |
t.save( { _id: 1, title: "Physics World", text: "Physics World is the | |
membership magazine of the Institute of Physics."} ); | |
t.save( { _id: 2, title: "A break away!", text: "'A break away!' is an | |
1891 painting by Australian artist Tom Roberts."} ); | |
t.save( { _id: 3, title: "Mahim Bora", text: "Mahim Bora (b.1926) is an | |
Indian writer and educationist from Assam state."}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iops, thousands | |
threads read test write test | |
------- --------- ---------- | |
1 4 8 | |
2 8 8 | |
4 16 8 | |
8 32 8 | |
16 64 8 | |
32 70 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require(mongoose), | |
User = require(./user-model); | |
var connStr = mongodb://localhost:27017/mongoose-bcrypt-test; | |
mongoose.connect(connStr, function(err) { | |
if (err) throw err; | |
console.log(Successfully connected to MongoDB); | |
}); | |
// create a user a new user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require(‘mongoose’), | |
Schema = mongoose.Schema, | |
bcrypt = require(‘bcrypt’), | |
SALT_WORK_FACTOR = 10; | |
var UserSchema = new Schema({ | |
username: { type: String, required: true, index: { unique: true } }, | |
password: { type: String, required: true } | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.mongodb.*; | |
import javax.net.ssl.SSLSocketFactory; | |
import java.util.Arrays; | |
public class SSLApp { | |
public static void main(String args[]) throws Exception { | |
MongoClient m = new MongoClient(new MongoClientURI("mongodb://gssapitest%40MONGOTEST.COM@rhel64.mongotest.com/?authMechanism=GSSAPI&ssl=true")); | |
DB db = m.getDB( "test" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema, | |
bcrypt = require(bcrypt), | |
SALT_WORK_FACTOR = 10; | |
var UserSchema = new Schema({ | |
username: { type: String, required: true, index: { unique: true } }, | |
password: { type: String, required: true } | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sh.setBalancerState (false) | |
use config | |
#adjust lower bound of the "current" range | |
db.tags.update( { "tag" : "current" }, { "$set" : { "min._id" : 201208140000032543 } } ) | |
#adjust upper bound of the "archive" range | |
db.tags.update( { "tag" : "archive" }, { "$set" : { "max._id" : 201208140000000000 } } ) | |
sh.setBalancerState(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#add two shards | |
sh.addShardTag ("shard0000", "archive") | |
sh.addShardTag ("shard0001", "recent") | |
#shard database and collection, use "_id" as shard key | |
sh.enableSharding("mydb") | |
sh.shardCollection("mydb.mydata", { "_id" : 1 }) | |
#define tag ranges | |
#first tag range: from the beginning of time until 1 Jan 2013, everything goes to "archive" |
NewerOlder