Reading Materials
o 15 - Networking
And Threads (pages
489 – 528)
o Chapter 4 - Methods
Common to All Objects (Item 15)
o Chapter 10 - Concurrency
·
Oracle Java Tutorial
§ Interfaces: Condition, Lock, ReadWriteLock.
§ Classes: ReentrantLock, ReentrantReadWriteLock.
Exercise:
·
Add an option
to encrypt an entire directory.
The directory may contain several files, and the system should encrypt them all with the same key (and the same algorithm).
The encrypted files shall sit under a sub-directory named “encrypted”. File names shall not be changed.
Only files with .txt extension should be encrypted. Do not encrypt any sub directories. The key will be saved inside the directory, as key.txt.
The directory may contain several files, and the system should encrypt them all with the same key (and the same algorithm).
The encrypted files shall sit under a sub-directory named “encrypted”. File names shall not be changed.
Only files with .txt extension should be encrypted. Do not encrypt any sub directories. The key will be saved inside the directory, as key.txt.
·
After a
single file encryption has completed – inform the user of the event and its
duration. After all files have been encrypted – inform the user about the event
and its whole duration.
·
Because we
are dealing with a large number of files, and some may be heavy, you have
decided that you want to use multithreading to try and improve the speed of
directory encryption.
o Write an interface named DirectoryProcessor and implement the following classes:
§ SyncDirectoryProcessor – responsible of encrypting a directory “normally”, with a single
thread.
§ AsyncDirectoryProcessor – responsible of encrypting a directory concurrently.
o Think: what changes have to be made in EncryptionLogger? (pay attention to locking and the way it has to be done –
synchronized? on what?)
·
Implement
the reverse functionality – decryption of a whole directory, similarly.
·
Compare the
running time of each method. Apply each encryption method on a directory with
some big files (each file should be ~5MB). Selection of the method should be
done in the main method.
o Which method is faster? Why?
Emphasis:
·
In the final
implementation you should perform encryption and decryption of a directory
asynchronously (AsyncDirectoryProcessor).
·
Pay
attention to how are the threads being run? Thread? Executor?
·
For the sake
of testing you probably should write something that generates large files. You
can write a little Java program for this task.
No comments:
Post a Comment