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"
33 void* thread1(void* pParam
);
34 void* thread2(void* pParam
);
35 void* thread3(void* pParam
);
36 void* thread4(void* pParam
);
37 void* thread5(void* pParam
);
39 static int g_flag
= 0;
41 TEST(ErasureCodeShec
, init_1
)
43 //all parameters are normal values
44 ErasureCodeShecTableCache tcache
;
45 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
47 ErasureCodeShec::MULTIPLE
);
48 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
49 (*profile
)["plugin"] = "shec";
50 (*profile
)["technique"] = "";
51 (*profile
)["ruleset-failure-domain"] = "osd";
52 (*profile
)["k"] = "4";
53 (*profile
)["m"] = "3";
54 (*profile
)["c"] = "2";
56 int r
= shec
->init(*profile
, &cerr
);
59 EXPECT_EQ(4, shec
->k
);
60 EXPECT_EQ(3, shec
->m
);
61 EXPECT_EQ(2, shec
->c
);
62 EXPECT_EQ(8, shec
->w
);
63 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
64 EXPECT_STREQ("default", shec
->ruleset_root
.c_str());
65 EXPECT_STREQ("osd", shec
->ruleset_failure_domain
.c_str());
66 EXPECT_TRUE(shec
->matrix
!= NULL
);
73 TEST(ErasureCodeShec
, init_2
)
75 //all parameters are normal values
76 ErasureCodeShecTableCache tcache
;
77 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
79 ErasureCodeShec::MULTIPLE
);
80 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
81 (*profile
)["plugin"] = "shec";
82 (*profile
)["technique"] = "";
83 (*profile
)["ruleset-root"] = "test";
84 (*profile
)["ruleset-failure-domain"] = "host";
85 (*profile
)["k"] = "4";
86 (*profile
)["m"] = "3";
87 (*profile
)["c"] = "2";
88 (*profile
)["w"] = "8";
90 int r
= shec
->init(*profile
, &cerr
);
93 EXPECT_EQ(4, shec
->k
);
94 EXPECT_EQ(3, shec
->m
);
95 EXPECT_EQ(2, shec
->c
);
96 EXPECT_EQ(8, shec
->w
);
97 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
98 EXPECT_STREQ("test", shec
->ruleset_root
.c_str());
99 EXPECT_STREQ("host", shec
->ruleset_failure_domain
.c_str());
100 EXPECT_TRUE(shec
->matrix
!= NULL
);
107 TEST(ErasureCodeShec
, init_3
)
109 //all parameters are normal values
110 ErasureCodeShecTableCache tcache
;
111 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
113 ErasureCodeShec::MULTIPLE
);
114 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
115 (*profile
)["plugin"] = "shec";
116 (*profile
)["technique"] = "";
117 (*profile
)["ruleset-failure-domain"] = "osd";
118 (*profile
)["k"] = "4";
119 (*profile
)["m"] = "3";
120 (*profile
)["c"] = "2";
121 (*profile
)["w"] = "16";
123 int r
= shec
->init(*profile
, &cerr
);
126 EXPECT_EQ(4, shec
->k
);
127 EXPECT_EQ(3, shec
->m
);
128 EXPECT_EQ(2, shec
->c
);
129 EXPECT_EQ(16, shec
->w
);
130 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
131 EXPECT_STREQ("default", shec
->ruleset_root
.c_str());
132 EXPECT_STREQ("osd", shec
->ruleset_failure_domain
.c_str());
133 EXPECT_TRUE(shec
->matrix
!= NULL
);
140 TEST(ErasureCodeShec
, init_4
)
142 //all parameters are normal values
143 ErasureCodeShecTableCache tcache
;
144 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
146 ErasureCodeShec::MULTIPLE
);
147 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
148 (*profile
)["plugin"] = "shec";
149 (*profile
)["technique"] = "";
150 (*profile
)["ruleset-failure-domain"] = "osd";
151 (*profile
)["k"] = "4";
152 (*profile
)["m"] = "3";
153 (*profile
)["c"] = "2";
154 (*profile
)["w"] = "32";
156 int r
= shec
->init(*profile
, &cerr
);
159 EXPECT_EQ(4, shec
->k
);
160 EXPECT_EQ(3, shec
->m
);
161 EXPECT_EQ(2, shec
->c
);
162 EXPECT_EQ(32, shec
->w
);
163 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
164 EXPECT_STREQ("default", shec
->ruleset_root
.c_str());
165 EXPECT_STREQ("osd", shec
->ruleset_failure_domain
.c_str());
166 EXPECT_TRUE(shec
->matrix
!= NULL
);
173 TEST(ErasureCodeShec
, init_5
)
175 ErasureCodeShecTableCache tcache
;
176 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
178 ErasureCodeShec::MULTIPLE
);
179 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
180 //plugin is not specified
181 (*profile
)["technique"] = "";
182 (*profile
)["ruleset-failure-domain"] = "osd";
183 (*profile
)["k"] = "4";
184 (*profile
)["m"] = "3";
185 (*profile
)["c"] = "2";
187 int r
= shec
->init(*profile
, &cerr
);
189 EXPECT_TRUE(shec
->matrix
!= NULL
);
196 TEST(ErasureCodeShec
, init_6
)
198 ErasureCodeShecTableCache tcache
;
199 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
201 ErasureCodeShec::MULTIPLE
);
202 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
203 (*profile
)["plugin"] = "jerasure"; //unexpected value
204 (*profile
)["technique"] = "";
205 (*profile
)["ruleset-failure-domain"] = "osd";
206 (*profile
)["k"] = "4";
207 (*profile
)["m"] = "3";
208 (*profile
)["c"] = "2";
210 int r
= shec
->init(*profile
, &cerr
);
212 EXPECT_TRUE(shec
->matrix
!= NULL
);
219 TEST(ErasureCodeShec
, init_7
)
221 ErasureCodeShecTableCache tcache
;
222 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
224 ErasureCodeShec::MULTIPLE
);
225 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
226 (*profile
)["plugin"] = "abc"; //unexpected value
227 (*profile
)["technique"] = "";
228 (*profile
)["ruleset-failure-domain"] = "osd";
229 (*profile
)["k"] = "4";
230 (*profile
)["m"] = "3";
231 (*profile
)["c"] = "2";
233 int r
= shec
->init(*profile
, &cerr
);
235 EXPECT_TRUE(shec
->matrix
!= NULL
);
242 TEST(ErasureCodeShec
, init_8
)
244 ErasureCodeShecTableCache tcache
;
245 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
247 ErasureCodeShec::MULTIPLE
);
248 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
249 (*profile
)["plugin"] = "shec";
250 (*profile
)["technique"] = "";
251 (*profile
)["ruleset-failure-domain"] = "osd";
252 (*profile
)["k"] = "4";
253 (*profile
)["m"] = "3";
254 (*profile
)["c"] = "2";
256 int r
= shec
->init(*profile
, &cerr
);
258 EXPECT_TRUE(shec
->matrix
!= NULL
);
265 TEST(ErasureCodeShec
, init_9
)
267 ErasureCodeShecTableCache tcache
;
268 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
270 ErasureCodeShec::MULTIPLE
);
271 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
272 (*profile
)["plugin"] = "shec";
273 (*profile
)["technique"] = "";
274 (*profile
)["ruleset-root"] = "abc"; //unexpected value
275 (*profile
)["ruleset-failure-domain"] = "osd";
276 (*profile
)["k"] = "4";
277 (*profile
)["m"] = "3";
278 (*profile
)["c"] = "2";
280 int r
= shec
->init(*profile
, &cerr
);
282 EXPECT_TRUE(shec
->matrix
!= NULL
);
289 TEST(ErasureCodeShec
, init_10
)
291 ErasureCodeShecTableCache tcache
;
292 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
294 ErasureCodeShec::MULTIPLE
);
295 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
296 (*profile
)["plugin"] = "shec";
297 (*profile
)["technique"] = "";
298 (*profile
)["ruleset-failure-domain"] = "abc"; //unexpected value
299 (*profile
)["k"] = "4";
300 (*profile
)["m"] = "3";
301 (*profile
)["c"] = "2";
303 int r
= shec
->init(*profile
, &cerr
);
305 EXPECT_TRUE(shec
->matrix
!= NULL
);
312 TEST(ErasureCodeShec
, init_11
)
314 ErasureCodeShecTableCache tcache
;
315 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
317 ErasureCodeShec::MULTIPLE
);
318 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
319 (*profile
)["plugin"] = "shec";
320 (*profile
)["technique"] = "abc"; //unexpected value
321 (*profile
)["ruleset-failure-domain"] = "osd";
322 (*profile
)["k"] = "4";
323 (*profile
)["m"] = "3";
324 (*profile
)["c"] = "2";
326 int r
= shec
->init(*profile
, &cerr
);
328 EXPECT_TRUE(shec
->matrix
!= NULL
);
335 TEST(ErasureCodeShec
, init_12
)
337 ErasureCodeShecTableCache tcache
;
338 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
340 ErasureCodeShec::MULTIPLE
);
341 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
342 (*profile
)["plugin"] = "shec";
343 (*profile
)["technique"] = "";
344 (*profile
)["ruleset-failure-domain"] = "osd";
345 (*profile
)["k"] = "-1"; //unexpected value
346 (*profile
)["m"] = "3";
347 (*profile
)["c"] = "2";
349 int r
= shec
->init(*profile
, &cerr
);
351 EXPECT_EQ(-EINVAL
, r
);
357 TEST(ErasureCodeShec
, init_13
)
359 ErasureCodeShecTableCache tcache
;
360 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
362 ErasureCodeShec::MULTIPLE
);
363 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
364 (*profile
)["plugin"] = "shec";
365 (*profile
)["technique"] = "";
366 (*profile
)["ruleset-failure-domain"] = "abc";
367 (*profile
)["k"] = "0.1"; //unexpected value
368 (*profile
)["m"] = "3";
369 (*profile
)["c"] = "2";
371 int r
= shec
->init(*profile
, &cerr
);
373 EXPECT_EQ(-EINVAL
, r
);
379 TEST(ErasureCodeShec
, init_14
)
381 ErasureCodeShecTableCache tcache
;
382 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
384 ErasureCodeShec::MULTIPLE
);
385 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
386 (*profile
)["plugin"] = "shec";
387 (*profile
)["technique"] = "";
388 (*profile
)["ruleset-failure-domain"] = "osd";
389 (*profile
)["k"] = "a"; //unexpected value
390 (*profile
)["m"] = "3";
391 (*profile
)["c"] = "2";
393 int r
= shec
->init(*profile
, &cerr
);
395 EXPECT_EQ(-EINVAL
, r
);
401 TEST(ErasureCodeShec
, init_15
)
403 ErasureCodeShecTableCache tcache
;
404 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
406 ErasureCodeShec::MULTIPLE
);
407 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
408 (*profile
)["plugin"] = "shec";
409 (*profile
)["technique"] = "";
410 (*profile
)["ruleset-failure-domain"] = "osd";
412 (*profile
)["m"] = "3";
413 (*profile
)["c"] = "2";
415 int r
= shec
->init(*profile
, &cerr
);
417 EXPECT_EQ(-EINVAL
, r
);
423 TEST(ErasureCodeShec
, init_16
)
425 ErasureCodeShecTableCache tcache
;
426 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
428 ErasureCodeShec::MULTIPLE
);
429 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
430 (*profile
)["plugin"] = "shec";
431 (*profile
)["technique"] = "";
432 (*profile
)["ruleset-failure-domain"] = "osd";
433 (*profile
)["k"] = "4";
434 (*profile
)["m"] = "-1"; //unexpected value
435 (*profile
)["c"] = "2";
437 int r
= shec
->init(*profile
, &cerr
);
439 EXPECT_EQ(-EINVAL
, r
);
445 TEST(ErasureCodeShec
, init_17
)
447 ErasureCodeShecTableCache tcache
;
448 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
450 ErasureCodeShec::MULTIPLE
);
451 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
452 (*profile
)["plugin"] = "shec";
453 (*profile
)["technique"] = "";
454 (*profile
)["ruleset-failure-domain"] = "osd";
455 (*profile
)["k"] = "4";
456 (*profile
)["m"] = "0.1"; //unexpected value
457 (*profile
)["c"] = "2";
459 int r
= shec
->init(*profile
, &cerr
);
461 EXPECT_EQ(-EINVAL
, r
);
467 TEST(ErasureCodeShec
, init_18
)
469 ErasureCodeShecTableCache tcache
;
470 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
472 ErasureCodeShec::MULTIPLE
);
473 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
474 (*profile
)["plugin"] = "shec";
475 (*profile
)["technique"] = "";
476 (*profile
)["ruleset-failure-domain"] = "osd";
477 (*profile
)["k"] = "4";
478 (*profile
)["m"] = "a"; //unexpected value
479 (*profile
)["c"] = "2";
481 int r
= shec
->init(*profile
, &cerr
);
483 EXPECT_EQ(-EINVAL
, r
);
489 TEST(ErasureCodeShec
, init_19
)
491 ErasureCodeShecTableCache tcache
;
492 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
494 ErasureCodeShec::MULTIPLE
);
495 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
496 (*profile
)["plugin"] = "shec";
497 (*profile
)["technique"] = "";
498 (*profile
)["ruleset-failure-domain"] = "osd";
499 (*profile
)["k"] = "4";
501 (*profile
)["c"] = "2";
503 int r
= shec
->init(*profile
, &cerr
);
505 EXPECT_EQ(-EINVAL
, r
);
511 TEST(ErasureCodeShec
, init_20
)
513 ErasureCodeShecTableCache tcache
;
514 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
516 ErasureCodeShec::MULTIPLE
);
517 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
518 (*profile
)["plugin"] = "shec";
519 (*profile
)["technique"] = "";
520 (*profile
)["ruleset-failure-domain"] = "osd";
521 (*profile
)["k"] = "4";
522 (*profile
)["m"] = "3";
523 (*profile
)["c"] = "-1"; //unexpected value
525 int r
= shec
->init(*profile
, &cerr
);
527 EXPECT_EQ(-EINVAL
, r
);
533 TEST(ErasureCodeShec
, init_21
)
535 ErasureCodeShecTableCache tcache
;
536 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
538 ErasureCodeShec::MULTIPLE
);
539 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
540 (*profile
)["plugin"] = "shec";
541 (*profile
)["technique"] = "";
542 (*profile
)["ruleset-failure-domain"] = "osd";
543 (*profile
)["k"] = "4";
544 (*profile
)["m"] = "3";
545 (*profile
)["c"] = "0.1"; //unexpected value
547 int r
= shec
->init(*profile
, &cerr
);
549 EXPECT_EQ(-EINVAL
, r
);
555 TEST(ErasureCodeShec
, init_22
)
557 ErasureCodeShecTableCache tcache
;
558 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
560 ErasureCodeShec::MULTIPLE
);
561 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
562 (*profile
)["plugin"] = "shec";
563 (*profile
)["technique"] = "";
564 (*profile
)["ruleset-failure-domain"] = "osd";
565 (*profile
)["k"] = "4";
566 (*profile
)["m"] = "3";
567 (*profile
)["c"] = "a"; //unexpected value
569 int r
= shec
->init(*profile
, &cerr
);
571 EXPECT_EQ(-EINVAL
, r
);
577 TEST(ErasureCodeShec
, init_23
)
579 ErasureCodeShecTableCache tcache
;
580 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
582 ErasureCodeShec::MULTIPLE
);
583 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
584 (*profile
)["plugin"] = "shec";
585 (*profile
)["technique"] = "";
586 (*profile
)["ruleset-failure-domain"] = "osd";
587 (*profile
)["k"] = "4";
588 (*profile
)["m"] = "3";
591 int r
= shec
->init(*profile
, &cerr
);
593 EXPECT_EQ(-EINVAL
, r
);
599 TEST(ErasureCodeShec
, init_24
)
601 ErasureCodeShecTableCache tcache
;
602 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
604 ErasureCodeShec::MULTIPLE
);
605 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
606 (*profile
)["plugin"] = "shec";
607 (*profile
)["technique"] = "";
608 (*profile
)["ruleset-failure-domain"] = "osd";
609 (*profile
)["k"] = "4";
610 (*profile
)["m"] = "3";
611 (*profile
)["c"] = "2";
612 (*profile
)["w"] = "1"; //unexpected value
614 int r
= shec
->init(*profile
, &cerr
);
616 EXPECT_TRUE(shec
->matrix
!= NULL
);
618 EXPECT_EQ(4, shec
->k
);
619 EXPECT_EQ(3, shec
->m
);
620 EXPECT_EQ(2, shec
->c
);
621 EXPECT_EQ(8, shec
->w
);
628 TEST(ErasureCodeShec
, init_25
)
630 ErasureCodeShecTableCache tcache
;
631 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
633 ErasureCodeShec::MULTIPLE
);
634 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
635 (*profile
)["plugin"] = "shec";
636 (*profile
)["technique"] = "";
637 (*profile
)["ruleset-failure-domain"] = "osd";
638 (*profile
)["k"] = "4";
639 (*profile
)["m"] = "3";
640 (*profile
)["c"] = "2";
641 (*profile
)["w"] = "-1"; //unexpected value
643 int r
= shec
->init(*profile
, &cerr
);
645 EXPECT_TRUE(shec
->matrix
!= NULL
);
647 EXPECT_EQ(4, shec
->k
);
648 EXPECT_EQ(3, shec
->m
);
649 EXPECT_EQ(2, shec
->c
);
650 EXPECT_EQ(8, shec
->w
);
657 TEST(ErasureCodeShec
, init_26
)
659 ErasureCodeShecTableCache tcache
;
660 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
662 ErasureCodeShec::MULTIPLE
);
663 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
664 (*profile
)["plugin"] = "shec";
665 (*profile
)["technique"] = "";
666 (*profile
)["ruleset-failure-domain"] = "osd";
667 (*profile
)["k"] = "4";
668 (*profile
)["m"] = "3";
669 (*profile
)["c"] = "2";
670 (*profile
)["w"] = "0.1"; //unexpected value
672 int r
= shec
->init(*profile
, &cerr
);
674 EXPECT_TRUE(shec
->matrix
!= NULL
);
676 EXPECT_EQ(4, shec
->k
);
677 EXPECT_EQ(3, shec
->m
);
678 EXPECT_EQ(2, shec
->c
);
679 EXPECT_EQ(8, shec
->w
);
686 TEST(ErasureCodeShec
, init_27
)
688 ErasureCodeShecTableCache tcache
;
689 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
691 ErasureCodeShec::MULTIPLE
);
692 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
693 (*profile
)["plugin"] = "shec";
694 (*profile
)["technique"] = "";
695 (*profile
)["ruleset-failure-domain"] = "osd";
696 (*profile
)["k"] = "4";
697 (*profile
)["m"] = "3";
698 (*profile
)["c"] = "2";
699 (*profile
)["w"] = "a"; //unexpected value
701 int r
= shec
->init(*profile
, &cerr
);
703 EXPECT_TRUE(shec
->matrix
!= NULL
);
705 EXPECT_EQ(4, shec
->k
);
706 EXPECT_EQ(3, shec
->m
);
707 EXPECT_EQ(2, shec
->c
);
708 EXPECT_EQ(8, shec
->w
);
715 TEST(ErasureCodeShec
, init_28
)
717 ErasureCodeShecTableCache tcache
;
718 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
720 ErasureCodeShec::MULTIPLE
);
721 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
722 (*profile
)["plugin"] = "shec";
723 (*profile
)["technique"] = "";
724 (*profile
)["ruleset-failure-domain"] = "osd";
725 (*profile
)["k"] = "4";
726 (*profile
)["m"] = "3";
727 (*profile
)["c"] = "10"; //c > m
729 int r
= shec
->init(*profile
, &cerr
);
731 EXPECT_EQ(-EINVAL
, r
);
737 TEST(ErasureCodeShec
, init_29
)
739 ErasureCodeShecTableCache tcache
;
740 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
742 ErasureCodeShec::MULTIPLE
);
743 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
744 (*profile
)["plugin"] = "shec";
745 (*profile
)["technique"] = "";
746 (*profile
)["ruleset-failure-domain"] = "osd";
751 int r
= shec
->init(*profile
, &cerr
);
753 EXPECT_TRUE(shec
->matrix
!= NULL
);
755 //k,m,c are default values
756 EXPECT_EQ(4, shec
->k
);
757 EXPECT_EQ(3, shec
->m
);
758 EXPECT_EQ(2, shec
->c
);
764 TEST(ErasureCodeShec
, init_30
)
766 ErasureCodeShecTableCache tcache
;
767 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
769 ErasureCodeShec::MULTIPLE
);
770 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
771 (*profile
)["plugin"] = "shec";
772 (*profile
)["technique"] = "";
773 (*profile
)["ruleset-failure-domain"] = "osd";
774 (*profile
)["k"] = "12";
775 (*profile
)["m"] = "8";
776 (*profile
)["c"] = "8";
778 int r
= shec
->init(*profile
, &cerr
);
780 EXPECT_TRUE(shec
->matrix
!= NULL
);
782 EXPECT_EQ(12, shec
->k
);
783 EXPECT_EQ(8, shec
->m
);
784 EXPECT_EQ(8, shec
->c
);
790 TEST(ErasureCodeShec
, init_31
)
792 ErasureCodeShecTableCache tcache
;
793 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
795 ErasureCodeShec::MULTIPLE
);
796 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
797 (*profile
)["plugin"] = "shec";
798 (*profile
)["technique"] = "";
799 (*profile
)["ruleset-failure-domain"] = "osd";
800 (*profile
)["k"] = "13";
801 (*profile
)["m"] = "7";
802 (*profile
)["c"] = "7";
804 int r
= shec
->init(*profile
, &cerr
);
806 EXPECT_EQ(-EINVAL
, r
);
812 TEST(ErasureCodeShec
, init_32
)
814 ErasureCodeShecTableCache tcache
;
815 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
817 ErasureCodeShec::MULTIPLE
);
818 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
819 (*profile
)["plugin"] = "shec";
820 (*profile
)["technique"] = "";
821 (*profile
)["ruleset-failure-domain"] = "osd";
822 (*profile
)["k"] = "7";
823 (*profile
)["m"] = "13";
824 (*profile
)["c"] = "13";
826 int r
= shec
->init(*profile
, &cerr
);
828 EXPECT_EQ(-EINVAL
, r
);
834 TEST(ErasureCodeShec
, init_33
)
836 ErasureCodeShecTableCache tcache
;
837 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
839 ErasureCodeShec::MULTIPLE
);
840 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
841 (*profile
)["plugin"] = "shec";
842 (*profile
)["technique"] = "";
843 (*profile
)["ruleset-failure-domain"] = "osd";
844 (*profile
)["k"] = "12";
845 (*profile
)["m"] = "9";
846 (*profile
)["c"] = "8";
848 int r
= shec
->init(*profile
, &cerr
);
850 EXPECT_EQ(-EINVAL
, r
);
856 TEST(ErasureCodeShec
, init_34
)
858 ErasureCodeShecTableCache tcache
;
859 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
861 ErasureCodeShec::MULTIPLE
);
862 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
863 (*profile
)["plugin"] = "shec";
864 (*profile
)["technique"] = "";
865 (*profile
)["ruleset-failure-domain"] = "osd";
866 (*profile
)["k"] = "8";
867 (*profile
)["m"] = "12";
868 (*profile
)["c"] = "12";
870 int r
= shec
->init(*profile
, &cerr
);
872 EXPECT_EQ(-EINVAL
, r
);
878 TEST(ErasureCodeShec
, init2_4
)
880 //all parameters are normal values
881 ErasureCodeShecTableCache tcache
;
882 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
884 ErasureCodeShec::MULTIPLE
);
885 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
886 (*profile
)["plugin"] = "shec";
887 (*profile
)["technique"] = "";
888 (*profile
)["ruleset-failure-domain"] = "osd";
889 (*profile
)["k"] = "4";
890 (*profile
)["m"] = "3";
891 (*profile
)["c"] = "2";
892 shec
->init(*profile
, &cerr
);
893 int r
= shec
->init(*profile
, &cerr
); //init executed twice
896 EXPECT_EQ(4, shec
->k
);
897 EXPECT_EQ(3, shec
->m
);
898 EXPECT_EQ(2, shec
->c
);
899 EXPECT_EQ(8, shec
->w
);
900 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
901 EXPECT_STREQ("default", shec
->ruleset_root
.c_str());
902 EXPECT_STREQ("osd", shec
->ruleset_failure_domain
.c_str());
903 EXPECT_TRUE(shec
->matrix
!= NULL
);
910 TEST(ErasureCodeShec
, init2_5
)
912 //all parameters are normal values
913 ErasureCodeShecTableCache tcache
;
914 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
916 ErasureCodeShec::MULTIPLE
);
917 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
918 ErasureCodeProfile
*profile2
= new ErasureCodeProfile();
919 (*profile
)["plugin"] = "shec";
920 (*profile
)["technique"] = "";
921 (*profile
)["ruleset-failure-domain"] = "host";
922 (*profile
)["k"] = "10";
923 (*profile
)["m"] = "6";
924 (*profile
)["c"] = "5";
925 (*profile
)["w"] = "16";
927 int r
= shec
->init(*profile
, &cerr
);
930 (*profile2
)["plugin"] = "shec";
931 (*profile2
)["technique"] = "";
932 (*profile2
)["ruleset-failure-domain"] = "osd";
933 (*profile2
)["k"] = "4";
934 (*profile2
)["m"] = "3";
935 (*profile2
)["c"] = "2";
936 shec
->init(*profile2
, &cerr
);
938 EXPECT_EQ(4, shec
->k
);
939 EXPECT_EQ(3, shec
->m
);
940 EXPECT_EQ(2, shec
->c
);
941 EXPECT_EQ(8, shec
->w
);
942 EXPECT_EQ(ErasureCodeShec::MULTIPLE
, shec
->technique
);
943 EXPECT_STREQ("default", shec
->ruleset_root
.c_str());
944 EXPECT_STREQ("osd", shec
->ruleset_failure_domain
.c_str());
945 EXPECT_TRUE(shec
->matrix
!= NULL
);
952 TEST(ErasureCodeShec
, minimum_to_decode_8
)
955 ErasureCodeShecTableCache tcache
;
956 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
958 ErasureCodeShec::MULTIPLE
);
959 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
960 (*profile
)["plugin"] = "shec";
961 (*profile
)["technique"] = "";
962 (*profile
)["ruleset-failure-domain"] = "osd";
963 (*profile
)["k"] = "4";
964 (*profile
)["m"] = "3";
965 (*profile
)["c"] = "2";
966 shec
->init(*profile
, &cerr
);
969 set
<int> want_to_decode
;
970 set
<int> available_chunks
;
971 set
<int> minimum_chunks
;
973 for (int i
= 0; i
< 8; ++i
) {
974 want_to_decode
.insert(i
);
976 for (int i
= 0; i
< 5; ++i
) {
977 available_chunks
.insert(i
);
980 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
982 EXPECT_EQ(-EINVAL
, r
);
988 TEST(ErasureCodeShec
, minimum_to_decode_9
)
991 ErasureCodeShecTableCache tcache
;
992 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
994 ErasureCodeShec::MULTIPLE
);
995 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
996 (*profile
)["plugin"] = "shec";
997 (*profile
)["technique"] = "";
998 (*profile
)["ruleset-failure-domain"] = "osd";
999 (*profile
)["k"] = "4";
1000 (*profile
)["m"] = "3";
1001 (*profile
)["c"] = "2";
1002 shec
->init(*profile
, &cerr
);
1005 set
<int> want_to_decode
;
1006 set
<int> available_chunks
;
1007 set
<int> minimum_chunks
;
1009 for (int i
= 0; i
< 4; ++i
) {
1010 want_to_decode
.insert(i
);
1012 for (int i
= 0; i
< 8; ++i
) {
1013 available_chunks
.insert(i
);
1016 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
1018 EXPECT_EQ(-EINVAL
, r
);
1024 TEST(ErasureCodeShec
, minimum_to_decode_10
)
1027 ErasureCodeShecTableCache tcache
;
1028 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1030 ErasureCodeShec::MULTIPLE
);
1031 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1032 (*profile
)["plugin"] = "shec";
1033 (*profile
)["technique"] = "";
1034 (*profile
)["ruleset-failure-domain"] = "osd";
1035 (*profile
)["k"] = "4";
1036 (*profile
)["m"] = "3";
1037 (*profile
)["c"] = "2";
1038 shec
->init(*profile
, &cerr
);
1041 set
<int> want_to_decode
;
1042 set
<int> available_chunks
;
1043 set
<int> minimum_chunks
;
1045 for (int i
= 0; i
< 7; ++i
) {
1046 want_to_decode
.insert(i
);
1048 for (int i
= 4; i
< 7; ++i
) {
1049 available_chunks
.insert(i
);
1052 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
1060 TEST(ErasureCodeShec
, minimum_to_decode_11
)
1063 ErasureCodeShecTableCache tcache
;
1064 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1066 ErasureCodeShec::MULTIPLE
);
1067 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1068 (*profile
)["plugin"] = "shec";
1069 (*profile
)["technique"] = "";
1070 (*profile
)["ruleset-failure-domain"] = "osd";
1071 (*profile
)["k"] = "4";
1072 (*profile
)["m"] = "3";
1073 (*profile
)["c"] = "2";
1074 shec
->init(*profile
, &cerr
);
1077 set
<int> want_to_decode
;
1078 set
<int> available_chunks
;
1079 set
<int> minimum_chunks
;
1081 for (int i
= 0; i
< 5; ++i
) {
1082 want_to_decode
.insert(i
);
1084 for (int i
= 4; i
< 7; ++i
) {
1085 available_chunks
.insert(i
);
1088 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
1096 TEST(ErasureCodeShec
, minimum_to_decode_12
)
1099 ErasureCodeShecTableCache tcache
;
1100 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1102 ErasureCodeShec::MULTIPLE
);
1103 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1104 (*profile
)["plugin"] = "shec";
1105 (*profile
)["technique"] = "";
1106 (*profile
)["ruleset-failure-domain"] = "osd";
1107 (*profile
)["k"] = "4";
1108 (*profile
)["m"] = "3";
1109 (*profile
)["c"] = "2";
1110 shec
->init(*profile
, &cerr
);
1113 set
<int> want_to_decode
;
1114 set
<int> available_chunks
;
1115 //minimum_chunks is NULL
1117 for (int i
= 0; i
< 7; ++i
) {
1118 want_to_decode
.insert(i
);
1119 available_chunks
.insert(i
);
1122 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
, NULL
);
1123 EXPECT_EQ(-EINVAL
, r
);
1129 TEST(ErasureCodeShec
, minimum_to_decode_13
)
1132 ErasureCodeShecTableCache tcache
;
1133 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1135 ErasureCodeShec::MULTIPLE
);
1136 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1137 (*profile
)["plugin"] = "shec";
1138 (*profile
)["technique"] = "";
1139 (*profile
)["ruleset-failure-domain"] = "osd";
1140 (*profile
)["k"] = "4";
1141 (*profile
)["m"] = "3";
1142 (*profile
)["c"] = "2";
1143 shec
->init(*profile
, &cerr
);
1146 set
<int> want_to_decode
;
1147 set
<int> available_chunks
;
1148 set
<int> minimum_chunks
, minimum
;
1150 for (int i
= 0; i
< 7; ++i
) {
1151 want_to_decode
.insert(i
);
1152 available_chunks
.insert(i
);
1154 shec
->minimum_to_decode(want_to_decode
, available_chunks
, &minimum_chunks
);
1155 minimum
= minimum_chunks
; //normal value
1156 for (int i
= 100; i
< 120; ++i
) {
1157 minimum_chunks
.insert(i
); //insert extra data
1160 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
1162 EXPECT_TRUE(shec
->matrix
!= NULL
);
1164 EXPECT_EQ(minimum
, minimum_chunks
);
1170 TEST(ErasureCodeShec
, minimum_to_decode2_1
)
1173 ErasureCodeShecTableCache tcache
;
1174 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1176 ErasureCodeShec::MULTIPLE
);
1177 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1178 (*profile
)["plugin"] = "shec";
1179 (*profile
)["technique"] = "";
1180 (*profile
)["ruleset-failure-domain"] = "osd";
1181 (*profile
)["k"] = "4";
1182 (*profile
)["m"] = "3";
1183 (*profile
)["c"] = "2";
1184 shec
->init(*profile
, &cerr
);
1187 set
<int> want_to_decode
;
1188 set
<int> available_chunks
;
1189 set
<int> minimum_chunks
;
1191 want_to_decode
.insert(0);
1192 available_chunks
.insert(0);
1193 available_chunks
.insert(1);
1194 available_chunks
.insert(2);
1196 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
1198 EXPECT_TRUE(shec
->matrix
!= NULL
);
1200 EXPECT_TRUE(minimum_chunks
.size());
1206 TEST(ErasureCodeShec
, minimum_to_decode2_3
)
1209 ErasureCodeShecTableCache tcache
;
1210 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1212 ErasureCodeShec::MULTIPLE
);
1213 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1214 (*profile
)["plugin"] = "shec";
1215 (*profile
)["technique"] = "";
1216 (*profile
)["ruleset-failure-domain"] = "osd";
1217 (*profile
)["k"] = "4";
1218 (*profile
)["m"] = "3";
1219 (*profile
)["c"] = "2";
1220 shec
->init(*profile
, &cerr
);
1223 set
<int> want_to_decode
;
1224 set
<int> available_chunks
;
1225 set
<int> minimum_chunks
;
1227 want_to_decode
.insert(0);
1228 want_to_decode
.insert(2);
1229 available_chunks
.insert(0);
1230 available_chunks
.insert(1);
1231 available_chunks
.insert(2);
1232 available_chunks
.insert(3);
1236 pthread_create(&tid
, NULL
, thread1
, shec
);
1237 while (g_flag
== 0) {
1241 printf("*** test start ***\n");
1242 int r
= shec
->minimum_to_decode(want_to_decode
, available_chunks
,
1244 EXPECT_TRUE(shec
->matrix
!= NULL
);
1246 EXPECT_EQ(want_to_decode
, minimum_chunks
);
1247 printf("*** test end ***\n");
1249 pthread_join(tid
, NULL
);
1255 TEST(ErasureCodeShec
, minimum_to_decode_with_cost_1
)
1258 ErasureCodeShecTableCache tcache
;
1259 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1261 ErasureCodeShec::MULTIPLE
);
1262 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1263 (*profile
)["plugin"] = "shec";
1264 (*profile
)["technique"] = "";
1265 (*profile
)["ruleset-failure-domain"] = "osd";
1266 (*profile
)["k"] = "4";
1267 (*profile
)["m"] = "3";
1268 (*profile
)["c"] = "2";
1269 shec
->init(*profile
, &cerr
);
1271 //minimum_to_decode_with_cost
1272 set
<int> want_to_decode
;
1273 map
<int, int> available_chunks
;
1274 set
<int> minimum_chunks
;
1276 for (int i
= 0; i
< 7; ++i
) {
1277 want_to_decode
.insert(i
);
1278 available_chunks
.insert(make_pair(i
, i
));
1281 int r
= shec
->minimum_to_decode_with_cost(want_to_decode
, available_chunks
,
1283 EXPECT_TRUE(shec
->matrix
!= NULL
);
1285 EXPECT_TRUE(minimum_chunks
.size());
1291 TEST(ErasureCodeShec
, minimum_to_decode_with_cost_2_3
)
1294 ErasureCodeShecTableCache tcache
;
1295 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1297 ErasureCodeShec::MULTIPLE
);
1298 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1299 (*profile
)["plugin"] = "shec";
1300 (*profile
)["technique"] = "";
1301 (*profile
)["ruleset-failure-domain"] = "osd";
1302 (*profile
)["k"] = "4";
1303 (*profile
)["m"] = "3";
1304 (*profile
)["c"] = "2";
1305 shec
->init(*profile
, &cerr
);
1307 //minimum_to_decode_with_cost
1308 set
<int> want_to_decode
;
1309 map
<int, int> available_chunks
;
1310 set
<int> minimum_chunks
;
1312 want_to_decode
.insert(0);
1313 want_to_decode
.insert(2);
1314 available_chunks
[0] = 0;
1315 available_chunks
[1] = 1;
1316 available_chunks
[2] = 2;
1317 available_chunks
[3] = 3;
1321 pthread_create(&tid
, NULL
, thread2
, shec
);
1322 while (g_flag
== 0) {
1326 printf("*** test start ***\n");
1327 int r
= shec
->minimum_to_decode_with_cost(want_to_decode
, available_chunks
,
1329 EXPECT_TRUE(shec
->matrix
!= NULL
);
1331 EXPECT_EQ(want_to_decode
, minimum_chunks
);
1332 printf("*** test end ***\n");
1334 pthread_join(tid
, NULL
);
1340 TEST(ErasureCodeShec
, encode_1
)
1343 ErasureCodeShecTableCache tcache
;
1344 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1346 ErasureCodeShec::MULTIPLE
);
1347 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1348 (*profile
)["plugin"] = "shec";
1349 (*profile
)["technique"] = "";
1350 (*profile
)["ruleset-failure-domain"] = "osd";
1351 (*profile
)["k"] = "4";
1352 (*profile
)["m"] = "3";
1353 (*profile
)["c"] = "2";
1354 shec
->init(*profile
, &cerr
);
1358 set
<int> want_to_encode
;
1359 map
<int, bufferlist
> encoded
;
1361 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1362 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1365 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1366 want_to_encode
.insert(i
);
1369 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1371 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1372 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1375 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1376 map
<int, bufferlist
> decoded
;
1378 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2),
1381 EXPECT_TRUE(shec
->matrix
!= NULL
);
1383 EXPECT_EQ(2u, decoded
.size());
1384 EXPECT_EQ(32u, decoded
[0].length());
1386 bufferlist out1
, out2
, usable
;
1388 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1389 out1
.append(encoded
[i
]);
1392 r
= shec
->decode_concat(encoded
, &out2
);
1393 usable
.substr_of(out2
, 0, in
.length());
1394 EXPECT_FALSE(out1
== in
);
1395 EXPECT_TRUE(usable
== in
);
1401 TEST(ErasureCodeShec
, encode_2
)
1404 ErasureCodeShecTableCache tcache
;
1405 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1407 ErasureCodeShec::MULTIPLE
);
1408 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1409 (*profile
)["plugin"] = "shec";
1410 (*profile
)["technique"] = "";
1411 (*profile
)["ruleset-failure-domain"] = "osd";
1412 (*profile
)["k"] = "4";
1413 (*profile
)["m"] = "3";
1414 (*profile
)["c"] = "2";
1415 shec
->init(*profile
, &cerr
);
1419 set
<int> want_to_encode
;
1420 map
<int, bufferlist
> encoded
;
1422 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1423 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1425 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1426 want_to_encode
.insert(i
);
1429 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1431 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1432 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1435 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1436 map
<int, bufferlist
> decoded
;
1437 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1439 EXPECT_TRUE(shec
->matrix
!= NULL
);
1441 EXPECT_EQ(2u, decoded
.size());
1442 EXPECT_EQ(32u, decoded
[0].length());
1444 bufferlist out1
, out2
, usable
;
1446 for (unsigned int i
= 0; i
< encoded
.size(); ++i
)
1447 out1
.append(encoded
[i
]);
1449 shec
->decode_concat(encoded
, &out2
);
1450 usable
.substr_of(out2
, 0, in
.length());
1451 EXPECT_FALSE(out1
== in
);
1452 EXPECT_TRUE(usable
== in
);
1458 TEST(ErasureCodeShec
, encode_3
)
1460 ErasureCodeShecTableCache tcache
;
1461 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1463 ErasureCodeShec::MULTIPLE
);
1464 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1465 (*profile
)["plugin"] = "shec";
1466 (*profile
)["technique"] = "";
1467 (*profile
)["ruleset-failure-domain"] = "osd";
1468 (*profile
)["k"] = "4";
1469 (*profile
)["m"] = "3";
1470 (*profile
)["c"] = "2";
1471 shec
->init(*profile
, &cerr
);
1474 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1475 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1477 set
<int> want_to_encode
;
1478 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1479 want_to_encode
.insert(i
);
1481 want_to_encode
.insert(10);
1482 want_to_encode
.insert(11);
1483 map
<int, bufferlist
> encoded
;
1484 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1486 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1487 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1490 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1491 map
<int, bufferlist
> decoded
;
1492 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1494 EXPECT_TRUE(shec
->matrix
!= NULL
);
1496 EXPECT_EQ(2u, decoded
.size());
1497 EXPECT_EQ(shec
->get_chunk_size(in
.length()), decoded
[0].length());
1499 bufferlist out1
, out2
, usable
;
1501 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1502 out1
.append(encoded
[i
]);
1505 shec
->decode_concat(encoded
, &out2
);
1506 usable
.substr_of(out2
, 0, in
.length());
1507 EXPECT_FALSE(out1
== in
);
1508 EXPECT_TRUE(usable
== in
);
1514 TEST(ErasureCodeShec
, encode_4
)
1517 ErasureCodeShecTableCache tcache
;
1518 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1520 ErasureCodeShec::MULTIPLE
);
1521 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1522 (*profile
)["plugin"] = "shec";
1523 (*profile
)["technique"] = "";
1524 (*profile
)["ruleset-failure-domain"] = "osd";
1525 (*profile
)["k"] = "4";
1526 (*profile
)["m"] = "3";
1527 (*profile
)["c"] = "2";
1528 shec
->init(*profile
, &cerr
);
1532 set
<int> want_to_encode
;
1533 map
<int, bufferlist
> encoded
;
1535 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1536 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1538 for (unsigned int i
= 0; i
< shec
->get_chunk_count() - 1; ++i
) {
1539 want_to_encode
.insert(i
);
1541 want_to_encode
.insert(100);
1543 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1545 EXPECT_EQ(shec
->get_chunk_count()-1, encoded
.size());
1546 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1549 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1550 map
<int, bufferlist
> decoded
;
1551 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1553 EXPECT_TRUE(shec
->matrix
!= NULL
);
1555 EXPECT_EQ(2u, decoded
.size());
1556 EXPECT_EQ(shec
->get_chunk_size(in
.length()), decoded
[0].length());
1558 bufferlist out1
, out2
, usable
;
1560 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1561 out1
.append(encoded
[i
]);
1564 shec
->decode_concat(encoded
, &out2
);
1565 usable
.substr_of(out2
, 0, in
.length());
1566 EXPECT_FALSE(out1
== in
);
1567 EXPECT_TRUE(usable
== in
);
1573 TEST(ErasureCodeShec
, encode_8
)
1576 ErasureCodeShecTableCache tcache
;
1577 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1579 ErasureCodeShec::MULTIPLE
);
1580 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1581 (*profile
)["plugin"] = "shec";
1582 (*profile
)["technique"] = "";
1583 (*profile
)["ruleset-failure-domain"] = "osd";
1584 (*profile
)["k"] = "4";
1585 (*profile
)["m"] = "3";
1586 (*profile
)["c"] = "2";
1587 shec
->init(*profile
, &cerr
);
1591 set
<int> want_to_encode
;
1593 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1594 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1596 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1597 want_to_encode
.insert(i
);
1600 int r
= shec
->encode(want_to_encode
, in
, NULL
); //encoded = NULL
1601 EXPECT_EQ(-EINVAL
, r
);
1607 TEST(ErasureCodeShec
, encode_9
)
1610 ErasureCodeShecTableCache tcache
;
1611 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1613 ErasureCodeShec::MULTIPLE
);
1614 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1615 (*profile
)["plugin"] = "shec";
1616 (*profile
)["technique"] = "";
1617 (*profile
)["ruleset-failure-domain"] = "osd";
1618 (*profile
)["k"] = "4";
1619 (*profile
)["m"] = "3";
1620 (*profile
)["c"] = "2";
1621 shec
->init(*profile
, &cerr
);
1625 set
<int> want_to_encode
;
1626 map
<int, bufferlist
> encoded
;
1628 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1629 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1631 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1632 want_to_encode
.insert(i
);
1634 for (int i
= 0; i
< 100; ++i
) {
1635 encoded
[i
].append("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
1638 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1639 EXPECT_EQ(-EINVAL
, r
);
1645 TEST(ErasureCodeShec
, encode2_1
)
1648 ErasureCodeShecTableCache tcache
;
1649 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1651 ErasureCodeShec::MULTIPLE
);
1652 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1653 (*profile
)["plugin"] = "shec";
1654 (*profile
)["technique"] = "";
1655 (*profile
)["ruleset-failure-domain"] = "osd";
1656 (*profile
)["k"] = "4";
1657 (*profile
)["m"] = "3";
1658 (*profile
)["c"] = "2";
1659 shec
->init(*profile
, &cerr
);
1663 set
<int> want_to_encode
;
1664 map
<int, bufferlist
> encoded
;
1666 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1667 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1670 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1671 want_to_encode
.insert(i
);
1674 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1676 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1677 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1680 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1681 map
<int, bufferlist
> decoded
;
1682 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1684 EXPECT_TRUE(shec
->matrix
!= NULL
);
1686 EXPECT_EQ(2u, decoded
.size());
1687 EXPECT_EQ(32u, decoded
[0].length());
1689 bufferlist out1
, out2
, usable
;
1691 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1692 out1
.append(encoded
[i
]);
1695 shec
->decode_concat(encoded
, &out2
);
1696 usable
.substr_of(out2
, 0, in
.length());
1697 EXPECT_FALSE(out1
== in
);
1698 EXPECT_TRUE(usable
== in
);
1704 TEST(ErasureCodeShec
, encode2_3
)
1707 ErasureCodeShecTableCache tcache
;
1708 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1710 ErasureCodeShec::MULTIPLE
);
1711 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1712 (*profile
)["plugin"] = "shec";
1713 (*profile
)["technique"] = "";
1714 (*profile
)["ruleset-failure-domain"] = "osd";
1715 (*profile
)["k"] = "4";
1716 (*profile
)["m"] = "3";
1717 (*profile
)["c"] = "2";
1718 shec
->init(*profile
, &cerr
);
1722 set
<int> want_to_encode
;
1723 map
<int, bufferlist
> encoded
;
1725 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1726 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1729 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1730 want_to_encode
.insert(i
);
1735 pthread_create(&tid
, NULL
, thread4
, shec
);
1736 while (g_flag
== 0) {
1740 printf("*** test start ***\n");
1741 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1743 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1744 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1745 printf("*** test end ***\n");
1747 pthread_join(tid
, NULL
);
1750 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1751 map
<int, bufferlist
> decoded
;
1753 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
1755 EXPECT_TRUE(shec
->matrix
!= NULL
);
1757 EXPECT_EQ(2u, decoded
.size());
1758 EXPECT_EQ(32u, decoded
[0].length());
1760 bufferlist out1
, out2
, usable
;
1762 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1763 out1
.append(encoded
[i
]);
1766 shec
->decode_concat(encoded
, &out2
);
1767 usable
.substr_of(out2
, 0, in
.length());
1768 EXPECT_FALSE(out1
== in
);
1769 EXPECT_TRUE(usable
== in
);
1775 TEST(ErasureCodeShec
, decode_1
)
1778 ErasureCodeShecTableCache tcache
;
1779 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1781 ErasureCodeShec::MULTIPLE
);
1782 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1783 (*profile
)["plugin"] = "shec";
1784 (*profile
)["technique"] = "";
1785 (*profile
)["ruleset-failure-domain"] = "osd";
1786 (*profile
)["k"] = "4";
1787 (*profile
)["m"] = "3";
1788 (*profile
)["c"] = "2";
1789 shec
->init(*profile
, &cerr
);
1793 set
<int> want_to_encode
;
1794 map
<int, bufferlist
> encoded
;
1796 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1797 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1798 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
1799 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
1801 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1802 want_to_encode
.insert(i
);
1805 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1807 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1808 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1810 // all chunks are available
1812 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
1813 map
<int, bufferlist
> decoded
;
1815 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 7), encoded
,
1817 EXPECT_TRUE(shec
->matrix
!= NULL
);
1819 EXPECT_EQ(7u, decoded
.size());
1823 unsigned int c_size
= shec
->get_chunk_size(in
.length());
1824 for (unsigned int i
= 0; i
< shec
->get_data_chunk_count(); ++i
) {
1826 EXPECT_EQ(c_size
, decoded
[i
].length());
1827 if ( c_size
* (i
+1) <= in
.length() ) {
1828 usable
.substr_of(in
, c_size
* i
, c_size
);
1829 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), c_size
);
1831 usable
.substr_of(in
, c_size
* i
, in
.length() % c_size
);
1832 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), in
.length() % c_size
);
1841 TEST(ErasureCodeShec
, decode_8
)
1844 ErasureCodeShecTableCache tcache
;
1845 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1847 ErasureCodeShec::MULTIPLE
);
1848 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1849 (*profile
)["plugin"] = "shec";
1850 (*profile
)["technique"] = "";
1851 (*profile
)["ruleset-failure-domain"] = "osd";
1852 (*profile
)["k"] = "4";
1853 (*profile
)["m"] = "3";
1854 (*profile
)["c"] = "2";
1855 shec
->init(*profile
, &cerr
);
1859 set
<int> want_to_encode
;
1860 map
<int, bufferlist
> encoded
;
1862 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1863 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1864 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
1865 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
1867 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1868 want_to_encode
.insert(i
);
1871 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1873 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1874 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1876 // all chunks are available
1878 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; //more than k+m
1879 map
<int, bufferlist
> decoded
;
1881 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 8), encoded
,
1884 EXPECT_EQ(7u, decoded
.size());
1885 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1889 unsigned int c_size
= shec
->get_chunk_size(in
.length());
1890 for (unsigned int i
= 0; i
< shec
->get_data_chunk_count(); ++i
) {
1892 EXPECT_EQ(c_size
, decoded
[i
].length());
1893 if ( c_size
* (i
+1) <= in
.length() ) {
1894 usable
.substr_of(in
, c_size
* i
, c_size
);
1895 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), c_size
);
1897 usable
.substr_of(in
, c_size
* i
, in
.length() % c_size
);
1898 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), in
.length() % c_size
);
1907 TEST(ErasureCodeShec
, decode_9
)
1910 ErasureCodeShecTableCache tcache
;
1911 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1913 ErasureCodeShec::MULTIPLE
);
1914 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1915 (*profile
)["plugin"] = "shec";
1916 (*profile
)["technique"] = "";
1917 (*profile
)["ruleset-failure-domain"] = "osd";
1918 (*profile
)["k"] = "4";
1919 (*profile
)["m"] = "3";
1920 (*profile
)["c"] = "2";
1921 shec
->init(*profile
, &cerr
);
1925 set
<int> want_to_encode
;
1926 map
<int, bufferlist
> encoded
;
1928 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
1929 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
1930 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
1931 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
1933 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
1934 want_to_encode
.insert(i
);
1937 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
1939 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
1940 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
1942 // all chunks are available
1944 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
1945 map
<int, bufferlist
> decoded
;
1952 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 10), encoded
,
1954 EXPECT_TRUE(shec
->matrix
!= NULL
);
1956 EXPECT_EQ(7u, decoded
.size());
1957 EXPECT_EQ(shec
->get_chunk_size(in
.length()), decoded
[0].length());
1959 bufferlist out1
, usable
;
1961 for (unsigned int i
= 0; i
< encoded
.size(); ++i
) {
1962 out1
.append(encoded
[i
]);
1964 EXPECT_FALSE(out1
== in
);
1965 //usable is "decoded"
1967 unsigned int c_size
= shec
->get_chunk_size(in
.length());
1968 for (unsigned int i
= 0; i
< shec
->get_data_chunk_count(); ++i
) {
1970 EXPECT_EQ(c_size
, decoded
[i
].length());
1971 if ( c_size
* (i
+1) <= in
.length() ) {
1972 usable
.substr_of(in
, c_size
* i
, c_size
);
1973 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), c_size
);
1975 usable
.substr_of(in
, c_size
* i
, in
.length() % c_size
);
1976 cmp
= memcmp(decoded
[i
].c_str(), usable
.c_str(), in
.length() % c_size
);
1985 TEST(ErasureCodeShec
, decode_10
)
1988 ErasureCodeShecTableCache tcache
;
1989 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
1991 ErasureCodeShec::MULTIPLE
);
1992 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
1993 (*profile
)["plugin"] = "shec";
1994 (*profile
)["technique"] = "";
1995 (*profile
)["ruleset-failure-domain"] = "osd";
1996 (*profile
)["k"] = "4";
1997 (*profile
)["m"] = "3";
1998 (*profile
)["c"] = "2";
1999 shec
->init(*profile
, &cerr
);
2003 set
<int> want_to_encode
;
2004 map
<int, bufferlist
> encoded
;
2006 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2007 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2008 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2009 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2011 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2012 want_to_encode
.insert(i
);
2015 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2017 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2018 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2021 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 }; //more than k+m
2022 map
<int, bufferlist
> decoded
, inchunks
;
2024 for ( unsigned int i
= 0; i
< 3; ++i
) {
2025 inchunks
.insert(make_pair(i
, encoded
[i
]));
2028 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 7), inchunks
,
2036 TEST(ErasureCodeShec
, decode_11
)
2039 ErasureCodeShecTableCache tcache
;
2040 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2042 ErasureCodeShec::MULTIPLE
);
2043 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2044 (*profile
)["plugin"] = "shec";
2045 (*profile
)["technique"] = "";
2046 (*profile
)["ruleset-failure-domain"] = "osd";
2047 (*profile
)["k"] = "4";
2048 (*profile
)["m"] = "3";
2049 (*profile
)["c"] = "2";
2050 shec
->init(*profile
, &cerr
);
2054 set
<int> want_to_encode
;
2055 map
<int, bufferlist
> encoded
;
2057 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2058 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2061 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2062 want_to_encode
.insert(i
);
2065 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2067 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2068 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2071 int want_to_decode
[] = { 0, 1, 2, 3, 4 };
2072 map
<int, bufferlist
> decoded
, inchunks
;
2074 for ( unsigned int i
= 4; i
< 7; ++i
) {
2075 inchunks
.insert(make_pair(i
, encoded
[i
]));
2078 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 5), inchunks
,
2086 TEST(ErasureCodeShec
, decode_12
)
2089 ErasureCodeShecTableCache tcache
;
2090 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2092 ErasureCodeShec::MULTIPLE
);
2093 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2094 (*profile
)["plugin"] = "shec";
2095 (*profile
)["technique"] = "";
2096 (*profile
)["ruleset-failure-domain"] = "osd";
2097 (*profile
)["k"] = "4";
2098 (*profile
)["m"] = "3";
2099 (*profile
)["c"] = "2";
2100 shec
->init(*profile
, &cerr
);
2104 set
<int> want_to_encode
;
2105 map
<int, bufferlist
> encoded
;
2107 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2108 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2109 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2110 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2112 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2113 want_to_encode
.insert(i
);
2116 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2118 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2119 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2121 // all chunks are available
2123 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
2126 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 7), encoded
,
2134 TEST(ErasureCodeShec
, decode_13
)
2137 ErasureCodeShecTableCache tcache
;
2138 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2140 ErasureCodeShec::MULTIPLE
);
2141 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2142 (*profile
)["plugin"] = "shec";
2143 (*profile
)["technique"] = "";
2144 (*profile
)["ruleset-failure-domain"] = "osd";
2145 (*profile
)["k"] = "4";
2146 (*profile
)["m"] = "3";
2147 (*profile
)["c"] = "2";
2148 shec
->init(*profile
, &cerr
);
2152 set
<int> want_to_encode
;
2153 map
<int, bufferlist
> encoded
;
2155 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2156 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2157 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2158 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2160 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2161 want_to_encode
.insert(i
);
2164 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2166 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2167 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2169 // all chunks are available
2171 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6 };
2172 map
<int, bufferlist
> decoded
;
2177 for (int i
= 0; i
< 100; ++i
) {
2181 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 7), encoded
,
2189 TEST(ErasureCodeShec
, decode2_1
)
2192 ErasureCodeShecTableCache tcache
;
2193 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2195 ErasureCodeShec::MULTIPLE
);
2196 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2197 (*profile
)["plugin"] = "shec";
2198 (*profile
)["technique"] = "";
2199 (*profile
)["ruleset-failure-domain"] = "osd";
2200 (*profile
)["k"] = "4";
2201 (*profile
)["m"] = "3";
2202 (*profile
)["c"] = "2";
2203 shec
->init(*profile
, &cerr
);
2207 set
<int> want_to_encode
;
2208 map
<int, bufferlist
> encoded
;
2210 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2211 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2212 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2213 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2215 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2216 want_to_encode
.insert(i
);
2219 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2221 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2222 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2224 // all chunks are available
2226 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
2227 map
<int, bufferlist
> decoded
;
2229 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
2231 EXPECT_TRUE(shec
->matrix
!= NULL
);
2233 EXPECT_EQ(2u, decoded
.size());
2236 shec
->decode_concat(encoded
, &out
);
2238 usable
.substr_of(out
, 0, in
.length());
2239 EXPECT_TRUE(usable
== in
);
2245 TEST(ErasureCodeShec
, decode2_3
)
2248 ErasureCodeShecTableCache tcache
;
2249 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2251 ErasureCodeShec::MULTIPLE
);
2252 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2253 (*profile
)["plugin"] = "shec";
2254 (*profile
)["technique"] = "";
2255 (*profile
)["ruleset-failure-domain"] = "osd";
2256 (*profile
)["k"] = "4";
2257 (*profile
)["m"] = "3";
2258 (*profile
)["c"] = "2";
2259 shec
->init(*profile
, &cerr
);
2263 set
<int> want_to_encode
;
2264 map
<int, bufferlist
> encoded
;
2266 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2267 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2268 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2269 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2271 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2272 want_to_encode
.insert(i
);
2275 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2277 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2278 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2280 // all chunks are available
2282 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
2283 map
<int, bufferlist
> decoded
;
2287 pthread_create(&tid
, NULL
, thread4
, shec
);
2288 while (g_flag
== 0) {
2292 printf("*** test start ***\n");
2293 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
2295 EXPECT_TRUE(shec
->matrix
!= NULL
);
2297 EXPECT_EQ(2u, decoded
.size());
2298 printf("*** test end ***\n");
2300 pthread_join(tid
, NULL
);
2303 shec
->decode_concat(encoded
, &out
);
2305 usable
.substr_of(out
, 0, in
.length());
2306 EXPECT_TRUE(usable
== in
);
2312 TEST(ErasureCodeShec
, decode2_4
)
2315 ErasureCodeShecTableCache tcache
;
2316 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2318 ErasureCodeShec::MULTIPLE
);
2319 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2320 (*profile
)["plugin"] = "shec";
2321 (*profile
)["technique"] = "";
2322 (*profile
)["ruleset-failure-domain"] = "osd";
2323 (*profile
)["k"] = "4";
2324 (*profile
)["m"] = "3";
2325 (*profile
)["c"] = "2";
2326 shec
->init(*profile
, &cerr
);
2330 set
<int> want_to_encode
;
2331 map
<int, bufferlist
> encoded
;
2333 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2334 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2335 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2336 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2338 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2339 want_to_encode
.insert(i
);
2342 int r
= shec
->encode(want_to_encode
, in
, &encoded
);
2344 EXPECT_EQ(shec
->get_chunk_count(), encoded
.size());
2345 EXPECT_EQ(shec
->get_chunk_size(in
.length()), encoded
[0].length());
2348 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
2349 map
<int, bufferlist
> decoded
;
2353 map
<int, bufferlist
> degraded
;
2354 degraded
[0] = encoded
[0];
2356 r
= shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), degraded
,
2364 TEST(ErasureCodeShec
, create_ruleset_1_2
)
2367 CrushWrapper
*crush
= new CrushWrapper
;
2369 crush
->set_type_name(2, "root");
2370 crush
->set_type_name(1, "host");
2371 crush
->set_type_name(0, "osd");
2374 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2376 crush
->set_item_name(rootno
, "default");
2378 map
< string
, string
> loc
;
2379 loc
["root"] = "default";
2384 for (int h
= 0; h
< num_host
; ++h
) {
2385 loc
["host"] = string("host-") + stringify(h
);
2386 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2387 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2388 string("osd.") + stringify(osd
), loc
);
2393 ErasureCodeShecTableCache tcache
;
2394 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2396 ErasureCodeShec::MULTIPLE
);
2397 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2398 (*profile
)["plugin"] = "shec";
2399 (*profile
)["technique"] = "";
2400 (*profile
)["ruleset-failure-domain"] = "osd";
2401 (*profile
)["k"] = "4";
2402 (*profile
)["m"] = "3";
2403 (*profile
)["c"] = "2";
2404 shec
->init(*profile
, &cerr
);
2409 int r
= shec
->create_ruleset("myrule", *crush
, &ss
);
2411 EXPECT_STREQ("myrule", crush
->rule_name_map
[0].c_str());
2413 //reexecute create_ruleset
2414 r
= shec
->create_ruleset("myrule", *crush
, &ss
);
2415 EXPECT_EQ(-EEXIST
, r
);
2422 TEST(ErasureCodeShec
, create_ruleset_4
)
2425 CrushWrapper
*crush
= new CrushWrapper
;
2427 crush
->set_type_name(2, "root");
2428 crush
->set_type_name(1, "host");
2429 crush
->set_type_name(0, "osd");
2432 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2434 crush
->set_item_name(rootno
, "default");
2436 map
< string
, string
> loc
;
2437 loc
["root"] = "default";
2442 for (int h
= 0; h
< num_host
; ++h
) {
2443 loc
["host"] = string("host-") + stringify(h
);
2444 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2445 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2446 string("osd.") + stringify(osd
), loc
);
2451 ErasureCodeShecTableCache tcache
;
2452 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2454 ErasureCodeShec::MULTIPLE
);
2455 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2456 (*profile
)["plugin"] = "shec";
2457 (*profile
)["technique"] = "";
2458 (*profile
)["ruleset-failure-domain"] = "osd";
2459 (*profile
)["k"] = "4";
2460 (*profile
)["m"] = "3";
2461 (*profile
)["c"] = "2";
2462 shec
->init(*profile
, &cerr
);
2465 int r
= shec
->create_ruleset("myrule", *crush
, NULL
); //ss = NULL
2473 TEST(ErasureCodeShec
, create_ruleset2_1
)
2476 CrushWrapper
*crush
= new CrushWrapper
;
2478 crush
->set_type_name(2, "root");
2479 crush
->set_type_name(1, "host");
2480 crush
->set_type_name(0, "osd");
2483 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2485 crush
->set_item_name(rootno
, "default");
2487 map
< string
, string
> loc
;
2488 loc
["root"] = "default";
2493 for (int h
= 0; h
< num_host
; ++h
) {
2494 loc
["host"] = string("host-") + stringify(h
);
2495 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2496 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2497 string("osd.") + stringify(osd
), loc
);
2502 ErasureCodeShecTableCache tcache
;
2503 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2505 ErasureCodeShec::MULTIPLE
);
2506 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2507 (*profile
)["plugin"] = "shec";
2508 (*profile
)["technique"] = "";
2509 (*profile
)["ruleset-failure-domain"] = "osd";
2510 (*profile
)["k"] = "4";
2511 (*profile
)["m"] = "3";
2512 (*profile
)["c"] = "2";
2513 shec
->init(*profile
, &cerr
);
2518 int r
= shec
->create_ruleset("myrule", *crush
, &ss
);
2520 EXPECT_STREQ("myrule", crush
->rule_name_map
[0].c_str());
2527 struct CreateRuleset2_3_Param_d
{
2528 ErasureCodeShec
*shec
;
2529 CrushWrapper
*crush
;
2532 TEST(ErasureCodeShec
, create_ruleset2_3
)
2535 CrushWrapper
*crush
= new CrushWrapper
;
2537 crush
->set_type_name(2, "root");
2538 crush
->set_type_name(1, "host");
2539 crush
->set_type_name(0, "osd");
2542 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2544 crush
->set_item_name(rootno
, "default");
2546 map
< string
, string
> loc
;
2547 loc
["root"] = "default";
2552 for (int h
= 0; h
< num_host
; ++h
) {
2553 loc
["host"] = string("host-") + stringify(h
);
2554 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2555 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2556 string("osd.") + stringify(osd
), loc
);
2561 ErasureCodeShecTableCache tcache
;
2562 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2564 ErasureCodeShec::MULTIPLE
);
2565 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2566 (*profile
)["plugin"] = "shec";
2567 (*profile
)["technique"] = "";
2568 (*profile
)["ruleset-failure-domain"] = "osd";
2569 (*profile
)["k"] = "4";
2570 (*profile
)["m"] = "3";
2571 (*profile
)["c"] = "2";
2572 shec
->init(*profile
, &cerr
);
2579 pthread_create(&tid
, NULL
, thread3
, shec
);
2580 while (g_flag
== 0) {
2584 printf("*** test start ***\n");
2585 int r
= (shec
->create_ruleset("myrule", *crush
, &ss
));
2586 EXPECT_TRUE(r
>= 0);
2587 printf("*** test end ***\n");
2589 pthread_join(tid
, NULL
);
2596 TEST(ErasureCodeShec
, get_chunk_count_1
)
2599 ErasureCodeShecTableCache tcache
;
2600 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2602 ErasureCodeShec::MULTIPLE
);
2603 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2604 (*profile
)["plugin"] = "shec";
2605 (*profile
)["technique"] = "";
2606 (*profile
)["ruleset-failure-domain"] = "osd";
2607 (*profile
)["k"] = "4";
2608 (*profile
)["m"] = "3";
2609 (*profile
)["c"] = "2";
2610 shec
->init(*profile
, &cerr
);
2613 EXPECT_EQ(7u, shec
->get_chunk_count());
2619 TEST(ErasureCodeShec
, get_data_chunk_count_1
)
2622 ErasureCodeShecTableCache tcache
;
2623 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2625 ErasureCodeShec::MULTIPLE
);
2626 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2627 (*profile
)["plugin"] = "shec";
2628 (*profile
)["technique"] = "";
2629 (*profile
)["ruleset-failure-domain"] = "osd";
2630 (*profile
)["k"] = "4";
2631 (*profile
)["m"] = "3";
2632 (*profile
)["c"] = "2";
2633 shec
->init(*profile
, &cerr
);
2635 //get_data_chunk_count
2636 EXPECT_EQ(4u, shec
->get_data_chunk_count());
2642 TEST(ErasureCodeShec
, get_chunk_size_1_2
)
2645 ErasureCodeShecTableCache tcache
;
2646 ErasureCodeShec
* shec
= new ErasureCodeShecReedSolomonVandermonde(
2648 ErasureCodeShec::MULTIPLE
);
2649 ErasureCodeProfile
*profile
= new ErasureCodeProfile();
2650 (*profile
)["plugin"] = "shec";
2651 (*profile
)["technique"] = "";
2652 (*profile
)["ruleset-failure-domain"] = "osd";
2653 (*profile
)["k"] = "4";
2654 (*profile
)["m"] = "3";
2655 (*profile
)["c"] = "2";
2656 (*profile
)["w"] = "8";
2657 shec
->init(*profile
, &cerr
);
2659 //when there is no padding(128=k*w*4)
2660 EXPECT_EQ(32u, shec
->get_chunk_size(128));
2661 //when there is padding(126=k*w*4-2)
2662 EXPECT_EQ(32u, shec
->get_chunk_size(126));
2668 void* thread1(void* pParam
)
2670 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2671 set
<int> want_to_decode
;
2672 set
<int> available_chunks
;
2673 set
<int> minimum_chunks
;
2675 want_to_decode
.insert(0);
2676 want_to_decode
.insert(1);
2677 available_chunks
.insert(0);
2678 available_chunks
.insert(1);
2679 available_chunks
.insert(2);
2681 printf("*** thread loop start ***\n");
2683 while (g_flag
== 1) {
2684 shec
->minimum_to_decode(want_to_decode
, available_chunks
, &minimum_chunks
);
2686 printf("*** thread loop end ***\n");
2691 void* thread2(void* pParam
)
2693 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2694 set
<int> want_to_decode
;
2695 map
<int, int> available_chunks
;
2696 set
<int> minimum_chunks
;
2698 want_to_decode
.insert(0);
2699 want_to_decode
.insert(1);
2700 available_chunks
[0] = 0;
2701 available_chunks
[1] = 1;
2702 available_chunks
[2] = 2;
2704 printf("*** thread loop start ***\n");
2706 while (g_flag
== 1) {
2707 shec
->minimum_to_decode_with_cost(want_to_decode
, available_chunks
,
2709 minimum_chunks
.clear();
2711 printf("*** thread loop end ***\n");
2716 void* thread3(void* pParam
)
2718 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2720 CrushWrapper
*crush
= new CrushWrapper
;
2722 crush
->set_type_name(2, "root");
2723 crush
->set_type_name(1, "host");
2724 crush
->set_type_name(0, "osd");
2727 crush
->add_bucket(0, CRUSH_BUCKET_STRAW
, CRUSH_HASH_RJENKINS1
, 2, 0, NULL
,
2729 crush
->set_item_name(rootno
, "default");
2731 map
< string
, string
> loc
;
2732 loc
["root"] = "default";
2737 for (int h
= 0; h
< num_host
; ++h
) {
2738 loc
["host"] = string("host-") + stringify(h
);
2739 for (int o
= 0; o
< num_osd
; ++o
, ++osd
) {
2740 crush
->insert_item(g_ceph_context
, osd
, 1.0,
2741 string("osd.") + stringify(osd
), loc
);
2749 printf("*** thread loop start ***\n");
2751 while (g_flag
== 1) {
2752 sprintf(name
, "myrule%d", i
);
2753 shec
->create_ruleset(name
, *crush
, &ss
);
2756 printf("*** thread loop end ***\n");
2761 void* thread4(void* pParam
)
2763 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2766 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2767 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2768 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2769 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2771 set
<int> want_to_encode
;
2772 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2773 want_to_encode
.insert(i
);
2776 map
<int, bufferlist
> encoded
;
2778 printf("*** thread loop start ***\n");
2780 while (g_flag
== 1) {
2781 shec
->encode(want_to_encode
, in
, &encoded
);
2784 printf("*** thread loop end ***\n");
2789 void* thread5(void* pParam
)
2791 ErasureCodeShec
* shec
= (ErasureCodeShec
*) pParam
;
2794 in
.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//length = 62
2795 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//124
2796 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//186
2797 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//248
2798 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//310
2800 set
<int> want_to_encode
;
2801 for (unsigned int i
= 0; i
< shec
->get_chunk_count(); ++i
) {
2802 want_to_encode
.insert(i
);
2804 map
<int, bufferlist
> encoded
;
2805 shec
->encode(want_to_encode
, in
, &encoded
);
2807 int want_to_decode
[] = { 0, 1, 2, 3, 4, 5 };
2808 map
<int, bufferlist
> decoded
;
2810 printf("*** thread loop start ***\n");
2812 while (g_flag
== 1) {
2813 shec
->decode(set
<int>(want_to_decode
, want_to_decode
+ 2), encoded
,
2817 printf("*** thread loop end ***\n");