예제 #1
0
파일: timo.c 프로젝트: QuentinPerez/Droplet
void
make_folder()
{
  dpl_status_t ret, ret2;
  dpl_async_task_t *atask = NULL;
  dpl_buf_t *buf = NULL;

  banner("creating folder");

  buf = dpl_buf_new();
  if (NULL == buf)
    exit(1);

  atask = (dpl_async_task_t *) dpl_put_async_prepare(ctx,           //the context
                                                     NULL,          //no bucket
                                                     folder,        //the folder
                                                     NULL,          //no option
                                                     DPL_FTYPE_DIR, //directory
                                                     NULL,          //no condition
                                                     NULL,          //no range
                                                     NULL,          //no metadata
                                                     NULL,          //no sysmd
                                                     buf);         //object body
  if (NULL == atask)
    {
      fprintf(stderr, "error preparing task\n");
      exit(1);
    }

  atask->cb_func = cb_make_folder;
  atask->cb_arg = atask;
  
  dpl_task_pool_put(pool, (dpl_task_t *) atask);
}
예제 #2
0
파일: timo.c 프로젝트: QuentinPerez/Droplet
void
append_to_nonexisting_named_object_precond()
{
  dpl_async_task_t *atask = NULL;
  dpl_buf_t *buf = NULL;
  dpl_status_t ret;
  dpl_condition_t condition;

  buf = dpl_buf_new();
  if (NULL == buf)
    exit(1);

  buf->size = DATA_LEN;
  buf->ptr = malloc(buf->size);
  if (NULL == buf->ptr)
    {
      fprintf(stderr, "alloc data failed\n");
      exit(1);
    }
  
  memset(buf->ptr, 'z', buf->size);

  banner("4 - append data to nonexisting named object with precondition");
  
  condition.conds[0].type = DPL_CONDITION_IF_MATCH;
  condition.conds[0].etag[0] = '*';
  condition.conds[0].etag[1] = 0;
  condition.n_conds = 1;

  atask = (dpl_async_task_t *) dpl_post_async_prepare(ctx,
                                                      NULL,          //no bucket
                                                      file3_path,    //the id
                                                      NULL,          //option
                                                      DPL_FTYPE_REG, //regular object
                                                      &condition,    //expect failure if exists
                                                      NULL,          //range
                                                      NULL,          //the metadata
                                                      NULL,          //no sysmd
                                                      buf,           //object body
                                                      NULL);         //query params
  if (NULL == atask)
    {
      fprintf(stderr, "error preparing task\n");
      exit(1);
    }

  atask->cb_func = cb_append_to_nonexisting_named_object_precond;
  atask->cb_arg = atask;
  
  dpl_task_pool_put(pool, (dpl_task_t *) atask);
}
예제 #3
0
파일: timo.c 프로젝트: pozdnychev/Droplet
void
add_existing_named_object()
{
  dpl_async_task_t *atask = NULL;
  dpl_buf_t *buf = NULL;
  dpl_status_t ret;
  dpl_condition_t condition;

  buf = dpl_buf_new();
  if (NULL == buf)
    exit(1);

  buf->size = DATA_LEN;
  buf->ptr = malloc(buf->size);
  if (NULL == buf->ptr)
    {
      fprintf(stderr, "alloc data failed\n");
      exit(1);
    }

  memset(buf->ptr, 'y', buf->size);

  banner("3 - add existing named object with precondition");
  
  condition.mask = DPL_CONDITION_IF_NONE_MATCH;
  condition.etag[0] = '*';
  condition.etag[1] = 0;

  atask = (dpl_async_task_t *) dpl_put_async_prepare(ctx,
                                                     NULL,          //no bucket
                                                     file2_path,    //the id
                                                     NULL,          //no option
                                                     DPL_FTYPE_REG, //regular object
                                                     &condition,    //expect failure if exists
                                                     NULL,          //no range
                                                     NULL,          //the metadata
                                                     NULL,          //no sysmd
                                                     buf);          //object body
  if (NULL == atask)
    {
      fprintf(stderr, "error preparing task\n");
      exit(1);
    }

  atask->cb_func = cb_add_existing_named_object;
  atask->cb_arg = atask;
  
  dpl_task_pool_put(pool, (dpl_task_t *) atask);
}
예제 #4
0
파일: timo.c 프로젝트: QuentinPerez/Droplet
void
add_nameless_object()
{
  dpl_async_task_t *atask = NULL;
  dpl_buf_t *buf = NULL;
  dpl_status_t ret;

  buf = dpl_buf_new();
  if (NULL == buf)
    exit(1);

  buf->size = DATA_LEN;
  buf->ptr = malloc(buf->size);
  if (NULL == buf->ptr)
    {
      fprintf(stderr, "alloc data failed\n");
      exit(1);
    }

  memset(buf->ptr, 'x', buf->size);

  banner("1 - add nameless object");

  atask = (dpl_async_task_t *) dpl_post_id_async_prepare(ctx,           //the context
                                                         NULL,          //no bucket
                                                         NULL,          //no id
                                                         NULL,          //no option
                                                         DPL_FTYPE_REG, //regular object
                                                         NULL,          //condition
                                                         NULL,          //range
                                                         NULL,          //the metadata
                                                         NULL,          //no sysmd
                                                         buf,           //object body
                                                         NULL);         //no query params
  if (NULL == atask)
    {
      fprintf(stderr, "error preparing task\n");
      exit(1);
    }

  atask->cb_func = cb_add_nameless_object;
  atask->cb_arg = atask;
  
  dpl_task_pool_put(pool, (dpl_task_t *) atask);
}
예제 #5
0
파일: timo.c 프로젝트: QuentinPerez/Droplet
void
append_to_nonexisting_named_object()
{
  dpl_async_task_t *atask = NULL;
  dpl_buf_t *buf = NULL;
  dpl_status_t ret;

  buf = dpl_buf_new();
  if (NULL == buf)
    exit(1);

  buf->size = DATA_LEN;
  buf->ptr = malloc(buf->size);
  if (NULL == buf->ptr)
    {
      fprintf(stderr, "alloc data failed\n");
      exit(1);
    }

  memset(buf->ptr, 'z', buf->size);

  banner("5 - append data to nonexisting named object");
  
  atask = (dpl_async_task_t *) dpl_post_async_prepare(ctx,
                                                      NULL,          //no bucket
                                                      file3_path,    //the id
                                                      NULL,          //option
                                                      DPL_FTYPE_REG, //regular object
                                                      NULL,          //no condition
                                                      NULL,          //range
                                                      NULL,          //the metadata
                                                      NULL,          //no sysmd
                                                      buf,           //object body
                                                      NULL);         //query params
  if (NULL == atask)
    {
      fprintf(stderr, "error preparing task\n");
      exit(1);
    }

  atask->cb_func = cb_append_to_nonexisting_named_object;
  atask->cb_arg = atask;
  
  dpl_task_pool_put(pool, (dpl_task_t *) atask);
}
예제 #6
0
void
create_object()
{
  dpl_async_task_t *atask = NULL;
  dpl_buf_t *buf = NULL;
  dpl_status_t ret;

  buf = dpl_buf_new();
  if (NULL == buf)
    exit(1);

  buf->size = DATA_LEN;
  buf->ptr = malloc(DATA_LEN);
  if (NULL == buf->ptr)
    {
      fprintf(stderr, "alloc data failed\n");
      exit(1);
    }

  memset(buf->ptr, 'z', buf->size);

  metadata = dpl_dict_new(13);
  if (NULL == metadata)
    {
      fprintf(stderr, "dpl_dict_new failed\n");
      exit(1);
    }
 
  ret = dpl_dict_add(metadata, "foo", "bar", 0);
  if (DPL_SUCCESS != ret)
    {
      fprintf(stderr, "dpl_dict_add failed\n");
      exit(1);
    }

  ret = dpl_dict_add(metadata, "foo2", "qux", 0);
  if (DPL_SUCCESS != ret)
    {
      fprintf(stderr, "dpl_dict_add failed\n");
      exit(1);
    }

  fprintf(stderr, "atomic creation of an object+MD\n");

  atask = (dpl_async_task_t *) dpl_post_async_prepare(ctx,           //the context
                                                      NULL,          //no bucket
                                                      folder,        //the folder
                                                      NULL,          //no option
                                                      DPL_FTYPE_REG, //regular object
                                                      NULL,          //condition
                                                      NULL,          //range
                                                      metadata,      //the metadata
                                                      NULL,          //no sysmd
                                                      buf,           //object body
                                                      NULL);         //no query params
  if (NULL == atask)
    {
      fprintf(stderr, "error preparing task\n");
      exit(1);
    }

  atask->cb_func = cb_create_object;
  atask->cb_arg = atask;
  
  dpl_task_pool_put(pool, (dpl_task_t *) atask);
}