summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/gfdb/gfdb_data_store.h
diff options
context:
space:
mode:
authorJoseph Fernandes <josferna@redhat.com>2015-02-18 19:45:23 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-18 10:36:42 -0700
commit87c7fa3cfdadca4ee883daf84373302a42ad5fdc (patch)
treee61b744ea3c2058a95a5057bb8c2fe7763eb101f /libglusterfs/src/gfdb/gfdb_data_store.h
parentdbd62a8d2b50392fbed0a0781a4f241dadb8f506 (diff)
Adding Libgfdb to GlusterFS
************************************************************************* Libgfdb | ************************************************************************* Libgfdb provides abstract mechanism to record extra/rich metadata required for data maintenance, such as data tiering/classification. It provides consumer with API for recording and querying, keeping the consumer abstracted from the data store used beneath for storing data. It works in a plug-and-play model, where data stores can be plugged-in. Presently we have plugin for Sqlite3. In the future will provide recording and querying performance optimizer. In the current implementation the schema of metadata is fixed. Schema: ~~~~~~ GF_FILE_TB Table: ~~~~~~~~~~~~~~~~~ This table has one entry per file inode. It holds the metadata required to make decisions in data maintenance. GF_ID (Primary key) : File GFID (Universal Unique IDentifier in the namespace) W_SEC, W_MSEC : Write wind time in sec & micro-sec UW_SEC, UW_MSEC : Write un-wind time in sec & micro-sec W_READ_SEC, W_READ_MSEC : Read wind time in sec & micro-sec UW_READ_SEC, UW_READ_MSEC : Read un-wind time in sec & micro-sec WRITE_FREQ_CNTR INTEGER : Write Frequency Counter READ_FREQ_CNTR INTEGER : Read Frequency Counter GF_FLINK_TABLE: ~~~~~~~~~~~~~~ This table has all the hardlinks to a file inode. GF_ID : File GFID (Composite Primary Key)``| GF_PID : Parent Directory GFID (Composite Primary Key) |-> Primary Key FNAME : File Base Name (Composite Primary Key)__| FPATH : File Full Path (Its redundant for now, this will go) W_DEL_FLAG : This Flag is used for crash consistancy, when a link is unlinked. i.e Set to 1 during unlink wind and during unwind this record is deleted LINK_UPDATE : This Flag is used when a link is changed i.e rename. Set to 1 when rename wind and set to 0 in rename unwind Libgfdb API: ~~~~~~~~~~~ Refer libglusterfs/src/gfdb/gfdb_data_store.h Change-Id: I2e9fbab3878ce630a7f41221ef61017dc43db11f BUG: 1194753 Signed-off-by: Joseph Fernandes <josferna@redhat.com> Signed-off-by: Dan Lambright <dlambrig@redhat.com> Signed-off-by: Joseph Fernandes <josferna@redhat.com> Reviewed-on: http://review.gluster.org/9683 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src/gfdb/gfdb_data_store.h')
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store.h219
1 files changed, 219 insertions, 0 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_data_store.h b/libglusterfs/src/gfdb/gfdb_data_store.h
new file mode 100644
index 00000000000..1212c2b3fe1
--- /dev/null
+++ b/libglusterfs/src/gfdb/gfdb_data_store.h
@@ -0,0 +1,219 @@
+/*
+ Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+#ifndef __GFDB_DATA_STORE_H
+#define __GFDB_DATA_STORE_H
+
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glusterfs.h"
+#include "xlator.h"
+#include "logging.h"
+#include "common-utils.h"
+#include <time.h>
+#include <sys/time.h>
+
+#include "gfdb_data_store_types.h"
+#include "gfdb_sqlite3.h"
+
+
+/* GFDB Connection Node:
+ * ~~~~~~~~~~~~~~~~~~~~
+ * Represents the connection to the database while using libgfdb
+ * The connection node is not thread safe as far as fini_db is concerned.
+ * You can use a single connection node
+ * to do multithreaded db operations like insert/delete/find of records.
+ * But you need to wait for all the operating threads to complete i.e
+ * pthread_join() and then do fini_db() to kill the connection node.
+ * gfdb_conn_node_t is an opaque structure.
+ * */
+typedef struct gfdb_conn_node_t gfdb_conn_node_t;
+
+
+
+
+/*Libgfdb API Function: Used to initialize db connection
+ * Arguments:
+ * args : Dictionary containing database specific parameters
+ * eg: For sqlite3, pagesize, cachesize, db name, db path
+ etc
+ * gfdb_db_type : Type of data base used i.e sqlite or hyperdex etc
+ * Returns : if successful return the GFDB Connection Node to the caller or
+ * NULL value in case of failure*/
+gfdb_conn_node_t *
+init_db(dict_t *arg, gfdb_db_type_t db_type);
+
+
+
+
+
+/*Libgfdb API Function: Used to terminate/de-initialize db connection
+ * (Destructor function for db connection object)
+ * Arguments:
+ * _conn_node : DB Connection Index of the DB Connection
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int
+fini_db(gfdb_conn_node_t *);
+
+
+
+
+/*Libgfdb API Function: Used to insert/updated records in the database
+ * NOTE: In current gfdb_sqlite plugin we use that
+ * same function to delete the record. Set the
+ * gfdb_fop_path to GFDB_FOP_UNDEL to delete the
+ * link of inode from GF_FLINK_TB and
+ * GFDB_FOP_UNDEL_ALL to delete all the records from
+ * GF_FLINK_TB and GF_FILE_TB.
+ * TODO: Should seperate this function into the
+ * delete_record function
+ * Refer CTR Xlator features/changetimerecorder for usage
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * gfdb_db_record : Record to be inserted/updated
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int
+insert_record(gfdb_conn_node_t *, gfdb_db_record_t *gfdb_db_record);
+
+
+
+
+/*Libgfdb API Function: Used to delete record from the database
+ * NOTE: In the current gfdb_sqlite3 plugin
+ * implementation this function is dummy.
+ * Use the insert_record function.
+ * Refer CTR Xlator features/changetimerecorder for usage
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * gfdb_db_record : Record to be deleted
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int
+delete_record(gfdb_conn_node_t *, gfdb_db_record_t *gfdb_db_record);
+
+
+
+
+
+/*Libgfdb API Function: Query all the records from the database
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * query_callback : Call back function that will be called
+ * for every record found
+ * _query_cbk_args : Custom argument passed for the call back
+ * function query_callback
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int find_all(gfdb_conn_node_t *, gf_query_callback_t query_callback,
+ void *_query_cbk_args);
+
+
+
+
+
+/*Libgfdb API Function: Query records/files that have not changed/accessed
+ * from a time in past to current time
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * query_callback : Call back function that will be called
+ * for every record found
+ * _query_cbk_args : Custom argument passed for the call back
+ * function query_callback
+ * for_time : Time from where the file/s are not
+ * changed/accessed
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int find_unchanged_for_time(gfdb_conn_node_t *,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args, gfdb_time_t *for_time);
+
+
+
+
+/*Libgfdb API Function: Query records/files that have changed/accessed from a
+ * time in past to current time
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * query_callback : Call back function that will be called
+ * for every record found
+ * _query_cbk_args : Custom argument passed for the call back
+ * function query_callback
+ * for_time : Time from where the file/s are
+ * changed/accessed
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int find_recently_changed_files(gfdb_conn_node_t *_conn,
+ gf_query_callback_t query_callback, void *_query_cbk_args,
+ gfdb_time_t *from_time);
+
+
+
+
+
+/*Libgfdb API Function: Query records/files that have not changed/accessed
+ * from a time in past to current time, with
+ * a desired frequency
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * query_callback : Call back function that will be called
+ * for every record found
+ * _query_cbk_args : Custom argument passed for the call back
+ * function query_callback
+ * for_time : Time from where the file/s are not
+ * changed/accessed
+ * write_freq_thresold : Desired Write Frequency lower limit
+ * read_freq_thresold : Desired Read Frequency lower limit
+ * _clear_counters : If true, Clears all the frequency counters of
+ * all files.
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int find_unchanged_for_time_freq(gfdb_conn_node_t *_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args,
+ gfdb_time_t *for_time,
+ int write_freq_thresold,
+ int read_freq_thresold,
+ gf_boolean_t _clear_counters);
+
+
+
+
+
+/*Libgfdb API Function: Query records/files that have changed/accessed from a
+ * time in past to current time, with
+ * a desired frequency
+ * Arguments:
+ * _conn_node : GFDB Connection node
+ * query_callback : Call back function that will be called
+ * for every record found
+ * _query_cbk_args : Custom argument passed for the call back
+ * function query_callback
+ * for_time : Time from where the file/s are
+ * changed/accessed
+ * write_freq_thresold : Desired Write Frequency lower limit
+ * read_freq_thresold : Desired Read Frequency lower limit
+ * _clear_counters : If true, Clears all the frequency counters of
+ * all files.
+ * Returns : if successful return 0 or
+ * -ve value in case of failure*/
+int find_recently_changed_files_freq(gfdb_conn_node_t *_conn,
+ gf_query_callback_t query_callback,
+ void *_query_cbk_args,
+ gfdb_time_t *from_time,
+ int write_freq_thresold,
+ int read_freq_thresold,
+ gf_boolean_t _clear_counters);
+
+#endif