Example #1
0
int main( int argc, char** argv ) {
   
   struct md_HTTP syndicate_http;
   
   int test_optind = -1;

   // set up the test 
   syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http );
   
   // arguments: getxattr [syndicate options] /path/to/file xattr_name
   if( test_optind < 0 )
      usage( argv[0] );
   
   if( test_optind + 1 >= argc )
      usage( argv[0] );
   
   char* path = argv[test_optind];
   char* xattr_name = argv[test_optind+1];
   
   // stop Valgrind errors
   char xattr_value[65536];
   for( int i = 0; i <= 65536; i++ ) {
      xattr_value[i] = 0;
   }
   
   // get state 
   struct syndicate_state* state = syndicate_get_state();
   
   // get the xattr size
   dbprintf("\n\n\nfs_entry_getxattr( %s, %s )\n\n\n", path, xattr_name );
   
   ssize_t rc = fs_entry_getxattr( state->core, path, xattr_name, xattr_value, 0, SYS_USER, 0 );
   if( rc < 0 || rc > 65535 ) {
      errorf("\n\n\nfs_entry_getxattr( %s, %s ) rc = %zd\n\n\n", path, xattr_name, rc );
      syndicate_functional_test_shutdown( &syndicate_http );
      exit(1);
   }
   
   dbprintf("\n\n\nfs_entry_getxattr( %s, %s, 0 ) rc = %zd\n\n\n", path, xattr_name, rc );
   
   // get the xattr for real this time 
   rc = fs_entry_getxattr( state->core, path, xattr_name, xattr_value, rc, SYS_USER, 0 );
   if( rc < 0 || rc > 65535 ) {
      errorf("\n\n\nfs_entry_getxattr( %s, %s ) rc = %zd\n\n\n", path, xattr_name, rc );
      syndicate_functional_test_shutdown( &syndicate_http );
      exit(1);
   }
   
   dbprintf("\n\n\nfs_entry_getxattr( %s, %s ) = '%s'\n\n\n", path, xattr_name, xattr_value );
   
   // shut down the test 
   syndicate_functional_test_shutdown( &syndicate_http );
   
   return 0;
}
Example #2
0
int main( int argc, char** argv ) {
   
   struct md_HTTP syndicate_http;
   
   int test_optind = -1;

   // set up the test 
   syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http );
   
   // arguments: getxattr [syndicate options] /path/to/file xattr_name
   if( test_optind < 0 )
      usage( argv[0] );
   
   if( test_optind + 2 >= argc )
      usage( argv[0] );
   
   char* path = argv[test_optind];
   char* xattr_name = argv[test_optind+1];
   char* xattr_mode_str = argv[test_optind+2];
   
   char* end = NULL;
   mode_t xattr_mode = strtol( xattr_mode_str, &end, 8 );
   if( end == NULL )
      usage( argv[0] );
   
   // get state 
   struct syndicate_state* state = syndicate_get_state();
   
   // get the xattr size
   dbprintf("\n\n\nfs_entry_chmodxattr( %s, %s, mode=0%o )\n\n\n", path, xattr_name, xattr_mode );
   
   int rc = fs_entry_chmodxattr( state->core, path, xattr_name, xattr_mode );
   if( rc < 0 ) {
      errorf("\n\n\nfs_entry_chmodxattr( %s, %s, mode=0%o ) rc = %d\n\n\n", path, xattr_name, xattr_mode, rc );
      syndicate_functional_test_shutdown( &syndicate_http );
      exit(1);
   }
   
   errorf("\n\n\nfs_entry_chmodxattr( %s, %s, mode=0%o ) rc = %d\n\n\n", path, xattr_name, xattr_mode, rc );
   
   // shut down the test 
   syndicate_functional_test_shutdown( &syndicate_http );
   
   return 0;
}
Example #3
0
int main(int argc, char** argv) {
   md_debug(1);
   md_error(1);
   SG_debug("%s\n", "starting up debugging");
   SG_error("%s\n", "starting up errors");

   int c;
   char* config_file = (char*)CLIENT_DEFAULT_CONFIG;
   int portnum = 0;

   struct md_HTTP syndicate_http;
   char* username = NULL;
   char* password = NULL;
   char* volume_name = NULL;
   char* volume_secret = NULL;
   char* ms_url = NULL;
   int read_count = 1;

   static struct option syndicate_options[] = {
      {"config-file",     required_argument,   0, 'c'},
      {"volume-name",     required_argument,   0, 'v'},
      {"volume-secret",   required_argument,   0, 's'},
      {"username",        required_argument,   0, 'u'},
      {"password",        required_argument,   0, 'p'},
      {"port",            required_argument,   0, 'P'},
      {"MS",              required_argument,   0, 'm'},
      {"read-count",      required_argument,   0, 'R'},
      {0, 0, 0, 0}
   };

   int opt_index = 0;

   while((c = getopt_long(argc, argv, "c:v:s:u:p:P:fm:R:", syndicate_options, &opt_index)) != -1) {
      switch( c ) {
         case 'R': {
            read_count = strtol(optarg, NULL, 10);
            break;
         }
         case 'v': {
            volume_name = optarg;
            break;
         }
         case 'c': {
            config_file = optarg;
            break;
         }
         case 's': {
            volume_secret = optarg;
            break;
         }
         case 'u': {
            username = optarg;
            break;
         }
         case 'p': {
            password = optarg;
            break;
         }
         case 'P': {
            portnum = strtol(optarg, NULL, 10);
            break;
         }
         case 'm': {
            ms_url = optarg;
            break;
         }
         default: {
            break;
         }
      }
   }

   int rc = syndicate_init( config_file, &syndicate_http, portnum, ms_url, volume_name, volume_secret, username, password );
   if( rc != 0 )
      exit(1);

   struct md_syndicate_conf* conf = syndicate_get_conf();
   if( portnum == 0 )
      portnum = conf->httpd_portnum;

   struct syndicate_state* state = syndicate_get_state();

   // synchronous everything
   conf->default_write_freshness = 0;
   conf->default_read_freshness = 0;

   char file[PATH_MAX];
   memset(file, 0, PATH_MAX);
   strcpy( file, READ_FILE );

   struct fs_file_handle* fh = NULL;
   ssize_t nw = 0;

   ssize_t file_size = conf->blocking_factor * 100;
   char* buf = SG_CALLOC( char, file_size );
   char fill = rand() % 26 + 'A';
   memset( buf, fill, file_size );

   struct timespec ts, ts2;

   DATA_BLOCK("open");

   SG_BEGIN_TIMING_DATA( ts );

   // create the file
   fh = fs_entry_open( state->core, file, NULL, conf->owner, conf->volume, O_SYNC | O_RDWR, 0666, &rc );
   if( rc != 0 ) {
      SG_error("fs_entry_open(%s) rc = %d\n", file, rc );
      exit(1);
   }

   SG_END_TIMING_DATA( ts, ts2, "open + MS revalidate + manifest refresh" );

   
   DATA_BLOCK("remote read miss");

   // mark the file as stale
   fs_entry_wlock( fh->fent );
   fs_entry_mark_read_stale( fh->fent );
   fs_entry_unlock( fh->fent );

   char const* key = "remote read miss";
   char const* hit = "remote read hit";
   
   for( int i = 0; i < read_count; i++ ) {
      // read the file

      SG_BEGIN_TIMING_DATA( ts );
      
      nw = fs_entry_read( state->core, fh, buf, file_size, 0 );
      if( nw != file_size ) {
         SG_error("fs_entry_read(%s) rc = %ld\n", file, nw );
         exit(1);
      }

      SG_END_TIMING_DATA( ts, ts2, key );

      key = hit;

      char buf[100];
      sprintf(buf, "remote read hit %d", i );
      DATA_BLOCK(buf);
   }


   SG_BEGIN_TIMING_DATA( ts );
   
   // close
   rc = fs_entry_close( state->core, fh );
   if( rc != 0 ) {
      SG_error("fs_entry_close(%s) rc = %d\n", file, rc );
      exit(1);
   }

   SG_END_TIMING_DATA( ts, ts2, "close" );
   
   DATA_BLOCK("");

   free( fh );


   syndicate_destroy();

   free( buf );
   
   return 0;
}
Example #4
0
int main( int argc, char** argv ) {
   
   struct md_HTTP syndicate_http;
   
   int test_optind = -1;

   // set up the test 
   syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http );
   
   // arguments: creat [syndicate options] /path/to/file [data to write]
   if( test_optind < 0 )
      usage( argv[0] );
   
   if( test_optind >= argc )
      usage( argv[0] );
   
   char* path = argv[test_optind];
   
   // get state 
   struct syndicate_state* state = syndicate_get_state();
   
   // open the file
   int rc = 0;
   SG_debug("\n\n\nfs_entry_open( %s )\n\n\n", path );
   struct fs_file_handle* fh = fs_entry_open( state->core, path, SG_SYS_USER, state->core->volume, O_WRONLY, 0755, &rc );
   
   if( fh == NULL || rc != 0 ) {
      SG_error("\n\n\nfs_entry_open( %s ) rc = %d\n\n\n", path, rc );
      exit(1);
   }
   else {
      SG_debug("\n\n\nfs_entry_open( %s ) rc = %d\n\n\n", path, rc );
   }
   
   // write data
   for( int i = test_optind + 1; i < argc; i++ ) {
      
      // get offset
      long offset = strtol( argv[i], NULL, 10 );
      
      i++;
      if( i >= argc ) {
         // must have [offset size] pairs
         usage( argv[0] );
      }
      
      // get data
      char* buf = argv[i];
      size_t size = strlen(buf);
      
      // write the data
      SG_debug("\n\n\nfs_entry_write( %s, %ld, %ld, '%s' )\n\n\n", path, size, offset, buf );
      ssize_t nw = fs_entry_write( state->core, fh, buf, size, offset );
      
      if( nw < 0 ) {
         SG_error("\n\n\nfs_entry_write( %s, %ld, %ld, '%s' ) rc = %d\n\n\n", path, size, offset, buf, nw );
         exit(1);
      }
      else {
         SG_debug("\n\n\nfs_entry_write( %s, %ld, %ld, '%s' ) rc = %zd\n\n\n", path, size, offset, buf, nw );
      }
   }
   
   // close
   SG_debug("\n\n\nfs_entry_close( %s )\n\n\n", path );
   rc = fs_entry_close( state->core, fh );
   if( rc != 0 ) {
      SG_error("\n\n\nfs_entry_close( %s ) rc = %d\n\n\n", path, rc );
      exit(1);
   }
   else {
      SG_debug("\n\n\nfs_entry_close( %s ) rc = %d\n\n\n", path, rc );
   }
   
   free( fh );
   
   // shut down the test 
   syndicate_functional_test_shutdown( &syndicate_http );
   
   return 0;
}
Example #5
0
int main( int argc, char** argv ) {
   
   struct md_HTTP syndicate_http;
   
   int test_optind = -1;

   // set up the test 
   syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http );
   
   // arguments: listxattr [syndicate options] /path/to/file
   if( test_optind < 0 )
      usage( argv[0] );
   
   if( test_optind >= argc )
      usage( argv[0] );
   
   char* path = argv[test_optind];
   
   char xattr_listing[65536];
   memset( xattr_listing, 65536, 0 );
   
   // get state 
   struct syndicate_state* state = syndicate_get_state();
   
   // get the xattr list size
   dbprintf("\n\n\nfs_entry_listxattr( %s )\n\n\n", path );
   
   ssize_t rc = fs_entry_listxattr( state->core, path, xattr_listing, 0, SYS_USER, 0 );
   if( rc < 0 || rc > 65535 ) {
      errorf("\n\n\nfs_entry_listxattr( %s ) rc = %zd\n\n\n", path, rc );
      syndicate_functional_test_shutdown( &syndicate_http );
      exit(1);
   }
   
   dbprintf("\n\n\nfs_entry_listxattr( %s, 0 ) rc = %zd\n\n\n", path, rc );
   
   // get the xattr list for real this time 
   memset( xattr_listing, 0, 65536 );
   
   rc = fs_entry_listxattr( state->core, path, xattr_listing, rc, SYS_USER, 0 );
   if( rc < 0 || rc > 65535 ) {
      errorf("\n\n\nfs_entry_listxattr( %s ) rc = %zd\n\n\n", path, rc );
      syndicate_functional_test_shutdown( &syndicate_http );
      exit(1);
   }
   
   dbprintf("\n\n\nfs_entry_listxattr( %s ) rc = %zd\n", path, rc );
   
   // tokenize and print the xattr listing 
   ssize_t off = 0;
   while( off < rc ) {
      printf("  %s\n", xattr_listing + off);
      
      off += strlen(xattr_listing + off);
      off += 1;
   }
   printf("\n");
   
   // shut down the test 
   syndicate_functional_test_shutdown( &syndicate_http );
   
   return 0;
}