@@ -45,35 +45,38 @@ static char *fence_name;
4545static bool syncflag = false;
4646static bool symlinkflag = false;
4747static const char * namespace = NULL ;
48+ static int opcount = 1 ;
4849
49- #define OPTIONS "n:Ss "
50+ #define OPTIONS "n:Sso: "
5051static const struct option longopts [] = {
5152 {"namespace" , required_argument , 0 , 'n' },
5253 {"sync" , no_argument , 0 , 'S' },
5354 {"symlink" , no_argument , 0 , 's' },
55+ {"opcount" , required_argument , 0 , 'o' },
5456 {0 , 0 , 0 , 0 },
5557};
5658
5759static void usage (void )
5860{
5961 fprintf (stderr ,
6062 "Usage: fence_api "
61- "[--sync] [--symlink] [--namespace=ns] "
63+ "[--sync] [--symlink] [--namespace=ns] [--opcount=num] "
6264 "<fencecount> <prefix>\n" );
6365 exit (1 );
6466}
6567
6668void * thread (void * arg )
6769{
6870 thd_t * t = arg ;
69- char * key ;
71+ char * key = NULL ;
7072 uint32_t rank ;
7173 flux_future_t * f ;
7274 flux_kvs_txn_t * txn ;
7375 const char * treeobj ;
7476 const char * rootref ;
7577 int sequence ;
7678 int flags = 0 ;
79+ int i ;
7780
7881 if (!(t -> h = flux_open (NULL , 0 ))) {
7982 log_err ("%d: flux_open" , t -> n );
@@ -90,15 +93,19 @@ void *thread (void *arg)
9093 if (!(txn = flux_kvs_txn_create ()))
9194 log_err_exit ("flux_kvs_txn_create" );
9295
93- key = xasprintf ("%s.%" PRIu32 ".%d" , prefix , rank , t -> n );
96+ for (i = 0 ; i < opcount ; i ++ ) {
97+ key = xasprintf ("%s.%" PRIu32 ".%d.%d" , prefix , rank , t -> n , i );
9498
95- if (symlinkflag ) {
96- if (flux_kvs_txn_symlink (txn , 0 , key , NULL , "a-target" ) < 0 )
97- log_err_exit ("%s" , key );
98- }
99- else {
100- if (flux_kvs_txn_pack (txn , 0 , key , "i" , 42 ) < 0 )
101- log_err_exit ("%s" , key );
99+ if (symlinkflag ) {
100+ if (flux_kvs_txn_symlink (txn , 0 , key , NULL , "a-target" ) < 0 )
101+ log_err_exit ("%s" , key );
102+ }
103+ else {
104+ if (flux_kvs_txn_pack (txn , 0 , key , "i" , 42 + i ) < 0 )
105+ log_err_exit ("%s" , key );
106+ }
107+
108+ free (key );
102109 }
103110
104111 if (syncflag )
@@ -131,7 +138,6 @@ void *thread (void *arg)
131138
132139 flux_future_destroy (f );
133140
134- free (key );
135141 flux_kvs_txn_destroy (txn );
136142
137143done :
@@ -158,6 +164,10 @@ int main (int argc, char *argv[])
158164 case 'n' :
159165 namespace = optarg ;
160166 break ;
167+ case 'o' :
168+ opcount = atoi (optarg );
169+ if (opcount <= 0 )
170+ usage ();
161171 default :
162172 usage ();
163173 }
0 commit comments