void rados_version(int *major, int *minor, int *extra);
/* initialization */
-int rados_init(rados_t *cluster);
-void rados_release(rados_t cluster);
+int rados_create(rados_t *cluster);
+
+/* Connect to the cluster */
+int rados_connect(rados_t cluster);
+
+/* destroy the cluster instance */
+void rados_destroy(rados_t cluster);
/* Config
*
* Returns 0 on success, error code otherwise. */
int rados_conf_set(rados_t cluster, const char *option, const char *value);
-/* Applies any configuration changes */
-int rados_conf_apply(void);
+/* Reopens the log file.
+ * You must do this after changing the logging configuration.
+ * It is also good practice to call this from your SIGHUP signal handler, so that users can send you
+ * a SIGHUP to reopen the log.
+ */
+int rados_reopen_log(void);
/* Returns a configuration value as a string.
* If len is positive, that is the maximum number of bytes we'll write into the
SafeTimer timer;
public:
- RadosClient() : messenger(NULL), lock("radosclient"), timer(lock),
- max_watch_cookie(0) {
- messenger = new SimpleMessenger();
+ RadosClient() : messenger(NULL), objecter(NULL),
+ lock("radosclient"), timer(lock), max_watch_cookie(0)
+ {
}
~RadosClient();
- int init();
+ int connect();
void shutdown();
struct PoolCtx {
}
};
-int RadosClient::init()
+int RadosClient::connect()
{
// get monmap
int ret = monclient.build_initial_monmap();
if (ret < 0)
return ret;
- assert_warn(messenger);
+ messenger = new SimpleMessenger();
if (!messenger)
return -ENOMEM;
common_set_defaults(false);
common_init(args, "librados", STARTUP_FLAG_INIT_KEYS);
- client = new RadosClient();
- return client->init();
+ return 0;
}
void Rados::shutdown()
static Mutex rados_init_mutex("rados_init");
static int rados_initialized = 0;
-extern "C" int rados_init(rados_t *pcluster)
+extern "C" int rados_create(rados_t *pcluster)
{
- int ret = 0;
-
rados_init_mutex.Lock();
if (!rados_initialized) {
// parse environment
++rados_initialized;
}
rados_init_mutex.Unlock();
-
RadosClient *radosp = new RadosClient;
- ret = radosp->init();
- if (ret < 0) {
- delete radosp;
- } else {
- *pcluster = (void *)radosp;
- }
- return ret;
+ *pcluster = (void *)radosp;
+ return 0;
}
-extern "C" void rados_release(rados_t cluster)
+extern "C" int rados_connect(rados_t cluster)
+{
+ RadosClient *radosp = (RadosClient *)cluster;
+ return radosp->connect();
+}
+
+extern "C" void rados_destroy(rados_t cluster)
{
RadosClient *radosp = (RadosClient *)cluster;
radosp->shutdown();
return g_conf.set_val(option, value);
}
-extern "C" int rados_conf_apply(void)
+extern "C" int rados_reopen_log(void)
{
- // Simulate SIGHUP after a configuration change.
sighup_handler(SIGHUP);
return 0;
}
return g_conf.get_val(option, buf, len);
}
-
extern "C" int rados_lookup_pool(rados_t cluster, const char *name)
{
RadosClient *radosp = (RadosClient *)cluster;
exit(1);
}
- rados_conf_parse_argv(cl, argc, argv);
+ if (rados_connect(cl)) {
+ printf("error connecting\n");
+ exit(1);
+ }
/* create a pool */
r = rados_create_pool("foo");
printf("rados_delete_pool = %d\n", r);
r = rados_close_pool(pool);
- rados_deinitialize();
+ rados_destroy(cl);
return 0;
}