org.apache.nutch.ipc
Class Client

java.lang.Object
  extended byorg.apache.nutch.ipc.Client
Direct Known Subclasses:
NDFS.DataNode

public class Client
extends Object

A client for an IPC service. IPC calls take a single Writable as a parameter, and return a Writable as their value. A service runs on a port and is defined by a parameter class and a value class.

Author:
Doug Cutting
See Also:
Server

Field Summary
static Logger LOG
           
 
Constructor Summary
Client(Class valueClass)
          Construct an IPC client whose values are of the given Writable class.
 
Method Summary
 Writable[] call(Writable[] params, InetSocketAddress[] addresses)
          Makes a set of calls in parallel.
 Writable call(Writable param, InetSocketAddress address)
          Make a call, passing param, to the IPC server running at address, returning the value.
 void setTimeout(int timeout)
          Sets the timeout used for network i/o.
 void stop()
          Stop all threads related to this client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final Logger LOG
Constructor Detail

Client

public Client(Class valueClass)
Construct an IPC client whose values are of the given Writable class.

Method Detail

stop

public void stop()
Stop all threads related to this client. No further calls may be made using this client.


setTimeout

public void setTimeout(int timeout)
Sets the timeout used for network i/o.


call

public Writable call(Writable param,
                     InetSocketAddress address)
              throws IOException
Make a call, passing param, to the IPC server running at address, returning the value. Throws exceptions if there are network problems or if the remote code threw an exception.

Throws:
IOException

call

public Writable[] call(Writable[] params,
                       InetSocketAddress[] addresses)
                throws IOException
Makes a set of calls in parallel. Each parameter is sent to the corresponding address. When all values are available, or have timed out or errored, the collected results are returned in an array. The array contains nulls for calls that timed out or errored.

Throws:
IOException


Copyright © 2006 The Apache Software Foundation