コード例 #1
0
ファイル: gfccinfo.c プロジェクト: ddk50/gfarm_v2
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;
}
コード例 #2
0
ファイル: gfccinfo.c プロジェクト: ddk50/gfarm_v2
/*
 * 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;
}
コード例 #3
0
ファイル: gfs_statfsnode.c プロジェクト: eterps/pwrake
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);
}
コード例 #4
0
ファイル: gfccinfo.c プロジェクト: ddk50/gfarm_v2
static void
gfarm_paraccess_connect_finish(void *closure)
{
	struct gfarm_access *a = closure;
	gfarm_error_t e;
	struct gfs_connection *gfs_server;

	e = gfs_client_connect_result_multiplexed(a->protocol_state,
	    &gfs_server);
	if (e != GFARM_ERR_NO_ERROR) {
		gfarm_paraccess_callback(a->pa, a, &a->load, NULL, e);
		return;
	}
	gfarm_paraccess_callback(a->pa, a, &a->load, gfs_server, e);
	gfs_client_connection_free(gfs_server);
}
コード例 #5
0
ファイル: gfs_pio_local.c プロジェクト: ddk50/gfarm_v2
static gfarm_error_t
gfs_pio_local_storage_close(GFS_File gf)
{
	gfarm_error_t e, e2;
	struct gfs_file_section_context *vc = gf->view_context;
	struct gfs_connection *gfs_server = vc->storage_context;

	if (close(vc->fd) == -1)
		e = gfarm_errno_to_error(errno);
	else
		e = GFARM_ERR_NO_ERROR;
#ifndef __KERNEL__
	/*
	 * Do not close remote file from a child process because its
	 * open file count is not incremented.
	 * XXX - This behavior is not the same as expected, but better
	 * than closing the remote file.
	 */
	if (vc->pid != getpid()) {
		if (e != GFARM_ERR_NO_ERROR) {
			gflog_debug(GFARM_MSG_1001362,
				"close operation on view context "
				"file descriptor failed: %s",
				gfarm_error_string(e));
		}
		return (e);
	}
#endif /* __KERNEL__ */
	e2 = gfs_client_close(gfs_server, gf->fd);
	gfarm_schedule_host_unused(
	    gfs_client_hostname(gfs_server),
	    gfs_client_port(gfs_server),
	    gfs_client_username(gfs_server),
	    gf->scheduled_age);

	gfs_client_connection_free(gfs_server);

	if (e != GFARM_ERR_NO_ERROR || e2 != GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1001363,
			"Close operation on local storage failed: %s",
			gfarm_error_string(
				e != GFARM_ERR_NO_ERROR ? e : e2));
	}

	return (e != GFARM_ERR_NO_ERROR ? e : e2);
}
コード例 #6
0
ファイル: gfs_pio_remote.c プロジェクト: eterps/pwrake
static gfarm_error_t
gfs_pio_remote_storage_close(GFS_File gf)
{
	gfarm_error_t e;
	struct gfs_file_section_context *vc = gf->view_context;
	struct gfs_connection *gfs_server = vc->storage_context;

	/*
	 * Do not close remote file from a child process because its
	 * open file count is not incremented.
	 * XXX - This behavior is not the same as expected, but better
	 * than closing the remote file.
	 */
	if (vc->pid != getpid())
		return (GFARM_ERR_NO_ERROR);
	e = gfs_client_close(gfs_server, gf->fd);
	gfs_client_connection_free(gfs_server);
	return (e);
}
コード例 #7
0
ファイル: gfs_replicate.c プロジェクト: ddk50/gfarm_v2
/* XXX FIXME */
static gfarm_error_t
gfs_replicate_from_to_internal(GFS_File gf, char *srchost, int srcport,
	char *dsthost, int dstport)
{
	gfarm_error_t e;
	struct gfm_connection *gfm_server = gfs_pio_metadb(gf);
	struct gfs_connection *gfs_server;
	int nretry = 1, gfsd_retried = 0, failover_retried = 0;

retry:
	gfm_server = gfs_pio_metadb(gf);
	if ((e = gfs_client_connection_and_process_acquire(
	    &gfm_server, dsthost, dstport, &gfs_server, NULL))
		!= GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1001388,
			"acquirement of client connection failed: %s",
			gfarm_error_string(e));
		return (e);
	}

	e = gfs_client_replica_add_from(gfs_server, srchost, srcport,
	    gfs_pio_fileno(gf));
	gfs_client_connection_free(gfs_server);
	if (e != GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1003878,
		    "gfs_client_replica_add_from: %s",
		    gfarm_error_string(e));
		if (nretry-- > 0) {
			if (gfs_client_is_connection_error(e)) {
				gfsd_retried = 1;
				goto retry;
			}
			if (gfs_pio_should_failover(gf, e)) {
				if ((e = gfs_pio_failover(gf))
				    != GFARM_ERR_NO_ERROR) {
					gflog_debug(GFARM_MSG_1003879,
					    "gfs_pio_failover: %s",
					    gfarm_error_string(e));
				} else {
					failover_retried = 1;
					goto retry;
				}
			}
		}
	}
	if ((e == GFARM_ERR_ALREADY_EXISTS || e == GFARM_ERR_FILE_BUSY) &&
	    (gfsd_retried || failover_retried)) {
		gflog_warning(GFARM_MSG_1003453,
		    "error ocurred at retry for the operation after "
		    "connection to %s, "
		    "so the operation possibly succeeded in the server."
		    " error='%s'",
		    gfsd_retried && failover_retried ?
		    "gfsd was disconnected and connection to "
		    "gfmd was failed over" :
		    gfsd_retried ?
		    "gfsd was disconnected" :
		    "gfmd was failed over" ,
		    gfarm_error_string(e));
	}
	return (e);
}