|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--JSort
JSort (Jini Sort)
This is a Jini service that performs a virtual sort of fixed length strings based on sort fields within the string. This is a familiar service to those who have written batch programs.
Use the r1.bat, r2.bat, and r3.bat files in JiniExample1 to start the Jini environment before running JSort or JClient.
Error Return Codes
0 -- Sorted with no errors.
1 -- Parameter error.
3 -- Available memory work area is too small.
4 -- Available memory too small for rec length.
5 -- Memory allocation error.
6 -- File creation error.
8 -- Illegal item length.
9 -- More than 32K records to sort.
10 -- Write error during sorting (disk full?)
11 -- Read error during sorting.
12 -- Impossible to create new file (dir full?)
ToDo
Development Environment
Compiled under JDK 1.2.0, Jini 1.0.0
History
03/10/99 NDE Created the program.
| Field Summary | |
(package private) static double |
HALFSEG
Maximum value of 2 bytes signed. |
(package private) java.util.Hashtable |
htSortJobs
key = "sortjob3", v = JSortJob object. |
(package private) static double |
LONGLGTH
Maximum value of a signed int. |
(package private) static int |
MAXRPAGES
The maximum number of real pages. |
(package private) static int |
MAXSTACK
Used in quickSort() for a local stack. |
(package private) static int |
SECTSIZE
Sector size for block reads and writes. |
(package private) static double |
SEGLGTH
Maximum value of 2 bytes unsigned. |
(package private) static double |
USERSTACK
Heap reserved for user stack. |
| Fields inherited from class java.rmi.server.UnicastRemoteObject |
csf,
port,
portFactoryParamTypes,
portParamTypes,
serialVersionUID,
ssf |
| Fields inherited from class java.rmi.server.RemoteServer |
log,
logname,
serialVersionUID |
| Fields inherited from class java.rmi.server.RemoteObject |
ref,
serialVersionUID |
| Constructor Summary | |
JSort()
|
|
| Method Summary | |
private boolean |
adjustForFieldOrder(int iSortOrderIn,
boolean bIsLessIn)
If the sort order is ascending, this method will return the same boolean that was passed to it, otherwise it returns the opposite. |
private void |
allocateBuffers(JSortJob jobIn,
java.util.Hashtable htParmsIn)
|
java.util.Hashtable |
close(java.util.Hashtable htParmsIn)
|
private void |
exchange(JSortJob jobIn,
long i,
long j,
byte[] swoppost)
This is called by quickSort() to exchange two sort item records. |
private java.lang.String |
getNextJobName()
|
private void |
initPage(byte[] abIn)
|
private boolean |
less(JSortJob jobIn,
byte[] abIn,
JSortItem itemIn)
This compares two byte array items according to the sort fields for the job. |
private boolean |
less(JSortJob jobIn,
JSortItem itemIn,
byte[] abIn)
This compares two byte array items according to the sort fields for the job. |
static void |
main(java.lang.String[] args)
|
java.util.Hashtable |
open(java.util.Hashtable htParmsIn)
|
private void |
pageIn(JSortJob jobIn,
long item_num,
long keep_rec1,
long keep_rec2)
After calling this function the page that contains the requested item_num is in memory. |
private void |
pageOut(JSortJob jobIn,
byte[] rpage_ptr,
int vpage_num)
Write the virtual page in the passed real memory location to the file. |
private void |
quickSort(JSortJob jobIn,
byte[] swoppost,
byte[] savez)
This is a non-recursive version of the quicksort algorithm as given in Nicklaus Wirth ALGORITHMS + DATA STRUCTURES = PROGRAMS. |
private void |
register(java.lang.String sServiceNameIn,
com.sun.jini.lookup.ServiceIDListener sidServiceIn)
|
void |
releaseBlock(java.lang.String sJobNameIn,
byte[] abIn)
This processes a block of sort items, one item at a time. |
java.util.Hashtable |
releaseRecord(java.util.Hashtable htParmsIn)
This function copies a record from the passed parameter hashtable into the virtual sort system. |
byte[] |
returnBlock(java.lang.String sJobNameIn,
int iNumReqItemsIn)
This accepts the number of requested sort items and returns a byte array that consists of the requested number of sort items. |
java.util.Hashtable |
returnRecord(java.util.Hashtable htParmsIn)
This finds the current sort output item and returns it to the caller. |
java.util.Hashtable |
rewind(java.util.Hashtable htParmsIn)
This resets the current item counter to 0 which allows returnRec to start over at the beginning of the sort work file. |
void |
serviceIDNotify(net.jini.core.lookup.ServiceID sidIn)
|
java.util.Hashtable |
sort(java.util.Hashtable htParmsIn)
|
private void |
test()
|
private void |
writeDebug(JSortJob jobIn,
java.lang.String sIn)
|
| Methods inherited from class java.rmi.server.UnicastRemoteObject |
|
| Methods inherited from class java.rmi.server.RemoteServer |
getClientHost,
getLog,
setLog |
| Methods inherited from class java.rmi.server.RemoteObject |
equals,
getRef,
hashCode,
toString,
toStub,
writeObject |
| Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
| Field Detail |
static final int MAXRPAGES
static final int MAXSTACK
static final int SECTSIZE
static final double USERSTACK
static final double LONGLGTH
static final double SEGLGTH
static final double HALFSEG
java.util.Hashtable htSortJobs
| Constructor Detail |
public JSort()
throws java.rmi.RemoteException
| Method Detail |
public static void main(java.lang.String[] args)
private boolean adjustForFieldOrder(int iSortOrderIn,
boolean bIsLessIn)
private void allocateBuffers(JSortJob jobIn,
java.util.Hashtable htParmsIn)
public java.util.Hashtable close(java.util.Hashtable htParmsIn)
throws java.rmi.RemoteException
private void exchange(JSortJob jobIn,
long i,
long j,
byte[] swoppost)
i - - first item number.j - - second item number.swoppost - - storage within which an item can be saved during swop.private java.lang.String getNextJobName()
private void initPage(byte[] abIn)
private boolean less(JSortJob jobIn,
JSortItem itemIn,
byte[] abIn)
private boolean less(JSortJob jobIn,
byte[] abIn,
JSortItem itemIn)
public java.util.Hashtable open(java.util.Hashtable htParmsIn)
throws java.rmi.RemoteException
private void pageIn(JSortJob jobIn,
long item_num,
long keep_rec1,
long keep_rec2)
jobIn - - the sort job object.item_num - - item number (rec number) whose page is sought.keep_rec1 - - 1st item number to not swap out of memory.keep_rec2 - - 2nd item number to not swap out of memory.
private void pageOut(JSortJob jobIn,
byte[] rpage_ptr,
int vpage_num)
jobIn - - The sort job object.rpage_ptr - - the real page to store.vpage_num - - number of the virtual page.
private void quickSort(JSortJob jobIn,
byte[] swoppost,
byte[] savez)
jobIn - - job object that contains the real and virtual page
arrays.swoppost - - save area during the sort exchange.savez - - save area for the middle record during the sort.
private void register(java.lang.String sServiceNameIn,
com.sun.jini.lookup.ServiceIDListener sidServiceIn)
public void releaseBlock(java.lang.String sJobNameIn,
byte[] abIn)
throws java.rmi.RemoteException
public java.util.Hashtable releaseRecord(java.util.Hashtable htParmsIn)
throws java.rmi.RemoteException
public byte[] returnBlock(java.lang.String sJobNameIn,
int iNumReqItemsIn)
throws java.rmi.RemoteException
public java.util.Hashtable returnRecord(java.util.Hashtable htParmsIn)
throws java.rmi.RemoteException
public java.util.Hashtable rewind(java.util.Hashtable htParmsIn)
throws java.rmi.RemoteException
public void serviceIDNotify(net.jini.core.lookup.ServiceID sidIn)
public java.util.Hashtable sort(java.util.Hashtable htParmsIn)
throws java.rmi.RemoteException
private void test()
private void writeDebug(JSortJob jobIn,
java.lang.String sIn)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||