CephContext

A CephContext represents a single view of the Ceph cluster. It comes completewith a configuration, a set of performance counters (PerfCounters), and aheartbeat map. You can find more information about CephContext insrc/common/ceph_context.h.

Generally, you will have only one CephContext in your application, calledg_ceph_context. However, in library code, it is possible that the library userwill initialize multiple CephContexts. For example, this would happen if hecalled rados_create more than once.

A ceph context is required to issue log messages. Why is this? Well, withoutthe CephContext, we would not know which log messages were disabled and whichwere enabled. The dout() macro implicitly references g_ceph_context, so itcan’t be used in library code. It is fine to use dout and derr in daemons, butin library code, you must use ldout and lderr, and pass in your own CephContextobject. The compiler will enforce this restriction.