From ec49fc6bad95e516b9124e0f9fceedbb692826c1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 7 Mar 2017 07:19:40 -0400 Subject: [PATCH] =?UTF-8?q?renamed=20=E2=80=9Apath=E2=80=98=20setting=20of?= =?UTF-8?q?=20file=20node-type=20to=20=E2=80=9Auri=E2=80=98=20in=20prepara?= =?UTF-8?q?tion=20for=20upcoming=20advio=20remote=20IO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/nodes/File.md | 14 +++++++------- etc/example.conf | 4 ++-- include/villas/nodes/file.h | 4 ++-- lib/nodes/file.c | 22 +++++++++++----------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/nodes/File.md b/doc/nodes/File.md index 9b37a6aaa..42839398d 100644 --- a/doc/nodes/File.md +++ b/doc/nodes/File.md @@ -7,9 +7,9 @@ The `file` node-type can be used to log or replay samples to / from disk. Every `file` node can be configured to only read or write or to do both at the same time. The node configuration is splitted in to groups: `in` and `out`. -#### `path` *(string: filesystem path)* +#### `uri` *(string: libcurl URI)* -Specifies the path to a file from which is written to or read from (depending in which group is used). +Specifies the URI to a file from which is written to or read from depending in which group (`in`or `out`) is used. See below for a description of the file format. This setting allows to add special paceholders for time and date values. @@ -17,7 +17,7 @@ See [strftime(3)](http://man7.org/linux/man-pages/man3/strftime.3.html) for a li **Example**: - out = "logs/measurements_%Y-%m-%d_%H-%M-%S.log" + uri = "logs/measurements_%Y-%m-%d_%H-%M-%S.log" will create a file called: *path_of_working_directory*/logs/measurements_2015-08-09_22-20-50.log @@ -29,7 +29,7 @@ Specifies the mode which should be used to open the output file. See [open(2)](http://man7.org/linux/man-pages/man2/open.2.html) for an explanation of allowed values. The default value is `w+` which will start writing at the beginning of the file and create it in case it does not exist yet. -#### `epoch_mode` *("direct"|"wait" | "relative"|"absolute")* +#### `epoch_mode` *("direct" | "wait" | "relative" | "absolute")* The *epoch* describes the point in time when the first message will be read from the file. This setting allows to select the behaviour of the following `epoch` setting. @@ -65,7 +65,7 @@ If this setting has a non-zero value, the default behaviour is overwritten with Only valid for the `out` group. -Splits the output file every `split` mega-byte. This setting will append the chunk number to the `path` setting. +Splits the output file every `split` mega-byte. This setting will append the chunk number to the `uri` setting. Example: `data/my_measurements.log_001` @@ -84,7 +84,7 @@ Expects the input data in splitted format. ### The following settings are specific to the file node-type!! ### in = { - path = "logs/input.log", # These options specify the path prefix where the the files are stored + uri = "logs/input.log", # These options specify the URI where the the files are stored mode = "w+", # The mode in which files should be opened (see open(2)) epoch_mode = "direct" # One of: direct (default), wait, relative, absolute @@ -98,7 +98,7 @@ Expects the input data in splitted format. splitted = false }, out = { - path = "logs/output_%F_%T.log" # The output path accepts all format tokens of (see strftime(3)) + URI = "logs/output_%F_%T.log" # The output URI accepts all format tokens of (see strftime(3)) mode = "a+" # You might want to use "a+" to append to a file split = 100, # Split output file every 100 MB diff --git a/etc/example.conf b/etc/example.conf index 177537cbe..806a6919c 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -84,7 +84,7 @@ nodes = { ### The following settings are specific to the file node-type!! ### in = { - path = "logs/input.log", # These options specify the path prefix where the the files are stored + uri = "logs/input.log", # These options specify the path prefix where the the files are stored mode = "r", # The mode in which files should be opened (see open(2)) epoch_mode = "direct" # One of: direct (default), wait, relative, absolute @@ -98,7 +98,7 @@ nodes = { splitted = false }, out = { - path = "logs/output_%F_%T.log" # The output path accepts all format tokens of (see strftime(3)) + uri = "logs/output_%F_%T.log" # The output path accepts all format tokens of (see strftime(3)) mode = "a+" # You might want to use "a+" to append to a file split = 100, # Split output file every 100 MB diff --git a/include/villas/nodes/file.h b/include/villas/nodes/file.h index 0804691aa..4d9225850 100644 --- a/include/villas/nodes/file.h +++ b/include/villas/nodes/file.h @@ -31,7 +31,7 @@ struct file { const char *mode; /**< libc: fopen() mode */ const char *fmt; /**< Format string for file name. */ - char *path; /**< Real file name */ + char *uri; /**< Real file name */ int chunk; /**< Current chunk number. */ int split; /**< Split file every file::split mega bytes. */ @@ -44,7 +44,7 @@ struct file { EPOCH_ABSOLUTE } read_epoch_mode; /**< Specifies how file::offset is calculated. */ - struct timespec read_first; /**< The first timestamp in the file file::path_in */ + struct timespec read_first; /**< The first timestamp in the file file::{read,write}::uri */ struct timespec read_epoch; /**< The epoch timestamp from the configuration. */ struct timespec read_offset; /**< An offset between the timestamp in the input file and the current time */ diff --git a/lib/nodes/file.c b/lib/nodes/file.c index 0789e4b48..ea808eab8 100644 --- a/lib/nodes/file.c +++ b/lib/nodes/file.c @@ -41,13 +41,13 @@ static char * file_format_name(const char *format, struct timespec *ts) static FILE * file_reopen(struct file_direction *dir) { char buf[FILE_MAX_PATHLEN]; - const char *path = buf; + const char *uri = buf; /* Append chunk number to filename */ if (dir->chunk >= 0) - snprintf(buf, FILE_MAX_PATHLEN, "%s_%03u", dir->path, dir->chunk); + snprintf(buf, FILE_MAX_PATHLEN, "%s_%03u", dir->uri, dir->chunk); else - path = dir->path; + uri = dir->uri; if (dir->handle) fclose(dir->handle); @@ -59,7 +59,7 @@ static int file_parse_direction(config_setting_t *cfg, struct file *f, int d) { struct file_direction *dir = (d == FILE_READ) ? &f->read : &f->write; - if (!config_setting_lookup_string(cfg, "path", &dir->fmt)) + if (!config_setting_lookup_string(cfg, "uri", &dir->fmt)) return -1; if (!config_setting_lookup_string(cfg, "mode", &dir->mode)) @@ -139,7 +139,7 @@ char * file_print(struct node *n) } strcatf(&buf, "in=%s, epoch_mode=%s, epoch=%.2f, ", - f->read.path ? f->read.path : f->read.fmt, + f->read.uri ? f->read.uri : f->read.fmt, epoch_str, time_to_double(&f->read_epoch) ); @@ -150,7 +150,7 @@ char * file_print(struct node *n) if (f->write.fmt) { strcatf(&buf, "out=%s, mode=%s, ", - f->write.path ? f->write.path : f->write.fmt, + f->write.uri ? f->write.uri : f->write.fmt, f->write.mode ); } @@ -187,15 +187,15 @@ int file_open(struct node *n) if (f->read.fmt) { /* Prepare file name */ f->read.chunk = f->read.split ? 0 : -1; - f->read.path = file_format_name(f->read.fmt, &now); + f->read.uri = file_format_name(f->read.fmt, &now); /* Open file */ f->read.handle = file_reopen(&f->read); if (!f->read.handle) - serror("Failed to open file for reading: '%s'", f->read.path); + serror("Failed to open file for reading: '%s'", f->read.uri); /* Create timer */ - f->read_timer = (f->read_rate) + f->read_timer = f->read_rate ? timerfd_create_rate(f->read_rate) : timerfd_create(CLOCK_REALTIME, 0); if (f->read_timer < 0) @@ -252,8 +252,8 @@ int file_close(struct node *n) { struct file *f = n->_vd; - free(f->read.path); - free(f->write.path); + free(f->read.uri); + free(f->write.uri); if (f->read_timer) close(f->read_timer);