5 #include <clovis/clovis.h> 6 #include <clovis/clovis_internal.h> 16 #define SMALL_UNIT_SIZE (4096) // Default layout. 17 #define LARGE_UNIT_SIZE (1024*4096) // Large layout. 25 static struct m0_clovis *
m0c;
41 struct m0_clovis_op *
ops[1] = {
NULL };
55 attr.ov_vec.v_count[0] = 0;
57 for (
int i = 0;
i < nblocks;
i++) {
62 m0_clovis_obj_op(
obj, M0_CLOVIS_OC_WRITE, &ivec, &
bvec, &
attr, 0,
65 m0_clovis_op_launch(
ops, 1);
67 rc = m0_clovis_op_wait(
ops[0],
71 rc = m0_clovis_rc(
ops[0]);
73 m0_clovis_op_fini(
ops[0]);
74 m0_clovis_op_free(
ops[0]);
81 struct m0_clovis_op *open_op[1] = {
NULL };
84 m0_clovis_entity_open(&
obj->ob_entity, &open_op[0]);
85 m0_clovis_op_launch(open_op, 1);
87 m0_clovis_op_wait(open_op[0],
M0_BITS(M0_CLOVIS_OS_FAILED,
90 rc = m0_clovis_rc(open_op[0]);
92 printf(
"open rc=%d\n",
rc);
93 m0_clovis_op_fini(open_op[0]);
94 m0_clovis_op_free(open_op[0]);
103 struct m0_clovis_op *
ops[1] = {
NULL };
105 memset(
obj, 0,
sizeof(
struct m0_clovis_obj));
109 m0_clovis_entity_create(&
obj->ob_entity, &
ops[0]);
111 m0_clovis_op_launch(
ops, 1);
113 m0_clovis_op_wait(
ops[0],
114 M0_BITS(M0_CLOVIS_OS_FAILED, M0_CLOVIS_OS_STABLE),
117 rc = m0_clovis_rc(
ops[0]);
119 m0_clovis_op_fini(
ops[0]);
120 m0_clovis_op_free(
ops[0]);
128 struct m0_clovis_container cont;
129 struct m0_clovis_op *
op =
NULL;
135 rc = m0_clovis_container_op(&cont, M0_CLOVIS_IC_LIST, &keys,
NULL, rcs,
137 m0_clovis_op_launch(&
op, 1);
141 fprintf(stderr,
"Failed to list container items.\n");
144 printf(
"%s\n", (
char *)keys.
ov_buf[
i]);
151 int main(
int argc,
char **argv)
168 struct m0_clovis_config cfg = {
169 .cc_is_oostore =
true,
170 .cc_is_read_verify =
false,
171 .cc_ha_addr = argv[1],
172 .cc_local_addr = argv[2],
173 .cc_profile = argv[3],
174 .cc_process_fid = argv[4],
177 .cc_idx_service_id = M0_CLOVIS_IDX_DIX,
179 .cc_idx_service_conf = (
void *)&idx_service_conf
182 rc = m0_clovis_init(&
m0c, &cfg,
true);
191 NULL, &M0_CLOVIS_UBER_REALM,
192 M0_CLOVIS_ST_CONTAINER,
m0c);
194 printf(
"Clovis init OK. Creating %d objects...\n",
NOBJS);
202 bool large =
rand() > RAND_MAX / 2;
205 struct m0_clovis_obj
obj;
209 printf(
"Creating %s object #%d... ", large ?
"large" :
"small",
224 "Failed writing object %d (rc=%d). Skipping...\n",
230 printf(
"Listing containers.\n ");
233 struct m0_uint128 small_cont_id = M0_CLOVIS_ID_APP;
234 struct m0_uint128 large_cont_id = M0_CLOVIS_ID_APP;
235 small_cont_id.
u_hi = small_cont_id.
u_hi + 1;
236 large_cont_id.
u_hi = large_cont_id.
u_hi + 2;
239 printf(
"==================\n");
240 printf(
"SMALL OBJECTS: \n");
241 printf(
"==================\n");
245 printf(
"==================\n");
246 printf(
"LARGE OBJECTS: \n");
247 printf(
"==================\n");
252 m0_clovis_fini(
m0c,
false);
253 printf(
"End of program\n");
M0_INTERNAL int m0_indexvec_alloc(struct m0_indexvec *ivec, uint32_t len)
struct m0_dix_ldesc kc_layout_ldesc
const m0_time_t M0_TIME_NEVER
static struct m0_clovis * m0c
static uint64_t small_layout
static uint64_t large_layout
M0_INTERNAL int m0_bufvec_alloc(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size)
static struct m0_clovis_container large_cont
static uint32_t unit_size
static struct m0_fid CLASSIFY_PLUGIN_FID
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
#define M0_FID_TINIT(type, container, key)
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
static struct m0_bufvec bvec
M0_INTERNAL int m0_dix_ldesc_init(struct m0_dix_ldesc *ld, struct m0_ext *range, m0_bcount_t range_nr, enum m0_dix_hash_fnc_type htype, struct m0_fid *pver)
static struct m0_pool pool
static int m0_open_obj(struct m0_clovis_obj *obj)
struct m0_dix_ldesc kc_ldescr_ldesc
static struct m0_clovis_container small_cont
static int m0_write_n_blocks(int nblocks, int unit_size, struct m0_clovis_obj *obj, int off, void *data)
struct m0_clovis_realm my_realm
void list_container(struct m0_uint128 container_id)
static int m0_create_obj(struct m0_uint128 id, int layout, struct m0_clovis_obj *obj)
int main(int argc, char *argv[])