Distributed File System 1
Distributed file system in C
Loading...
Searching...
No Matches
dnode.h
Go to the documentation of this file.
1/* lib/dnode.h
2 *
3 * These are the data nodes that the DFS uses.
4 *
5 */
6#ifndef DNODE_H_
7#define DNODE_H_
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/* ----- Includes ----- */
14
15#include "lib.h"
16#include "list.h"
17#include "uuid.h"
18#include "enchufe.h"
19
20/* ---- Macros ----- */
21
22#define DNODE_TABLE "data/dnode.bin"
23
24/* ----- Types ----- */
25
27typedef struct {
31} DNode;
32
33
35typedef struct {
38 size_t seq;
39} DNodeInfo;
40
41/* ----- Functions ----- */
42
43
44// Define List for data nodes
46
47// Define List for data node infos
49
50
56
63
70
76ListDNode ListDNode_deserialize(Buffer buf);
77
83
90
96
102ListDNodeInfo ListDNodeInfo_deserialize(Buffer buf);
103
108void insert_into_dnode(IPv4 address, Port port);
109
116ListDNode select_from_dnode(UUID* nid, IPv4* address, Port* port);
117
121ListDNode DNode_get_db(void);
122
123
125void DNode_set_db(ListDNode dnodes);
126
130void print_dnode(DNode dnode);
131
132
145ListDNodeInfo insert(ListDNodeInfo l, DNodeInfo a);
146
155ListDNodeInfo sort(ListDNodeInfo l);
156
157#ifdef __cplusplus
158}
159#endif
160
161#endif // DNODE_H_
Buffer DNode_serialize(DNode dnode)
Definition dnode.c:48
DNode DNode_deserialize(Buffer buf)
Deserialize a Buffer into a DNode.
Definition dnode.c:56
ListDNode ListDNode_deserialize(Buffer buf)
Deserialize a Buffer into a List of DNode's.
Definition dnode.c:87
Buffer ListDNode_serialize(ListDNode list)
Serialize a List of DNode's into a Buffer.
Definition dnode.c:82
void print_dnode(DNode dnode)
Print a DNode's data as a tuple.
Definition dnode.c:176
ListDNodeInfo ListDNodeInfo_deserialize(Buffer buf)
Deserialize a Buffer into a List of DNodeInfo's.
Definition dnode.c:36
ListDNodeInfo sort(ListDNodeInfo l)
Sort a ListDNodeInfo depending on the sequence numbers of its entries.
Definition dnode.c:191
ListDNode select_from_dnode(UUID *nid, IPv4 *address, Port *port)
SELECT from the DNode table.
Definition dnode.c:133
ListDNode DNode_get_db(void)
Get the DNode table from the database.
Definition dnode.c:149
void DNode_set_db(ListDNode dnodes)
Write the database with the List of DNode's.
Definition dnode.c:163
Buffer DNodeInfo_serialize(DNodeInfo dinfo)
Serialize a DNodeInfo to a buffer.
void insert_into_dnode(IPv4 address, Port port)
INSERT into the DNode table.
Definition dnode.c:101
ListDNodeInfo insert(ListDNodeInfo l, DNodeInfo a)
Insert a DNodeInfo into a ListDNodeInfo in a sorted fashion.
Definition dnode.c:181
DNodeInfo DNodeInfo_deserialize(Buffer buf)
Deserialize a Buffer into a List of DNodeInfo's.
Definition dnode.c:11
Buffer ListDNodeInfo_serialize(ListDNodeInfo list)
Serialize a ListDNodeInfo to a buffer.
Definition dnode.c:26
uint16_t Port
El puerto de la conexion.
Definition enchufe.h:28
#define DefList(type)
Definition list.h:93
void list(Enchufe cliente)
Definition meta-data.c:14
Byte buffer.
Definition lib.h:92
This carries all the necessary information that a chunk should have.
Definition dnode.h:35
DNode dnode
the DNode of the chunk
Definition dnode.h:36
size_t seq
The place in the sequence of chunks where this chunk should be.
Definition dnode.h:38
UUID cid
The UUID of the chunk.
Definition dnode.h:37
Saves the connection data.
Definition dnode.h:27
Port port
Port of where the connection came from.
Definition dnode.h:30
UUID nid
DNode ID (primary key)
Definition dnode.h:28
IPv4 address
Address of where the connection came from.
Definition dnode.h:29
UUID type Layout taken from: https://en.wikipedia.org/wiki/Universally_unique_identifier#Binary_repre...
Definition uuid.h:24
Tipo para un IPv4 Ademas te ayuda convertir entre little endian y big endian.
Definition enchufe.h:33