resetSnapshot()

语法

db.resetSnapshot( [options] )

重置快照。主要针对一些统计信息,比如TotalDataRead、TotalDataWrite等。它的作用是清空之前的统计,重新开始统计。

参数描述

参数名参数类型描述是否必填
optionsJson 对象设定快照类型、会话号、命令位置参数
  • options 格式

属性名描述默认值格式Type指定重置的快照类型。取值:"sessions""sessions current""database""health""collections""all""all"Type: "sessions"SessionID指定重置的会话ID。所有会话SessionID: 1CollectionSpace指定需要重置快照统计信息的集合空间名称,字符串类型。空CollectionSpace : "foo"Collection指定需要重置快照统计信息的集合名称,字符串类型。需要为集合全名。空Collection : "foo.bar"Location Elements命令位置参数所有节点GroupName:"db1"

Note:

  • Type: "all" 表示重置所有快照。
  • SessionID 字段只在 Type: "sessions" 才生效。
  • CollectionSpace 字段和 Collection 字段只在 Type : "collections" 时生效;CollectionSpace 字段和 Collection 字段不能同时指定;Collection 字段和 CollectionSpace 字段不指定时为清空所有所有集合的快照统计信息。
  • 重置项

快照类型重置项sessions"TotalDataRead","TotalIndexRead","TotalDataWrite","TotalIndexWrite""WriteTimeSpent","ResetTimestamp","LastOpType","LastOpBegin""TotalRead","TotalReadTime","TotalWriteTime","ReadTimeSpent""LastOpEnd","LastOpInfo","ReadTimeSpent","WriteTimeSpent""TotalUpdate","TotalDelete","TotalInsert","TotalSelect"sessions current与"sessions"重置项相同database"totalDataRead","totalIndexRead","totalLobRead","TotalDataWrite""svcNetOut","totalReadTime","totalWriteTime","resetTimestamp""TotalIndexWrite","totalLobWrite","totalUpdate","totalDelete""totalInsert","totalSelect","totalRead","receiveNum""replUpdate","replInsert","replDelete","svcNetIn"health"ErrNum":{"SDB_OOM","SDB_NOSPC","SDB_TOO_MANY_OPEN_FD"}collections"TotalDataRead","TotalIndexRead","TotalDataWrite","TotalIndexWrite""TotalUpdate","TotalDelete","TotalInsert","TotalSelect""TotalRead","TotalWrite","TotalTbScan","TotalIxScan""ResetTimestamp"all除了重置上述所有的项,还包括:"totalTime","totalContexts"

返回值

无返回值,出错抛异常,并输出错误信息。可以通过 getLastErrObj()getLastErrMsg() 获取错误信息 或 通过 getLastError() 获取错误码。

关于错误处理可以参考常见错误处理指南

示例

  • 重置 SessionID 为22的快照。

重置前:

  1. >db.snapshot(SDB_SNAP_CONTEXTS,{"SessionID":22})
  2. {
  3. "NodeName": "u1604-nzb:31820",
  4. "SessionID": 22,
  5. "TID": 11076,
  6. "Status": "Waiting",
  7. "Type": "ShardAgent",
  8. "Name": "Type:Shard,NetID:1,R-TID:12930,R-IP:192.168.20.53,R-Port:11810",
  9. "QueueSize": 0,
  10. "ProcessEventCount": 32,
  11. "RelatedID": "c0a814352e2200003282",
  12. "Contexts": [
  13. 200
  14. ],
  15. "TotalDataRead": 27577,
  16. "TotalIndexRead": 0,
  17. "TotalDataWrite": 0,
  18. "TotalIndexWrite": 0,
  19. "TotalUpdate": 0,
  20. "TotalDelete": 0,
  21. "TotalInsert": 0,
  22. "TotalSelect": 27577,
  23. "TotalRead": 27577,
  24. "TotalReadTime": 0,
  25. "TotalWriteTime": 0,
  26. "ReadTimeSpent": 0,
  27. "WriteTimeSpent": 0,
  28. "ConnectTimestamp": "2019-06-20-13.55.52.646730",
  29. "ResetTimestamp": "2019-06-20-13.55.52.646730",
  30. "LastOpType": "GETMORE",
  31. "LastOpBegin": "--",
  32. "LastOpEnd": "2019-06-20-14.20.22.223637",
  33. "LastOpInfo": "ContextID:200, NumToRead:-1",
  34. "UserCPU": 0.38,
  35. "SysCPU": 0.29
  36. }

重置快照:

  1. > db.resetSnapshot({Type : "session", SessionID: 22})
  2. Takes 0.001436s.

重置后:

  1. >db.snapshot(SDB_SNAP_CONTEXTS,{"SessionID":22})
  2. {
  3. "NodeName": "u1604-nzb:31820",
  4. "SessionID": 22,
  5. "TID": 11076,
  6. "Status": "Waiting",
  7. "Type": "ShardAgent",
  8. "Name": "Type:Shard,NetID:1,R-TID:12930,R-IP:192.168.20.53,R-Port:11810",
  9. "QueueSize": 0,
  10. "ProcessEventCount": 32,
  11. "RelatedID": "c0a814352e2200003282",
  12. "Contexts": [
  13. 200
  14. ],
  15. "TotalDataRead": 0,
  16. "TotalIndexRead": 0,
  17. "TotalDataWrite": 0,
  18. "TotalIndexWrite": 0,
  19. "TotalUpdate": 0,
  20. "TotalDelete": 0,
  21. "TotalInsert": 0,
  22. "TotalSelect": 0,
  23. "TotalRead": 0,
  24. "TotalReadTime": 0,
  25. "TotalWriteTime": 0,
  26. "ReadTimeSpent": 0,
  27. "WriteTimeSpent": 0,
  28. "ConnectTimestamp": "2019-06-20-13.55.52.646730",
  29. "ResetTimestamp": "2019-06-20-14.23.42.059988",
  30. "LastOpType": "UNKNOW",
  31. "LastOpBegin": "--",
  32. "LastOpEnd": "--",
  33. "LastOpInfo": "",
  34. "UserCPU": 0.38,
  35. "SysCPU": 0.3
  36. }