Java Reference
In-Depth Information
Chapter 17
Distributed computing - the client
17.1 Introduction
Chapter 16 introduced distributed computing and enough UML to describe
server-side interactions. In this chapter we describe the design of the client for
a distributed scientific application in which the computationally intense calcula-
tions are performed on a remote server. Like the server, the client details neces-
sarily depend heavily on the calculation being performed and the data that is to
be presented to the user. Nevertheless we can provide some general guidelines
that should apply to many scientific applications.
17.2 Multithreaded client
Recall that the server in Chapter 16 is running on a remote machine, at least
conceptually, and is generating results continuously as the simulation is running.
To avoid problems with intervening firewalls, we designed the server to be polled
by the client rather than using a callback from the server to the client when new
data is available. That is, the client must poll the server periodically to retrieve
the results being calculated by the server. Assuming that the server calculation
is generating results somewhat uniformly, we clearly would prefer for the client
to poll the server on a regular basis. Meanwhile, once the client receives the
current set of results, the client must display them to the user in some fashion
and allow the user to interact with the displayed data. Whenever human users
are involved, one can be assured that the user's actions will not be uniform and
regular. The user may pause to closely examine the data being displayed or may
even take a coffee break while the calculation runs. It is clear that the polling
loop cannot rely on user behavior. The time required for the client to display
the data may depend on the user's actions and choices and may also depend
on the data itself. So it is also clear that the polling loop should not rely on
a uniform processing time for the most recent set of data. What is needed is
a multithreaded client with one thread handling a regular and uniform polling
of the server for new data and one or more other threads handling the display
of the data and the user interactions. As always in a multithreaded design, care
must be taken to prevent thread collisions. In this case, we must ensure that the
492
Search WWH ::




Custom Search