Package com.mongodb

Examples of com.mongodb.Mongo$CursorCleanerThread


  public static DB connectDB(String hostname, int port, String dbName)
      throws DBException
  {
    try
    {
      Mongo m = new Mongo(hostname, port);

      DB db = m.getDB(dbName);
      db.setWriteConcern(WriteConcern.FSYNC_SAFE);

      //boolean auth = db.authenticate(myUserName, myPassword);
      return db;
    }
View Full Code Here


    /**
     * Should access a singleton of type Mongo
     */
    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
        Mongo db = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining, Mongo.class);

        Endpoint endpoint = new MongoDbEndpoint(uri, this);
        parameters.put("mongoConnection", db);
        setProperties(endpoint, parameters);
       
View Full Code Here

    private DBCollection nodesStore;
    private DBCollection settingsStore;

    NodeMapInMongoDb(String dir) {
        try {
            con = new Mongo();
            db = con.getDB(DB);
            db.setWriteConcern(WriteConcern.SAFE);
            nodesStore = db.getCollection(NODES_COLLECTION);
            nodesStore.ensureIndex(
                    new BasicDBObject(KEY_FIELD, 1),
View Full Code Here

    @Override
    public String check() throws ManifoldCFException {
        try {
            getSession();
            if (session != null) {
                Mongo currentMongoSession = session.getMongo();
                DBTCPConnector currentTCPConnection = currentMongoSession.getConnector();
                boolean status = currentTCPConnection.isOpen();
                if (status) {
                    session.getMongo().close();
                    session = null;
                    return super.check();
View Full Code Here

    @Override
    public boolean isConnected() {
        if (session == null) {
            return false;
        }
        Mongo currentMongoSession = session.getMongo();
        DBTCPConnector currentTCPConnection = currentMongoSession.getConnector();
        return currentTCPConnection.isOpen();
    }
View Full Code Here

  private void buildModel() throws UnknownHostException {
    userIsObject = false;
    itemIsObject = false;
    idCounter = 0;
    preferenceIsString = true;
    Mongo mongoDDBB = new Mongo(mongoHost, mongoPort);
    DB db = mongoDDBB.getDB(mongoDB);
    mongoTimestamp = new Date(0);
    FastByIDMap<Collection<Preference>> userIDPrefMap = new FastByIDMap<Collection<Preference>>();
    if (!mongoAuth || db.authenticate(mongoUsername, mongoPassword.toCharArray())) {
      collection = db.getCollection(mongoCollection);
      collectionMap = db.getCollection(mongoMapCollection);
View Full Code Here

    if (this.connection != null)
    {
      disconnect();
    }
   
    this.connection = new Mongo(URL, port);
  }
View Full Code Here

    logger = Logger.getLogger(FeedCollections.class);
  }

  public static void open() throws Exception {
    try {
      Mongo conn = new Mongo(HOST, PORT);
      db = conn.getDB(DB_NAME);

      logger.debug("与Feed数据库" + DB_NAME + "尝试连接");

      boolean loginSuccess = db.authenticate(USER, PASSWORD.toCharArray());
      if (loginSuccess) {//将其改为if (loginSuccess==false) {
View Full Code Here

 
  @Test
   public  void initTest() throws Exception{  
          try {  
            long beginTime=System.currentTimeMillis();
              Mongo conn=new Mongo(HOST,PORT);//建立数据库连接  
            
              long endTime=System.currentTimeMillis();
              DB testDB=conn.getDB(DB_NAME);//取得test数据库
             
              System.out.println(endTime-beginTime);
              /** 
               * 如果test数据库没有设定用户权限认证,则无需下面的验证 
               */ 
              boolean loginSuccess=testDB.authenticate(USER, PASSWORD.toCharArray());  
              if(!loginSuccess){  
                  throw new Exception("登录"+DB_NAME+"验证失败,请确认用户名和密码");  
              }  
              testDB=conn.getDB(DB_NAME);//取得test数据库  
              /** 
               * 如果COLLECTION不存在,则MongoDB会自动为你创建此collection 
               */ 
              DBCollection collection=testDB.getCollection(COLLECTION);  
              //开始插入数据操作  
View Full Code Here

            if (_isSlaveOK) {
                _mongoOptions.readPreference = ReadPreference.secondaryPreferred();
            }

            _mongo = new Mongo(serverAddressList, _mongoOptions);

        } catch (UnknownHostException e) {
            throw Throwables.propagate(e);
        }
View Full Code Here

TOP

Related Classes of com.mongodb.Mongo$CursorCleanerThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.