Exemplo n.º 1
0
gfarm_error_t
request_gfsd_cacheinfo(struct gfarm_host_info *host_info,
	struct gfarm_paraccess *pa)
{
	gfarm_error_t e;
	char *canonical_hostname;
	char *str;
	struct sockaddr addr;
	struct gfs_connection *gfs_server;

	/* dup `host_info->hostname' -> `hostname' */
	canonical_hostname = strdup(host_info->hostname);
	if (canonical_hostname == NULL) {
		e = GFARM_ERR_NO_MEMORY;
		fprintf(stderr, "%s: %s\n", program_name,
		    gfarm_error_string(e));
		return (e);
	}

	e = (*opt_resolv_addr)(
	    canonical_hostname, host_info->port, host_info,
	    &addr, NULL);
	if (e != GFARM_ERR_NO_ERROR) {
		output_process(NULL, canonical_hostname, NULL, NULL, NULL, e);
		return (e);
	}

	/* 
	 * Few additions by Kazushi
	 */
	e = gfs_client_connection_acquire_by_host(gfm_server, canonical_hostname, 
		host_info->port, &gfs_server, "192.168.100.1");
	if (e != GFARM_ERR_NO_ERROR) {
		fprintf(stderr, 
		    "Could not establish to connect gfs client (%s)\n", 
			 canonical_hostname);
		return (e);
	}
	
	e = gfs_client_recv_hitrates(gfs_server, &str);
	if (e != GFARM_ERR_NO_ERROR) {
		fprintf(stderr, 
		    "Could not clear hitrate in (%s)\n", 
				canonical_hostname);
		return (e);
	}

	fprintf(stdout, "<%s:%d> -- %s\n", 
	        canonical_hostname, host_info->port, str);
	free(str);

	gfs_client_connection_free(gfs_server);

	/* return (gfarm_paraccess_request(pa, */
	/*     if_hostname, canonical_hostname, info->port, &addr)); */
	return GFARM_ERR_NO_ERROR;
}
Exemplo n.º 2
0
/*
 * Note that this may be called when opt_use_metadb == 0.
 * In that case, the host_info is faked, and all members in the info structure
 * except info->hostname are not valid. (see list_gfsd_info())
 */
gfarm_error_t
request_clear_gfsd_cacheinfo(struct gfarm_host_info *info,
	struct gfarm_paraccess *pa)
{	
	gfarm_error_t e;
	struct sockaddr addr;
	struct gfs_connection *gfs_server;
	char *canonical_hostname, *if_hostname;

	canonical_hostname = strdup(info->hostname);
	if (canonical_hostname == NULL) {
		e = GFARM_ERR_NO_MEMORY;
	} else {
		e = (*opt_resolv_addr)(
		    canonical_hostname, info->port, info,
		    &addr, &if_hostname);
	}
	if (e != GFARM_ERR_NO_ERROR) {
		fprintf(stderr, "%s: %s\n", info->hostname,
		    gfarm_error_string(e));
		if (canonical_hostname != NULL)
			free(canonical_hostname);
		return (e);
	}


	/* 
	 * Few additions by Kazushi
	 */
	e = gfs_client_connection_acquire_by_host(gfm_server, canonical_hostname, 
		info->port, &gfs_server, "192.168.100.1");
	if (e != GFARM_ERR_NO_ERROR) {
		fprintf(stderr, 
		    "Could not establish to connect gfs client (%s)\n", 
			 canonical_hostname);
		return (e);
	}	

	e = gfs_client_hitrates_clear(gfs_server);
	if (e != GFARM_ERR_NO_ERROR) {
		fprintf(stderr, 
		    "Could not clear hitrate in (%s)\n", 
				canonical_hostname);
		return (e);
	}

	gfs_client_connection_free(gfs_server);

	fprintf(stdout, "cache information on %s:%d was cleared\n", 
        canonical_hostname, info->port);

	/* return (gfarm_paraccess_request(pa, */
	/*     if_hostname, canonical_hostname, info->port, &addr)); */
	return GFARM_ERR_NO_ERROR;
}
Exemplo n.º 3
0
gfarm_error_t
gfs_statfsnode(char *host, int port,
	gfarm_int32_t *bsize, gfarm_off_t *blocks, gfarm_off_t *bfree,
	gfarm_off_t *bavail, gfarm_off_t *files, gfarm_off_t *ffree,
	gfarm_off_t *favail)
{
	gfarm_error_t e;
	struct gfm_connection *gfm_server;
	struct gfs_connection *gfs_server;
	int retry = 0;

	for (;;) {
		if ((e = gfm_client_connection_and_process_acquire(
		    gfarm_metadb_server_name, gfarm_metadb_server_port,
		    &gfm_server)) != GFARM_ERR_NO_ERROR)
			return (e);

		if ((e = gfs_client_connection_acquire_by_host(gfm_server,
		    host, port, &gfs_server, NULL))!= GFARM_ERR_NO_ERROR)
			goto free_gfm_connection;

		if (gfs_client_pid(gfs_server) == 0)
			e = gfarm_client_process_set(gfs_server, gfm_server);
		if (e == GFARM_ERR_NO_ERROR) {
			/* "/" is actually not used */
			e = gfs_client_statfs(gfs_server, "/", bsize, blocks,
				bfree, bavail, files, ffree, favail);
			if (gfs_client_is_connection_error(e) && ++retry<=1) {
				gfs_client_connection_free(gfs_server);
				continue;
			}
		}
		break;
	}
	gfs_client_connection_free(gfs_server);
 free_gfm_connection:
	gfm_client_connection_free(gfm_server);
	return (e);
}