Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kim, Jungwon
papyrus
Commits
e5a2df72
Commit
e5a2df72
authored
Feb 23, 2018
by
Antonio Gomez
Browse files
cleaning
parent
14fd2585
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
kv/src/CAPI.cpp
View file @
e5a2df72
...
...
@@ -63,7 +63,7 @@ int papyruskv_unmount_file(int db, const char*src) {
//Functions to provide read/write functionality
int
papyruskv_fread
(
int
db
,
void
*
buff
,
size_t
size
,
off_t
offset
,
const
char
*
src
)
{
_debug
(
"calling fread"
,
NULL
);
//
_debug ("calling fread", NULL);
if
(
!
buff
)
{
_error
(
"destination buffer not allocated"
,
NULL
);
return
PAPYRUSKV_ERR
;
...
...
kv/src/DB.cpp
View file @
e5a2df72
...
...
@@ -78,7 +78,7 @@ int DB::BroadcastKV(const char* key, size_t keylen, const char* val, size_t vall
//Iterate over all ranks
int
ret
;
for
(
int
dest
=
0
;
dest
<
nranks_
;
++
dest
)
{
_info
(
"[%d] Broadcasting KV [%s (%d) - %s (%lu)] to rank %d"
,
rank_
,
key
,
keylen
,
val
,
vallen
,
dest
);
//
_info("[%d] Broadcasting KV [%s (%d) - %s (%lu)] to rank %d", rank_, key, keylen, val, vallen, dest);
//Put a command on each node
if
(
dest
==
rank_
)
ret
=
PutLocal
(
key
,
keylen
,
val
,
vallen
,
false
);
...
...
@@ -104,7 +104,7 @@ int DB::PutLocalOffset (Slice* slice) {
int
DB
::
GetLocalOffset
(
const
char
*
key
,
size_t
keylen
,
char
*
valp
,
size_t
vallenp
,
const
off_t
offset
,
int
mode
,
papyruskv_pos_t
*
pos
)
{
//TODO
_debug
(
"Getting local file offset [%lu] size[%lu]"
,
offset
,
vallenp
);
//
_debug ("Getting local file offset [%lu] size[%lu]", offset, vallenp);
int
ret
=
GetFileOffset
(
key
,
keylen
,
valp
,
vallenp
,
offset
);
if
(
ret
!=
PAPYRUSKV_OK
)
{
_error
(
"error while getting local offset [%d]"
,
ret
);
...
...
@@ -125,19 +125,19 @@ int DB::PutFileOffset(const char* key, size_t keylen, const char* val, size_t va
//TODO: check whether the data already exists in the system (has been previously broacast)
int
rank
=
affinity_
->
getDestination
(
rank_
,
nranks_
);
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] rank[%d]"
,
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
rank
);
_debug
(
"[%d] Putting file offset on rank %d"
,
rank_
,
rank
);
//
_debug ("[%d] Putting file offset on rank %d", rank_, rank);
return
rank
==
rank_
?
PutLocalFileOffset
(
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
offset
,
false
)
:
PutRemoteFileOffset
(
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
offset
,
false
,
rank
);
}
int
DB
::
PutLocalFileOffset
(
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
,
const
off_t
offset
,
bool
tombstone
)
{
_debug
(
"Writing to object locally"
,
NULL
);
//
_debug ("Writing to object locally", NULL);
return
PutLocalObjectOffset
(
key
,
keylen
,
val
,
vallen
,
offset
);
}
int
DB
::
PutRemoteFileOffset
(
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
,
const
off_t
offset
,
bool
tombstone
,
int
rank
)
{
_debug
(
"
\n
writting to object remotely [%d]
\n
"
,
rank
);
//
_debug ("\n writting to object remotely [%d]\n", rank);
//TODO: make sure this is correct
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] tombstone[%d] rank[%d]"
,
key
,
keylen
,
val
,
vallen
,
tombstone
,
rank
);
...
...
@@ -170,7 +170,7 @@ int DB::PutFile(const char* key, size_t keylen, const char* val, size_t vallen)
std
::
string
keystr1
(
key
);
std
::
string
keystr
(
keystr1
.
substr
(
0
,
keystr1
.
find
(
'\0'
)));
_debug
(
"[%d] Checking if key %s already exists"
,
rank_
,
keystr
.
c_str
());
//
_debug ("[%d] Checking if key %s already exists", rank_, keystr.c_str());
char
**
dump
;
size_t
dumpl
;
...
...
@@ -178,11 +178,11 @@ int DB::PutFile(const char* key, size_t keylen, const char* val, size_t vallen)
_error
(
"[%d] key %s already exists, nothing to do"
,
rank_
,
keystr
.
c_str
());
return
PAPYRUSKV_OK
;
}
_info
(
"[%d] key %s did not exist, I have to add it"
,
rank_
,
keystr
.
c_str
());
//
_info ("[%d] key %s did not exist, I have to add it", rank_, keystr.c_str());
int
rank
=
affinity_
->
getDestination
(
rank_
,
nranks_
);
//
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] rank[%d]"
,
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
rank
);
_info
(
"key [%s] destination [%d]"
,
keystr
.
c_str
(),
rank
);
//
_info("key [%s] destination [%d]", keystr.c_str(), rank);
int
length
=
snprintf
(
NULL
,
0
,
"%d"
,
rank
);
char
*
crank
=
new
char
[
length
];
...
...
@@ -194,22 +194,22 @@ int DB::PutFile(const char* key, size_t keylen, const char* val, size_t vallen)
return
PAPYRUSKV_ERR
;
}
_info
(
"[%d] file %s in %d and broadcast"
,
rank_
,
keystr
.
c_str
(),
rank_
);
//
_info ("[%d] file %s in %d and broadcast", rank_, keystr.c_str(), rank_);
return
rank
==
rank_
?
PutLocalFile
(
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
false
)
:
PutRemoteFile
(
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
false
,
rank
);
}
int
DB
::
PutLocalObject
(
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
)
{
std
::
unique_ptr
<
Object
>
obj
(
new
Object
());
_debug
(
"[%d] writing data key %s (size %d) to object"
,
rank_
,
key
,
vallen
);
//
_debug ("[%d] writing data key %s (size %d) to object", rank_, key, vallen);
int
ret
=
obj
->
writeData
(
val
,
vallen
,
0
);
if
(
ret
!=
PAPYRUSKV_OK
)
{
_error
(
"Error writing to object offset 0"
,
NULL
);
return
ret
;
}
_debug
(
"[%d] inserting key [%s] to objects"
,
rank_
,
key
);
//
_debug ("[%d] inserting key [%s] to objects", rank_, key);
objects
.
insert
(
std
::
make_pair
(
std
::
string
(
key
),
std
::
move
(
obj
)));
_debug
(
"object inserted [%d]"
,
objects
.
size
());
//
_debug ("object inserted [%d]", objects.size());
return
PAPYRUSKV_OK
;
}
...
...
@@ -219,10 +219,10 @@ int DB::PutLocalObjectOffset(const char* key, size_t keylen, const char* val, si
auto
it
=
objects
.
find
(
key
);
if
(
it
==
objects
.
end
())
{
_debug
(
"Object for offset %d not found. A new object is needed"
,
offset
);
//
_debug ("Object for offset %d not found. A new object is needed", offset);
//TODO: consider the case of appending new data (kind of implemented already in File.cpp)
std
::
unique_ptr
<
Object
>
obj
(
new
Object
());
_debug
(
"Writing data to new object"
,
NULL
);
//
_debug ("Writing data to new object", NULL);
int
ret
=
obj
->
writeData
(
val
,
vallen
,
offset
);
if
(
ret
!=
PAPYRUSKV_OK
)
{
_error
(
"Error while writing data to object"
,
NULL
);
...
...
@@ -249,7 +249,7 @@ int DB::PutLocalObjectOffset(const char* key, size_t keylen, const char* val, si
}
}
else
{
_debug
(
"Writing data with offset %d to object"
,
offset
);
//
_debug ("Writing data with offset %d to object", offset);
int
ret
=
it
->
second
->
writeData
(
val
,
vallen
,
offset
);
if
(
ret
!=
PAPYRUSKV_OK
)
{
_error
(
"Error writing offset %d"
,
offset
);
...
...
@@ -266,7 +266,7 @@ int DB::PutLocalFile(const char* key, size_t keylen, const char* val, size_t val
int
DB
::
PutRemoteFile
(
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
,
bool
tombstone
,
int
rank
)
{
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] tombstone[%d] rank[%d]"
,
key
,
keylen
,
val
,
vallen
,
tombstone
,
rank
);
_todo
(
"Putting remote file (size %lu)"
,
vallen
);
//
_todo ("Putting remote file (size %lu)", vallen);
if
(
protection_
==
PAPYRUSKV_RDWR
||
protection_
==
PAPYRUSKV_UDONLY
)
remote_cache_
->
Invalidate
(
key
,
keylen
);
if
(
consistency_
==
PAPYRUSKV_SEQUENTIAL
)
{
...
...
@@ -347,7 +347,8 @@ int DB::PutFilename (const char* filename, const size_t keylen, int rank) {
if
(
rank
==
rank_
)
return
PAPYRUSKV_OK
;
_todo
(
"putting filename %s to rank %d"
,
filename
,
rank
);
// _todo("putting filename %s to rank %d", filename, rank);
/* if (protection_ == PAPYRUSKV_RDWR || protection_ == PAPYRUSKV_UDONLY) {
_debug ("invalidating", NULL);
remote_cache_->Invalidate(filename, keylen);
...
...
@@ -372,7 +373,7 @@ int DB::PutFilename (const char* filename, const size_t keylen, int rank) {
}
*/
_
debug
(
"error"
,
NULL
);
_
error
(
"error"
,
NULL
);
return
PAPYRUSKV_ERR
;
}
...
...
@@ -383,7 +384,7 @@ int DB::Put(const char* key, size_t keylen, const char* val, size_t vallen) {
}
int
rank
=
hasher_
->
KeyRank
(
key
,
keylen
);
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] rank[%d]"
,
key
,
keylen
,
val
,
vallen
,
rank
);
_debug
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] rank[%d]"
,
key
,
keylen
,
val
,
vallen
,
rank
);
//
_debug("key[%s] keylen[%lu] val[%s] vallen[%lu] rank[%d]", key, keylen, val, vallen, rank);
return
rank
==
rank_
?
PutLocal
(
key
,
keylen
,
val
,
vallen
,
false
)
:
PutRemote
(
key
,
keylen
,
val
,
vallen
,
false
,
rank
);
}
...
...
@@ -411,7 +412,7 @@ int DB::PutLocal(const char* key, size_t keylen, const char* val, size_t vallen,
int
DB
::
PutRemote
(
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
,
bool
tombstone
,
int
rank
)
{
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] tombstone[%d] rank[%d]"
,
key
,
keylen
,
val
,
vallen
,
tombstone
,
rank
);
_todo
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] tombstone[%d] rank[%d]"
,
key
,
keylen
,
val
,
vallen
,
tombstone
,
rank
);
//
_todo("key[%s] keylen[%lu] val[%s] vallen[%lu] tombstone[%d] rank[%d]", key, keylen, val, vallen, tombstone, rank);
if
(
protection_
==
PAPYRUSKV_RDWR
||
protection_
==
PAPYRUSKV_UDONLY
)
{
// _debug ("invalidating key" , NULL);
remote_cache_
->
Invalidate
(
key
,
keylen
);
...
...
@@ -444,7 +445,7 @@ int DB::PutRemote(const char* key, size_t keylen, const char* val, size_t vallen
int
DB
::
GetFileOffset
(
const
char
*
key
,
size_t
keylen
,
char
*
val
,
size_t
vallen
,
const
off_t
offset
)
{
std
::
string
keystr1
(
key
);
std
::
string
keystr
(
keystr1
.
substr
(
0
,
keystr1
.
find
(
'\0'
)));
_debug
(
"reading key %s"
,
keystr
.
c_str
());
//
_debug("reading key %s", keystr.c_str());
char
*
crank
=
(
char
*
)
malloc
(
10
*
sizeof
(
char
));
size_t
length
;
...
...
@@ -456,7 +457,7 @@ int DB::GetFileOffset(const char* key, size_t keylen, char* val, size_t vallen,
// _todo("the rank returned is %s [%d]", crank, length);
int
rank
=
(
int
)
strtol
(
crank
,
(
char
**
)
NULL
,
10
);
_debug
(
"rank where the data is located: %d [%s]"
,
rank
,
crank
);
//
_debug ("rank where the data is located: %d [%s]", rank, crank);
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] rank[%d]"
,
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
rank
);
free
(
crank
);
return
rank
==
rank_
?
GetLocalFileOffset
(
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
offset
,
false
)
:
GetRemoteFileOffset
(
keystr
.
c_str
(),
keystr
.
length
(),
val
,
vallen
,
offset
,
false
,
rank
);
...
...
@@ -464,7 +465,7 @@ int DB::GetFileOffset(const char* key, size_t keylen, char* val, size_t vallen,
int
DB
::
GetLocalFileOffset
(
const
char
*
key
,
size_t
keylen
,
char
*
val
,
size_t
vallen
,
const
off_t
offset
,
bool
tombstone
)
{
_debug
(
"Finding object with offset %d [key %s]"
,
offset
,
key
);
//
_debug ("Finding object with offset %d [key %s]", offset, key);
int
found
=
0
;
auto
it
=
objects
.
find
(
key
);
...
...
@@ -484,12 +485,12 @@ int DB::GetLocalFileOffset(const char* key, size_t keylen, char* val, size_t val
}
int
DB
::
GetRemoteFileOffset
(
const
char
*
key
,
size_t
keylen
,
char
*
val
,
size_t
vallen
,
const
off_t
offset
,
bool
tombstone
,
int
rank
)
{
_debug
(
"getting remote file offset from rank %d"
,
rank
);
//
_debug ("getting remote file offset from rank %d", rank);
//Put request to rank 'rank' and get the response
int
ret
=
dispatcher_
->
ExecuteGetOffset
(
this
,
key
,
keylen
,
val
,
vallen
,
offset
,
false
,
false
,
rank
);
_trace
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] ret[%x]"
,
key
,
keylen
,
val
,
vallen
,
ret
);
_debug
(
"key[%s] keylen[%lu] val[%s] vallen[%lu] ret[%x]"
,
key
,
keylen
,
val
,
vallen
,
ret
);
//
_debug("key[%s] keylen[%lu] val[%s] vallen[%lu] ret[%x]", key, keylen, val, vallen, ret);
/*
if (protection_ == PAPYRUSKV_RDONLY) {
...
...
@@ -511,7 +512,7 @@ int DB::GetFile(const char* key, size_t keylen, char** valp, size_t* vallenp, pa
//First get where the object is actually stored. We have previously stored all that info using KV on all the nodes
char
*
crank
,
*
endptr
;
size_t
len
;
_debug
(
"Getting the rank that has the data for key %s"
,
key
);
//
_debug ("Getting the rank that has the data for key %s", key);
std
::
string
keystr1
(
key
);
std
::
string
keystr
(
keystr1
.
substr
(
0
,
keystr1
.
find
(
'\0'
)));
int
ret
=
Get
(
keystr
.
c_str
(),
keystr
.
length
(),
&
crank
,
&
len
,
pos
);
...
...
@@ -520,7 +521,7 @@ int DB::GetFile(const char* key, size_t keylen, char** valp, size_t* vallenp, pa
return
PAPYRUSKV_ERR
;
}
int
rank
=
strtol
(
crank
,
&
endptr
,
10
);
_debug
(
"object with key %s located in rank %d"
,
key
,
rank
);
//
_debug ("object with key %s located in rank %d", key, rank);
ret
=
rank
==
rank_
?
GetLocalFile
(
keystr
.
c_str
(),
keylen
,
valp
,
vallenp
,
offset
,
PAPYRUSKV_MEMTABLE
|
PAPYRUSKV_SSTABLE
,
pos
)
:
GetRemoteFile
(
keystr
.
c_str
(),
keylen
,
valp
,
vallenp
,
offset
,
rank
,
pos
);
_trace
(
"rank[%d] key[%s] keylen[%lu] val[%s] vallen[%lu] ret[%x]"
,
rank
,
keystr
.
c_str
(),
keylen
,
*
valp
,
*
vallenp
,
ret
);
...
...
@@ -531,18 +532,18 @@ int DB::GetFile(const char* key, size_t keylen, char** valp, size_t* vallenp, pa
int
DB
::
GetLocalFile
(
const
char
*
key
,
size_t
keylen
,
char
**
valp
,
size_t
*
vallenp
,
const
off_t
offset
,
int
mode
,
papyruskv_pos_t
*
pos
)
{
std
::
string
keystr1
(
key
);
std
::
string
keystr
(
keystr1
.
substr
(
0
,
keystr1
.
find
(
'\0'
)));
_info
(
"looking for key %s with length %d offset %d"
,
keystr
.
c_str
(),
keystr
.
length
(),
offset
);
//
_info ("looking for key %s with length %d offset %d", keystr.c_str(), keystr.length(), offset);
auto
it
=
objects
.
find
(
keystr
);
if
(
it
==
objects
.
end
())
{
_error
(
"Object with key %s not found"
,
keystr
.
c_str
());
return
PAPYRUSKV_ERR
;
}
_info
(
"key %s found"
,
keystr
.
c_str
());
//
_info ("key %s found", keystr.c_str());
//TODO: getting the size and allocating the vector should be done earlier than this
//We need the +1 to make sure that we at least read one block
int
last
=
it
->
second
->
getLastBlock
()
+
1
;
_debug
(
"reading %d blocks"
,
last
);
//
_debug ("reading %d blocks", last);
*
valp
=
new
char
[
BLOCK_SIZE
*
last
];
int
ret
=
it
->
second
->
readAllData
(
*
valp
,
vallenp
);
// _debug ("Read data %s", *valp);
...
...
@@ -620,7 +621,7 @@ int DB::Get(const char* key, size_t keylen, char** valp, size_t* vallenp, papyru
}
int
DB
::
GetLocal
(
const
char
*
key
,
size_t
keylen
,
char
**
valp
,
size_t
*
vallenp
,
int
mode
,
papyruskv_pos_t
*
pos
)
{
_debug
(
"[%d] getting local key %s"
,
rank_
,
key
);
//
_debug ("[%d] getting local key %s", rank_, key);
int
ret
=
PAPYRUSKV_SLICE_NOT_FOUND
;
if
(
pos
)
pos
->
handle
=
NULL
;
if
(
mode
&
PAPYRUSKV_MEMTABLE
)
{
...
...
kv/src/DFS.cpp
View file @
e5a2df72
...
...
@@ -58,17 +58,17 @@ int DFS::AddFile(int db, const char* src, bool newfile) {
auto
it
=
folders
.
find
(
folder
);
//If the folder is not there, create it
if
(
it
==
folders
.
end
())
{
_debug
(
"Folder %s wasn't in the system. Creating it..."
,
folder
);
//
_debug ("Folder %s wasn't in the system. Creating it...", folder);
std
::
unique_ptr
<
Folder
>
f
(
new
Folder
(
folder
,
db
));
folders
.
insert
(
std
::
pair
<
const
std
::
string
,
std
::
unique_ptr
<
Folder
>
>
(
folder
,
std
::
move
(
f
)));
_debug
(
"Folder %s in the system now"
,
folder
);
//
_debug ("Folder %s in the system now", folder);
it
=
folders
.
find
(
folder
);
}
if
(
it
->
second
->
AddFile
(
src
,
newfile
)
!=
PAPYRUSKV_OK
)
{
_error
(
"Impossible to add file %s"
,
src
);
return
PAPYRUSKV_ERR
;
}
_debug
(
"File %s added"
,
src
);
//
_debug ("File %s added", src);
return
PAPYRUSKV_OK
;
}
...
...
@@ -78,10 +78,10 @@ int DFS::MountFile(int db, const char*src, const char* mode, int persistance) {
auto
it
=
folders
.
find
(
folder
);
//If the folder is not there, create it
if
(
it
==
folders
.
end
())
{
_debug
(
"Folder %s wasn't in the system. Creating it..."
,
folder
);
//
_debug ("Folder %s wasn't in the system. Creating it...", folder);
std
::
unique_ptr
<
Folder
>
f
(
new
Folder
(
folder
,
db
));
folders
.
insert
(
std
::
pair
<
const
std
::
string
,
std
::
unique_ptr
<
Folder
>
>
(
folder
,
std
::
move
(
f
)));
_debug
(
"Folder %s in the system now"
,
folder
);
//
_debug ("Folder %s in the system now", folder);
it
=
folders
.
find
(
folder
);
}
if
(
it
->
second
->
MountFile
(
src
,
mode
,
persistance
)
!=
PAPYRUSKV_OK
)
{
...
...
@@ -113,10 +113,10 @@ int DFS::UnmountFile(int db, const char* filename) {
Utils
::
getFolder
(
filename
,
folder
);
auto
it
=
folders
.
find
(
folder
);
if
(
it
==
folders
.
end
())
{
_error
(
"Folder %s was not mounted. Listing folders..."
,
folder
);
for
(
auto
it2
=
folders
.
begin
();
it2
!=
folders
.
end
();
it2
++
)
{
_debug
(
"Found folder %s"
,
it2
->
first
.
c_str
());
}
//
_error("Folder %s was not mounted. Listing folders...", folder);
//
for (auto it2 = folders.begin(); it2!=folders.end(); it2++) {
//
_debug ("Found folder %s", it2->first.c_str());
//
}
return
PAPYRUSKV_ERR
;
}
...
...
@@ -151,7 +151,7 @@ int DFS::ReadFile(int db, void *buff, size_t size, off_t offset, const char* fil
_error
(
"destination buffer not allocated"
,
NULL
);
return
PAPYRUSKV_ERR
;
}
_debug
(
"reading from file %s"
,
filename
);
//
_debug ("reading from file %s", filename);
char
folder
[
PATH_MAX
];
Utils
::
getFolder
(
filename
,
folder
);
...
...
@@ -171,7 +171,7 @@ int DFS::ReadFile(int db, void *buff, size_t size, off_t offset, const char* fil
}
int
DFS
::
WriteFile
(
int
db
,
const
void
*
buff
,
size_t
size
,
off_t
offset
,
const
char
*
filename
)
{
_debug
(
"Writing to file %s"
,
filename
);
//
_debug ("Writing to file %s", filename);
char
dirname
[
PATH_MAX
];
Utils
::
getFolder
(
filename
,
dirname
);
std
::
string
folder
(
dirname
);
...
...
kv/src/Dispatcher.cpp
View file @
e5a2df72
...
...
@@ -68,7 +68,7 @@ int Dispatcher::ExecuteGetOffset (DB* db, const char* key, size_t keylen, char*
int
tag
=
Tag
(
cid
);
_trace
(
"cid[%lu] tag[%d] key[%s] keylen[%lu] valp[%p] vallenp[%p] group[%d] rank[%d]"
,
cid
,
tag
,
key
,
keylen
,
valp
,
vallenp
,
group
,
rank
);
_debug
(
"cid[%lu] tag[%d] key[%s] keylen[%lu] valp[%p] vallenp[%p] offset[%lu] group[%d] rank[%d]"
,
cid
,
tag
,
key
,
keylen
,
valp
,
vallenp
,
offset
,
rank
);
//
_debug("cid[%lu] tag[%d] key[%s] keylen[%lu] valp[%p] vallenp[%p] offset[%lu] group[%d] rank[%d]", cid, tag, key, keylen, valp, vallenp, offset, rank);
Message
msg
(
PAPYRUSKV_MSG_GET_OFF
);
msg
.
WriteULong
(
db
->
dbid
());
...
...
@@ -91,7 +91,7 @@ int Dispatcher::ExecuteGetOffset (DB* db, const char* key, size_t keylen, char*
size_t
pos_handle
=
packet
[
4
];
_trace
(
"ret[%d] mode[%d] vallen[%lu] sid[%lu] pos_handle[0x%x]"
,
ret
,
mode
,
vallen
,
sid
,
pos_handle
);
_debug
(
"ret[%d] mode[%d] vallen[%lu] sid[%lu] pos_handle[0x%x]"
,
ret
,
mode
,
vallen
,
sid
,
pos_handle
);
//
_debug("ret[%d] mode[%d] vallen[%lu] sid[%lu] pos_handle[0x%x]", ret, mode, vallen, sid, pos_handle);
if
(
ret
==
PAPYRUSKV_SLICE_FOUND
)
{
if
(
vallenp
)
vallenp
=
vallen
;
...
...
@@ -102,7 +102,7 @@ int Dispatcher::ExecuteGetOffset (DB* db, const char* key, size_t keylen, char*
}
else
{
MPI_Recv
(
valp
,
(
int
)
vallen
,
MPI_CHAR
,
rank
,
tag
,
mpi_comm_ext_
,
MPI_STATUS_IGNORE
);
_debug
(
"Received %s"
,
valp
);
//
_debug ("Received %s", valp);
}
}
// if (pos && pos_handle) pos->handle = (void*) pos_handle;
...
...
@@ -173,7 +173,7 @@ int Dispatcher::ExecutePutFilename(DB* db, const char* key, size_t keylen, const
unsigned
long
cid
=
Platform
::
NewCID
();
int
tag
=
Tag
(
cid
);
_debug
(
"calling putfilename with size %lu"
,
vallen
);
//
_debug ("calling putfilename with size %lu", vallen);
Message
msg
(
PAPYRUSKV_MSG_PUT_FILE
);
msg
.
WriteULong
(
db
->
dbid
());
msg
.
WriteInt
(
tag
);
...
...
@@ -215,7 +215,7 @@ int Dispatcher::ExecutePut(DB* db, const char* key, size_t keylen, const char* v
int
size
=
keylen
+
vallen
;
MPI_Send
(
big_buffer_
,
size
,
MPI_CHAR
,
rank
,
tag
,
mpi_comm_
);
_debug
(
"Sent %d bytes to %d"
,
size
,
rank
);
//
_debug ("Sent %d bytes to %d", size, rank);
if
(
!
sync
)
return
PAPYRUSKV_OK
;
...
...
kv/src/File.cpp
View file @
e5a2df72
...
...
@@ -15,7 +15,7 @@ namespace papyruskv {
permissions
->
setExecute
(
PAPYRUSKV_USER
,
Utils
::
fileExecutable
(
filename
.
c_str
()));
permissions
->
setWrite
(
PAPYRUSKV_USER
,
Utils
::
fileWritable
(
filename
.
c_str
()));
permissions
->
setRead
(
PAPYRUSKV_USER
,
Utils
::
fileReadable
(
filename
.
c_str
()));
_debug
(
"permissions set for %s"
,
filename
.
c_str
());
//
_debug ("permissions set for %s", filename.c_str());
return
PAPYRUSKV_OK
;
}
...
...
@@ -23,7 +23,7 @@ namespace papyruskv {
void
File
::
GetMode
(
const
char
*
mode
)
{
//TODO: support '+' modes
int
i
=
0
;
_debug
(
"getting open mode for %s"
,
filename
.
c_str
());
//
_debug ("getting open mode for %s", filename.c_str());
while
(
mode
[
i
]
!=
'\0'
)
{
if
(
mode
[
i
]
==
'a'
)
{
append
=
1
;
...
...
@@ -116,7 +116,7 @@ namespace papyruskv {
written
=
0
;
//read all the content of the file in chunks
while
(
written
<
size
)
{
_debug
(
"written %d of %d (start %d)"
,
written
,
size
,
start
);
//
_debug ("written %d of %d (start %d)", written, size, start);
size_t
read_size
;
char
*
buffer
;
//Get the chunk size
...
...
@@ -131,7 +131,7 @@ namespace papyruskv {
//Calculate the end byte to be read
end
=
start
+
read_size
;
_debug
(
"read size %zu"
,
read_size
);
//
_debug ("read size %zu", read_size);
if
(
read_size
<=
0
)
return
PAPYRUSKV_OK
;
...
...
@@ -168,7 +168,7 @@ namespace papyruskv {
strcat
(
key
,
cstart
);
_debug
(
"Calling papyruskv_put with key %s"
,
key
);
//
_debug ("Calling papyruskv_put with key %s", key);
ret
=
papyruskv_put
(
db
,
key
,
PAPYRUSKV_MAX_KEYLEN
+
1
,
buffer
,
read_size
);
if
(
ret
!=
PAPYRUSKV_OK
)
{
_error
(
"storing object, ret value %d"
,
ret
);
...
...
@@ -184,7 +184,7 @@ namespace papyruskv {
fclose
(
f
);
mounted
=
true
;
_info
(
"file %s mounted"
,
filename
.
c_str
());
//
_info ("file %s mounted", filename.c_str());
// _debug ("file %s mounted in %d pools", filename.c_str(), objects.size());
return
PAPYRUSKV_OK
;
}
...
...
@@ -195,7 +195,7 @@ namespace papyruskv {
// if it's permanent, it does nothing with the data
// if it's scratch, deletes the data
int
File
::
Unmount
()
{
_debug
(
"unmounting file %s"
,
filename
.
c_str
());
//
_debug ("unmounting file %s", filename.c_str());
if
(
!
mounted
)
{
_error
(
"file %s not mounted"
,
filename
.
c_str
());
return
PAPYRUSKV_ERR
;
...
...
@@ -215,7 +215,7 @@ namespace papyruskv {
//todo: change wb to whatever applies
*/
//first, write the file back to the pfs
std
::
string
filename2
(
filename
+
"_new"
);
_debug
(
"writing content to file %s"
,
filename2
.
c_str
());
//
_debug ("writing content to file %s", filename2.c_str());
FILE
*
f
=
fopen
(
filename2
.
c_str
(),
"w"
);
int
ret
=
PAPYRUSKV_OK
;
...
...
@@ -232,15 +232,15 @@ namespace papyruskv {
snprintf
(
cstart
,
length
+
1
,
"%d"
,
start
);
strcat
(
key
,
cstart
);
size_t
read_size
=
-
1
;
_debug
(
"getting buffer for key %s"
,
key
);
//
_debug ("getting buffer for key %s", key);
ret
=
papyruskv_get
(
db
,
key
,
PAPYRUSKV_MAX_KEYLEN
+
1
,
&
buffer
,
&
read_size
);
if
(
ret
!=
PAPYRUSKV_OK
)
break
;
if
(
read_size
==
0
)
{
_info
(
"read 0 bytes, done"
,
NULL
);
//
_info ("read 0 bytes, done", NULL);
break
;
}
_debug
(
"writing %d bytes to file"
,
read_size
);
//
_debug ("writing %d bytes to file", read_size);
//_info ("Read data %s", buffer);
start
+=
read_size
;
if
(
isText
)
...
...
@@ -251,11 +251,11 @@ namespace papyruskv {
//Deallocate the buffer
delete
[]
buffer
;
// free(buffer);
_debug
(
"data written"
,
NULL
);
//
_debug ("data written", NULL);
}
_debug
(
"all data in file %s written"
,
filename2
.
c_str
());
//
_debug("all data in file %s written", filename2.c_str());
// delete[] key;
_debug
(
"file %s built"
,
filename2
.
c_str
());
//
_debug ("file %s built", filename2.c_str());
fclose
(
f
);
//Now mark the file for deletion
...
...
@@ -267,7 +267,7 @@ namespace papyruskv {
return
PAPYRUSKV_OK
;
//Here, delete the file
_debug
(
"deleting file %s from DFS"
,
filename
.
c_str
());
//
_debug ("deleting file %s from DFS", filename.c_str());
//TODO
/*
for (auto it = objects.begin(); it!=objects.end(); ++it) {
...
...
@@ -285,7 +285,7 @@ namespace papyruskv {
_error
(
"destination buffer not allocated"
,
NULL
);
return
PAPYRUSKV_ERR
;
}
_debug
(
"looking for object with offset %d"
,
offset
);
//
_debug ("looking for object with offset %d", offset);
size_t
remain_size
=
size
;
while
(
remain_size
>
0
)
{
size_t
read_from_block
=
papyrus_min
(
remain_size
,
POOL_MAX_AVAIL
);
...
...
@@ -300,11 +300,13 @@ namespace papyruskv {
snprintf
(
cstart
,
length
+
1
,
"%d"
,
start
);
strcat
(
key
,
cstart
);
/*
struct timeval tv1, tv2;
gettimeofday(&tv1, NULL);
// auto start = chrono::steady_clock::now();
*/
int
ret
=
papyruskv_get_offset
(
db
,
key
,
PAPYRUSKV_MAX_KEYLEN
+
1
,
(
char
*
)
buf
+
(
size
-
remain_size
),
read_from_block
,
offset
);
// auto end = chrono::steady_clock::now();
/*
gettimeofday(&tv2, NULL);
...
...
@@ -314,8 +316,7 @@ namespace papyruskv {
_error ("\n\n (read) ellapsed time (us): %f", ellapsed);
double bw = ((double)read_from_block/(1024.0*1024.0))/ellapsed;
_error ("bandwidth [%d]: %f GB/s\n\n", read_from_block, bw);
*/
if
(
ret
!=
PAPYRUSKV_OK
)
{
_error
(
"Impossible to put offset %d to key %s"
,
offset
,
key
);
...
...
kv/src/File.h
View file @
e5a2df72
...
...
@@ -59,9 +59,7 @@ private:
public:
File
(
std
::
string
name
,
const
int
_db
)
:
filename
(
name
),
db
(
_db
),
isText
(
true
),
mounted
(
false
),
append
(
0
),
write
(
0
){
std
::
unique_ptr
<
Permissions
>
permissions
(
new
Permissions
());
_debug
(
"Discovering properties for file %s"
,
filename
.
c_str
());
discoverProperties
();
_debug
(
"File %s initialized"
,
filename
.
c_str
());
std
::
unique_ptr
<
Persistance
>
persistance
(
new
Persistance
());
}
...
...
kv/src/Folder.cpp
View file @
e5a2df72
...
...
@@ -165,14 +165,14 @@ int Folder::InsertFile (const std::string filename, std::unique_ptr<File> file,
PLATFORM
->
PutFilename
(
db
,
filename
.
c_str
(),
filename
.
size
());
}
files
.
insert
(
std
::
pair
<
const
std
::
string
,
std
::
unique_ptr
<
File
>
>
(
filename
,
std
::
move
(
file
)));
_debug
(
"File %s successfully added to the system"
,
filename
.
c_str
());
//
_debug ("File %s successfully added to the system", filename.c_str());
return
PAPYRUSKV_OK
;
}
int
Folder
::
CreateFile
(
const
std
::
string
filename
,
const
char
*
mode
,
int
persistance
)
{
if
(
files
.
find
(
filename
)
!=
files
.
end
())
{
_info
(
"File %s was already mounted"
,
filename
.
c_str
());
return
PAPYRUSKV_
ERR
;
//
_info ("File %s was already mounted", filename.c_str());
return
PAPYRUSKV_
OK
;
}
//Create the new object
std
::
unique_ptr
<
File
>
file
(
new
File
(
filename
,
db
));
...
...
@@ -182,16 +182,16 @@ int Folder::CreateFile(const std::string filename, const char* mode, int persist
}
InsertFile
(
filename
,
std
::
move
(
file
),
true
);
// files.insert (std::pair<const std::string, std::unique_ptr<File> > (filename, std::move(file)));
_debug
(
"File %s successfully created"
,
filename
.
c_str
());
//
_debug ("File %s successfully created", filename.c_str());
return
PAPYRUSKV_OK
;
}
int
Folder
::
AddFile
(
const
std
::
string
filename
,
bool
newfile
)
{
_debug
(
"Checking if file %s has been previously mounted"
,
filename
.
c_str
());
//
_debug ("Checking if file %s has been previously mounted", filename.c_str());
if
(
files
.
find
(
filename
)
==
files
.
end
())
{
_debug
(
"File %s was not previously mounted"
,
filename
.
c_str
());
//
_debug ("File %s was not previously mounted", filename.c_str());
std
::
unique_ptr
<
File
>
file
(
new
File
(
filename
,
db
));
_debug
(
"Mounting file %s"
,
filename
.
c_str
());
//
_debug ("Mounting file %s", filename.c_str());
InsertFile
(
filename
,
std
::
move
(
file
),
newfile
);
// files.insert (std::pair<const std::string, std::unique_ptr<File> > (filename, std::move(file)));
// _debug ("File %s has been added to the list of files", filename.c_str());
...
...
@@ -202,11 +202,11 @@ int Folder::AddFile (const std::string filename, bool newfile) {
int
Folder
::
MountFile
(
const
std
::
string
filename
,
const
char
*
mode
,
int
persistance
)
{
//if the file has not been previously mounted
_debug
(
"Checking if file %s has been previously mounted"
,
filename
.
c_str
());
//
_debug ("Checking if file %s has been previously mounted", filename.c_str());
if
(
files
.
find
(
filename
)
==
files
.
end
())
{
_debug
(
"File %s was not previously mounted"
,
filename
.
c_str
());
//
_debug ("File %s was not previously mounted", filename.c_str());
std
::
unique_ptr
<
File
>
file
(
new
File
(
filename
,
db
));
_debug
(
"Mounting file %s"
,
filename
.
c_str
());
//
_debug ("Mounting file %s", filename.c_str());
if
(
file
->
Mount
(
mode
)
!=
PAPYRUSKV_OK
)
{
_error
(
"Error mounting file %s"
,
filename
.
c_str
());
return
PAPYRUSKV_ERR
;
...
...
@@ -221,7 +221,7 @@ int Folder::MountFile(const std::string filename, const char *mode, int persista
}
int
Folder
::
UnmountFile
(
const
std
::
string
filename
)
{
_debug
(
"Unmounting file %s"
,
filename
.
c_str
());
//
_debug ("Unmounting file %s", filename.c_str());
auto
it
=
files
.
find
(
filename
);
if
(
it
==
files
.
end
())
{
_error
(
"file %s not found in current folder"
,
filename
.
c_str
());
...
...
@@ -231,7 +231,7 @@ int Folder::UnmountFile(const std::string filename) {
}
int
Folder
::
WriteFile
(
const
void
*
buff
,
size_t
size
,
off_t
offset
,
const
std
::
string
filename
)
{
_debug
(
"Looking for file %s"
,
filename
.
c_str
());
//
_debug ("Looking for file %s", filename.c_str());
auto
it
=
files
.
find
(
filename
);
if
(
it
==
files
.
end
())
{
_error
(
"File %s wasn't mounted"
,
filename
.
c_str
());
...
...
@@ -242,7 +242,7 @@ int Folder::WriteFile(const void *buff, size_t size, off_t offset, const std::st
_error
(
"error writing to file %s"
,
filename
.
c_str
());
return
ret
;
}
_debug
(
"File %s successfully written to DFS"
,
filename
.
c_str
());
//
_debug ("File %s successfully written to DFS", filename.c_str());
return
PAPYRUSKV_OK
;
}
...
...
@@ -251,7 +251,7 @@ int Folder::ReadFile(void *buff, size_t size, off_t offset, const std::string fi
_error
(
"destination buffer not allocated"
,
NULL
);
return
PAPYRUSKV_ERR
;
}
_debug
(
"Looking for file %s"
,
filename
.
c_str
());
//
_debug ("Looking for file %s", filename.c_str());
auto
it
=
files
.
find
(
filename
);
if
(
it
==
files
.
end
())
{
_error
(
"File %s wasn't mounted"
,
filename
.
c_str
());
...
...
kv/src/Listener.cpp
View file @
e5a2df72
...
...
@@ -73,7 +73,7 @@ void Listener::ExecutePutFilename(Message& msg, int rank) {
Slice
*
slice
=
new
Slice
(
keylen
,
vallen
,
rank_
,
tombstone
);
MPI_Recv
(
slice
->
buf
(),
(
int
)
(
keylen
+
vallen
),
MPI_CHAR
,
rank
,
tag
,
mpi_comm_
,
MPI_STATUS_IGNORE
);
_trace
(
"rank[%d] dbid[%lu] tag[%d] key[%s] keylen[%lu] val[%s] vallen[%lu] tombstone[%d] sync[%d]"
,
rank
,
dbid
,
tag
,
slice
->
key
(),
slice
->
keylen
(),
slice
->
val
(),
slice
->
vallen
(),
slice
->
tombstone
(),
sync
);
_todo
(
"putting filename from rank[%d] dbid[%lu] tag[%d] sync[%d] key[%s]"
,
rank
,
dbid
,
tag
,
sync
,
slice
->
key
());
//
_todo("putting filename from rank[%d] dbid[%lu] tag[%d] sync[%d] key[%s]", rank, dbid, tag, sync, slice->key());
int
ret
=
papyruskv_mount_remote_file
(
dbid
,
slice
->
key
());
...
...
@@ -81,7 +81,7 @@ void Listener::ExecutePutFilename(Message& msg, int rank) {
_error
(
"impossible to mount remote file %s"
,
slice
->
key
());