Ejemplo n.º 1
0
        /** \fn BsonDocument GetDetail()
         *  \brief Get the detail information of current group
         *  \return The detail information in BsonDocument object
         *  \exception SequoiaDB.BaseException
         *  \exception System.Exception
         */
        public BsonDocument GetDetail()
        {
            BsonDocument matcher  = new BsonDocument();
            BsonDocument dummyobj = new BsonDocument();

            matcher.Add(SequoiadbConstants.FIELD_GROUPNAME, groupName);
            matcher.Add(SequoiadbConstants.FIELD_GROUPID, groupID);
            DBCursor cursor = sdb.GetList(SDBConst.SDB_LIST_GROUPS, matcher, dummyobj, dummyobj);

            if (cursor != null)
            {
                BsonDocument detail = cursor.Next();
                if (detail != null)
                {
                    return(detail);
                }
                else
                {
                    throw new BaseException("SDB_CLS_GRP_NOT_EXIST");
                }
            }
            else
            {
                throw new BaseException("SDB_SYS");
            }
        }
Ejemplo n.º 2
0
        /** \fn BsonDocument GetDetail()
         *  \brief Get the detail of data center.
         *  \return void
         *  \exception SequoiaDB.BaseException
         *  \exception System.Exception
         */
        public BsonDocument GetDetail()
        {
            string   command = SequoiadbConstants.ADMIN_PROMPT + SequoiadbConstants.CMD_NAME_GET_DCINFO;
            DBCursor cursor  = RunCommand.RunGeneralCmd(sdb, command,
                                                        null, null, null, null, 0, 0, -1, -1);

            if (null == cursor)
            {
                throw new BaseException("SDB_SYS");
            }
            return(cursor.Next());
        }
Ejemplo n.º 3
0
        private DBCursor ListCSCL(int type)
        {
            // append argument
            BsonDocument matcher  = new BsonDocument();
            BsonDocument selector = new BsonDocument();

            matcher.Add(SequoiadbConstants.FIELD_DOMAIN, this.name);
            selector.Add(SequoiadbConstants.FIELD_NAME, BsonNull.Value);
            // get cs or cl in current domain
            DBCursor cursor = this.sdb.GetList(type, matcher, selector, null);

            return(cursor);
        }
Ejemplo n.º 4
0
 /** \fn long SplitAsync(String sourceGroupName,
  *	                    String destGroupName,
  *	                    double percent)
  *  \brief Split the specified collection from source group to target group by percent asynchronously.
  *  \param sourceGroupName the source group name
  *  \param destGroupName the destination group name
  *  \param percent
  *            the split percent, Range:(0,100]
  *  \return return the task id, we can use the return id to manage the sharding which is run backgroup.
  *  \exception SequoiaDB.BaseException
  *  \exception System.Exception
  *  \see listTask, cancelTask
  */
 public long SplitAsync(String sourceGroupName,
     String destGroupName,
     double percent)
 {
     // check argument
     if (sourceGroupName == null || sourceGroupName.Equals("") ||
         destGroupName == null || destGroupName.Equals("") ||
         percent <= 0.0 || percent > 100.0)
         throw new BaseException("SDB_INVALIDARG");
     // build a bson to send
     BsonDocument asyncObj = new BsonDocument();
     asyncObj.Add(SequoiadbConstants.FIELD_NAME, collectionFullName);
     asyncObj.Add(SequoiadbConstants.FIELD_SOURCE, sourceGroupName);
     asyncObj.Add(SequoiadbConstants.FIELD_TARGET, destGroupName);
     asyncObj.Add(SequoiadbConstants.FIELD_SPLITPERCENT, percent);
     asyncObj.Add(SequoiadbConstants.FIELD_ASYNC, true);
     // build run command
     string commandString = SequoiadbConstants.ADMIN_PROMPT + SequoiadbConstants.SPLIT_CMD;
     // run command
     BsonDocument dummyObj = new BsonDocument();
     SDBMessage rtnSDBMessage = AdminCommand(commandString, asyncObj, dummyObj, dummyObj, dummyObj, 0, -1, 0);
     // check return flag
     int flags = rtnSDBMessage.Flags;
     if (flags != 0)
         throw new BaseException(flags);
     // build cursor object to get result from database
     DBCursor cursor = new DBCursor(rtnSDBMessage, this);
     BsonDocument result = cursor.Next();
     if (result == null)
         throw new BaseException("SDB_CAT_TASK_NOTFOUND");
     bool flag = result.Contains(SequoiadbConstants.FIELD_TASKID);
     if (!flag)
         throw new BaseException("SDB_CAT_TASK_NOTFOUND");
     long taskid = result.GetValue(SequoiadbConstants.FIELD_TASKID).AsInt64;
     return taskid;
 }
Ejemplo n.º 5
0
 /** \fn DBCursor ListLobs()
  * \brief List all of the lobs in current collection
  * \retval DBCursor of lobs
  * \exception SequoiaDB.BaseException
  * \exception System.Exception
  */
 public DBCursor ListLobs()
 {
     DBCursor cursor = null;
     // build command
     string command = SequoiadbConstants.ADMIN_PROMPT
         + SequoiadbConstants.LIST_LOBS_CMD;
     // build a bson to send
     BsonDocument newObj = new BsonDocument();
     newObj.Add(SequoiadbConstants.FIELD_COLLECTION, collectionFullName);
     // run command
     BsonDocument dummyObj = new BsonDocument();
     SDBMessage rtnSDBMessage = AdminCommand(command, newObj, dummyObj, dummyObj, dummyObj, 0, -1, 0);
     // check the return flag
     int flags = rtnSDBMessage.Flags;
     if (flags != 0)
     {
         int errCode = new BaseException("SDB_DMS_EOC").ErrorCode;
         if (errCode == flags)
         {
             return cursor;
         }
         else
         {
             throw new BaseException(flags);
         }
     }
     cursor = new DBCursor(rtnSDBMessage, this);
     return cursor;
 }
Ejemplo n.º 6
0
 /** \fn DBCursor ListTasks(BsonDocument matcher, BsonDocument selector, BsonDocument orderBy, BsonDocument hint)
  *  \brief List the tasks.
  *  \param matcher The matching rule, return all the documents if null
  *  \param selector The selective rule, return the whole document if null
  *  \param orderBy The ordered rule, never sort if null
  *  \param hint The hint, automatically match the optimal hint if null
  *  \exception SequoiaDB.BaseException
  *  \exception System.Exception
  */
 public DBCursor ListTasks(BsonDocument matcher, BsonDocument selector, BsonDocument orderBy, BsonDocument hint)
 {
     // build command
     string commandString = SequoiadbConstants.ADMIN_PROMPT + SequoiadbConstants.LIST_TASK_CMD;
     // run command
     SDBMessage rtn = AdminCommand(commandString,
                                   matcher, selector, orderBy, hint);
     int flags = rtn.Flags;
     if (flags != 0)
     {
         throw new BaseException(flags);
     }
     // return the result by cursor
     DBCursor cursor = null;
     cursor = new DBCursor(rtn, this);
     return cursor;
 }
Ejemplo n.º 7
0
 /** \fn DBCursor ListBackup(BsonDocument options, BsonDocument matcher,
  *	                        BsonDocument selector, BsonDocument orderBy)
  *  \brief List the backups.
  *  \param options Contains configuration infomations for remove backups, list all the backups in the default backup path if null.
  *         The "options" contains 3 options as below. All the elements in options are optional.
  *         eg: {"GroupName":["rgName1", "rgName2"], "Path":"/opt/sequoiadb/backup", "Name":"backupName"}
  *         <ul>
  *          <li>GroupName   : Assign the backups of specifed replica groups to be list
  *          <li>Path        : Assign the backups in specifed path to be list, if not assign, use the backup path asigned in the configuration file
  *          <li>Name        : Assign the backups with specifed name to be list
  *         </ul>
  *  \param matcher The matching rule, return all the documents if null
  *  \param selector The selective rule, return the whole document if null
  *  \param orderBy The ordered rule, never sort if null
  *  \return the DBCursor of the backup or null while having no backup infonation
  *  \exception SequoiaDB.BaseException
  *  \exception System.Exception
  */
 public DBCursor ListBackup(BsonDocument options, BsonDocument matcher,
     BsonDocument selector, BsonDocument orderBy)
 {
     // check argument
     if (options != null)
     {
         foreach (string key in options.Names)
         {
             if (key.Equals(SequoiadbConstants.FIELD_GROUPNAME) ||
                 key.Equals(SequoiadbConstants.FIELD_NAME) ||
                 key.Equals(SequoiadbConstants.FIELD_PATH))
                 continue;
             else
                 throw new BaseException("INVALIDARG");
         }
     }
     // build command
     string commandString = SequoiadbConstants.ADMIN_PROMPT + SequoiadbConstants.LIST_BACKUP_CMD;
     // run command
     SDBMessage rtn = AdminCommand(commandString,
                                   matcher, selector, orderBy, options);
     // check return flag and retrun cursor
     DBCursor cursor = null;
     int flags = rtn.Flags;
     if (flags != 0)
     {
         if(flags == SequoiadbConstants.SDB_DMS_EOC)
             return null;
         else
             throw new BaseException(flags);
     }
     cursor = new DBCursor(rtn, this);
     return cursor;
 }