How does the Scan Policy in C Client SDK work?


#1

I use the modified example from SDK:

    indent preformatted text by 4 spacesbool scan_cb(const as_val* p_val, void* udata)
{
   if (! p_val) {
      LOG("scan callback returned null - scan is complete");
      return true;
   }
   as_record* p_rec = as_record_fromval(p_val);
   if (! p_rec) {
      LOG("scan callback returned non-as_record object");
      return true;
   }
   example_dump_record(p_rec);
   return true;
}


void walk_interests () {
   as_scan scan;
   as_error err;
   as_scan_init(&scan, "dmp", "userdata");

//initialise scan policy:
   as_policy_scan policy;
   as_policy_scan_init(&policy);
   policy.fail_on_cluster_change=false;

   LOG("starting scan all ...");

   if (aerospike_scan_foreach(&as, &err, &policy, &scan, scan_cb, NULL) !=
         AEROSPIKE_OK) {
      LOG("aerospike_scan_foreach() returned %d - %s", err.code, err.message);
      as_scan_destroy(&scan);
      exit(-1);
   }
   LOG("scan finished");
}

The program generates the following output, regardless of the value of the fail_on_cluster_change field:

starting scan all ...
aerospike_scan_foreach() returned 504 - AEROSPIKE_ERR_CLUSTER_CHANGE