17 #define MAX_ELEMENT_SIZE 8192 34 case KMR_KV_POINTER_OWNED:
35 return "POINTER_OWNED";
36 case KMR_KV_POINTER_UNMANAGED:
37 return "KMR_KV_POINTER_UNMANAGED";
46 char *buf,
int buflen)
48 if ( (data == KMR_KV_OPAQUE || data == KMR_KV_CSTRING)
49 && (strncmp(
"maxprocs", e.p, 8) == 0) ) {
50 int clen = (len < buflen) ? len : buflen;
51 memcpy(buf, e.p, (
size_t)clen);
53 for (
int i = 0; i < len - 1; i++) {
59 kmr_dump_slot(e, len, data, buf, buflen);
64 main(
int argc,
char *argv[])
67 printf(
"%s ckpt-filename\n", argv[0]);
72 FILE *fp = fopen(argv[1],
"r");
79 int ret = stat(argv[1], &sb);
85 if (strstr(argv[1],
"_data_") != NULL) {
88 size_t rc = fread((
void *)&data_hdr, hdrsz, 1, fp);
89 if (rc != 1 && feof(fp) == 1) {
90 fprintf(stderr,
"fread failed\n");
94 printf(
"================Header================\n");
95 printf(
"kvs_id = %ld\n", data_hdr.kvs_id);
96 printf(
"nprocs = %d\n", data_hdr.nprocs);
97 printf(
"rank = %d\n", data_hdr.rank);
98 printf(
"key_data = %s\n", kv_field_str(data_hdr.key_data));
99 printf(
"value_data = %s\n", kv_field_str(data_hdr.value_data));
100 printf(
"======================================\n");
103 unsigned int total = (
unsigned int)hdrsz;
104 while(total < sb.st_size){
105 char buf[MAX_ELEMENT_SIZE];
108 rc = fread(buf, evhdrsz, 1, fp);
109 if (rc != 1 && feof(fp) == 1) {
110 fprintf(stderr,
"fread failed\n");
116 if (datasz + evhdrsz >
sizeof(buf)) {
117 printf(
"Key-value data too long for dump.\n");
120 rc = fread(buf+evhdrsz, datasz, 1, fp);
121 if (rc != 1 && feof(fp) == 1) {
122 fprintf(stderr,
"fread failed\n");
126 ev = kmr_pick_kv2(e, data_hdr.key_data, data_hdr.value_data);
127 int kvlen = MAX_ELEMENT_SIZE / 2;
128 char keystr[kvlen], valstr[kvlen];
129 kmr_dump_slot(ev.k, e->klen, data_hdr.key_data, keystr,
130 (
int)
sizeof(keystr));
131 dump_value(ev.v, e->vlen, data_hdr.value_data, valstr,
132 (
int)
sizeof(valstr));
133 printf(
"[%d] key[%d] = %s | value[%d] = %s\n", cnt, ev.klen,
134 keystr, ev.vlen, valstr);
136 total += (
unsigned int)(evhdrsz + datasz);
138 }
else if (strstr(argv[1],
"_log_") != NULL) {
141 size_t rc = fread((
void *)&log_hdr, hdrsz, 1, fp);
142 if (rc != 1 && feof(fp) == 1) {
143 fprintf(stderr,
"fread failed\n");
147 printf(
"================Header================\n");
148 switch (log_hdr.mode) {
150 printf(
"mode = SAVE_ALL\n");
152 case KMR_CKPT_SELECTIVE:
153 printf(
"mode = SAVE_SELECTIVE\n");
156 printf(
"nprocs = %d\n", log_hdr.nprocs);
157 printf(
"rank = %d\n", log_hdr.rank);
158 printf(
"======================================\n");
161 unsigned int total = (
unsigned int)hdrsz;
162 while(total < sb.st_size){
165 rc = fread((
void *)&e,
sizeof(e), 1, fp);
166 if (rc != 1 && feof(fp) == 1) {
167 fprintf(stderr,
"fread failed\n");
171 case KMR_CKPT_LOG_WHOLE_START:
172 printf(
"[%05d] state = SAVE_WHOLE_START\n" 176 cnt, e.op_seqno, e.kvi_id, e.kvo_id);
178 case KMR_CKPT_LOG_WHOLE_FINISH:
179 printf(
"[%05d] state = SAVE_WHOLE_FINISH\n" 183 cnt, e.op_seqno, e.kvi_id, e.kvo_id);
185 case KMR_CKPT_LOG_BLOCK_START:
186 printf(
"[%05d] state = SAVE_BLOCK_START\n" 192 cnt, e.op_seqno, e.kvi_id, e.kvo_id, e.n_kvi, e.n_kvo);
194 case KMR_CKPT_LOG_BLOCK_ADD:
195 printf(
"[%05d] state = SAVE_BLOCK_ADD\n" 201 cnt, e.op_seqno, e.kvi_id, e.kvo_id, e.n_kvi, e.n_kvo);
203 case KMR_CKPT_LOG_BLOCK_FINISH:
204 printf(
"[%05d] state = SAVE_BLOCK_FINISH\n", cnt);
206 case KMR_CKPT_LOG_INDEX_START:
207 printf(
"[%05d] state = SAVE_INDEX_START\n" 213 cnt, e.op_seqno, e.kvi_id, e.kvo_id, e.n_kvi, e.n_kvo);
215 case KMR_CKPT_LOG_INDEX_ADD:
216 printf(
"[%05d] state = SAVE_INDEX_ADD\n" 222 cnt, e.op_seqno, e.kvi_id, e.kvo_id, e.n_kvi, e.n_kvo);
224 case KMR_CKPT_LOG_INDEX_FINISH:
225 printf(
"[%05d] state = SAVE_INDEX_FINISH\n", cnt);
227 case KMR_CKPT_LOG_DELETE_START:
228 printf(
"[%05d] state = DATA_DELETE_START\n" 229 " kvs_id = %ld\n", cnt, e.kvi_id);
231 case KMR_CKPT_LOG_DELETE_FINISH:
232 printf(
"[%05d] state = DATA_DELETE_FINISH\n" 233 " kvs_id = %ld\n", cnt, e.kvi_id);
235 case KMR_CKPT_LOG_DELETABLE:
236 printf(
"[%05d] state = DATA_DELETABLE\n" 237 " kvs_id = %ld\n", cnt, e.kvi_id);
239 case KMR_CKPT_LOG_PROGRESS:
240 printf(
"[%05d] state = PROGRESS\n" 244 cnt, e.op_seqno, e.kvi_id, e.kvo_id);
246 case KMR_CKPT_LOG_SKIPPED:
247 printf(
"[%05d] state = SKIPPED\n" 251 cnt, e.op_seqno, e.kvi_id, e.kvo_id);
253 case KMR_CKPT_LOG_LOCK_START:
254 printf(
"[%05d] state = LOCK_START\n", cnt);
256 case KMR_CKPT_LOG_LOCK_FINISH:
257 printf(
"[%05d] state = LOCK_FINISH\n", cnt);
261 total += (
unsigned int)
sizeof(e);
264 fprintf(stderr,
"File is not a checkpoint file\n");
Utilities Private Part (do not include from applications).
#define KMR_ALIGN(X)
Rounds up a given size to the alignment restriction (currently eight bytes).
kmr_kv_field
Datatypes of Keys or Values.
Handy Copy of a Key-Value Field.
Checkpoint/Restart Support.