Commit c04e6c09 authored by Matthieu Dorier's avatar Matthieu Dorier

updated copy-to program to take target id into account

parent 7835a534
......@@ -28,8 +28,6 @@ int main(int argc, char **argv)
margo_instance_id mid;
bake_client_t bcl;
bake_provider_handle_t bph;
uint64_t num_targets;
bake_target_id_t bti;
uint8_t mplex_id;
hg_return_t hret;
int ret;
......@@ -47,6 +45,7 @@ int main(int argc, char **argv)
}
svr_addr_str = argv[1];
mplex_id = atoi(argv[2]);
/* initialize Margo using the transport portion of the server
* address (i.e., the part before the first : character if present)
*/
......@@ -87,17 +86,6 @@ int main(int argc, char **argv)
return(-1);
}
ret = bake_probe(bph, 1, &bti, &num_targets);
if(ret < 0)
{
fprintf(stderr, "Error: bake_probe()\n");
bake_provider_handle_release(bph);
margo_addr_free(mid, svr_addr);
bake_client_finalize(bcl);
margo_finalize(mid);
return(-1);
}
region_fd = open(argv[3], O_RDONLY);
if(region_fd < 0)
{
......
......@@ -28,9 +28,8 @@ int main(int argc, char **argv)
margo_instance_id mid;
bake_client_t bcl;
bake_provider_handle_t bph;
uint64_t num_targets;
bake_target_id_t bti;
uint8_t mplex_id;
uint32_t target_number;
hg_return_t hret;
int ret;
bake_region_id_t rid;
......@@ -41,14 +40,18 @@ int main(int argc, char **argv)
char region_file[128];
uint64_t check_size;
if(argc != 4)
if(argc != 5)
{
fprintf(stderr, "Usage: bake-copy-to <local file> <server addr> <mplex id>\n");
fprintf(stderr, " Example: ./bake-copy-to /tmp/foo.dat tcp://localhost:1234 1\n");
fprintf(stderr, "Usage: bake-copy-to <local file> <server addr> <mplex id> <target number>\n");
fprintf(stderr, " Example: ./bake-copy-to /tmp/foo.dat tcp://localhost:1234 1 3\n");
return(-1);
}
svr_addr_str = argv[2];
mplex_id = atoi(argv[3]);
target_number = atoi(argv[4]);
uint64_t num_targets;
bake_target_id_t bti[target_number];
fd = open(argv[1], O_RDONLY);
if(fd < 0)
......@@ -120,7 +123,7 @@ int main(int argc, char **argv)
return(-1);
}
ret = bake_probe(bph, 1, &bti, &num_targets);
ret = bake_probe(bph, target_number, bti, &num_targets);
if(ret < 0)
{
bake_provider_handle_release(bph);
......@@ -133,8 +136,18 @@ int main(int argc, char **argv)
return(-1);
}
if(num_targets < target_number) {
fprintf(stderr, "Error: provider has only %d storage targets\n", num_targets);
margo_addr_free(mid, svr_addr);
bake_client_finalize(bcl);
margo_finalize(mid);
munmap(local_region, statbuf.st_size);
close(fd);
return -1;
}
/* create region */
ret = bake_create(bph, bti, statbuf.st_size, &rid);
ret = bake_create(bph, bti[target_number-1], statbuf.st_size, &rid);
if(ret != 0)
{
bake_provider_handle_release(bph);
......
......@@ -13,7 +13,7 @@ test_start_servers 1 2 20
#####################
echo "Hello world." > $TMPBASE/foo.dat
CPOUT=`run_to 10 src/bake-copy-to $TMPBASE/foo.dat $svr1 1`
CPOUT=`run_to 10 src/bake-copy-to $TMPBASE/foo.dat $svr1 1 1`
if [ $? -ne 0 ]; then
run_to 10 src/bake-shutdown $svr1
wait
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment