Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.mit.media.hive.support
Class CellAddress  view CellAddress download CellAddress.java

java.lang.Object
  extended byedu.mit.media.hive.support.CellAddress
All Implemented Interfaces:
java.io.Serializable

public class CellAddress
extends java.lang.Object
implements java.io.Serializable

This immutable class represents the URL of a Hive Cell. The protocol portion of the url is defined to be "hive", and will not allow the construction of urls with a different protocol. CellAddress follows the CISS (Common Internet Scheme Standard) Spec, although currently the file and ref portions of the URL are not used by the Hive system. WARNING: Java deviates from it's spec (at least on windows) in the DNS lookup behavior. Doing a InetAdderss.getByName(host).getHostName() does NOT return the fully qualified hostname as it should. Rather, some wierd caching behavior is causing the original argument to be returned. To work around this, we do a lookup to an IP Address and then do a lookup from that. This requires one more DNS lookup and is hence lower performance. Also, hostnames are internally represented as they are returned by the DNS Cell, but for the purposes of equal and hashCode, the hostname is converted to lowercase, because some DNS servers return inconsistent case information. ANOTHER WARNING: Because this class is specified in the RemoteCell interface that is absolutely core to Hive, any changes in the SerialVersionID of this class will cause an incompatibility with any existing Hive cells. So think very carefully before performing even 'minor' modifications to this class.


Field Summary
static int DEFAULT_PORT
          This is the default port that is assumed if one is not specified, or if -1 is used as an argument.
private  java.lang.String file
          The file of the URL.
private  int hashCode
          The Hashcode of the URL.
private  java.lang.String host
          The Host of the URL.
private  int port
          The port of the URL.
static java.lang.String PROTOCOL
          The fixed string representing the protocol used in Hive cells.
private  java.lang.String ref
          The Reference or Anchor of the URL.
static java.lang.String RMI_NAME
           
 
Constructor Summary
CellAddress(java.lang.String cellAddress)
          This rather grotesque method does all the parsing of the string necessary to construct an URL.
CellAddress(java.lang.String host, int port)
          A convenience method for the most common types of CellAddress
CellAddress(java.lang.String host, int port, java.lang.String file, java.lang.String ref)
          This Constructor allows the creation of a CellAddress with individual arguments rather than a parseable string.
 
Method Summary
private  void calculateHashCode()
          This method calculates the hashcode.
static CellAddress createLocalCellAddress()
          Returns a cell address for the local machine and the default port.
static CellAddress createLocalCellAddress(int port)
          Returns a cell address for the local machine and the specified port.
 boolean equals(java.lang.Object obj)
          Returns true if the argument refers to the same cell as the one defined.
 java.lang.String getFile()
          Return the file of the cell address.
 java.lang.String getHost()
          Return the host of the CellAddress
 int getPort()
          return the port number of the CellAdress
 java.lang.String getProtocol()
          Returns the protocol of the URL.
 java.lang.String getRef()
          Return the reference of the CellAdress.
 edu.mit.media.hive.cell.RemoteCell getRemoteCell()
          Find the Cell on the specified remote host.
 int hashCode()
          Returns a hashcode for the CellAddress.
 boolean isLocal()
          Returns true if the address is determined to specify the local machine.
static void main(java.lang.String[] args)
          Test cases to check the complicated parsing method.
private static void test(java.lang.String str)
          Private testing method for test cases.
 java.lang.String toString()
          Returns the string representation of the CellAddress.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
This is the default port that is assumed if one is not specified, or if -1 is used as an argument.

See Also:
Constant Field Values

PROTOCOL

public static final java.lang.String PROTOCOL
The fixed string representing the protocol used in Hive cells.

See Also:
Constant Field Values

RMI_NAME

public static final java.lang.String RMI_NAME
See Also:
Constant Field Values

port

private int port
The port of the URL.


host

private java.lang.String host
The Host of the URL. Canonicalized at construction.


file

private java.lang.String file
The file of the URL.


ref

private java.lang.String ref
The Reference or Anchor of the URL.


hashCode

private int hashCode
The Hashcode of the URL. Created at construction.

Constructor Detail

CellAddress

public CellAddress(java.lang.String cellAddress)
            throws MalformedHiveURLException
This rather grotesque method does all the parsing of the string necessary to construct an URL. Anything that is unparsable, including URLs with a protocol other than "hive" will be rejected with a MalformedHiveURLException. The constructor does a lot of work up front, including canonicalizing the hostname (which requires two DNS lookups, and calculating the hashcode.) Hosts that are not in DNS will throw a MalformedHiveURLException.


CellAddress

public CellAddress(java.lang.String host,
                   int port,
                   java.lang.String file,
                   java.lang.String ref)
            throws MalformedHiveURLException
This Constructor allows the creation of a CellAddress with individual arguments rather than a parseable string.


CellAddress

public CellAddress(java.lang.String host,
                   int port)
            throws MalformedHiveURLException
A convenience method for the most common types of CellAddress

Method Detail

createLocalCellAddress

public static CellAddress createLocalCellAddress(int port)
Returns a cell address for the local machine and the specified port.


createLocalCellAddress

public static CellAddress createLocalCellAddress()
Returns a cell address for the local machine and the default port.


calculateHashCode

private void calculateHashCode()
This method calculates the hashcode. All the fields must be valid before this method is called.


getHost

public java.lang.String getHost()
Return the host of the CellAddress


getPort

public int getPort()
return the port number of the CellAdress


getFile

public java.lang.String getFile()
Return the file of the cell address. May return the empty string.


getRef

public java.lang.String getRef()
Return the reference of the CellAdress. May return the empty string.


getProtocol

public java.lang.String getProtocol()
Returns the protocol of the URL. (Always "hive")


equals

public boolean equals(java.lang.Object obj)
Returns true if the argument refers to the same cell as the one defined.


hashCode

public int hashCode()
Returns a hashcode for the CellAddress.


toString

public java.lang.String toString()
Returns the string representation of the CellAddress.


isLocal

public boolean isLocal()
Returns true if the address is determined to specify the local machine.


getRemoteCell

public edu.mit.media.hive.cell.RemoteCell getRemoteCell()
                                                 throws CellConnectException
Find the Cell on the specified remote host.


test

private static void test(java.lang.String str)
Private testing method for test cases.


main

public static final void main(java.lang.String[] args)
Test cases to check the complicated parsing method.