#C14779. Distributed File System Simulation

    ID: 44465 Type: Default 1000ms 256MiB

Distributed File System Simulation

Distributed File System Simulation

You are given a simulation of a distributed file system that consists of multiple nodes. The system supports two commands:

  • ADD file_path data: Adds a new file with the specified file path and data. The file is stored in one of the available nodes using a round-robin load balancing strategy.
  • GET file_path: Retrieves the data stored under the given file path. If the file does not exist, output FileNotFound.

The system is initially set up with two nodes, and files are allocated to these nodes in a round-robin fashion. Implement the system so that it processes a sequence of commands read from standard input (stdin) and prints any required output to standard output (stdout). For each GET command, print the corresponding data (or FileNotFound if the file does not exist) on a new line.

Note: Use LaTeX format for any formulas. For example, the round robin strategy can be interpreted as selecting node \(i = (current\_count \mod N)\), where \(N\) is the number of nodes.

inputFormat

The first line contains an integer N representing the number of commands. The following N lines each contain a command. Each command will be one of the following two types:

  • ADD file_path data
  • GET file_path

Note that data in the ADD command may contain alphanumeric strings without spaces.

outputFormat

For each GET command, output the stored data on a new line. If a file does not exist, print FileNotFound instead.

## sample
4
ADD /file1 Hello
ADD /file2 World
GET /file1
GET /file2
Hello

World

</p>