1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014,2015 FUJITSU LIMITED
8 * Author: Shotaro Kawaguchi <kawaguchi.s@jp.fujitsu.com>
9 * Author: Takanori Nakao <nakao.takanori@jp.fujitsu.com>
10 * Author: Takeshi Miyamae <miyamae.takeshi@jp.fujitsu.com>
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
19 //SUMMARY: TestErasureCodeShec
25 #include "crush/CrushWrapper.h"
26 #include "osd/osd_types.h"
27 #include "include/stringify.h"
28 #include "erasure-code/shec/ErasureCodeShec.h"
29 #include "erasure-code/ErasureCodePlugin.h"
30 #include "global/global_context.h"
31 #include "gtest/gtest.h"
35 void* thread1(void* pParam
);
36 void* thread2(void* pParam
);
37 void* thread3(void* pParam
);
38 void* thread4(void* pParam
);
39 void* thread5(void* pParam
);
41 static int g_flag
= 0;
43 TEST(ErasureCodeShec
, init_1
)
45 //all parameters are normal values
46 ErasureCodeShecTableCache tcache
;
47 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
49 ErasureCodeShec::MULTIPLE
);
50 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
51 (*profile
)["plugin"] = "shec";
52 (*profile
)["technique"] = "";
53 (*profile
)["crush-failure-domain"] = "osd";
54 (*profile
)["k"] = "4";
55 (*profile
)["m"] = "3";
56 (*profile
)["c"] = "2";
58 int r
= shec
->init(*profile
, &cerr
);
61 EXPECT_EQ(4, shec
->k
);
62 EXPECT_EQ(3, shec
->m
);
63 EXPECT_EQ(2, shec
->c
);
64 EXPECT_EQ(8, shec
->w
);
65 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
66 EXPECT_STREQ("default", shec
->rule_root
.c_str());
67 EXPECT_STREQ("osd", shec
->rule_failure_domain
.c_str());
68 EXPECT_TRUE(shec
->matrix
!= NULL
);
75 TEST(ErasureCodeShec
, init_2
)
77 //all parameters are normal values
78 ErasureCodeShecTableCache tcache
;
79 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
81 ErasureCodeShec::MULTIPLE
);
82 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
83 (*profile
)["plugin"] = "shec";
84 (*profile
)["technique"] = "";
85 (*profile
)["crush-root"] = "test";
86 (*profile
)["crush-failure-domain"] = "host";
87 (*profile
)["k"] = "4";
88 (*profile
)["m"] = "3";
89 (*profile
)["c"] = "2";
90 (*profile
)["w"] = "8";
92 int r
= shec
->init(*profile
, &cerr
);
95 EXPECT_EQ(4, shec
->k
);
96 EXPECT_EQ(3, shec
->m
);
97 EXPECT_EQ(2, shec
->c
);
98 EXPECT_EQ(8, shec
->w
);
99 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
100 EXPECT_STREQ("test", shec
->rule_root
.c_str());
101 EXPECT_STREQ("host", shec
->rule_failure_domain
.c_str());
102 EXPECT_TRUE(shec
->matrix
!= NULL
);
109 TEST(ErasureCodeShec
, init_3
)
111 //all parameters are normal values
112 ErasureCodeShecTableCache tcache
;
113 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
115 ErasureCodeShec::MULTIPLE
);
116 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
117 (*profile
)["plugin"] = "shec";
118 (*profile
)["technique"] = "";
119 (*profile
)["crush-failure-domain"] = "osd";
120 (*profile
)["k"] = "4";
121 (*profile
)["m"] = "3";
122 (*profile
)["c"] = "2";
123 (*profile
)["w"] = "16";
125 int r
= shec
->init(*profile
, &cerr
);
128 EXPECT_EQ(4, shec
->k
);
129 EXPECT_EQ(3, shec
->m
);
130 EXPECT_EQ(2, shec
->c
);
131 EXPECT_EQ(16, shec
->w
);
132 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
133 EXPECT_STREQ("default", shec
->rule_root
.c_str());
134 EXPECT_STREQ("osd", shec
->rule_failure_domain
.c_str());
135 EXPECT_TRUE(shec
->matrix
!= NULL
);
142 TEST(ErasureCodeShec
, init_4
)
144 //all parameters are normal values
145 ErasureCodeShecTableCache tcache
;
146 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
148 ErasureCodeShec::MULTIPLE
);
149 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
150 (*profile
)["plugin"] = "shec";
151 (*profile
)["technique"] = "";
152 (*profile
)["crush-failure-domain"] = "osd";
153 (*profile
)["k"] = "4";
154 (*profile
)["m"] = "3";
155 (*profile
)["c"] = "2";
156 (*profile
)["w"] = "32";
158 int r
= shec
->init(*profile
, &cerr
);
161 EXPECT_EQ(4, shec
->k
);
162 EXPECT_EQ(3, shec
->m
);
163 EXPECT_EQ(2, shec
->c
);
164 EXPECT_EQ(32, shec
->w
);
165 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
166 EXPECT_STREQ("default", shec
->rule_root
.c_str());
167 EXPECT_STREQ("osd", shec
->rule_failure_domain
.c_str());
168 EXPECT_TRUE(shec
->matrix
!= NULL
);
175 TEST(ErasureCodeShec
, init_5
)
177 ErasureCodeShecTableCache tcache
;
178 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
180 ErasureCodeShec::MULTIPLE
);
181 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
182 //plugin is not specified
183 (*profile
)["technique"] = "";
184 (*profile
)["crush-failure-domain"] = "osd";
185 (*profile
)["k"] = "4";
186 (*profile
)["m"] = "3";
187 (*profile
)["c"] = "2";
189 int r
= shec
->init(*profile
, &cerr
);
191 EXPECT_TRUE(shec
->matrix
!= NULL
);
198 TEST(ErasureCodeShec
, init_6
)
200 ErasureCodeShecTableCache tcache
;
201 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
203 ErasureCodeShec::MULTIPLE
);
204 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
205 (*profile
)["plugin"] = "jerasure"; //unexpected value
206 (*profile
)["technique"] = "";
207 (*profile
)["crush-failure-domain"] = "osd";
208 (*profile
)["k"] = "4";
209 (*profile
)["m"] = "3";
210 (*profile
)["c"] = "2";
212 int r
= shec
->init(*profile
, &cerr
);
214 EXPECT_TRUE(shec
->matrix
!= NULL
);
221 TEST(ErasureCodeShec
, init_7
)
223 ErasureCodeShecTableCache tcache
;
224 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
226 ErasureCodeShec::MULTIPLE
);
227 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
228 (*profile
)["plugin"] = "abc"; //unexpected value
229 (*profile
)["technique"] = "";
230 (*profile
)["crush-failure-domain"] = "osd";
231 (*profile
)["k"] = "4";
232 (*profile
)["m"] = "3";
233 (*profile
)["c"] = "2";
235 int r
= shec
->init(*profile
, &cerr
);
237 EXPECT_TRUE(shec
->matrix
!= NULL
);
244 TEST(ErasureCodeShec
, init_8
)
246 ErasureCodeShecTableCache tcache
;
247 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
249 ErasureCodeShec::MULTIPLE
);
250 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
251 (*profile
)["plugin"] = "shec";
252 (*profile
)["technique"] = "";
253 (*profile
)["crush-failure-domain"] = "osd";
254 (*profile
)["k"] = "4";
255 (*profile
)["m"] = "3";
256 (*profile
)["c"] = "2";
258 int r
= shec
->init(*profile
, &cerr
);
260 EXPECT_TRUE(shec
->matrix
!= NULL
);
267 TEST(ErasureCodeShec
, init_9
)
269 ErasureCodeShecTableCache tcache
;
270 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
272 ErasureCodeShec::MULTIPLE
);
273 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
274 (*profile
)["plugin"] = "shec";
275 (*profile
)["technique"] = "";
276 (*profile
)["crush-root"] = "abc"; //unexpected value
277 (*profile
)["crush-failure-domain"] = "osd";
278 (*profile
)["k"] = "4";
279 (*profile
)["m"] = "3";
280 (*profile
)["c"] = "2";
282 int r
= shec
->init(*profile
, &cerr
);
284 EXPECT_TRUE(shec
->matrix
!= NULL
);
291 TEST(ErasureCodeShec
, init_10
)
293 ErasureCodeShecTableCache tcache
;
294 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
296 ErasureCodeShec::MULTIPLE
);
297 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
298 (*profile
)["plugin"] = "shec";
299 (*profile
)["technique"] = "";
300 (*profile
)["crush-failure-domain"] = "abc"; //unexpected value
301 (*profile
)["k"] = "4";
302 (*profile
)["m"] = "3";
303 (*profile
)["c"] = "2";
305 int r
= shec
->init(*profile
, &cerr
);
307 EXPECT_TRUE(shec
->matrix
!= NULL
);
314 TEST(ErasureCodeShec
, init_11
)
316 ErasureCodeShecTableCache tcache
;
317 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
319 ErasureCodeShec::MULTIPLE
);
320 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
321 (*profile
)["plugin"] = "shec";
322 (*profile
)["technique"] = "abc"; //unexpected value
323 (*profile
)["crush-failure-domain"] = "osd";
324 (*profile
)["k"] = "4";
325 (*profile
)["m"] = "3";
326 (*profile
)["c"] = "2";
328 int r
= shec
->init(*profile
, &cerr
);
330 EXPECT_TRUE(shec
->matrix
!= NULL
);
337 TEST(ErasureCodeShec
, init_12
)
339 ErasureCodeShecTableCache tcache
;
340 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
342 ErasureCodeShec::MULTIPLE
);
343 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
344 (*profile
)["plugin"] = "shec";
345 (*profile
)["technique"] = "";
346 (*profile
)["crush-failure-domain"] = "osd";
347 (*profile
)["k"] = "-1"; //unexpected value
348 (*profile
)["m"] = "3";
349 (*profile
)["c"] = "2";
351 int r
= shec
->init(*profile
, &cerr
);
353 EXPECT_EQ(-EINVAL
, r
);
359 TEST(ErasureCodeShec
, init_13
)
361 ErasureCodeShecTableCache tcache
;
362 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
364 ErasureCodeShec::MULTIPLE
);
365 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
366 (*profile
)["plugin"] = "shec";
367 (*profile
)["technique"] = "";
368 (*profile
)["crush-failure-domain"] = "abc";
369 (*profile
)["k"] = "0.1"; //unexpected value
370 (*profile
)["m"] = "3";
371 (*profile
)["c"] = "2";
373 int r
= shec
->init(*profile
, &cerr
);
375 EXPECT_EQ(-EINVAL
, r
);
381 TEST(ErasureCodeShec
, init_14
)
383 ErasureCodeShecTableCache tcache
;
384 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
386 ErasureCodeShec::MULTIPLE
);
387 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
388 (*profile
)["plugin"] = "shec";
389 (*profile
)["technique"] = "";
390 (*profile
)["crush-failure-domain"] = "osd";
391 (*profile
)["k"] = "a"; //unexpected value
392 (*profile
)["m"] = "3";
393 (*profile
)["c"] = "2";
395 int r
= shec
->init(*profile
, &cerr
);
397 EXPECT_EQ(-EINVAL
, r
);
403 TEST(ErasureCodeShec
, init_15
)
405 ErasureCodeShecTableCache tcache
;
406 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
408 ErasureCodeShec::MULTIPLE
);
409 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
410 (*profile
)["plugin"] = "shec";
411 (*profile
)["technique"] = "";
412 (*profile
)["crush-failure-domain"] = "osd";
414 (*profile
)["m"] = "3";
415 (*profile
)["c"] = "2";
417 int r
= shec
->init(*profile
, &cerr
);
419 EXPECT_EQ(-EINVAL
, r
);
425 TEST(ErasureCodeShec
, init_16
)
427 ErasureCodeShecTableCache tcache
;
428 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
430 ErasureCodeShec::MULTIPLE
);
431 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
432 (*profile
)["plugin"] = "shec";
433 (*profile
)["technique"] = "";
434 (*profile
)["crush-failure-domain"] = "osd";
435 (*profile
)["k"] = "4";
436 (*profile
)["m"] = "-1"; //unexpected value
437 (*profile
)["c"] = "2";
439 int r
= shec
->init(*profile
, &cerr
);
441 EXPECT_EQ(-EINVAL
, r
);
447 TEST(ErasureCodeShec
, init_17
)
449 ErasureCodeShecTableCache tcache
;
450 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
452 ErasureCodeShec::MULTIPLE
);
453 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
454 (*profile
)["plugin"] = "shec";
455 (*profile
)["technique"] = "";
456 (*profile
)["crush-failure-domain"] = "osd";
457 (*profile
)["k"] = "4";
458 (*profile
)["m"] = "0.1"; //unexpected value
459 (*profile
)["c"] = "2";
461 int r
= shec
->init(*profile
, &cerr
);
463 EXPECT_EQ(-EINVAL
, r
);
469 TEST(ErasureCodeShec
, init_18
)
471 ErasureCodeShecTableCache tcache
;
472 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
474 ErasureCodeShec::MULTIPLE
);
475 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
476 (*profile
)["plugin"] = "shec";
477 (*profile
)["technique"] = "";
478 (*profile
)["crush-failure-domain"] = "osd";
479 (*profile
)["k"] = "4";
480 (*profile
)["m"] = "a"; //unexpected value
481 (*profile
)["c"] = "2";
483 int r
= shec
->init(*profile
, &cerr
);
485 EXPECT_EQ(-EINVAL
, r
);
491 TEST(ErasureCodeShec
, init_19
)
493 ErasureCodeShecTableCache tcache
;
494 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
496 ErasureCodeShec::MULTIPLE
);
497 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
498 (*profile
)["plugin"] = "shec";
499 (*profile
)["technique"] = "";
500 (*profile
)["crush-failure-domain"] = "osd";
501 (*profile
)["k"] = "4";
503 (*profile
)["c"] = "2";
505 int r
= shec
->init(*profile
, &cerr
);
507 EXPECT_EQ(-EINVAL
, r
);
513 TEST(ErasureCodeShec
, init_20
)
515 ErasureCodeShecTableCache tcache
;
516 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
518 ErasureCodeShec::MULTIPLE
);
519 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
520 (*profile
)["plugin"] = "shec";
521 (*profile
)["technique"] = "";
522 (*profile
)["crush-failure-domain"] = "osd";
523 (*profile
)["k"] = "4";
524 (*profile
)["m"] = "3";
525 (*profile
)["c"] = "-1"; //unexpected value
527 int r
= shec
->init(*profile
, &cerr
);
529 EXPECT_EQ(-EINVAL
, r
);
535 TEST(ErasureCodeShec
, init_21
)
537 ErasureCodeShecTableCache tcache
;
538 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
540 ErasureCodeShec::MULTIPLE
);
541 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
542 (*profile
)["plugin"] = "shec";
543 (*profile
)["technique"] = "";
544 (*profile
)["crush-failure-domain"] = "osd";
545 (*profile
)["k"] = "4";
546 (*profile
)["m"] = "3";
547 (*profile
)["c"] = "0.1"; //unexpected value
549 int r
= shec
->init(*profile
, &cerr
);
551 EXPECT_EQ(-EINVAL
, r
);
557 TEST(ErasureCodeShec
, init_22
)
559 ErasureCodeShecTableCache tcache
;
560 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
562 ErasureCodeShec::MULTIPLE
);
563 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
564 (*profile
)["plugin"] = "shec";
565 (*profile
)["technique"] = "";
566 (*profile
)["crush-failure-domain"] = "osd";
567 (*profile
)["k"] = "4";
568 (*profile
)["m"] = "3";
569 (*profile
)["c"] = "a"; //unexpected value
571 int r
= shec
->init(*profile
, &cerr
);
573 EXPECT_EQ(-EINVAL
, r
);
579 TEST(ErasureCodeShec
, init_23
)
581 ErasureCodeShecTableCache tcache
;
582 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
584 ErasureCodeShec::MULTIPLE
);
585 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
586 (*profile
)["plugin"] = "shec";
587 (*profile
)["technique"] = "";
588 (*profile
)["crush-failure-domain"] = "osd";
589 (*profile
)["k"] = "4";
590 (*profile
)["m"] = "3";
593 int r
= shec
->init(*profile
, &cerr
);
595 EXPECT_EQ(-EINVAL
, r
);
601 TEST(ErasureCodeShec
, init_24
)
603 ErasureCodeShecTableCache tcache
;
604 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
606 ErasureCodeShec::MULTIPLE
);
607 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
608 (*profile
)["plugin"] = "shec";
609 (*profile
)["technique"] = "";
610 (*profile
)["crush-failure-domain"] = "osd";
611 (*profile
)["k"] = "4";
612 (*profile
)["m"] = "3";
613 (*profile
)["c"] = "2";
614 (*profile
)["w"] = "1"; //unexpected value
616 int r
= shec
->init(*profile
, &cerr
);
618 EXPECT_TRUE(shec
->matrix
!= NULL
);
620 EXPECT_EQ(4, shec
->k
);
621 EXPECT_EQ(3, shec
->m
);
622 EXPECT_EQ(2, shec
->c
);
623 EXPECT_EQ(8, shec
->w
);
630 TEST(ErasureCodeShec
, init_25
)
632 ErasureCodeShecTableCache tcache
;
633 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
635 ErasureCodeShec::MULTIPLE
);
636 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
637 (*profile
)["plugin"] = "shec";
638 (*profile
)["technique"] = "";
639 (*profile
)["crush-failure-domain"] = "osd";
640 (*profile
)["k"] = "4";
641 (*profile
)["m"] = "3";
642 (*profile
)["c"] = "2";
643 (*profile
)["w"] = "-1"; //unexpected value
645 int r
= shec
->init(*profile
, &cerr
);
647 EXPECT_TRUE(shec
->matrix
!= NULL
);
649 EXPECT_EQ(4, shec
->k
);
650 EXPECT_EQ(3, shec
->m
);
651 EXPECT_EQ(2, shec
->c
);
652 EXPECT_EQ(8, shec
->w
);
659 TEST(ErasureCodeShec
, init_26
)
661 ErasureCodeShecTableCache tcache
;
662 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
664 ErasureCodeShec::MULTIPLE
);
665 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
666 (*profile
)["plugin"] = "shec";
667 (*profile
)["technique"] = "";
668 (*profile
)["crush-failure-domain"] = "osd";
669 (*profile
)["k"] = "4";
670 (*profile
)["m"] = "3";
671 (*profile
)["c"] = "2";
672 (*profile
)["w"] = "0.1"; //unexpected value
674 int r
= shec
->init(*profile
, &cerr
);
676 EXPECT_TRUE(shec
->matrix
!= NULL
);
678 EXPECT_EQ(4, shec
->k
);
679 EXPECT_EQ(3, shec
->m
);
680 EXPECT_EQ(2, shec
->c
);
681 EXPECT_EQ(8, shec
->w
);
688 TEST(ErasureCodeShec
, init_27
)
690 ErasureCodeShecTableCache tcache
;
691 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
693 ErasureCodeShec::MULTIPLE
);
694 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
695 (*profile
)["plugin"] = "shec";
696 (*profile
)["technique"] = "";
697 (*profile
)["crush-failure-domain"] = "osd";
698 (*profile
)["k"] = "4";
699 (*profile
)["m"] = "3";
700 (*profile
)["c"] = "2";
701 (*profile
)["w"] = "a"; //unexpected value
703 int r
= shec
->init(*profile
, &cerr
);
705 EXPECT_TRUE(shec
->matrix
!= NULL
);
707 EXPECT_EQ(4, shec
->k
);
708 EXPECT_EQ(3, shec
->m
);
709 EXPECT_EQ(2, shec
->c
);
710 EXPECT_EQ(8, shec
->w
);
717 TEST(ErasureCodeShec
, init_28
)
719 ErasureCodeShecTableCache tcache
;
720 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
722 ErasureCodeShec::MULTIPLE
);
723 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
724 (*profile
)["plugin"] = "shec";
725 (*profile
)["technique"] = "";
726 (*profile
)["crush-failure-domain"] = "osd";
727 (*profile
)["k"] = "4";
728 (*profile
)["m"] = "3";
729 (*profile
)["c"] = "10"; //c > m
731 int r
= shec
->init(*profile
, &cerr
);
733 EXPECT_EQ(-EINVAL
, r
);
739 TEST(ErasureCodeShec
, init_29
)
741 ErasureCodeShecTableCache tcache
;
742 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
744 ErasureCodeShec::MULTIPLE
);
745 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
746 (*profile
)["plugin"] = "shec";
747 (*profile
)["technique"] = "";
748 (*profile
)["crush-failure-domain"] = "osd";
753 int r
= shec
->init(*profile
, &cerr
);
755 EXPECT_TRUE(shec
->matrix
!= NULL
);
757 //k,m,c are default values
758 EXPECT_EQ(4, shec
->k
);
759 EXPECT_EQ(3, shec
->m
);
760 EXPECT_EQ(2, shec
->c
);
766 TEST(ErasureCodeShec
, init_30
)
768 ErasureCodeShecTableCache tcache
;
769 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
771 ErasureCodeShec::MULTIPLE
);
772 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
773 (*profile
)["plugin"] = "shec";
774 (*profile
)["technique"] = "";
775 (*profile
)["crush-failure-domain"] = "osd";
776 (*profile
)["k"] = "12";
777 (*profile
)["m"] = "8";
778 (*profile
)["c"] = "8";
780 int r
= shec
->init(*profile
, &cerr
);
782 EXPECT_TRUE(shec
->matrix
!= NULL
);
784 EXPECT_EQ(12, shec
->k
);
785 EXPECT_EQ(8, shec
->m
);
786 EXPECT_EQ(8, shec
->c
);
792 TEST(ErasureCodeShec
, init_31
)
794 ErasureCodeShecTableCache tcache
;
795 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
797 ErasureCodeShec::MULTIPLE
);
798 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
799 (*profile
)["plugin"] = "shec";
800 (*profile
)["technique"] = "";
801 (*profile
)["crush-failure-domain"] = "osd";
802 (*profile
)["k"] = "13";
803 (*profile
)["m"] = "7";
804 (*profile
)["c"] = "7";
806 int r
= shec
->init(*profile
, &cerr
);
808 EXPECT_EQ(-EINVAL
, r
);
814 TEST(ErasureCodeShec
, init_32
)
816 ErasureCodeShecTableCache tcache
;
817 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
819 ErasureCodeShec::MULTIPLE
);
820 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
821 (*profile
)["plugin"] = "shec";
822 (*profile
)["technique"] = "";
823 (*profile
)["crush-failure-domain"] = "osd";
824 (*profile
)["k"] = "7";
825 (*profile
)["m"] = "13";
826 (*profile
)["c"] = "13";
828 int r
= shec
->init(*profile
, &cerr
);
830 EXPECT_EQ(-EINVAL
, r
);
836 TEST(ErasureCodeShec
, init_33
)
838 ErasureCodeShecTableCache tcache
;
839 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
841 ErasureCodeShec::MULTIPLE
);
842 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
843 (*profile
)["plugin"] = "shec";
844 (*profile
)["technique"] = "";
845 (*profile
)["crush-failure-domain"] = "osd";
846 (*profile
)["k"] = "12";
847 (*profile
)["m"] = "9";
848 (*profile
)["c"] = "8";
850 int r
= shec
->init(*profile
, &cerr
);
852 EXPECT_EQ(-EINVAL
, r
);
858 TEST(ErasureCodeShec
, init_34
)
860 ErasureCodeShecTableCache tcache
;
861 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
863 ErasureCodeShec::MULTIPLE
);
864 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
865 (*profile
)["plugin"] = "shec";
866 (*profile
)["technique"] = "";
867 (*profile
)["crush-failure-domain"] = "osd";
868 (*profile
)["k"] = "8";
869 (*profile
)["m"] = "12";
870 (*profile
)["c"] = "12";
872 int r
= shec
->init(*profile
, &cerr
);
874 EXPECT_EQ(-EINVAL
, r
);
880 TEST(ErasureCodeShec
, init2_4
)
882 //all parameters are normal values
883 ErasureCodeShecTableCache tcache
;
884 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
886 ErasureCodeShec::MULTIPLE
);
887 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
888 (*profile
)["plugin"] = "shec";
889 (*profile
)["technique"] = "";
890 (*profile
)["crush-failure-domain"] = "osd";
891 (*profile
)["k"] = "4";
892 (*profile
)["m"] = "3";
893 (*profile
)["c"] = "2";
894 shec
->init(*profile
, &cerr
);
895 int r
= shec
->init(*profile
, &cerr
); //init executed twice
898 EXPECT_EQ(4, shec
->k
);
899 EXPECT_EQ(3, shec
->m
);
900 EXPECT_EQ(2, shec
->c
);
901 EXPECT_EQ(8, shec
->w
);
902 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
903 EXPECT_STREQ("default", shec
->rule_root
.c_str());
904 EXPECT_STREQ("osd", shec
->rule_failure_domain
.c_str());
905 EXPECT_TRUE(shec
->matrix
!= NULL
);
912 TEST(ErasureCodeShec
, init2_5
)
914 //all parameters are normal values
915 ErasureCodeShecTableCache tcache
;
916 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
918 ErasureCodeShec::MULTIPLE
);
919 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
920 ErasureCodeProfile
*profile2
= new ErasureCodeProfile();
921 (*profile
)["plugin"] = "shec";
922 (*profile
)["technique"] = "";
923 (*profile
)["crush-failure-domain"] = "host";
924 (*profile
)["k"] = "10";
925 (*profile
)["m"] = "6";
926 (*profile
)["c"] = "5";
927 (*profile
)["w"] = "16";
929 int r
= shec
->init(*profile
, &cerr
);
932 (*profile2
)["plugin"] = "shec";
933 (*profile2
)["technique"] = "";
934 (*profile2
)["crush-failure-domain"] = "osd";
935 (*profile2
)["k"] = "4";
936 (*profile2
)["m"] = "3";
937 (*profile2
)["c"] = "2";
938 shec
->init(*profile2
, &cerr
);
940 EXPECT_EQ(4, shec
->k
);
941 EXPECT_EQ(3, shec
->m
);
942 EXPECT_EQ(2, shec
->c
);
943 EXPECT_EQ(8, shec
->w
);
944 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
945 EXPECT_STREQ("default", shec
->rule_root
.c_str());
946 EXPECT_STREQ("osd", shec
->rule_failure_domain
.c_str());
947 EXPECT_TRUE(shec
->matrix
!= NULL
);
955 TEST(ErasureCodeShec
, minimum_to_decode_8
)
958 ErasureCodeShecTableCache tcache
;
959 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
961 ErasureCodeShec::MULTIPLE
);
962 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
963 (*profile
)["plugin"] = "shec";
964 (*profile
)["technique"] = "";
965 (*profile
)["crush-failure-domain"] = "osd";
966 (*profile
)["k"] = "4";
967 (*profile
)["m"] = "3";
968 (*profile
)["c"] = "2";
969 shec
->init(*profile
, &cerr
);
972 set
<int> want_to_decode
;
973 set
<int> available_chunks
;
974 set
<int> minimum_chunks
;
976 for (int i
= 0; i
< 8; ++i
) {
977 want_to_decode
.insert(i
);
979 for (int i
= 0; i
< 5; ++i
) {
980 available_chunks
.insert(i
);
983 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
985 EXPECT_EQ(-EINVAL
, r
);
991 TEST(ErasureCodeShec
, minimum_to_decode_9
)
994 ErasureCodeShecTableCache tcache
;
995 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
997 ErasureCodeShec::MULTIPLE
);
998 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
999 (*profile
)["plugin"] = "shec";
1000 (*profile
)["technique"] = "";
1001 (*profile
)["crush-failure-domain"] = "osd";
1002 (*profile
)["k"] = "4";
1003 (*profile
)["m"] = "3";
1004 (*profile
)["c"] = "2";
1005 shec
->init(*profile
, &cerr
);
1008 set
<int> want_to_decode
;
1009 set
<int> available_chunks
;
1010 set
<int> minimum_chunks
;
1012 for (int i
= 0; i
< 4; ++i
) {
1013 want_to_decode
.insert(i
);
1015 for (int i
= 0; i
< 8; ++i
) {
1016 available_chunks
.insert(i
);
1019 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
1021 EXPECT_EQ(-EINVAL
, r
);
1027 TEST(ErasureCodeShec
, minimum_to_decode_10
)
1030 ErasureCodeShecTableCache tcache
;
1031 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1033 ErasureCodeShec::MULTIPLE
);
1034 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1035 (*profile
)["plugin"] = "shec";
1036 (*profile
)["technique"] = "";
1037 (*profile
)["crush-failure-domain"] = "osd";
1038 (*profile
)["k"] = "4";
1039 (*profile
)["m"] = "3";
1040 (*profile
)["c"] = "2";
1041 shec
->init(*profile
, &cerr
);
1044 set
<int> want_to_decode
;
1045 set
<int> available_chunks
;
1046 set
<int> minimum_chunks
;
1048 for (int i
= 0; i
< 7; ++i
) {
1049 want_to_decode
.insert(i
);
1051 for (int i
= 4; i
< 7; ++i
) {
1052 available_chunks
.insert(i
);
1055 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
1063 TEST(ErasureCodeShec
, minimum_to_decode_11
)
1066 ErasureCodeShecTableCache tcache
;
1067 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1069 ErasureCodeShec::MULTIPLE
);
1070 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1071 (*profile
)["plugin"] = "shec";
1072 (*profile
)["technique"] = "";
1073 (*profile
)["crush-failure-domain"] = "osd";
1074 (*profile
)["k"] = "4";
1075 (*profile
)["m"] = "3";
1076 (*profile
)["c"] = "2";
1077 shec
->init(*profile
, &cerr
);
1080 set
<int> want_to_decode
;
1081 set
<int> available_chunks
;
1082 set
<int> minimum_chunks
;
1084 for (int i
= 0; i
< 5; ++i
) {
1085 want_to_decode
.insert(i
);
1087 for (int i
= 4; i
< 7; ++i
) {
1088 available_chunks
.insert(i
);
1091 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
1099 TEST(ErasureCodeShec
, minimum_to_decode_12
)
1102 ErasureCodeShecTableCache tcache
;
1103 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1105 ErasureCodeShec::MULTIPLE
);
1106 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1107 (*profile
)["plugin"] = "shec";
1108 (*profile
)["technique"] = "";
1109 (*profile
)["crush-failure-domain"] = "osd";
1110 (*profile
)["k"] = "4";
1111 (*profile
)["m"] = "3";
1112 (*profile
)["c"] = "2";
1113 shec
->init(*profile
, &cerr
);
1116 set
<int> want_to_decode
;
1117 set
<int> available_chunks
;
1118 //minimum_chunks is NULL
1120 for (int i
= 0; i
< 7; ++i
) {
1121 want_to_decode
.insert(i
);
1122 available_chunks
.insert(i
);
1125 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
, NULL
);
1126 EXPECT_EQ(-EINVAL
, r
);
1132 TEST(ErasureCodeShec
, minimum_to_decode_13
)
1135 ErasureCodeShecTableCache tcache
;
1136 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1138 ErasureCodeShec::MULTIPLE
);
1139 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1140 (*profile
)["plugin"] = "shec";
1141 (*profile
)["technique"] = "";
1142 (*profile
)["crush-failure-domain"] = "osd";
1143 (*profile
)["k"] = "4";
1144 (*profile
)["m"] = "3";
1145 (*profile
)["c"] = "2";
1146 shec
->init(*profile
, &cerr
);
1149 set
<int> want_to_decode
;
1150 set
<int> available_chunks
;
1151 set
<int> minimum_chunks
, minimum
;
1153 for (int i
= 0; i
< 7; ++i
) {
1154 want_to_decode
.insert(i
);
1155 available_chunks
.insert(i
);
1157 shec
->_minimum_to_decode(want_to_decode
, available_chunks
, &minimum_chunks
);
1158 minimum
= minimum_chunks
; //normal value
1159 for (int i
= 100; i
< 120; ++i
) {
1160 minimum_chunks
.insert(i
); //insert extra data
1163 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
1165 EXPECT_TRUE(shec
->matrix
!= NULL
);
1167 EXPECT_EQ(minimum
, minimum_chunks
);
1173 TEST(ErasureCodeShec
, minimum_to_decode2_1
)
1176 ErasureCodeShecTableCache tcache
;
1177 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1179 ErasureCodeShec::MULTIPLE
);
1180 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1181 (*profile
)["plugin"] = "shec";
1182 (*profile
)["technique"] = "";
1183 (*profile
)["crush-failure-domain"] = "osd";
1184 (*profile
)["k"] = "4";
1185 (*profile
)["m"] = "3";
1186 (*profile
)["c"] = "2";
1187 shec
->init(*profile
, &cerr
);
1190 set
<int> want_to_decode
;
1191 set
<int> available_chunks
;
1192 set
<int> minimum_chunks
;
1194 want_to_decode
.insert(0);
1195 available_chunks
.insert(0);
1196 available_chunks
.insert(1);
1197 available_chunks
.insert(2);
1199 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
1201 EXPECT_TRUE(shec
->matrix
!= NULL
);
1203 EXPECT_TRUE(minimum_chunks
.size());
1209 TEST(ErasureCodeShec
, minimum_to_decode2_3
)
1212 ErasureCodeShecTableCache tcache
;
1213 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1215 ErasureCodeShec::MULTIPLE
);
1216 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1217 (*profile
)["plugin"] = "shec";
1218 (*profile
)["technique"] = "";
1219 (*profile
)["crush-failure-domain"] = "osd";
1220 (*profile
)["k"] = "4";
1221 (*profile
)["m"] = "3";
1222 (*profile
)["c"] = "2";
1223 shec
->init(*profile
, &cerr
);
1226 set
<int> want_to_decode
;
1227 set
<int> available_chunks
;
1228 set
<int> minimum_chunks
;
1230 want_to_decode
.insert(0);
1231 want_to_decode
.insert(2);
1232 available_chunks
.insert(0);
1233 available_chunks
.insert(1);
1234 available_chunks
.insert(2);
1235 available_chunks
.insert(3);
1239 pthread_create(&tid
, NULL
, thread1
, shec
);
1240 while (g_flag
== 0) {
1244 printf("*** test start ***\n");
1245 int r
= shec
->_minimum_to_decode(want_to_decode
, available_chunks
,
1247 EXPECT_TRUE(shec
->matrix
!= NULL
);
1249 EXPECT_EQ(want_to_decode
, minimum_chunks
);
1250 printf("*** test end ***\n");
1252 pthread_join(tid
, NULL
);
1258 TEST(ErasureCodeShec
, minimum_to_decode_with_cost_1
)
1261 ErasureCodeShecTableCache tcache
;
1262 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1264 ErasureCodeShec::MULTIPLE
);
1265 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1266 (*profile
)["plugin"] = "shec";
1267 (*profile
)["technique"] = "";
1268 (*profile
)["crush-failure-domain"] = "osd";
1269 (*profile
)["k"] = "4";
1270 (*profile
)["m"] = "3";
1271 (*profile
)["c"] = "2";
1272 shec
->init(*profile
, &cerr
);
1274 //minimum_to_decode_with_cost
1275 set
<int> want_to_decode
;
1276 map
<int, int> available_chunks
;
1277 set
<int> minimum_chunks
;
1279 for (int i
= 0; i
< 7; ++i
) {
1280 want_to_decode
.insert(i
);
1281 available_chunks
.insert(make_pair(i
, i
));
1284 int r
= shec
->minimum_to_decode_with_cost(want_to_decode
, available_chunks
,
1286 EXPECT_TRUE(shec
->matrix
!= NULL
);
1288 EXPECT_TRUE(minimum_chunks
.size());
1294 TEST(ErasureCodeShec
, minimum_to_decode_with_cost_2_3
)
1297 ErasureCodeShecTableCache tcache
;
1298 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1300 ErasureCodeShec::MULTIPLE
);
1301 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1302 (*profile
)["plugin"] = "shec";
1303 (*profile
)["technique"] = "";
1304 (*profile
)["crush-failure-domain"] = "osd";
1305 (*profile
)["k"] = "4";
1306 (*profile
)["m"] = "3";
1307 (*profile
)["c"] = "2";
1308 shec
->init(*profile
, &cerr
);
1310 //minimum_to_decode_with_cost
1311 set
<int> want_to_decode
;
1312 map
<int, int> available_chunks
;
1313 set
<int> minimum_chunks
;
1315 want_to_decode
.insert(0);
1316 want_to_decode
.insert(2);
1317 available_chunks
[0] = 0;
1318 available_chunks
[1] = 1;
1319 available_chunks
[2] = 2;
1320 available_chunks
[3] = 3;
1324 pthread_create(&tid
, NULL
, thread2
, shec
);
1325 while (g_flag
== 0) {
1329 printf("*** test start ***\n");
1330 int r
= shec
->minimum_to_decode_with_cost(want_to_decode
, available_chunks
,
1332 EXPECT_TRUE(shec
->matrix
!= NULL
);
1334 EXPECT_EQ(want_to_decode
, minimum_chunks
);
1335 printf("*** test end ***\n");
1337 pthread_join(tid
, NULL
);
1343 TEST(ErasureCodeShec
, encode_1
)
1346 ErasureCodeShecTableCache tcache
;
1347 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1349 ErasureCodeShec::MULTIPLE
);
1350 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1351 (*profile
)["plugin"] = "shec";
1352 (*profile
)["technique"] = "";
1353 (*profile
)["crush-failure-domain"] = "osd";
1354 (*profile
)["k"] = "4";
1355 (*profile
)["m"] = "3";
1356 (*profile
)["c"] = "2";
1357 shec
->init(*profile
, &cerr
);
1361 set
<int> want_to_encode
;
1362 map
<int, bufferlist
> encoded
;
1364 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1365 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1368 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1369 want_to_encode
.insert(i
);
1372 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1374 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1375 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1378 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1379 map
<int, bufferlist
> decoded
;
1381 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2),
1384 EXPECT_NE(nullptr, shec
->matrix
);
1386 EXPECT_EQ(2u, decoded
.size());
1387 EXPECT_EQ(32u, decoded
[0].length());
1389 bufferlist out1
, out2
, usable
;
1391 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1392 out1
.append(encoded
[i
]);
1395 r
= shec
->decode_concat(encoded
, &out2
);
1396 usable
.substr_of(out2
, 0, in
.length());
1397 EXPECT_FALSE(out1
== in
);
1398 EXPECT_TRUE(usable
== in
);
1404 TEST(ErasureCodeShec
, encode_2
)
1407 ErasureCodeShecTableCache tcache
;
1408 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1410 ErasureCodeShec::MULTIPLE
);
1411 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1412 (*profile
)["plugin"] = "shec";
1413 (*profile
)["technique"] = "";
1414 (*profile
)["crush-failure-domain"] = "osd";
1415 (*profile
)["k"] = "4";
1416 (*profile
)["m"] = "3";
1417 (*profile
)["c"] = "2";
1418 shec
->init(*profile
, &cerr
);
1422 set
<int> want_to_encode
;
1423 map
<int, bufferlist
> encoded
;
1425 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1426 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1428 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1429 want_to_encode
.insert(i
);
1432 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1434 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1435 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1438 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1439 map
<int, bufferlist
> decoded
;
1440 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1442 EXPECT_TRUE(shec
->matrix
!= NULL
);
1444 EXPECT_EQ(2u, decoded
.size());
1445 EXPECT_EQ(32u, decoded
[0].length());
1447 bufferlist out1
, out2
, usable
;
1449 for (unsigned int i
= 0; i
< encoded
.size(); ++i
)
1450 out1
.append(encoded
[i
]);
1452 shec
->decode_concat(encoded
, &out2
);
1453 usable
.substr_of(out2
, 0, in
.length());
1454 EXPECT_FALSE(out1
== in
);
1455 EXPECT_TRUE(usable
== in
);
1461 TEST(ErasureCodeShec
, encode_3
)
1463 ErasureCodeShecTableCache tcache
;
1464 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1466 ErasureCodeShec::MULTIPLE
);
1467 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1468 (*profile
)["plugin"] = "shec";
1469 (*profile
)["technique"] = "";
1470 (*profile
)["crush-failure-domain"] = "osd";
1471 (*profile
)["k"] = "4";
1472 (*profile
)["m"] = "3";
1473 (*profile
)["c"] = "2";
1474 shec
->init(*profile
, &cerr
);
1477 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1478 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1480 set
<int> want_to_encode
;
1481 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1482 want_to_encode
.insert(i
);
1484 want_to_encode
.insert(10);
1485 want_to_encode
.insert(11);
1486 map
<int, bufferlist
> encoded
;
1487 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1489 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1490 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1493 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1494 map
<int, bufferlist
> decoded
;
1495 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1497 EXPECT_TRUE(shec
->matrix
!= NULL
);
1499 EXPECT_EQ(2u, decoded
.size());
1500 EXPECT_EQ(shec
->get_chunk_size(in
.length()), decoded
[0].length());
1502 bufferlist out1
, out2
, usable
;
1504 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1505 out1
.append(encoded
[i
]);
1508 shec
->decode_concat(encoded
, &out2
);
1509 usable
.substr_of(out2
, 0, in
.length());
1510 EXPECT_FALSE(out1
== in
);
1511 EXPECT_TRUE(usable
== in
);
1517 TEST(ErasureCodeShec
, encode_4
)
1520 ErasureCodeShecTableCache tcache
;
1521 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1523 ErasureCodeShec::MULTIPLE
);
1524 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1525 (*profile
)["plugin"] = "shec";
1526 (*profile
)["technique"] = "";
1527 (*profile
)["crush-failure-domain"] = "osd";
1528 (*profile
)["k"] = "4";
1529 (*profile
)["m"] = "3";
1530 (*profile
)["c"] = "2";
1531 shec
->init(*profile
, &cerr
);
1535 set
<int> want_to_encode
;
1536 map
<int, bufferlist
> encoded
;
1538 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1539 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1541 for (unsigned int i
= 0; i
< shec
->get_chunk_count() - 1; ++i
) {
1542 want_to_encode
.insert(i
);
1544 want_to_encode
.insert(100);
1546 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1548 EXPECT_EQ(shec
->get_chunk_count()-1, encoded
.size());
1549 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1552 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1553 map
<int, bufferlist
> decoded
;
1554 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1556 EXPECT_TRUE(shec
->matrix
!= NULL
);
1558 EXPECT_EQ(2u, decoded
.size());
1559 EXPECT_EQ(shec
->get_chunk_size(in
.length()), decoded
[0].length());
1561 bufferlist out1
, out2
, usable
;
1563 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1564 out1
.append(encoded
[i
]);
1567 shec
->decode_concat(encoded
, &out2
);
1568 usable
.substr_of(out2
, 0, in
.length());
1569 EXPECT_FALSE(out1
== in
);
1570 EXPECT_TRUE(usable
== in
);
1576 TEST(ErasureCodeShec
, encode_8
)
1579 ErasureCodeShecTableCache tcache
;
1580 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1582 ErasureCodeShec::MULTIPLE
);
1583 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1584 (*profile
)["plugin"] = "shec";
1585 (*profile
)["technique"] = "";
1586 (*profile
)["crush-failure-domain"] = "osd";
1587 (*profile
)["k"] = "4";
1588 (*profile
)["m"] = "3";
1589 (*profile
)["c"] = "2";
1590 shec
->init(*profile
, &cerr
);
1594 set
<int> want_to_encode
;
1596 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1597 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1599 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1600 want_to_encode
.insert(i
);
1603 int r
= shec
->encode(want_to_encode
, in
, NULL
); //encoded = NULL
1604 EXPECT_EQ(-EINVAL
, r
);
1610 TEST(ErasureCodeShec
, encode_9
)
1613 ErasureCodeShecTableCache tcache
;
1614 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1616 ErasureCodeShec::MULTIPLE
);
1617 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1618 (*profile
)["plugin"] = "shec";
1619 (*profile
)["technique"] = "";
1620 (*profile
)["crush-failure-domain"] = "osd";
1621 (*profile
)["k"] = "4";
1622 (*profile
)["m"] = "3";
1623 (*profile
)["c"] = "2";
1624 shec
->init(*profile
, &cerr
);
1628 set
<int> want_to_encode
;
1629 map
<int, bufferlist
> encoded
;
1631 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1632 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1634 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1635 want_to_encode
.insert(i
);
1637 for (int i
= 0; i
< 100; ++i
) {
1638 encoded
[i
].append("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
1641 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1642 EXPECT_EQ(-EINVAL
, r
);
1648 TEST(ErasureCodeShec
, encode2_1
)
1651 ErasureCodeShecTableCache tcache
;
1652 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1654 ErasureCodeShec::MULTIPLE
);
1655 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1656 (*profile
)["plugin"] = "shec";
1657 (*profile
)["technique"] = "";
1658 (*profile
)["crush-failure-domain"] = "osd";
1659 (*profile
)["k"] = "4";
1660 (*profile
)["m"] = "3";
1661 (*profile
)["c"] = "2";
1662 shec
->init(*profile
, &cerr
);
1666 set
<int> want_to_encode
;
1667 map
<int, bufferlist
> encoded
;
1669 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1670 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1673 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1674 want_to_encode
.insert(i
);
1677 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1679 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1680 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1683 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1684 map
<int, bufferlist
> decoded
;
1685 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1687 EXPECT_TRUE(shec
->matrix
!= NULL
);
1689 EXPECT_EQ(2u, decoded
.size());
1690 EXPECT_EQ(32u, decoded
[0].length());
1692 bufferlist out1
, out2
, usable
;
1694 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1695 out1
.append(encoded
[i
]);
1698 shec
->decode_concat(encoded
, &out2
);
1699 usable
.substr_of(out2
, 0, in
.length());
1700 EXPECT_FALSE(out1
== in
);
1701 EXPECT_TRUE(usable
== in
);
1707 TEST(ErasureCodeShec
, encode2_3
)
1710 ErasureCodeShecTableCache tcache
;
1711 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1713 ErasureCodeShec::MULTIPLE
);
1714 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1715 (*profile
)["plugin"] = "shec";
1716 (*profile
)["technique"] = "";
1717 (*profile
)["crush-failure-domain"] = "osd";
1718 (*profile
)["k"] = "4";
1719 (*profile
)["m"] = "3";
1720 (*profile
)["c"] = "2";
1721 shec
->init(*profile
, &cerr
);
1725 set
<int> want_to_encode
;
1726 map
<int, bufferlist
> encoded
;
1728 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1729 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1732 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1733 want_to_encode
.insert(i
);
1738 pthread_create(&tid
, NULL
, thread4
, shec
);
1739 while (g_flag
== 0) {
1743 printf("*** test start ***\n");
1744 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1746 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1747 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1748 printf("*** test end ***\n");
1750 pthread_join(tid
, NULL
);
1753 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1754 map
<int, bufferlist
> decoded
;
1756 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1758 EXPECT_TRUE(shec
->matrix
!= NULL
);
1760 EXPECT_EQ(2u, decoded
.size());
1761 EXPECT_EQ(32u, decoded
[0].length());
1763 bufferlist out1
, out2
, usable
;
1765 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1766 out1
.append(encoded
[i
]);
1769 shec
->decode_concat(encoded
, &out2
);
1770 usable
.substr_of(out2
, 0, in
.length());
1771 EXPECT_FALSE(out1
== in
);
1772 EXPECT_TRUE(usable
== in
);
1778 TEST(ErasureCodeShec
, decode_1
)
1781 ErasureCodeShecTableCache tcache
;
1782 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1784 ErasureCodeShec::MULTIPLE
);
1785 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1786 (*profile
)["plugin"] = "shec";
1787 (*profile
)["technique"] = "";
1788 (*profile
)["crush-failure-domain"] = "osd";
1789 (*profile
)["k"] = "4";
1790 (*profile
)["m"] = "3";
1791 (*profile
)["c"] = "2";
1792 shec
->init(*profile
, &cerr
);
1796 set
<int> want_to_encode
;
1797 map
<int, bufferlist
> encoded
;
1799 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1800 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1801 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
1802 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
1804 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1805 want_to_encode
.insert(i
);
1808 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1810 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1811 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1813 // all chunks are available
1815 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1816 map
<int, bufferlist
> decoded
;
1818 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 7), encoded
,
1820 EXPECT_TRUE(shec
->matrix
!= NULL
);
1822 EXPECT_EQ(7u, decoded
.size());
1826 unsigned int c_size
= shec
->get_chunk_size(in
.length());
1827 for (unsigned int i
= 0; i
< shec
->get_data_chunk_count(); ++i
) {
1829 EXPECT_EQ(c_size
, decoded
[i
].length());
1830 if ( c_size
* (i
+1) <= in
.length() ) {
1831 usable
.substr_of(in
, c_size
* i
, c_size
);
1832 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), c_size
);
1834 usable
.substr_of(in
, c_size
* i
, in
.length() % c_size
);
1835 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), in
.length() % c_size
);
1844 TEST(ErasureCodeShec
, decode_8
)
1847 ErasureCodeShecTableCache tcache
;
1848 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1850 ErasureCodeShec::MULTIPLE
);
1851 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1852 (*profile
)["plugin"] = "shec";
1853 (*profile
)["technique"] = "";
1854 (*profile
)["crush-failure-domain"] = "osd";
1855 (*profile
)["k"] = "4";
1856 (*profile
)["m"] = "3";
1857 (*profile
)["c"] = "2";
1858 shec
->init(*profile
, &cerr
);
1862 set
<int> want_to_encode
;
1863 map
<int, bufferlist
> encoded
;
1865 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1866 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1867 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
1868 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
1870 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1871 want_to_encode
.insert(i
);
1874 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1876 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1877 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1879 // all chunks are available
1881 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; //more than k+m
1882 map
<int, bufferlist
> decoded
;
1884 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 8), encoded
,
1887 EXPECT_EQ(7u, decoded
.size());
1888 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1892 unsigned int c_size
= shec
->get_chunk_size(in
.length());
1893 for (unsigned int i
= 0; i
< shec
->get_data_chunk_count(); ++i
) {
1895 EXPECT_EQ(c_size
, decoded
[i
].length());
1896 if ( c_size
* (i
+1) <= in
.length() ) {
1897 usable
.substr_of(in
, c_size
* i
, c_size
);
1898 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), c_size
);
1900 usable
.substr_of(in
, c_size
* i
, in
.length() % c_size
);
1901 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), in
.length() % c_size
);
1910 TEST(ErasureCodeShec
, decode_9
)
1913 ErasureCodeShecTableCache tcache
;
1914 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1916 ErasureCodeShec::MULTIPLE
);
1917 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1918 (*profile
)["plugin"] = "shec";
1919 (*profile
)["technique"] = "";
1920 (*profile
)["crush-failure-domain"] = "osd";
1921 (*profile
)["k"] = "4";
1922 (*profile
)["m"] = "3";
1923 (*profile
)["c"] = "2";
1924 shec
->init(*profile
, &cerr
);
1928 set
<int> want_to_encode
;
1929 map
<int, bufferlist
> encoded
;
1931 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1932 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1933 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
1934 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
1936 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1937 want_to_encode
.insert(i
);
1940 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1942 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1943 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1945 // all chunks are available
1947 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
1948 map
<int, bufferlist
> decoded
;
1955 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 10), encoded
,
1957 EXPECT_TRUE(shec
->matrix
!= NULL
);
1959 EXPECT_EQ(7u, decoded
.size());
1960 EXPECT_EQ(shec
->get_chunk_size(in
.length()), decoded
[0].length());
1962 bufferlist out1
, usable
;
1964 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1965 out1
.append(encoded
[i
]);
1967 EXPECT_FALSE(out1
== in
);
1968 //usable is "decoded"
1970 unsigned int c_size
= shec
->get_chunk_size(in
.length());
1971 for (unsigned int i
= 0; i
< shec
->get_data_chunk_count(); ++i
) {
1973 EXPECT_EQ(c_size
, decoded
[i
].length());
1974 if ( c_size
* (i
+1) <= in
.length() ) {
1975 usable
.substr_of(in
, c_size
* i
, c_size
);
1976 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), c_size
);
1978 usable
.substr_of(in
, c_size
* i
, in
.length() % c_size
);
1979 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), in
.length() % c_size
);
1988 TEST(ErasureCodeShec
, decode_10
)
1991 ErasureCodeShecTableCache tcache
;
1992 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1994 ErasureCodeShec::MULTIPLE
);
1995 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1996 (*profile
)["plugin"] = "shec";
1997 (*profile
)["technique"] = "";
1998 (*profile
)["crush-failure-domain"] = "osd";
1999 (*profile
)["k"] = "4";
2000 (*profile
)["m"] = "3";
2001 (*profile
)["c"] = "2";
2002 shec
->init(*profile
, &cerr
);
2006 set
<int> want_to_encode
;
2007 map
<int, bufferlist
> encoded
;
2009 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2010 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2011 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2012 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2014 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2015 want_to_encode
.insert(i
);
2018 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2020 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2021 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2024 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 }; //more than k+m
2025 map
<int, bufferlist
> decoded
, inchunks
;
2027 for ( unsigned int i
= 0; i
< 3; ++i
) {
2028 inchunks
.insert(make_pair(i
, encoded
[i
]));
2031 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 7), inchunks
,
2039 TEST(ErasureCodeShec
, decode_11
)
2042 ErasureCodeShecTableCache tcache
;
2043 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2045 ErasureCodeShec::MULTIPLE
);
2046 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2047 (*profile
)["plugin"] = "shec";
2048 (*profile
)["technique"] = "";
2049 (*profile
)["crush-failure-domain"] = "osd";
2050 (*profile
)["k"] = "4";
2051 (*profile
)["m"] = "3";
2052 (*profile
)["c"] = "2";
2053 shec
->init(*profile
, &cerr
);
2057 set
<int> want_to_encode
;
2058 map
<int, bufferlist
> encoded
;
2060 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2061 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2064 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2065 want_to_encode
.insert(i
);
2068 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2070 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2071 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2074 int want_to_decode
[] = { 0, 1, 2, 3, 4 };
2075 map
<int, bufferlist
> decoded
, inchunks
;
2077 for ( unsigned int i
= 4; i
< 7; ++i
) {
2078 inchunks
.insert(make_pair(i
, encoded
[i
]));
2081 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 5), inchunks
,
2089 TEST(ErasureCodeShec
, decode_12
)
2092 ErasureCodeShecTableCache tcache
;
2093 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2095 ErasureCodeShec::MULTIPLE
);
2096 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2097 (*profile
)["plugin"] = "shec";
2098 (*profile
)["technique"] = "";
2099 (*profile
)["crush-failure-domain"] = "osd";
2100 (*profile
)["k"] = "4";
2101 (*profile
)["m"] = "3";
2102 (*profile
)["c"] = "2";
2103 shec
->init(*profile
, &cerr
);
2107 set
<int> want_to_encode
;
2108 map
<int, bufferlist
> encoded
;
2110 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2111 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2112 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2113 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2115 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2116 want_to_encode
.insert(i
);
2119 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2121 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2122 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2124 // all chunks are available
2126 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
2129 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 7), encoded
,
2137 TEST(ErasureCodeShec
, decode_13
)
2140 ErasureCodeShecTableCache tcache
;
2141 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2143 ErasureCodeShec::MULTIPLE
);
2144 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2145 (*profile
)["plugin"] = "shec";
2146 (*profile
)["technique"] = "";
2147 (*profile
)["crush-failure-domain"] = "osd";
2148 (*profile
)["k"] = "4";
2149 (*profile
)["m"] = "3";
2150 (*profile
)["c"] = "2";
2151 shec
->init(*profile
, &cerr
);
2155 set
<int> want_to_encode
;
2156 map
<int, bufferlist
> encoded
;
2158 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2159 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2160 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2161 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2163 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2164 want_to_encode
.insert(i
);
2167 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2169 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2170 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2172 // all chunks are available
2174 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
2175 map
<int, bufferlist
> decoded
;
2180 for (int i
= 0; i
< 100; ++i
) {
2184 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 7), encoded
,
2192 TEST(ErasureCodeShec
, decode2_1
)
2195 ErasureCodeShecTableCache tcache
;
2196 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2198 ErasureCodeShec::MULTIPLE
);
2199 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2200 (*profile
)["plugin"] = "shec";
2201 (*profile
)["technique"] = "";
2202 (*profile
)["crush-failure-domain"] = "osd";
2203 (*profile
)["k"] = "4";
2204 (*profile
)["m"] = "3";
2205 (*profile
)["c"] = "2";
2206 shec
->init(*profile
, &cerr
);
2210 set
<int> want_to_encode
;
2211 map
<int, bufferlist
> encoded
;
2213 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2214 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2215 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2216 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2218 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2219 want_to_encode
.insert(i
);
2222 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2224 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2225 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2227 // all chunks are available
2229 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
2230 map
<int, bufferlist
> decoded
;
2232 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
2234 EXPECT_TRUE(shec
->matrix
!= NULL
);
2236 EXPECT_EQ(2u, decoded
.size());
2239 shec
->decode_concat(encoded
, &out
);
2241 usable
.substr_of(out
, 0, in
.length());
2242 EXPECT_TRUE(usable
== in
);
2248 TEST(ErasureCodeShec
, decode2_3
)
2251 ErasureCodeShecTableCache tcache
;
2252 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2254 ErasureCodeShec::MULTIPLE
);
2255 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2256 (*profile
)["plugin"] = "shec";
2257 (*profile
)["technique"] = "";
2258 (*profile
)["crush-failure-domain"] = "osd";
2259 (*profile
)["k"] = "4";
2260 (*profile
)["m"] = "3";
2261 (*profile
)["c"] = "2";
2262 shec
->init(*profile
, &cerr
);
2266 set
<int> want_to_encode
;
2267 map
<int, bufferlist
> encoded
;
2269 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2270 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2271 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2272 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2274 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2275 want_to_encode
.insert(i
);
2278 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2280 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2281 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2283 // all chunks are available
2285 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
2286 map
<int, bufferlist
> decoded
;
2290 pthread_create(&tid
, NULL
, thread4
, shec
);
2291 while (g_flag
== 0) {
2295 printf("*** test start ***\n");
2296 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
2298 EXPECT_TRUE(shec
->matrix
!= NULL
);
2300 EXPECT_EQ(2u, decoded
.size());
2301 printf("*** test end ***\n");
2303 pthread_join(tid
, NULL
);
2306 shec
->decode_concat(encoded
, &out
);
2308 usable
.substr_of(out
, 0, in
.length());
2309 EXPECT_TRUE(usable
== in
);
2315 TEST(ErasureCodeShec
, decode2_4
)
2318 ErasureCodeShecTableCache tcache
;
2319 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2321 ErasureCodeShec::MULTIPLE
);
2322 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2323 (*profile
)["plugin"] = "shec";
2324 (*profile
)["technique"] = "";
2325 (*profile
)["crush-failure-domain"] = "osd";
2326 (*profile
)["k"] = "4";
2327 (*profile
)["m"] = "3";
2328 (*profile
)["c"] = "2";
2329 shec
->init(*profile
, &cerr
);
2333 set
<int> want_to_encode
;
2334 map
<int, bufferlist
> encoded
;
2336 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2337 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2338 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2339 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2341 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2342 want_to_encode
.insert(i
);
2345 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2347 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2348 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2351 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
2352 map
<int, bufferlist
> decoded
;
2356 map
<int, bufferlist
> degraded
;
2357 degraded
[0] = encoded
[0];
2359 r
= shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), degraded
,
2367 TEST(ErasureCodeShec
, create_rule_1_2
)
2370 CrushWrapper
*crush
= new CrushWrapper
;
2372 crush
->set_type_name(2, "root");
2373 crush
->set_type_name(1, "host");
2374 crush
->set_type_name(0, "osd");
2377 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2379 crush
->set_item_name(rootno
, "default");
2381 map
< string
, string
> loc
;
2382 loc
["root"] = "default";
2387 for (int h
= 0; h
< num_host
; ++h
) {
2388 loc
["host"] = string("host-") + stringify(h
);
2389 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2390 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2391 string("osd.") + stringify(osd
), loc
);
2396 ErasureCodeShecTableCache tcache
;
2397 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2399 ErasureCodeShec::MULTIPLE
);
2400 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2401 (*profile
)["plugin"] = "shec";
2402 (*profile
)["technique"] = "";
2403 (*profile
)["crush-failure-domain"] = "osd";
2404 (*profile
)["k"] = "4";
2405 (*profile
)["m"] = "3";
2406 (*profile
)["c"] = "2";
2407 shec
->init(*profile
, &cerr
);
2412 int r
= shec
->create_rule("myrule", *crush
, &ss
);
2414 EXPECT_STREQ("myrule", crush
->rule_name_map
[0].c_str());
2416 //reexecute create_rule
2417 r
= shec
->create_rule("myrule", *crush
, &ss
);
2418 EXPECT_EQ(-EEXIST
, r
);
2425 TEST(ErasureCodeShec
, create_rule_4
)
2428 CrushWrapper
*crush
= new CrushWrapper
;
2430 crush
->set_type_name(2, "root");
2431 crush
->set_type_name(1, "host");
2432 crush
->set_type_name(0, "osd");
2435 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2437 crush
->set_item_name(rootno
, "default");
2439 map
< string
, string
> loc
;
2440 loc
["root"] = "default";
2445 for (int h
= 0; h
< num_host
; ++h
) {
2446 loc
["host"] = string("host-") + stringify(h
);
2447 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2448 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2449 string("osd.") + stringify(osd
), loc
);
2454 ErasureCodeShecTableCache tcache
;
2455 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2457 ErasureCodeShec::MULTIPLE
);
2458 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2459 (*profile
)["plugin"] = "shec";
2460 (*profile
)["technique"] = "";
2461 (*profile
)["crush-failure-domain"] = "osd";
2462 (*profile
)["k"] = "4";
2463 (*profile
)["m"] = "3";
2464 (*profile
)["c"] = "2";
2465 shec
->init(*profile
, &cerr
);
2468 int r
= shec
->create_rule("myrule", *crush
, NULL
); //ss = NULL
2476 TEST(ErasureCodeShec
, create_rule2_1
)
2479 CrushWrapper
*crush
= new CrushWrapper
;
2481 crush
->set_type_name(2, "root");
2482 crush
->set_type_name(1, "host");
2483 crush
->set_type_name(0, "osd");
2486 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2488 crush
->set_item_name(rootno
, "default");
2490 map
< string
, string
> loc
;
2491 loc
["root"] = "default";
2496 for (int h
= 0; h
< num_host
; ++h
) {
2497 loc
["host"] = string("host-") + stringify(h
);
2498 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2499 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2500 string("osd.") + stringify(osd
), loc
);
2505 ErasureCodeShecTableCache tcache
;
2506 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2508 ErasureCodeShec::MULTIPLE
);
2509 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2510 (*profile
)["plugin"] = "shec";
2511 (*profile
)["technique"] = "";
2512 (*profile
)["crush-failure-domain"] = "osd";
2513 (*profile
)["k"] = "4";
2514 (*profile
)["m"] = "3";
2515 (*profile
)["c"] = "2";
2516 shec
->init(*profile
, &cerr
);
2521 int r
= shec
->create_rule("myrule", *crush
, &ss
);
2523 EXPECT_STREQ("myrule", crush
->rule_name_map
[0].c_str());
2530 struct CreateRuleset2_3_Param_d
{
2531 ErasureCodeShec
*shec
;
2532 CrushWrapper
*crush
;
2535 TEST(ErasureCodeShec
, create_rule2_3
)
2538 CrushWrapper
*crush
= new CrushWrapper
;
2540 crush
->set_type_name(2, "root");
2541 crush
->set_type_name(1, "host");
2542 crush
->set_type_name(0, "osd");
2545 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2547 crush
->set_item_name(rootno
, "default");
2549 map
< string
, string
> loc
;
2550 loc
["root"] = "default";
2555 for (int h
= 0; h
< num_host
; ++h
) {
2556 loc
["host"] = string("host-") + stringify(h
);
2557 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2558 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2559 string("osd.") + stringify(osd
), loc
);
2564 ErasureCodeShecTableCache tcache
;
2565 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2567 ErasureCodeShec::MULTIPLE
);
2568 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2569 (*profile
)["plugin"] = "shec";
2570 (*profile
)["technique"] = "";
2571 (*profile
)["crush-failure-domain"] = "osd";
2572 (*profile
)["k"] = "4";
2573 (*profile
)["m"] = "3";
2574 (*profile
)["c"] = "2";
2575 shec
->init(*profile
, &cerr
);
2582 pthread_create(&tid
, NULL
, thread3
, shec
);
2583 while (g_flag
== 0) {
2587 printf("*** test start ***\n");
2588 int r
= (shec
->create_rule("myrule", *crush
, &ss
));
2589 EXPECT_TRUE(r
>= 0);
2590 printf("*** test end ***\n");
2592 pthread_join(tid
, NULL
);
2599 TEST(ErasureCodeShec
, get_chunk_count_1
)
2602 ErasureCodeShecTableCache tcache
;
2603 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2605 ErasureCodeShec::MULTIPLE
);
2606 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2607 (*profile
)["plugin"] = "shec";
2608 (*profile
)["technique"] = "";
2609 (*profile
)["crush-failure-domain"] = "osd";
2610 (*profile
)["k"] = "4";
2611 (*profile
)["m"] = "3";
2612 (*profile
)["c"] = "2";
2613 shec
->init(*profile
, &cerr
);
2616 EXPECT_EQ(7u, shec
->get_chunk_count());
2622 TEST(ErasureCodeShec
, get_data_chunk_count_1
)
2625 ErasureCodeShecTableCache tcache
;
2626 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2628 ErasureCodeShec::MULTIPLE
);
2629 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2630 (*profile
)["plugin"] = "shec";
2631 (*profile
)["technique"] = "";
2632 (*profile
)["crush-failure-domain"] = "osd";
2633 (*profile
)["k"] = "4";
2634 (*profile
)["m"] = "3";
2635 (*profile
)["c"] = "2";
2636 shec
->init(*profile
, &cerr
);
2638 //get_data_chunk_count
2639 EXPECT_EQ(4u, shec
->get_data_chunk_count());
2645 TEST(ErasureCodeShec
, get_chunk_size_1_2
)
2648 ErasureCodeShecTableCache tcache
;
2649 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2651 ErasureCodeShec::MULTIPLE
);
2652 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2653 (*profile
)["plugin"] = "shec";
2654 (*profile
)["technique"] = "";
2655 (*profile
)["crush-failure-domain"] = "osd";
2656 (*profile
)["k"] = "4";
2657 (*profile
)["m"] = "3";
2658 (*profile
)["c"] = "2";
2659 (*profile
)["w"] = "8";
2660 shec
->init(*profile
, &cerr
);
2662 //when there is no padding(128=k*w*4)
2663 EXPECT_EQ(32u, shec
->get_chunk_size(128));
2664 //when there is padding(126=k*w*4-2)
2665 EXPECT_EQ(32u, shec
->get_chunk_size(126));
2671 void* thread1(void* pParam
)
2673 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2674 set
<int> want_to_decode
;
2675 set
<int> available_chunks
;
2676 set
<int> minimum_chunks
;
2678 want_to_decode
.insert(0);
2679 want_to_decode
.insert(1);
2680 available_chunks
.insert(0);
2681 available_chunks
.insert(1);
2682 available_chunks
.insert(2);
2684 printf("*** thread loop start ***\n");
2686 while (g_flag
== 1) {
2687 shec
->_minimum_to_decode(want_to_decode
, available_chunks
, &minimum_chunks
);
2689 printf("*** thread loop end ***\n");
2694 void* thread2(void* pParam
)
2696 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2697 set
<int> want_to_decode
;
2698 map
<int, int> available_chunks
;
2699 set
<int> minimum_chunks
;
2701 want_to_decode
.insert(0);
2702 want_to_decode
.insert(1);
2703 available_chunks
[0] = 0;
2704 available_chunks
[1] = 1;
2705 available_chunks
[2] = 2;
2707 printf("*** thread loop start ***\n");
2709 while (g_flag
== 1) {
2710 shec
->minimum_to_decode_with_cost(want_to_decode
, available_chunks
,
2712 minimum_chunks
.clear();
2714 printf("*** thread loop end ***\n");
2719 void* thread3(void* pParam
)
2721 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2723 std::unique_ptr
<CrushWrapper
> crush
= std::make_unique
<CrushWrapper
>();
2725 crush
->set_type_name(2, "root");
2726 crush
->set_type_name(1, "host");
2727 crush
->set_type_name(0, "osd");
2730 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2732 crush
->set_item_name(rootno
, "default");
2734 map
< string
, string
> loc
;
2735 loc
["root"] = "default";
2740 for (int h
= 0; h
< num_host
; ++h
) {
2741 loc
["host"] = string("host-") + stringify(h
);
2742 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2743 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2744 string("osd.") + stringify(osd
), loc
);
2752 printf("*** thread loop start ***\n");
2754 while (g_flag
== 1) {
2755 sprintf(name
, "myrule%d", i
);
2756 shec
->create_rule(name
, *crush
, &ss
);
2759 printf("*** thread loop end ***\n");
2764 void* thread4(void* pParam
)
2766 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2769 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2770 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2771 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2772 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2774 set
<int> want_to_encode
;
2775 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2776 want_to_encode
.insert(i
);
2779 map
<int, bufferlist
> encoded
;
2781 printf("*** thread loop start ***\n");
2783 while (g_flag
== 1) {
2784 shec
->encode(want_to_encode
, in
, &encoded
);
2787 printf("*** thread loop end ***\n");
2792 void* thread5(void* pParam
)
2794 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2797 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2798 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2799 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2800 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2801 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//310
2803 set
<int> want_to_encode
;
2804 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2805 want_to_encode
.insert(i
);
2807 map
<int, bufferlist
> encoded
;
2808 shec
->encode(want_to_encode
, in
, &encoded
);
2810 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5 };
2811 map
<int, bufferlist
> decoded
;
2813 printf("*** thread loop start ***\n");
2815 while (g_flag
== 1) {
2816 shec
->_decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
2820 printf("*** thread loop end ***\n");