public class StorageServerApp extends ServerApplication
The storage server application expects three arguments: in order, the local hostname, the hostname of the remote naming server, and the directory that the storage server will use as its local storage for files.
The directory can be given as an absolute or a relative path. The current contents of the directory will be offered to the naming server during registration. Duplicate files in the directory will be deleted, and empty directories will be pruned.
For this reason, it is extremely important that the storage server not be started in a directory containing important files, as those files may be deleted. It is recommended that a special directory be created for each storage server, and the storage server only be started in that directory.
The user under which the storage server is run should have full read and write access to the directory in which the storage server is started.
Modifier and Type | Class and Description |
---|---|
private class |
StorageServerApp.StoppingStorageServer
Application storage server.
|
ServerApplication.BadUsageException
Modifier and Type | Field and Description |
---|---|
private static StorageServerApp.StoppingStorageServer |
server
The storage server itself.
|
EXIT_FAILURE, EXIT_SUCCESS
Constructor and Description |
---|
StorageServerApp() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] arguments)
Storage server application entry point.
|
protected java.lang.String |
serverType()
Returns
"storage" . |
protected void |
startServer(java.lang.String[] arguments)
Starts the storage server.
|
protected void |
stopServer()
Stops the storage server.
|
run, serverStopped, startTerminationTimer
private static StorageServerApp.StoppingStorageServer server
public static void main(java.lang.String[] arguments)
protected java.lang.String serverType()
"storage"
.serverType
in class ServerApplication
protected void startServer(java.lang.String[] arguments) throws ServerApplication.BadUsageException, java.net.UnknownHostException, java.io.FileNotFoundException, RMIException
startServer
in class ServerApplication
arguments
- The command line arguments.BadUsageException
- If there are not three arguments on the
command line.java.net.UnknownHostException
- If a storage server stub cannot be created
due to an unassigned address.java.io.FileNotFoundException
- If the directory in which the storage
server is being started does not exist, or
if the path does not refer to a directory.RMIException
- If the storage server cannot be started or the
naming server cannot be contacted for registration.java.lang.IllegalStateException
- If a storage server with the same hostname
and port number is already registered with
the naming server.ServerApplication.BadUsageException
protected void stopServer()
stopServer
in class ServerApplication