Exemplo n.º 1
0
/*-------------------------------------------------------------------------
 * Function: obj_stats
 *
 * Purpose: Gather statistics about an object
 *
 * Return: Success: 0
 *       Failure: -1
 *
 * Programmer: Quincey Koziol
 *             Tuesday, November 6, 2007
 *
 *-------------------------------------------------------------------------
 */
static herr_t
obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited,
    void *_iter)
{
    iter_t *iter = (iter_t *)_iter;

    /* If the object has already been seen then just return */
    if(NULL == already_visited) {
        /* Gather some general statistics about the object */
        if(oi->rc > iter->max_links)
            iter->max_links = oi->rc;

        switch(oi->type) {
            case H5O_TYPE_GROUP:
                group_stats(iter, path, oi);
                break;

            case H5O_TYPE_DATASET:
                dataset_stats(iter, path, oi);
                break;

            case H5O_TYPE_NAMED_DATATYPE:
    datatype_stats(iter, oi);
                break;

            default:
                /* Gather statistics about this type of object */
                iter->uniq_others++;
                break;
        } /* end switch */
    } /* end if */

    return 0;
} /* end obj_stats() */
Exemplo n.º 2
0
int
main( int argc, char **argv )
{
    int i;

    double eps;

    if( argc < 3 ) {
        fprintf( stderr, "Usage: " );
        fprintf( stderr, "  %s GADGET_SOFTENING BGC_file[s] \n", argv[0] );
        exit( EXIT_FAILURE );
    }

    {   /* convert 1st argument into double softening: eps */
        char **endptr;

        endptr = NULL;
        eps = strtod( argv[1], endptr );
    }

    fprintf( stderr, "Calculating DPP using plummer softened potential: eps = %g\n", eps );
    fprintf( stderr,
             "Output 11 columns:\n  gid(0) npart(1) group_mass(2) position(3,4,5)  velocity(6,7,8) vdisp(9) periodic_wrap?(10)\n" );

    /* loop over input files for processing */
    for( i = 2; i < argc; i++ ) {
        char *bgc_file = argv[i];

        group_stats( bgc_file, eps );
    }

    return ( EXIT_SUCCESS );
}
Exemplo n.º 3
0
int
main( int argc, char **argv )
{
    int i;

    if( argc < 2 ) {
        fprintf( stderr, "Usage: " );
        fprintf( stderr, "  %s BGC_file[s] \n", argv[0] );
        exit( EXIT_FAILURE );
    }

    /* loop over input files for processing */
    for( i = 1; i < argc; i++ ) {
        char *bgc_file = argv[i];

        group_stats( bgc_file );
    }

    return ( EXIT_SUCCESS );
}
Exemplo n.º 4
0
void
test_group_stats(void) {
  struct bridge *bridge;
  struct group_table *group_table;
  struct group *group;
  struct ofp_group_mod group_mod;
  struct bucket_list bucket_list;
  struct ofp_group_stats_request request;
  struct group_stats_list group_stats_list;
  struct group_stats *stats;
  struct ofp_error error;
  struct ofp_flow_mod flow_mod;
  struct match_list match_list;
  struct instruction_list instruction_list;
  struct instruction *instruction;
  struct action *action;
  lagopus_result_t ret;

  bridge = dp_bridge_lookup("br0");
  TEST_ASSERT_NOT_NULL_MESSAGE(bridge, "bridge alloc error.");
  TAILQ_INIT(&bucket_list);
  group_table = group_table_alloc(bridge);
  TEST_ASSERT_NOT_NULL_MESSAGE(bridge, "group_table alloc error.");
  bridge->group_table = group_table;

  group_mod.group_id = 1;
  group_mod.type = OFPGT_ALL;
  group = group_alloc(&group_mod, &bucket_list);
  ret = group_table_add(group_table, group, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "group_table_add error");

  group_mod.group_id = 1000000;
  group_mod.type = OFPGT_ALL;
  group = group_alloc(&group_mod, &bucket_list);
  ret = group_table_add(group_table, group, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "group_table_add error");

  request.group_id = 1;
  TAILQ_INIT(&group_stats_list);
  ret = group_stats(group_table, &request, &group_stats_list, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "get stats error");
  stats = TAILQ_FIRST(&group_stats_list);
  TEST_ASSERT_NOT_NULL_MESSAGE(stats, "group not found");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.group_id, 1,
                            "group id error");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.duration_sec, 0,
                            "duration sec error");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.ref_count, 0,
                            "ref_count error");
  stats = TAILQ_NEXT(stats, entry);
  TEST_ASSERT_NULL_MESSAGE(stats, "number of groups error");

  TAILQ_INIT(&match_list);
  TAILQ_INIT(&instruction_list);
  instruction = instruction_alloc();
  TEST_ASSERT_NOT_NULL_MESSAGE(instruction, "instruction alloc error.");
  instruction->ofpit.type = OFPIT_APPLY_ACTIONS;
  TAILQ_INIT(&instruction->action_list);
  action = action_alloc(sizeof(struct ofp_action_group));
  TEST_ASSERT_NOT_NULL_MESSAGE(action, "action alloc error.");
  action->ofpat.type = OFPAT_GROUP;
  ((struct ofp_action_group *)&action->ofpat)->group_id = 5;
  TAILQ_INSERT_TAIL(&instruction->action_list, action, entry);
  TAILQ_INSERT_TAIL(&instruction_list, instruction, entry);
  flow_mod.table_id = 0;
  flow_mod.priority = 1;
  flow_mod.flags = 0;
  flow_mod.cookie = 0;
  ret = flowdb_flow_add(bridge, &flow_mod, &match_list,
                        &instruction_list, &error);
  TEST_ASSERT_NOT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                                "flowdb_flow_add: group check error");
  TAILQ_INIT(&match_list);
  TAILQ_INIT(&instruction_list);
  instruction = instruction_alloc();
  TEST_ASSERT_NOT_NULL_MESSAGE(instruction, "instruction alloc error.");
  instruction->ofpit.type = OFPIT_APPLY_ACTIONS;
  TAILQ_INIT(&instruction->action_list);
  action = action_alloc(sizeof(struct ofp_action_group));
  TEST_ASSERT_NOT_NULL_MESSAGE(action, "action alloc error.");
  action->ofpat.type = OFPAT_GROUP;
  ((struct ofp_action_group *)&action->ofpat)->group_id = 1;
  TAILQ_INSERT_TAIL(&instruction->action_list, action, entry);
  TAILQ_INSERT_TAIL(&instruction_list, instruction, entry);
  ret = flowdb_flow_add(bridge, &flow_mod, &match_list,
                        &instruction_list, &error);
  printf("%d.%d\n", error.type, error.code);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "flowdb_flow_add: add to empty table error");

  request.group_id = 1;
  TAILQ_INIT(&group_stats_list);
  ret = group_stats(group_table, &request, &group_stats_list, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "get stats error");
  stats = TAILQ_FIRST(&group_stats_list);
  TEST_ASSERT_NOT_NULL_MESSAGE(stats, "group not found");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.group_id, 1,
                            "group id error");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.duration_sec, 0,
                            "duration sec error");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.ref_count, 1,
                            "ref_count error");
  stats = TAILQ_NEXT(stats, entry);
  TEST_ASSERT_NULL_MESSAGE(stats, "number of groups error");

  request.group_id = OFPG_ALL;
  TAILQ_INIT(&group_stats_list);
  ret = group_stats(group_table, &request, &group_stats_list, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "get stats error");
  stats = TAILQ_FIRST(&group_stats_list);
  TEST_ASSERT_NOT_NULL_MESSAGE(stats, "group not found");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.group_id, 1,
                            "group id error");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.duration_sec, 0,
                            "duration sec error");
  stats = TAILQ_NEXT(stats, entry);
  TEST_ASSERT_NOT_NULL_MESSAGE(stats, "group not found");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.group_id, 1000000,
                            "group id error");
  stats = TAILQ_NEXT(stats, entry);
  TEST_ASSERT_NULL_MESSAGE(stats, "number of groups error");

  sleep(1);
  TAILQ_INIT(&group_stats_list);
  ret = group_stats(group_table, &request, &group_stats_list, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "get stats error");
  stats = TAILQ_FIRST(&group_stats_list);
  TEST_ASSERT_NOT_NULL_MESSAGE(stats, "group not found");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.group_id, 1,
                            "group id error");
  TEST_ASSERT_EQUAL_MESSAGE(stats->ofp.duration_sec, 1,
                            "duration sec error");

  request.group_id = 20;
  TAILQ_INIT(&group_stats_list);
  ret = group_stats(group_table, &request, &group_stats_list, &error);
  TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_OK,
                            "get stats error");
  stats = TAILQ_FIRST(&group_stats_list);
  TEST_ASSERT_NULL_MESSAGE(stats, "stats is not empry");
}