Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: true
BreakBeforeBinaryOperators: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
Expand Down Expand Up @@ -53,4 +53,3 @@ ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: Never
DisableFormat: false
...

196 changes: 196 additions & 0 deletions scripts/util/cascade_runner
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
#!/bin/bash

set -euo pipefail

SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
HELP_STRING="A helper script to set up a local cascade instance
Usage: $SCRIPT_NAME [options]
-h Print this message and exit.
-d D CFG directory location (defaults to cfg).
-n N Sets a range from 0..N-1 for range commands commands.

-u K update key in range.
-v V update value in range.
(ex. -n 7 -u default_log_level -v info)

-k Kill running cascade nodes.
-r Remove old logs in range.
-s Start server nodes in range.
-f D directory to mount (requires -c flag to start and -k to end).
-c I Start client node at folder cfg/nI."

CFG_DIR="$SCRIPT_DIR/cfg"
FUSE_DIR=""
HELP=false
KILL=false
CLEAN=false
SERVERS=false
NODES=0
CLIENT=-1

UPDATE_KEY=""
UPDATE_VALUE=""

# TODO get from env? or as arg
BASE_PATH="/root/workspace/cascade/build-Release/src"

export PATH="$PATH:$BASE_PATH/service"
export PATH="$PATH:$BASE_PATH/service/fuse"

FUSE_COMMAND="cascade_fuse_client"
CLIENT_COMMAND="cascade_client"
SERVER_COMMAND="cascade_server"
LOG_FILE="node_info.log"

if ! command -v $SERVER_COMMAND &>/dev/null; then
echo "$SERVER_COMMAND could not be found"
exit_abnormal
fi

usage() {
echo "$HELP_STRING" 1>&2
}

exit_abnormal() {
usage
exit 1
}

check_num() {
# $1: string to check
RE_ISNUM='^[0-9]+$'
if ! [[ $1 =~ $RE_ISNUM ]]; then
exit_abnormal
fi
}

foreach() {
# $1: command to do (accepts count as arg)
COUNT=0
while [ $COUNT -lt "$NODES" ]; do
DIR="$CFG_DIR/n$COUNT"
cd "$DIR"

$1 $COUNT

cd - &>/dev/null
((COUNT += 1))
done
}

main() {
while getopts 'hd:n:f:krsc:u:v:' opt; do
case "$opt" in
h) HELP=true ;;
d) CFG_DIR="$OPTARG" ;;
n)
NODES="$OPTARG"
check_num "$NODES"
;;
f) FUSE_DIR="$OPTARG" ;;
k) KILL=true ;;
r) CLEAN=true ;;
s) SERVERS=true ;;
c)
CLIENT="$OPTARG"
check_num "$CLIENT"
;;
u) UPDATE_KEY="$OPTARG" ;;
v) UPDATE_VALUE="$OPTARG" ;;
*) exit_abnormal ;;
esac
done

if [[ "$HELP" = true ]]; then
usage
exit
fi

if [[ -n "$FUSE_DIR" ]]; then
MOUNT="$(realpath "$FUSE_DIR")"

if [[ ! "$CLIENT" -eq "-1" ]]; then
DIR="$CFG_DIR/n$CLIENT"
cd "$DIR"

echo "fuse client mounting at $MOUNT"
mkdir -p "$MOUNT"
"$FUSE_COMMAND" -s -f "$MOUNT" &>"$LOG_FILE" &

cd - &>/dev/null
exit
fi

if [[ "$KILL" = true ]]; then
echo "unmounting $MOUNT and ending fuses client"
umount "$MOUNT"

pkill -SIGINT "$FUSE_COMMAND" || true

exit
fi
fi

if [[ "$KILL" = true ]]; then
# TODO better idea: save PIDs?

pkill -SIGINT "$CLIENT_COMMAND" || true
pkill -SIGINT "$SERVER_COMMAND" || true # kill cascade_server

# kill old cascade_runner and subprocesses (excluding itself)
# pgrep "${SCRIPT_NAME%.*}" | grep -v "$$" | while read -r LINE; do
# SUB_SLEEP=$(pgrep -P "$LINE")
# kill "$LINE" # kill cascade_runner while loop
# kill "$SUB_SLEEP" # kill sleep
# done
fi

if [[ "$CLEAN" = true ]]; then
x() {
echo "$1 > removing .plog and logs"
rm -rf .plog derecho_debug.log "$LOG_FILE"
}
foreach x
fi

if [[ -n "$UPDATE_KEY" ]]; then
x() {
CONFIG_FILE="derecho.cfg"
echo "$1 > updating $UPDATE_KEY with $UPDATE_VALUE in $CONFIG_FILE"
sed -i "s/\($UPDATE_KEY *= *\)\(.*\)/\1$UPDATE_VALUE/" "$CONFIG_FILE"
}
foreach x
fi

if [[ ! "$CLIENT" -eq "-1" ]]; then
DIR="$CFG_DIR/n$CLIENT"

if [[ -n "$FUSE_DIR" ]]; then
mkdir -p "$MOUNT"

cd "$DIR"
"$FUSE_COMMAND" -s -f "$MOUNT" &>"$LOG_FILE" &
else
cd "$DIR"
"$CLIENT_COMMAND"
fi

cd - &>/dev/null
exit
fi
set +e

if [[ "$SERVERS" = true ]]; then
x() {
echo "$1 > starting server node"
"$SERVER_COMMAND" --signal &>"$LOG_FILE" &
# (while true; do sleep 10000; done) |
# "$SERVER_COMMAND" &>"$LOG_FILE" &
}
foreach x

fi
}

main "$@"
3 changes: 1 addition & 2 deletions src/service/fuse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (${HAS_FUSE})
)
target_link_libraries(fuse_client cascade readline fuse3)
set_target_properties(fuse_client PROPERTIES OUTPUT_NAME cascade_fuse_client)

add_custom_command(TARGET fuse_client POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testfuse.py ${CMAKE_CURRENT_BINARY_DIR}/.
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/util.py ${CMAKE_CURRENT_BINARY_DIR}/.
Expand All @@ -29,4 +29,3 @@ if (${HAS_FUSE})
)

endif()

49 changes: 32 additions & 17 deletions src/service/fuse/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,64 @@
# Fuse API

Cascade service supports FUSE(Filesystem in Userspace) API to access data. It is a standalone client application that links with [`libfuse`](https://github.com/libfuse/libfuse). Cascade fuse api mount the file system to interact with Cascade K/V stored objects.
Cascade service supports FUSE(Filesystem in Userspace) API to access data. It is
a standalone client application that links with
[`libfuse`](https://github.com/libfuse/libfuse). Cascade fuse api mount the file
system to interact with Cascade K/V stored objects.

If you didn't see `-- Looking for include files fuse3/fuse.h, fuse3/fuse_lowlevel.h - found`, it is probably because the libfuse support is not installed. FUSE application shall be built as an executable in the built directory `src/service/fuse/cascade_fuse_client`
If you didn't see
`-- Looking for include files fuse3/fuse.h, fuse3/fuse_lowlevel.h - found`, it
is probably because the libfuse support is not installed. FUSE application shall
be built as an executable in the built directory
`src/service/fuse/cascade_fuse_client`

Running FUSE POSIX shell application is similar to run cascade cmd client. Once the cascade service is configured and started, in the client node, running `../../fuse/cascade_fuse_client [directory_to_mount]` will mount cascade file systsem to the dedicated directory.
Running FUSE POSIX shell application is similar to run cascade cmd client. Once
the cascade service is configured and started, in the client node, running
`../../fuse/cascade_fuse_client [directory_to_mount]` will mount cascade file
systsem to the dedicated directory.

Once fuse applicatino is mounted to the directory, you can access the K/V object stored in cascade using linux shell command. The structured of the mounted file system is as following
Once fuse application is mounted to the directory, you can access the K/V object
stored in cascade using linux shell command. The structured of the mounted file
system is as following

```bash
.
|-- MetadataService
|-- PersistentCascadeStoreWithStringKey
| |-- subgroup-0
| |-- shard-0
| |-- .cascade
| |-- .cascade
| |-- key-0
| ...
|-- VolatileCascadeStoreWithStringKey
| |-- subgroup-0
| |-- shard-0
| |-- .cascade
| |-- .cascade
| ...
|-- TriggerCascadeStoreWithStringKey
|-- ObjectPools
| |-- objectpoolpathname-a
| |-- a1
| |-- objectpool object 0
| ...
| |-- .cascade
| |-- a1
| |-- objectpool object 0
| ...
| |-- .cascade
| |-- .cascade
|-- .cascade
```

Support READ commands:

```
cd [dir] open directory
ls [dir] list directory
ls -a list directory with attributes
cat [file] read file
cat .cascade read directory metadata information
cd [dir] open directory
ls [dir] list directory
ls -a list directory with attributes
cat [file] read file
cat .cascade read directory metadata information
```

Limitation:

- Support only single-threaded fuse client
- Current read_file keeps a buffer of file_bytes in memory, needs further optimization to read large file
- Current read_file keeps a buffer of file_bytes in memory, needs further
optimization to read large file
- New features to come: WRITE commands to have fuse client interact with cascade
File write and editing commands, managing directories commands
File write and editing commands, managing directories commands
Loading