Example #1
0
int EntryProc_db_apply( struct entry_proc_op_t *p_op, lmgr_t * p_lmgr )
{
    int            rc;
    const pipeline_stage_t *stage_info = &entry_proc_pipeline[p_op->pipeline_stage];
#ifdef DEBUG
    printf( "stage %s - record #%u - id=[%llu,%u] - thread %lx\n",
            stage_info->stage_name, ( unsigned int ) p_op->entry_id.f_ver,
            p_op->entry_id.f_seq, p_op->entry_id.f_oid, pthread_self(  ) );
#endif

#ifdef _HAVE_FID
    if ( p_op->entry_id.f_ver % ( NB_OP_ENQUEUE / 10 ) == 0 )
        EntryProcessor_DumpCurrentStages(  );
#endif

    /* simulate slow DB query */
    usleep( 1000 );

#ifdef _HAVE_FID
    if ( ( unsigned int ) p_op->entry_id.f_ver == NB_OP_ENQUEUE - 1 )
        exit( 0 );
#endif

    /* acknowledge */
    rc = EntryProcessor_Acknowledge( p_op, 0, TRUE );
    if ( rc )
        printf( "Error acknowledging stage %s\n", stage_info->stage_name );

    return 0;
}
Example #2
0
int EntryProc_check_exist( struct entry_proc_op_t *p_op, lmgr_t * p_lmgr )
{
    int            rc;
    const pipeline_stage_t *stage_info = &entry_proc_pipeline[p_op->pipeline_stage];
#ifdef DEBUG
    printf( "stage %s - record #%u - id=[%llu,%u] - thread %lx\n",
            stage_info->stage_name, ( unsigned int ) p_op->entry_id.f_ver,
            p_op->entry_id.f_seq, p_op->entry_id.f_oid, pthread_self(  ) );

    EntryProcessor_DumpCurrentStages(  );
#endif

    /* acknowledge */
    /* and randomly return 1 entry out of 100 */
    if ( myrand( 100 ) == 0 )
    {
        rc = EntryProcessor_Acknowledge( p_op, p_op->pipeline_stage + 1, TRUE );
        if ( rc )
            printf( "Error acknowledging stage %s\n", stage_info->stage_name );
        return rc;
    }
    else
    {
        rc = EntryProcessor_Acknowledge( p_op, p_op->pipeline_stage + 1, FALSE );
        if ( rc )
            printf( "Error acknowledging stage %s\n", stage_info->stage_name );
    }

    /* if processing is async, simulate a long operation */
    if ( stage_info->stage_flags & STAGE_FLAG_ASYNC )
    {
        /* do this for 1 entry out of 1000 */
        if ( myrand( 1000 ) == 0 )
        {
            usleep( 100000 );
            DisplayLog( LVL_DEBUG, "CheckExist", "End of async processing for stage %s",
                        stage_info->stage_name );
        }
    }

    return 0;
}
int EntryProc_db_apply( struct entry_proc_op_t *p_op, lmgr_t * lmgr )
{
    int            rc;
    const pipeline_stage_t *stage_info = &entry_proc_pipeline[p_op->pipeline_stage];
#ifdef DEBUG
    printf( "stage %s - record #%u - id=[%llu,%u] - thread %lx\n",
            stage_info->stage_name, ( unsigned int ) p_op->entry_id.f_ver,
            p_op->entry_id.f_seq, p_op->entry_id.f_oid, pthread_self(  ) );
#endif

#ifdef _HAVE_FID
    if ( p_op->entry_id.f_ver % ( NB_OP_ENQUEUE / 10 ) == 0 )
        EntryProcessor_DumpCurrentStages(  );
#endif

    /* insert to DB */
    switch ( p_op->db_op_type )
    {
    case OP_TYPE_INSERT:
        rc = ListMgr_Insert( lmgr, &p_op->entry_id, &p_op->entry_attr );
        break;
    case OP_TYPE_UPDATE:
        rc = ListMgr_Update( lmgr, &p_op->entry_id, &p_op->entry_attr );
        break;
    default:
        printf( "unhandled\n" );
        rc = -1;
    }
    if ( rc )
        printf( "ERROR: ListMgr operation returned %d\n", rc );


#ifdef _HAVE_FID
    if ( ( unsigned int ) p_op->entry_id.f_ver == NB_OP_ENQUEUE - 1 )
        exit( 0 );
#endif

    if ( p_op->callback_func )
        p_op->callback_func( lmgr, p_op, p_op->callback_param );

    /* acknoledge */
    rc = EntryProcessor_Acknowledge( p_op, 0, TRUE );
    if ( rc )
        printf( "Error acknowledging stage %s\n", stage_info->stage_name );


    return 0;
}
Example #4
0
int EntryProc_get_attr( struct entry_proc_op_t *p_op, lmgr_t * p_lmgr )
#endif
{
    int            rc;
    entry_id_t     id;
    const pipeline_stage_t *stage_info = &entry_proc_pipeline[p_op->pipeline_stage];

    /* set id */
#ifdef _HAVE_FID
    id.f_seq = myrand( 1000 );
    id.f_oid = myrand( 1000 );
    id.f_ver = p_op->extra_info.log_record.record_id;
#else
    id.device = myrand( 1000 );
    id.inode = myrand( 1000 );
#endif
    EntryProcessor_SetEntryId( p_op, &id );

#ifdef DEBUG
    printf( "stage %s - record #%u - id=[%llu,%u] - thread %lx\n",
            stage_info->stage_name, ( unsigned int ) p_op->entry_id.f_ver,
            p_op->entry_id.f_seq, p_op->entry_id.f_oid, pthread_self(  ) );

    EntryProcessor_DumpCurrentStages(  );
#endif

    /* acknowledge */
    rc = EntryProcessor_Acknowledge( p_op, p_op->pipeline_stage + 1, FALSE );
    if ( rc )
        printf( "Error acknowledging stage %s\n", stage_info->stage_name );

    /* if processing is async, simulate a long operation */
    if ( stage_info->stage_flags & STAGE_FLAG_ASYNC )
    {
        /* do this for 1 entry out of 1000 */
        if ( myrand( 1000 ) == 0 )
        {
            usleep( 10000 );
            DisplayLog( LVL_DEBUG, "CheckExist", "End of async processing for stage %s",
                        stage_info->stage_name );
        }
    }

    return 0;
}
int EntryProc_db_flag_op( struct entry_proc_op_t *p_op, lmgr_t * lmgr )
{
    int            rc;

    /* insert to DB */
    switch ( p_op->db_op_type )
    {
        attr_set_t     attr_chg;
        lmgr_filter_t  filter;
        filter_value_t val;

    case OP_TYPE_UPDATE:
        /* set previous_scan flag */
        ATTR_MASK_INIT( &attr_chg );
        ATTR_MASK_SET( &attr_chg, previous_scan );
        ATTR( &attr_chg, previous_scan ) = TRUE;

        rc = ListMgr_MassUpdate( lmgr, NULL, &attr_chg );
        break;
    case OP_TYPE_REMOVE:
        val.val_bool = TRUE;
        lmgr_simple_filter_init( &filter );
        lmgr_simple_filter_add( &filter, ATTR_INDEX_previous_scan, EQUAL, val );

        /* remove entries with previous_scan flag */
        rc = ListMgr_MassRemove( lmgr, &filter );

        lmgr_simple_filter_free( &filter );
        break;
    default:
        printf( "unhandled\n" );
        rc = -1;
    }
    if ( rc )
        printf( "ERROR: ListMgr mass operation returned %d\n", rc );

    if ( p_op->callback_func )
        p_op->callback_func( lmgr, p_op, p_op->callback_param );

    rc = EntryProcessor_Acknowledge( p_op, 0, TRUE );

    return rc;
}
int EntryProc_get_info( struct entry_proc_op_t *p_op, lmgr_t * lmgr )
{
    int            rc;
    const pipeline_stage_t *stage_info = &entry_proc_pipeline[p_op->pipeline_stage];
    /* acknoledge */
    rc = EntryProcessor_Acknowledge( p_op, p_op->pipeline_stage + 1, FALSE );
    if ( rc )
        printf( "Error acknowledging stage %s\n", stage_info->stage_name );

    /* if processing is async, simulate a long operation */
    if ( stage_info->stage_flags & STAGE_FLAG_ASYNC )
    {
        /* do this for 1 entry out of 1000 */
        if ( myrand( 1000 ) == 0 )
        {
            usleep( 100 );
            /*printf( "End of async processing for stage %s\n",
               stage_info->stage_name ); */
        }
    }

    return 0;
}
Example #7
0
/**
 * For entries from FS scan, we must get the associated entry ID.
 */
int EntryProc_get_fid( struct entry_proc_op_t *p_op, lmgr_t * lmgr )
{
#ifdef _HAVE_FID
    int            rc;
    entry_id_t     tmp_id;
    char buff[RBH_PATH_MAX];
    char * path;

    /* 2 possible options: get fid using parent_fid/name or from fullpath */
    if (ATTR_MASK_TEST(&p_op->fs_attrs, parent_id)
        && ATTR_MASK_TEST(&p_op->fs_attrs, name))
    {
        BuildFidPath( &ATTR(&p_op->fs_attrs, parent_id), buff );
        long len = strlen(buff);
        sprintf(buff+len, "/%s", ATTR(&p_op->fs_attrs, name));
        path = buff;
    }
    else if (ATTR_MASK_TEST( &p_op->fs_attrs, fullpath))
    {
        path = ATTR(&p_op->fs_attrs, fullpath);
    }
    else
    {
        DisplayLog( LVL_CRIT, ENTRYPROC_TAG,
                    "Error: not enough information to get fid: parent_id/name or fullpath needed");
        EntryProcessor_Acknowledge(p_op, -1, true);
        return EINVAL;
    }

    /* perform path2fid */
    rc = Lustre_GetFidFromPath( path, &tmp_id );

    /* Workaround for Lustre 2.3: if parent is root, llapi_path2fid returns EINVAL (see LU-3245).
     * In this case, get fid from full path.
     */
    if ((rc == -EINVAL) && ATTR_MASK_TEST( &p_op->fs_attrs, fullpath))
    {
        path = ATTR(&p_op->fs_attrs, fullpath);
        rc =  Lustre_GetFidFromPath( path, &tmp_id );
    }

    if ( rc )
    {
        /* remove the operation from pipeline */
        rc = EntryProcessor_Acknowledge(p_op, -1, true);
        if ( rc )
            DisplayLog( LVL_CRIT, ENTRYPROC_TAG,
                        "Error %d acknowledging stage STAGE_GET_FID.", rc );
    }
    else
    {
        EntryProcessor_SetEntryId( p_op, &tmp_id );

        /* go to GET_INFO_DB stage */
        rc = EntryProcessor_Acknowledge(p_op, STAGE_GET_INFO_DB, false);
        if ( rc )
            DisplayLog( LVL_CRIT, ENTRYPROC_TAG,
                        "Error %d acknowledging stage STAGE_GET_FID.", rc );
    }
    return rc;
#else
    DisplayLog( LVL_CRIT, ENTRYPROC_TAG, "Error: unexpected stage in a filesystem with no fid: STAGE_GET_FID.");
    EntryProcessor_Acknowledge(p_op, -1, true);
    return EINVAL;
#endif
}