- Request Generator
Changes to SmartRequestGenerator
:
- add
saveDynamicTreeToFile
method to store the dynamic tree to file - add sample usage code to
example/RegularClient.java
. You can also find the usage and explanation here
Bug fix:
- fix the bug that changes to the configuration file does not take effect
- fix generator illegal bounds error when all files are deleted
Two components are added:
- File propagator: basically a generator genrates only
CREATE_FILE
request. - Smart request generator: a generator that maintains a copy of the directoies that propagated to the file system, thus generating requests based on its knowledge of directories structure.
Configuration file changes:
request_ratio
: enhancement ofread_write_ratio
with more predefined request types. The ratio should be declared in the order ofREAD, WRITE, DELETE, CREATE_FILE, RMDIR, LS, CREATE_DIR
. For example:0.25,0.25,0.25,0.25,0,0,0
Please make sure your configuration file is updated before using the updated code Things that are not important to the phase 2 project have been striked out in the following description.
You can download the data file in here
Build the project by using mvn install
. The artifact shall be generated under target
Make sure resources
folder is placed at the same folder with the jar
file.
The following command generate random request. You can specify the number of requests
needs to be generated, otherwise the generator uses the value specified in the configurate file (resources/config.properties
) NOTE: the number of requests is specified per thread.
java -jar RequestGenerator.jar -r <filename> [number of requests]
First, use the following command to generate a dataset.
java -jar RequestGenerator.jar -f <src> <dataset>
Then feed the generator with the dataset:
java -jar RequestGenerator.jar -s <dataset>
The file propagator uses data file to generate CREATE_FILE
requests. At the same time produces a rank file, which can be used later for request generator with zipf distribution.
java -jar RequestGenerator-1.0-SNAPSHOT.jar -p <data file> <output rank file>
The smart generator can take three parameters
- static file:
required
. If only static file is given, the generator won't genrateDELETE
request. - dynamic file:
optional
. dynamic file should be the same file that used for file propagator, and should be either the same as the static file or a portion of the static file. - rank file:
optional
. Rank file is the file generated by the file propagator
java -jar RequestGenerator-1.0-SNAPSHOT.jar -m <static file> [dynamic file] [rank file]
The callback provides a generated request and the id of which thread generates it.
RequestThread.RequestGenerateThreadCallBack callBack = new RequestThread.RequestGenerateThreadCallBack() {
@Override
public void onRequestGenerated(Request request, int threadId) {
System.out.println("thread[" + threadId + "]: " + request);
}
}
There are two types of generator: The following code demostrates how to declare ClientRequestGenerator
and SequentialRequestGenerator
, corresponding to what has been described on section 1.2.SmartRequestGenerator
. You can implement your own generator by extending the abstract class RequestGenerator
.
RequestGenerator generator = new SmartRequestGenerator("staticFile",
"dynamicFile",
"rankFile");
Pass the callback
and the generator
to the service. Parameters numThreads
, interarrivalRate
and numOfRequests
can be read from the configuration file
RequestService service = new RequestService(numThreads,
interarrivalRate,
numOfRequests,
generator,
callBack);
service.start();
The dynamic tree file is the file that you used for FilePropagator
to populate files to the file system. That means the dynamic tree file has all the data in the file system.
If you use SmartRequestGenerator
with dynamic tree file, the generator keeps tracking the changes made to the file system. For example, when a DELETE
or CREATE_FILE
request is generated, the tree removes or adds the correspoding file. After runing for a while, the file system may be created a lot of new files or deleted a lot of exisitng files. You want to save the new tree for next time to use. Thus, you can use saveDynamicTreeToFile
to do this.
((SmartRequestGenerator)generator).saveDynamicTreeToFile("dynamicTree.txt");
FSPropagator
takes the same callback interface as parameter.
FSPropagator propagator = new FSPropagator("src", "rankFile", callback);
propagator.start();
The configuration file contains the following parameters:
read_write_inter_arrival_rate
: uses possion distribution. rate = number of requests / total time in ms. For example, 5000 requests in 18 minutes, the rate would be = 5000 / (18 * 60 * 1000) = 0.00463request_distribution
: value can be [uniform|zipf]read_write_ratio
: percentage of read and write, sum to 1alpha
: used for zipfnumber_threads
num_of_requests
: number of requests per thread to generate, use -1 for infinite requestsrequest_ratio
: enhancement ofread_write_ratio
with more predefined request types. The ratio should be declared in the order ofREAD, WRITE, DELETE, CREATE_FILE, RMDIR, LS, CREATE_DIR
. For example:0.25,0.25,0.25,0.25,0,0,0