Exemple #1
0
static int chirp_fs_hdfs_init(const char url[CHIRP_PATH_MAX])
{
	static const char *groups[] = { "supergroup" };
	char *path;

	if(!hdfs_services) {
		if (hdfs_library_envinit() == -1)
			return -1;
		hdfs_services = hdfs_library_open();
		if(!hdfs_services)
			return -1;
	}

	debug(D_CHIRP, "url: %s", url);

	assert(strprfx(url, "hdfs://"));
	strcpy(hdfs_host, url+strlen("hdfs://"));
	path = strchr(hdfs_host, '/');
	if (path) {
		path_collapse(path, hdfs_root, 1);
		*path = '\0'; /* remove path from hdfs_host */
		/* now hdfs_host holds 'host[:port]' */
	} else {
		strcpy(hdfs_root, "/");
	}

	if (strlen(hdfs_host) == 0) {
		/* use default */
		strcpy(hdfs_host, "default");
		hdfs_port = 0;
	} else if (strchr(hdfs_host, ':')) {
		hdfs_port = atoi(strchr(hdfs_host, ':')+1);
		*strchr(hdfs_host, ':') = '\0';
	} else {
		hdfs_port = 50070; /* default namenode port */
	}

	debug(D_HDFS, "connecting to hdfs://%s:%u%s as '%s'\n", hdfs_host, hdfs_port, hdfs_root, chirp_owner);
	assert(fs == NULL);
	fs = hdfs_services->connect_as_user(hdfs_host, hdfs_port, chirp_owner, groups, 1);
	if (fs == NULL) {
		errno = EIO;
		return -1;
	}

	memset(open_files, 0, sizeof(open_files));

	return cfs_create_dir("/", 0711);
}
Exemple #2
0
static int chirp_fs_local_init(const char url[CHIRP_PATH_MAX])
{
    int i;
    char tmp[CHIRP_PATH_MAX];

    if (strprfx(url, "local://") || strprfx(url, "file://"))
        strcpy(tmp, strstr(url, "//")+2);
    else
        strcpy(tmp, url);

    path_collapse(tmp, local_root, 1);

    for (i = 0; i < CHIRP_FILESYSTEM_MAXFD; i++)
        open_files[i].fd = -1;

    return cfs_create_dir("/", 0711);
}