Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
629e1f4
(feat) test: added test scripts and folders
MHS-20 May 6, 2025
5eb1eda
(chore) client: removed old GUI library
Basigli May 12, 2025
b7f1f67
Create cmake-multi-platform.yml
MHS-20 May 12, 2025
35aae1b
(feat) gui: added loading popup when sync status
Basigli May 12, 2025
811a0da
Merge branch 'fault-tolerance' of https://github.com/MHS-20/Squid-Sto…
Basigli May 12, 2025
54aaaab
(feat) gui: loading popup when saving a file
Basigli May 13, 2025
150953f
(feat) gui: loading popup when opening a file
Basigli May 13, 2025
8868a3a
(feat) protocol: response format for file version
Basigli May 13, 2025
db693ec
(feat) protocol: response message for file version
Basigli May 13, 2025
2cf7fdf
(feat) filemanager: added support for file version
May 14, 2025
18604cc
(feat) gui: file version on create file
May 14, 2025
0d12afd
(feat) gui: updating version when saving file
May 14, 2025
28d32f2
(feat) protocol: create and update with version
May 14, 2025
1c6943a
(feat) dispatcher: support for file version
Basigli May 14, 2025
d0a50ab
(feat) server: file version logic
Basigli May 14, 2025
bbc90db
(feat) gui: gui uses crete file with version
Basigli May 15, 2025
67234f5
(feat) server: full support for file version
Basigli May 15, 2025
b77c945
(chore) server: removed old fileTime code
Basigli May 15, 2025
08f31fe
(feat) gui: gui even if connection is missing
Basigli May 15, 2025
9086857
(fix) server: error handling buildFileLockMap when getting NACK
Basigli May 15, 2025
8640c78
(fix) protocol: error handling in syncStatus
Basigli May 16, 2025
e16f57b
(fix) server: now select is async
Basigli May 18, 2025
7fb9bca
(fix) protocol: never setting version for new files
Basigli May 18, 2025
fefa567
(feat) server: now requesting fileVersionMap to datanodes
Basigli May 18, 2025
385ac66
(fix) protocol: fixed bug in syncStatus
Basigli May 18, 2025
4fb959d
(fix) server: typo in sendHeartbeats
Basigli May 19, 2025
575b62d
(fix) server: typo in sendHeartbeats
Basigli May 19, 2025
d5df5fa
(feat) gui: error message when file already opened
Basigli May 19, 2025
64be9d6
(feat) filemanager: added FileLock
Basigli May 19, 2025
64a8796
(feat) client: release lock handling
Basigli May 19, 2025
655ac87
(feat) gui: now using FileLock of FileManager
Basigli May 19, 2025
89c637d
(feat) gui: show refresh button when new file version exists
Basigli May 19, 2025
b96243a
(fix) gui: rendering when server is down
Basigli May 19, 2025
c9a75d8
(fix) gui: non blocking when losing connection
Basigli May 19, 2025
8b5e97a
(fix) gui: now reconnecting when connection is back
Basigli May 19, 2025
5bab3b7
(fix) server: fixed file rebalancing
May 21, 2025
801630a
(fix) server: fixed iterator in rebalancing
May 21, 2025
7d188da
(feat) CLI: added cli args for server and datanode
May 21, 2025
4c51009
(feat) client: added command line arguments
Basigli May 22, 2025
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
Binary file modified .DS_Store
Binary file not shown.
32 changes: 32 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CMake Build (Ubuntu + macOS)

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B build

- name: Build
run: cmake --build build

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: my-app-${{ matrix.os }}
path: |
build/my-executable # <-- cambia questo con il tuo eseguibile
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ CMakeFiles/*
!build/build.sh
!build/buildGnome.sh
!build/buildTestMultiClient.sh
!build/buildTestMultiDataNodes.sh
!build/buildTestMultiDataNode.sh
!build/buildTestMultiple.sh
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"${workspaceFolder}/**",
"/usr/local/Cellar/sdl2/2.32.2/include/SDL2",
"${workspaceFolder}/common/src/filesystem",
"${workspaceFolder}/common/src/squidprotocol"
"${workspaceFolder}/common/src/squidprotocol",
"/usr/include/SDL2"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
Expand Down
6 changes: 3 additions & 3 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ cmake ..
make -j 8

# Move executables to their respective directories
mv ./SquidStorage ../test_txt/test_client/SquidStorage
mv ./SquidStorageServer ../test_txt/test_server/SquidStorageServer
mv ./DataNode ../test_txt/test_datanode/DataNode
cp ./SquidStorage ../test_txt/test_client/SquidStorage
cp ./SquidStorageServer ../test_txt/test_server/SquidStorageServer
cp ./DataNode ../test_txt/test_datanode/DataNode

# Start a new tmux session
SESSION_NAME="SquidStorage"
Expand Down
46 changes: 46 additions & 0 deletions build/buildTestMultiDataNode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Build the project
cmake ..
make -j 8

# Move executables to their respective directories
cp ./SquidStorage ../test_txt/test_client1/SquidStorage
cp ./SquidStorageServer ../test_txt/test_server/SquidStorageServer
cp ./DataNode ../test_txt/test_datanode1/DataNode
cp ./DataNode ../test_txt/test_datanode2/DataNode
cp ./DataNode ../test_txt/test_datanode3/DataNode

# Start a new tmux session
SESSION_NAME="SquidStorage"
tmux new-session -d -s $SESSION_NAME
tmux set -g mouse on

# Run SquidStorageServer in the first pane
tmux rename-window -t $SESSION_NAME "Server"
tmux send-keys -t $SESSION_NAME "cd ../test_txt/test_server && ./SquidStorageServer" C-m
sleep 2
# Split the window and run DataNode in the second pane
tmux split-window -h
tmux send-keys "cd ../test_txt/test_datanode1 && ./DataNode" C-m

tmux split-window -h
tmux send-keys "cd ../test_txt/test_datanode2 && ./DataNode" C-m

tmux split-window -h
tmux send-keys "cd ../test_txt/test_datanode3 && ./DataNode" C-m

# Split the window vertically and run SquidStorage in the third pane
tmux split-window -v
tmux send-keys "cd ../test_txt/test_client1 && ./SquidStorage" C-m

# Attach to the tmux session
tmux select-pane -t 0
tmux attach-session -t $SESSION_NAME

# Clean up executables after execution
rm -f ../test_txt/test_client1/SquidStorage
rm -f ../test_txt/test_server/SquidStorageServer
rm -f ../test_txt/test_datanode1/DataNode
rm -f ../test_txt/test_datanode2/DataNode
rm -f ../test_txt/test_datanode3/DataNode
# make clean
37 changes: 30 additions & 7 deletions client/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ void Client::run()

void Client::checkSecondarySocket()
{
while (!secondarySquidProtocol.isAlive())
if (!secondarySquidProtocol.isAlive())
{
cout << "[CLIENT]: Lost connection, reconnecting..." << endl;
this_thread::sleep_for(chrono::seconds(5));
return;
// this->initiateConnection();
// if(secondarySquidProtocol.isAlive()) this->syncStatus();
}
Expand All @@ -62,15 +62,23 @@ void Client::checkSecondarySocket()
return;
}

// Se ci sono dati sulla socket secondaria
// if data on second socket
if (FD_ISSET(secondarySquidProtocol.getSocket(), &readfds))
{
try
{
// Ricevi e gestisci il messaggio
Message mex = secondarySquidProtocol.receiveAndParseMessage();
cout << "[CLIENT]: Received message on secondary socket: " + mex.keyword << endl;
secondarySquidProtocol.requestDispatcher(mex);
if (mex.keyword == RELEASE_LOCK)
{
cout << "[CLIENT]: Received request for FileLock release" << endl;
FileManager::getInstance().getFileLock().setIsLocked(true);
}
else
{
secondarySquidProtocol.requestDispatcher(mex);
}

}
catch (exception &e)
{
Expand All @@ -79,10 +87,11 @@ void Client::checkSecondarySocket()
}
else
{
// Nessun messaggio disponibile
cout << "[CLIENT]: No messages on secondary socket" << endl;
return;
// cout << "[CLIENT]: No message available on secondary socket" << endl;
}
}

void Client::initiateConnection()
{
this->connectToServer();
Expand Down Expand Up @@ -147,6 +156,10 @@ void Client::createFile(string filePath)
{
handleRequest(squidProtocol.createFile(filePath));
}
void Client::createFile(string filePath, int version)
{
handleRequest(squidProtocol.createFile(filePath, version));
}

void Client::deleteFile(string filePath)
{
Expand All @@ -158,6 +171,11 @@ void Client::updateFile(string filePath)
handleRequest(squidProtocol.updateFile(filePath));
}

void Client::updateFile(std::string filePath, int version)
{
handleRequest(squidProtocol.updateFile(filePath, version));
}

void Client::syncStatus()
{
handleRequest(squidProtocol.syncStatus());
Expand All @@ -173,6 +191,11 @@ void Client::releaseLock(string filePath)
handleRequest(squidProtocol.releaseLock(filePath));
}

bool Client::isSecondarySocketAlive()
{
return secondarySquidProtocol.isAlive();
}

void Client::testing()
{
this->initiateConnection();
Expand Down
5 changes: 4 additions & 1 deletion client/src/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "squidprotocol.hpp"

#define SERVER_IP "127.0.0.1"
#define SERVER_PORT 8080
#define SERVER_PORT 12345
#define BUFFER_SIZE 1024

class Client : public Peer
Expand All @@ -27,11 +27,14 @@ class Client : public Peer
virtual void initiateConnection();
virtual void checkSecondarySocket();
virtual void createFile(std::string filePath);
virtual void createFile(std::string filePath, int version);
virtual void deleteFile(std::string filePath);
virtual void updateFile(std::string filePath);
virtual void updateFile(std::string filePath, int version);
virtual void syncStatus();
virtual bool acquireLock(std::string filePath);
virtual void releaseLock(std::string filePath);
virtual bool isSecondarySocketAlive();

private:
SquidProtocol secondarySquidProtocol;
Expand Down
Loading
Loading