📄 dmcheckerimpl.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: DMCheckerImpl.java
package org.gudy.azureus2.core3.disk.impl.access.impl;
import com.aelitis.azureus.core.diskmanager.cache.CacheFile;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.disk.*;
import org.gudy.azureus2.core3.disk.impl.*;
import org.gudy.azureus2.core3.disk.impl.access.DMChecker;
import org.gudy.azureus2.core3.disk.impl.piecemapper.DMPieceList;
import org.gudy.azureus2.core3.disk.impl.piecemapper.DMPieceMapEntry;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
// Referenced classes of package org.gudy.azureus2.core3.disk.impl.access.impl:
// DiskManagerCheckRequestImpl
public class DMCheckerImpl
implements DMChecker
{
protected static final LogIDs LOGID;
private static boolean flush_pieces;
private static boolean checking_read_priority;
private static AEMonitor class_mon = new AEMonitor("DMChecker:class");
private static List async_check_queue = new ArrayList();
private static AESemaphore async_check_queue_sem = new AESemaphore("DMChecker::asyncCheck");
private static boolean fully_async;
protected DiskManagerHelper disk_manager;
protected int async_checks;
protected AESemaphore async_check_sem;
protected int async_reads;
protected AESemaphore async_read_sem;
private boolean started;
protected volatile boolean stopped;
private volatile boolean complete_recheck_in_progress;
private volatile int complete_recheck_progress;
private boolean checking_enabled;
protected AEMonitor this_mon;
public DMCheckerImpl(DiskManagerHelper _disk_manager)
{
async_check_sem = new AESemaphore("DMChecker::asyncCheck");
async_read_sem = new AESemaphore("DMChecker::asyncRead");
checking_enabled = true;
this_mon = new AEMonitor("DMChecker");
disk_manager = _disk_manager;
}
public void start()
{
this_mon.enter();
if (started)
throw new RuntimeException("DMChecker: start while started");
if (stopped)
throw new RuntimeException("DMChecker: start after stopped");
started = true;
this_mon.exit();
break MISSING_BLOCK_LABEL_66;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void stop()
{
this_mon.enter();
if (stopped || !started)
{
this_mon.exit();
return;
}
int check_wait;
int read_wait;
stopped = true;
read_wait = async_reads;
check_wait = async_checks;
this_mon.exit();
break MISSING_BLOCK_LABEL_64;
Exception exception;
exception;
this_mon.exit();
throw exception;
long log_time = SystemTime.getCurrentTime();
for (int i = 0; i < read_wait; i++)
{
long now = SystemTime.getCurrentTime();
if (now < log_time)
log_time = now;
else
if (now - log_time > 1000L)
{
log_time = now;
if (Logger.isEnabled())
Logger.log(new LogEvent(disk_manager, LOGID, (new StringBuilder()).append("Waiting for check-reads to complete - ").append(read_wait - i).append(" remaining").toString()));
}
async_read_sem.reserve();
}
log_time = SystemTime.getCurrentTime();
for (int i = 0; i < check_wait; i++)
{
long now = SystemTime.getCurrentTime();
if (now < log_time)
log_time = now;
else
if (now - log_time > 1000L)
{
log_time = now;
if (Logger.isEnabled())
Logger.log(new LogEvent(disk_manager, LOGID, (new StringBuilder()).append("Waiting for checks to complete - ").append(read_wait - i).append(" remaining").toString()));
}
async_check_sem.reserve();
}
return;
}
public int getCompleteRecheckStatus()
{
if (complete_recheck_in_progress)
return complete_recheck_progress;
else
return -1;
}
public void setCheckingEnabled(boolean enabled)
{
checking_enabled = enabled;
}
public DiskManagerCheckRequest createCheckRequest(int pieceNumber, Object user_data)
{
return new DiskManagerCheckRequestImpl(pieceNumber, user_data);
}
public void enqueueCompleteRecheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
{
if (!checking_enabled)
{
listener.checkCompleted(request, true);
return;
} else
{
complete_recheck_progress = 0;
complete_recheck_in_progress = true;
(new AEThread2(request, listener) {
final DiskManagerCheckRequest val$request;
final DiskManagerCheckRequestListener val$listener;
final DMCheckerImpl this$0;
public void run()
{
DiskManagerRecheckInstance recheck_inst = disk_manager.getRecheckScheduler().register(disk_manager, true);
final AESemaphore sem = new AESemaphore("DMChecker::completeRecheck");
int checks_submitted = 0;
final AESemaphore run_sem = new AESemaphore("DMChecker::completeRecheck:runsem", 2);
int nbPieces = disk_manager.getNbPieces();
for (int i = 0; i < nbPieces; i++)
{
complete_recheck_progress = (1000 * i) / nbPieces;
DiskManagerPiece dm_piece = disk_manager.getPiece(i);
if (!dm_piece.isDone() && dm_piece.isSkipped())
continue;
run_sem.reserve();
while (!stopped && !recheck_inst.getPermission()) ;
if (stopped)
break;
enqueueCheckRequest(createCheckRequest(i, request.getUserData()), new DiskManagerCheckRequestListener() {
final AESemaphore val$run_sem;
final AESemaphore val$sem;
final 3 this$1;
public void checkCompleted(DiskManagerCheckRequest request, boolean passed)
{
listener.checkCompleted(request, passed);
complete();
break MISSING_BLOCK_LABEL_42;
Throwable e;
e;
Debug.printStackTrace(e);
complete();
break MISSING_BLOCK_LABEL_42;
Exception exception1;
exception1;
complete();
throw exception1;
}
public void checkCancelled(DiskManagerCheckRequest request)
{
listener.checkCancelled(request);
complete();
break MISSING_BLOCK_LABEL_39;
Throwable e;
e;
Debug.printStackTrace(e);
complete();
break MISSING_BLOCK_LABEL_39;
Exception exception1;
exception1;
complete();
throw exception1;
}
public void checkFailed(DiskManagerCheckRequest request, Throwable cause)
{
listener.checkFailed(request, cause);
complete();
break MISSING_BLOCK_LABEL_42;
Throwable e;
e;
Debug.printStackTrace(e);
complete();
break MISSING_BLOCK_LABEL_42;
Exception exception1;
exception1;
complete();
throw exception1;
}
protected void complete()
{
run_sem.release();
sem.release();
}
{
this$1 = 3.this;
run_sem = aesemaphore;
sem = aesemaphore1;
super();
}
}, false);
checks_submitted++;
}
for (int i = 0; i < checks_submitted; i++)
sem.reserve();
complete_recheck_in_progress = false;
recheck_inst.unregister();
break MISSING_BLOCK_LABEL_262;
Exception exception;
exception;
complete_recheck_in_progress = false;
recheck_inst.unregister();
throw exception;
}
{
this$0 = DMCheckerImpl.this;
request = diskmanagercheckrequest;
listener = diskmanagercheckrequestlistener;
super(x0, x1);
}
}).start();
return;
}
}
public void enqueueCheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
{
if (!fully_async)
break MISSING_BLOCK_LABEL_110;
class_mon.enter();
async_check_queue.add(((Object) (new Object[] {
this, request, listener
})));
if (async_check_queue.size() % 100 == 0)
System.out.println((new StringBuilder()).append("async check queue size=").append(async_check_queue.size()).toString());
class_mon.exit();
break MISSING_BLOCK_LABEL_101;
Exception exception;
exception;
class_mon.exit();
throw exception;
async_check_queue_sem.release();
break MISSING_BLOCK_LABEL_119;
enqueueCheckRequest(request, listener, flush_pieces);
}
public boolean hasOutstandingCheckRequestForPiece(int piece_number)
{
if (!fully_async)
break MISSING_BLOCK_LABEL_106;
int i;
class_mon.enter();
i = 0;
_L1:
boolean flag;
if (i >= async_check_queue.size())
break MISSING_BLOCK_LABEL_86;
Object entry[] = (Object[])(Object[])async_check_queue.get(i);
if (entry[0] != this)
break MISSING_BLOCK_LABEL_80;
DiskManagerCheckRequest request = (DiskManagerCheckRequest)entry[1];
if (request.getPieceNumber() != piece_number)
break MISSING_BLOCK_LABEL_80;
flag = true;
class_mon.exit();
return flag;
i++;
goto _L1
class_mon.exit();
break MISSING_BLOCK_LABEL_106;
Exception exception;
exception;
class_mon.exit();
throw exception;
return false;
}
protected void enqueueCheckRequest(DiskManagerCheckRequest request, final DiskManagerCheckRequestListener listener, boolean read_flush)
{
request.requestStarts();
enqueueCheckRequestSupport(request, new DiskManagerCheckRequestListener() {
final DiskManagerCheckRequestListener val$listener;
final DMCheckerImpl this$0;
public void checkCompleted(DiskManagerCheckRequest request, boolean passed)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -