0

I need:

A client, which communicates with the front-end, which communicates with 3 file servers.

How should I go about doing this? It needs to use RMI as distributed systems.

I also need to monitor all three file servers.

From what I understand, I need to establish an RMI registry, but how do I establish three concurrent servers within one registry?

1 Answers1

1

Okay, so am I right in thinking i'd have the following: A server interface, a server implementation, and a master server which creates the three servers (with unique names) and finally a client?

  1. The 'master server' needs to create a Registry on its own localhost, bind itself to the Registry so the slave servers can find it, and export a remote interface that lets the servers register themselves with it.
  2. The master server must do the binding to this Registry on behalf of the slaves, as you can't bind to a remote Registry. But in fact the slaves don't need to be bound to the Registry at all, only registered with the master.
  3. The master needs to export a second remote interface that provides the API to the client, which provides the upload API and whose implementation performs the balancing act. I would keep this interface separate from the interface used by the slaves, both for security reasons and for simplicity: you don't need clients trying to be slaves, or worrying about what the slave-relevant methods in the remote interface are.
  4. All these servers and registries can run on port 1099.
  5. The slaves are presumably multiple instances of the same service, so they all use a common remote interface. This interface provides the upload-to-slave API, and it also needs to allow each slave to provide the knowledge about how full each slave is, possibly as a return value from the upload method, or else as a query method.

Quick sketch:

public interface UploadMaster extends Remote
{
    void upload(String name, byte[] contents) throws IOException, RemoteException;
}

public interface LoadBalancingMaster extends Remote
{
    void register(Slave slave) throws RemoteException;
    void unregister(Slave slave) throws RemoteException;
}

public interface Slave extends Remote
{
    /** @return the number of files now uploaded to this slave. */
    int upload(String name, byte[] contents) throws IOException, RemoteException;
    int getFileCount() throws RemoteException;
}

I hope this is homework. RMI is a poor choice for file transfer, as it bundles up the entire argument list into memory at both ends, rather than providing a streaming interface.

user207421
  • 289,834
  • 37
  • 266
  • 440
  • This is indeed for homework. Could you please list out which classes I'll actually need? Perhaps it's because i'm totally new to inheritance but I can't seem to get my head around a lot of what you wrote. So far, I've got a client class which implements UploadMaster (although i'll need to add download, delete and list as well), a server class which implements Slave, and a master class which implements LoadBalancingMaster. I then need to create the registry in the master class and register three servers to it? Apologies if I'm off, I don't find this stuff easy at all. – Sonya Arnolds Mar 06 '18 at 12:22
  • Well, you need classes that implement these interfaces, don't you? – user207421 Mar 07 '18 at 00:44