edu.unh.sdb.datasource
Class GraniteRemoteClient

java.lang.Object
  extended by edu.unh.sdb.datasource.DataCollection
      extended by edu.unh.sdb.datasource.DataSource
          extended by edu.unh.sdb.datasource.PhysicalDataSource
              extended by edu.unh.sdb.datasource.GraniteRemoteClient
All Implemented Interfaces:
Indexable

public class GraniteRemoteClient
extends PhysicalDataSource

This class will read data from a remote datasource using UDT or UDP logic.


Field Summary
static java.lang.String bounds
           
static int buffer_size
           
static java.net.Socket clientAlarmSocket
           
static java.net.Socket connectionSocket
           
 java.lang.String ctrlMsg
           
static byte[] dstByteArray
           
static long end
           
static java.lang.String fileName
           
static int fileSize
           
static int globalVal
           
static java.net.InetAddress ip
           
static java.lang.String ipStr
           
static int[] lower
           
static int[] lowerPartitioningArray
           
static int[] lowerSpaceArray
           
static long start
           
static int statusFlag
           
static int[] upper
           
static int[] upperPartitioningArray
           
static int[] upperSpaceArray
           
static java.net.ServerSocket welcomeSocket
           
 
Fields inherited from class edu.unh.sdb.datasource.PhysicalDataSource
BIG_ENDIAN, bufferBounds, bufferDimension, bufferSteps, byteBuffers, directMemoryLimit, endian, LITTLE_ENDIAN, maxBufferSize, maxGapSize, readCounter, readLength, url
 
Fields inherited from class edu.unh.sdb.datasource.DataSource
fdlDescriptor, isActivated, name, wsName
 
Fields inherited from class edu.unh.sdb.datasource.DataCollection
attributeOrder, axisOrdering, axisWeights, dataOrder, dimensionality, numAttributes, pointOrder, recordDesc
 
Constructor Summary
GraniteRemoteClient(java.lang.String name, RecordDescriptor recordDesc, ISBounds theBounds, AxisOrdering ordering, java.lang.String URL, java.lang.String serverURL)
          GraniteRemoteClient class constructor.
 
Method Summary
 void activate()
          Open the server socket on the client side.
 void buildBounds(ISBounds srcBounds)
          Builds the bounds string to be sent to the RemoteUDPServer.
static void bytesToFloats(float[] floatDst, byte[] bytes, int numBytes)
          private method, convert bytes into floats.
static void bytesToShorts(short[] shortDst, byte[] bytes, int numBytes)
          private method, convert bytes into shorts.
 void clearCache()
          Clear the filesystem cache on the server.
static void ClientToServerStencilPartitionList(byte[] b, int length)
          TCP Control Traffic to Server about Stencil's partition list.
 void datum(Datum datum, IndexSpaceID did, FieldIDMapper mp)
          Get the Datum and fill its values in the passed Datum at positions specified by the corresponding FieldIDMapper.
 void datum(Datum datum, IndexSpaceID did, RecordSpec recSpec)
          Get the Datum and fill its values in the passed Datum at positions specified by the corresponding RecordSpec.
 Datum datum(IndexSpaceID did)
          Return the Datum corresponding to the given IndexSpaceID.
 Datum datum(IndexSpaceID did, RecordSpec spec)
          Return the Datum corresponding to the given IndexSpaceID.
 void deactivate()
          Close the server socket on the client side.
 int GetBufferSize()
           
 int GetDataSize()
           
protected  void getStencilBlocks(DataBlockCollection dstBlock)
          this method will extract data from datasource on remote server using UDT or UDP logic.
protected  void getStencilBlocks(DSBlockStencil stencil)
          this method will extract data from datasource on remote server using UDT or UDP logic.
static void main(java.lang.String[] args)
          GraniteRemoteClient main.
protected  void pdatumUDP(Datum datum, IndexSpaceID did)
          this method will extract data from datasource on remote server using UDT or UDP logic.
protected  void psubblockUDP(BasicBlock dstBlock, ISBounds dstBounds, ISBounds srcBounds)
          this method will extract data from datasource on remote server using UDT or UDP logic.
 void ReceiveData()
          File transfer client program.
 void SendBounds(java.lang.String bounds)
           
static int SendControlCode(byte b)
          Send the given byte to the master thread on the server.
 void SendFileName(java.lang.String FileInfo)
           
 void SendPartitionListLengthInfo(java.lang.String partitionListLengthString)
           
 void SendStencilInfo(java.lang.String stencilInfo)
           
 void setBasicBlockBounds(java.lang.String s)
          Method to tell server the bounds for basic block construction.
static void setFileName(java.lang.String s)
          Sets the filename for transfer.
 void setRemoteDataSource(java.lang.String xmlFile, java.lang.String dsName)
          set the xml file for the remote datasource.
 void subblock(DataBlock dstBlock, ISBounds dstBounds, ISBounds srcBounds)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
 void subblock(DataBlock dstBlock, ISBounds dstBounds, ISBounds srcBounds, FieldIDMapper mp)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
 void subblock(DataBlock dstBlock, ISBounds dstBounds, ISBounds srcBounds, RecordSpec recSpec)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
 void subblock(DSBlockStencil stencil)
          Fill the datablocks specified as "active" in the DSBlockStencil.
 DataBlock subblock(ISBounds db)
          Returns a spatial subset of the DataSource as delimited by the ISBounds argument.
 long transmitTime()
           
 
Methods inherited from class edu.unh.sdb.datasource.PhysicalDataSource
allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, deleteBuffer, deleteBuffer, deleteBuffers, equals, getBuffer, getBuffer, getBufferSize, getBufferSize, getByteOrder, getDataFileString, getMaxBufferSize, getReadCounter, getReadLength, getURL, initializeBuffers, isBigEndian, makeBestBuffer, resetReadCounter, setBufferByteOrder, setMaxBufferSize, setMaxGapSize, toString, toString
 
Methods inherited from class edu.unh.sdb.datasource.DataSource
checkActivated, copyBestID, create, create, create, createRemote, createRemote, createRemoteClient, createRemoteClient, createRemoteDataSource, createRemoteDataSource, createRemoteDataSourceUDP, createRemoteUDP, createRemoteUDP, dumpData, getName, getValues, isActivated
 
Methods inherited from class edu.unh.sdb.datasource.DataCollection
byteSize, computeOffset, computeOffset, copyBounds, createDataBlock, createDataBlock, createDataBlock, createDatum, createDatum, createDatum, createDatum, createDatum, createDatum, datum, datum, datum, dim, getAxisOrdering, getAxisWeight, getAxisWeights, getBounds, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytesByAttribute, getBytesByAttribute, getBytesByPoint, getBytesByPoint, getDataOrder, getDimensionsArray, getDouble, getDoubles, getDoubles, getDoubles, getDoubles, getDoubles, getDoubles, getDoublesByAttribute, getDoublesByAttribute, getDoublesByPoint, getDoublesByPoint, getFloat, getFloats, getFloats, getFloats, getFloats, getFloats, getFloats, getFloatsByAttribute, getFloatsByAttribute, getFloatsByPoint, getFloatsByPoint, getInt, getInts, getInts, getInts, getInts, getInts, getInts, getIntsByAttribute, getIntsByAttribute, getIntsByPoint, getIntsByPoint, getLowerBoundsArray, getNumAttributes, getRecordDescriptor, getShort, getShorts, getShorts, getShorts, getShorts, getShorts, getShorts, getShortsByAttribute, getShortsByAttribute, getShortsByPoint, getShortsByPoint, getStorageType, getValues, getValuesByAttribute, getValuesByPoint, longVolume, setAxisOrdering, setBounds, setRecordDescriptor, size, subblock, subblock, subblock, subblock, subblock, subblock, subblock, useBytesOnly, volume
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer_size

public static int buffer_size

welcomeSocket

public static java.net.ServerSocket welcomeSocket

connectionSocket

public static java.net.Socket connectionSocket

clientAlarmSocket

public static java.net.Socket clientAlarmSocket

ip

public static java.net.InetAddress ip

ipStr

public static java.lang.String ipStr

ctrlMsg

public java.lang.String ctrlMsg

fileName

public static java.lang.String fileName

fileSize

public static int fileSize

globalVal

public static int globalVal

start

public static long start

end

public static long end

statusFlag

public static int statusFlag

dstByteArray

public static byte[] dstByteArray

lower

public static int[] lower

upper

public static int[] upper

lowerSpaceArray

public static int[] lowerSpaceArray

upperSpaceArray

public static int[] upperSpaceArray

lowerPartitioningArray

public static int[] lowerPartitioningArray

upperPartitioningArray

public static int[] upperPartitioningArray

bounds

public static java.lang.String bounds
Constructor Detail

GraniteRemoteClient

public GraniteRemoteClient(java.lang.String name,
                           RecordDescriptor recordDesc,
                           ISBounds theBounds,
                           AxisOrdering ordering,
                           java.lang.String URL,
                           java.lang.String serverURL)
GraniteRemoteClient class constructor.

Method Detail

setFileName

public static void setFileName(java.lang.String s)
Sets the filename for transfer.


SendFileName

public void SendFileName(java.lang.String FileInfo)

SendStencilInfo

public void SendStencilInfo(java.lang.String stencilInfo)

SendPartitionListLengthInfo

public void SendPartitionListLengthInfo(java.lang.String partitionListLengthString)

SendBounds

public void SendBounds(java.lang.String bounds)

GetBufferSize

public int GetBufferSize()

GetDataSize

public int GetDataSize()

activate

public void activate()
Open the server socket on the client side.

Overrides:
activate in class DataSource

deactivate

public void deactivate()
Close the server socket on the client side.

Overrides:
deactivate in class PhysicalDataSource

setBasicBlockBounds

public void setBasicBlockBounds(java.lang.String s)
                         throws java.io.IOException
Method to tell server the bounds for basic block construction.

Throws:
java.io.IOException

setRemoteDataSource

public void setRemoteDataSource(java.lang.String xmlFile,
                                java.lang.String dsName)
set the xml file for the remote datasource.


datum

public Datum datum(IndexSpaceID did)
Return the Datum corresponding to the given IndexSpaceID.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

datum

public void datum(Datum datum,
                  IndexSpaceID did,
                  RecordSpec recSpec)
Get the Datum and fill its values in the passed Datum at positions specified by the corresponding RecordSpec.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

datum

public void datum(Datum datum,
                  IndexSpaceID did,
                  FieldIDMapper mp)
Get the Datum and fill its values in the passed Datum at positions specified by the corresponding FieldIDMapper.

Specified by:
datum in interface Indexable
Specified by:
datum in class DataCollection

datum

public Datum datum(IndexSpaceID did,
                   RecordSpec spec)
Return the Datum corresponding to the given IndexSpaceID. The Datum will only contain attributes specified by the RecordSpec argument.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

pdatumUDP

protected void pdatumUDP(Datum datum,
                         IndexSpaceID did)
this method will extract data from datasource on remote server using UDT or UDP logic.


subblock

public void subblock(DataBlock dstBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds,
                     FieldIDMapper mp)
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds. The FieldIDMapper argument determines the mapping between datums in the datasource and datums in the DataBlock. Note that the DataBlock is assumed to already have a valid data array. the dataBlock can be basicBlock or compositeBlock

Specified by:
subblock in interface Indexable
Overrides:
subblock in class PhysicalDataSource

subblock

public void subblock(DataBlock dstBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds,
                     RecordSpec recSpec)
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds. The RecordSpec argument specifies a subset of the DataSource attributes to be written into the DataBlock datums. Note that the DataBlock is assumed to already have a valid data array. the DataBlock can be BasicBlock or CompositeBlock

Specified by:
subblock in interface Indexable
Overrides:
subblock in class PhysicalDataSource

subblock

public void subblock(DSBlockStencil stencil)
Description copied from class: DataCollection
Fill the datablocks specified as "active" in the DSBlockStencil. This method is meant to save latency costs across a network by filling several datablocks with a single query.

Overrides:
subblock in class DataCollection

subblock

public void subblock(DataBlock dstBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds)
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds. The BasicBlock is assumed to be created and a valid data array is already allocated. NOTE: dstBlock can be BasicBlock or CompositeBlock. data is copied from file to BasicBlock or CompositeBlock based on its data type.

Specified by:
subblock in interface Indexable
Overrides:
subblock in class PhysicalDataSource

psubblockUDP

protected void psubblockUDP(BasicBlock dstBlock,
                            ISBounds dstBounds,
                            ISBounds srcBounds)
this method will extract data from datasource on remote server using UDT or UDP logic.


getStencilBlocks

protected void getStencilBlocks(DSBlockStencil stencil)
this method will extract data from datasource on remote server using UDT or UDP logic.


getStencilBlocks

protected void getStencilBlocks(DataBlockCollection dstBlock)
this method will extract data from datasource on remote server using UDT or UDP logic.


buildBounds

public void buildBounds(ISBounds srcBounds)
Builds the bounds string to be sent to the RemoteUDPServer.


transmitTime

public long transmitTime()

bytesToFloats

public static void bytesToFloats(float[] floatDst,
                                 byte[] bytes,
                                 int numBytes)
private method, convert bytes into floats. It takes numBytes from bytes array starting from index 0, convert them into floats, and put them into floatDst array starting at index offset


bytesToShorts

public static void bytesToShorts(short[] shortDst,
                                 byte[] bytes,
                                 int numBytes)
private method, convert bytes into shorts. It takes numBytes from bytes array starting from index 0, convert them into shorts, and put them into shortDst array starting at index offset


subblock

public DataBlock subblock(ISBounds db)
Returns a spatial subset of the DataSource as delimited by the ISBounds argument. The DataSource data is copied when filling the DataBlock. This method returns a BasicBlock. Need more discussion on this method

Specified by:
subblock in interface Indexable
Overrides:
subblock in class DataCollection

ReceiveData

public void ReceiveData()
File transfer client program.


ClientToServerStencilPartitionList

public static void ClientToServerStencilPartitionList(byte[] b,
                                                      int length)
TCP Control Traffic to Server about Stencil's partition list.


SendControlCode

public static int SendControlCode(byte b)
Send the given byte to the master thread on the server. #################### Baoqiang Yan ################### Changed to return the actual received ACK to allow more specific control depending on the status of server ####################################################### if(ack != 0){ System.out.println("Non zero acknowledge from server in SendControlCode()"); ################################################################### We should stop the client since the non-zero ACK means the remote controller generateed some error and stopped ################################################################### }


clearCache

public void clearCache()
Clear the filesystem cache on the server.

Overrides:
clearCache in class DataSource

main

public static void main(java.lang.String[] args)
GraniteRemoteClient main.