Methods Summary |
---|
protected boolean | canBeAggregatedWith(com.aelitis.azureus.core.diskmanager.access.impl.DiskAccessRequestImpl other)
return( op == other.getOperation() && cache_policy == other.getCachePolicy());
|
public void | cancel()
cancelled = true;
|
public org.gudy.azureus2.core3.util.DirectByteBuffer | getBuffer()
return( buffer );
|
public short | getCachePolicy()
return( cache_policy );
|
public com.aelitis.azureus.core.diskmanager.cache.CacheFile | getFile()
return( file );
|
protected com.aelitis.azureus.core.diskmanager.access.DiskAccessRequestListener | getListener()
return( listener );
|
public long | getOffset()
return( offset );
|
protected int | getOperation()
return( op );
|
public int | getPriority()
return( listener.getPriority());
|
public int | getSize()
return( size );
|
public boolean | isCancelled()
return( cancelled );
|
protected static void | runAggregated(com.aelitis.azureus.core.diskmanager.access.impl.DiskAccessRequestImpl base_request, com.aelitis.azureus.core.diskmanager.access.impl.DiskAccessRequestImpl[] requests)
// assumption - they are all for the same file, sequential offsets and aggregatable, not cancelled
int op = base_request.getOperation();
CacheFile file = base_request.getFile();
long offset = base_request.getOffset();
short cache_policy = base_request.getCachePolicy();
DirectByteBuffer[] buffers = new DirectByteBuffer[requests.length];
long current_offset = offset;
long total_size = 0;
for (int i=0;i<buffers.length;i++){
DiskAccessRequestImpl request = requests[i];
if ( current_offset != request.getOffset()){
Debug.out( "assert failed: requests not contiguous" );
}
int size = request.getSize();
current_offset += size;
total_size += size;
buffers[i] = request.getBuffer();
}
try{
if ( op == OP_READ ){
file.read( buffers, offset, cache_policy );
}else if ( op == OP_WRITE ){
file.write( buffers, offset );
}else{
file.writeAndHandoverBuffers( buffers, offset );
}
base_request.getListener().requestExecuted( total_size );
for (int i=0;i<requests.length;i++){
DiskAccessRequestImpl request = requests[i];
request.getListener().requestComplete( request );
if ( request != base_request ){
request.getListener().requestExecuted( 0 );
}
}
}catch( CacheFileManagerException e ){
int fail_index = e.getFailIndex();
for (int i=0;i<fail_index;i++){
DiskAccessRequestImpl request = requests[i];
request.getListener().requestComplete( request );
}
for (int i=fail_index;i<requests.length;i++){
DiskAccessRequestImpl request = requests[i];
request.getListener().requestFailed( request, e );
}
}catch( Throwable e ){
for (int i=0;i<requests.length;i++){
DiskAccessRequestImpl request = requests[i];
request.getListener().requestFailed( request, e );
}
}
|
protected void | runRequest()
if ( cancelled ){
listener.requestCancelled( this );
return;
}
//System.out.println( "DiskReq:" + Thread.currentThread().getName() + ": " + op + " - " + offset );
try{
if ( op == OP_READ ){
file.read( buffer, offset, cache_policy );
}else if ( op == OP_WRITE ){
file.write( buffer, offset );
}else{
file.writeAndHandoverBuffer( buffer, offset );
}
listener.requestComplete( this );
}catch( Throwable e ){
listener.requestFailed( this, e );
}
|