本文整理汇总了Java中lbms.plugins.mldht.kad.DHT.LogLevel类的典型用法代码示例。如果您正苦于以下问题:Java LogLevel类的具体用法?Java LogLevel怎么用?Java LogLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogLevel类属于lbms.plugins.mldht.kad.DHT包,在下文中一共展示了LogLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public void stop() {
if(state == State.STOPPED)
return;
state = State.STOPPED;
try
{
sel.close();
} catch (IOException e)
{
DHT.log(e, LogLevel.Error);
}
dh_table.getNode().removeId(derivedId);
manager.serverRemoved(this);
pipeline.clear();
}
示例2: PullMetaDataConnection
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public PullMetaDataConnection(SocketChannel chan)
{
channel = chan;
incoming = true;
connectionOpenTime = System.currentTimeMillis();
try
{
channel.configureBlocking(false);
} catch (IOException e)
{
DHT.log(e, LogLevel.Error);
}
remoteAddress = (InetSocketAddress) chan.socket().getRemoteSocketAddress();
setState(STATE_INITIAL, STATE_BASIC_HANDSHAKING);
}
示例3: terminate
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public void terminate(String reasonStr, CloseReason reason) throws IOException {
synchronized (this) {
CONNECTION_STATE oldState = state.get();
if(!setState(EnumSet.complementOf(EnumSet.of(STATE_CLOSED)), STATE_CLOSED))
return;
//if(!isState(STATE_CONNECTING))
//System.out.println("closing connection for "+(infoHash != null ? new Key(infoHash).toString(false) : null)+" to "+destination+"/"+remoteClient+" state:"+state+" reason:"+reason);
if(pool != null)
pool.deRegister(this);
closeReason = reason;
if(metaHandler != null)
metaHandler.onTerminate();
channel.close();
if(DHT.isLogLevelEnabled(LogLevel.Debug)) {
String closemsg = String.format("closing pull connection inc: %b reason: %s flag: %s state: %s pid: %s fast: %b age: %d", incoming, reasonStr, reason, oldState, stripToAscii(remotePeerId), remoteSupportsFastExtension, System.currentTimeMillis() - connectionOpenTime);
DHT.log(closemsg , LogLevel.Debug);
}
}
}
示例4: stop
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public void stop() {
if(state == State.STOPPED)
return;
state = State.STOPPED;
try
{
sel.close();
} catch (IOException e)
{
DHT.log(e, LogLevel.Error);
}
dh_table.getNode().removeId(derivedId);
manager.serverRemoved(this);
Stream.of(calls.values().stream(), call_queue.stream(), pipeline.stream().map(es -> es.associatedCall).filter(Objects::nonNull)).flatMap(s -> s).forEach(r -> {
r.cancel();
});
pipeline.clear();
DHT.logInfo("Stopped RPC Server " + addr + " " + derivedId.toString(false));
}
示例5: selectLoop
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
void selectLoop() {
iterations = 0;
lastNonZeroIteration = 0;
while(true)
{
try
{
wakeupCalled = false;
selector.select(100);
wakeupCalled = false;
connectionChecks();
processSelected();
handleRegistrations();
updateInterestOps();
} catch (Exception e)
{
DHT.log(e, LogLevel.Error);
}
iterations++;
if(suspendOnIdle())
break;
}
}
示例6: update
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
@Override
void update () {
for(;;) {
// while(!todo.isEmpty() && canDoRequest() && !isClosestSetStable() && !nextTodoUseless())
RequestPermit p = checkFreeSlot();
if(p == RequestPermit.NONE_ALLOWED)
return;
KBucketEntry e = todo.next().orElse(null);
if(e == null)
return;
if(!new RequestCandidateEvaluator(this, closest, todo, e, inFlight).goodForRequest(p))
return;
// send a findNode to the node
FindNodeRequest fnr = new FindNodeRequest(targetKey);
fnr.setWant4(rpc.getDHT().getType() == DHTtype.IPV4_DHT || rpc.getDHT().getSiblings().stream().anyMatch(sib -> sib.isRunning() && sib.getType() == DHTtype.IPV4_DHT && sib.getNode().getNumEntriesInRoutingTable() < DHTConstants.BOOTSTRAP_IF_LESS_THAN_X_PEERS));
fnr.setWant6(rpc.getDHT().getType() == DHTtype.IPV6_DHT || rpc.getDHT().getSiblings().stream().anyMatch(sib -> sib.isRunning() && sib.getType() == DHTtype.IPV6_DHT && sib.getNode().getNumEntriesInRoutingTable() < DHTConstants.BOOTSTRAP_IF_LESS_THAN_X_PEERS));
fnr.setDestination(e.getAddress());
if(!rpcCall(fnr,e.getID(), (call) -> {
long rtt = e.getRTT();
rtt = rtt + rtt / 2; // *1.5 since this is the average and not the 90th percentile like the timeout filter
if(rtt < DHTConstants.RPC_CALL_TIMEOUT_MAX && rtt < rpc.getTimeoutFilter().getStallTimeout())
call.setExpectedRTT(rtt); // only set a node-specific timeout if it's better than what the server would apply anyway
call.builtFromEntry(e);
todo.addCall(call, e);
if(DHT.isLogLevelEnabled(LogLevel.Verbose)) {
List<InetSocketAddress> sources = todo.getSources(e).stream().map(KBucketEntry::getAddress).collect(Collectors.toList());
DHT.log("Task "+getTaskID()+" sending call to "+ e + " sources:" + sources, LogLevel.Verbose);
}
})) {
break;
}
}
}
示例7: start
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
/**
* Start the task, to be used when a task is queued.
*/
public void start () {
if (setState(EnumSet.of(TaskState.INITIAL, TaskState.QUEUED), TaskState.RUNNING)) {
DHT.logDebug("Starting Task: " + toString());
startTime = System.currentTimeMillis();
try
{
serializedUpdate.run();
} catch (Exception e)
{
DHT.log(e, LogLevel.Error);
}
}
}
示例8: getStringFromBytes
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
private static String getStringFromBytes (byte[] bytes, boolean preserveBytes) {
if (bytes == null) {
return null;
}
try {
return new String(bytes, preserveBytes ? StandardCharsets.ISO_8859_1 : StandardCharsets.UTF_8);
} catch (Exception e) {
DHT.log(e, LogLevel.Verbose);
return null;
}
}
示例9: ConnectionAcceptor
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public ConnectionAcceptor(Predicate<SocketChannel> acc) {
acceptor = acc;
try
{
channel = ServerSocketChannel.open();
channel.configureBlocking(false);
} catch (IOException e)
{
DHT.log(e, LogLevel.Error);
}
}
示例10: Launcher
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public Launcher() {
configReader = new ConfigReader(Paths.get(".", "config.xml"), configDefaults, configSchema);
configReader.read();
scheduler = new NonblockingScheduledExecutor("mlDHT", Math.max(Runtime.getRuntime().availableProcessors(), 4), (t, ex) -> {
logger.log(ex, LogLevel.Fatal);
});
}
示例11: update
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
@Override
void update () {
// check if the cache has any closer nodes after the initial query
if(useCache) {
Collection<KBucketEntry> cacheResults = cache.get(targetKey, requestConcurrency());
todo.addCandidates(null, cacheResults);
}
for(;;) {
synchronized (this) {
RequestPermit p = checkFreeSlot();
if(p == RequestPermit.NONE_ALLOWED)
break;
KBucketEntry e = todo.next2(kbe -> {
RequestCandidateEvaluator eval = new RequestCandidateEvaluator(this, closest, todo, kbe, inFlight);
return eval.goodForRequest(p);
}).orElse(null);
if(e == null)
break;
GetPeersRequest gpr = new GetPeersRequest(targetKey);
// we only request cross-seeding on find-node
gpr.setWant4(rpc.getDHT().getType() == DHTtype.IPV4_DHT);
gpr.setWant6(rpc.getDHT().getType() == DHTtype.IPV6_DHT);
gpr.setDestination(e.getAddress());
gpr.setScrape(scrapeHandler != null);
gpr.setNoSeeds(noSeeds);
if(!rpcCall(gpr, e.getID(), call -> {
if(useCache)
call.addListener(cache.getRPCListener());
call.builtFromEntry(e);
long rtt = e.getRTT();
long defaultTimeout = rpc.getTimeoutFilter().getStallTimeout();
if(rtt < DHTConstants.RPC_CALL_TIMEOUT_MAX) {
// the measured RTT is a mean and not the 90th percentile unlike the RPCServer's timeout filter
// -> add some safety margin to account for variance
rtt = (long) (rtt * (rtt < defaultTimeout ? 2 : 1.5));
call.setExpectedRTT(min(rtt, DHTConstants.RPC_CALL_TIMEOUT_MAX));
}
if(DHT.isLogLevelEnabled(LogLevel.Verbose)) {
List<InetSocketAddress> sources = todo.getSources(e).stream().map(KBucketEntry::getAddress).collect(Collectors.toList());
DHT.log("Task "+getTaskID()+" sending call to "+ e + " sources:" + sources, LogLevel.Verbose);
}
todo.addCall(call, e);
})) {
break;
}
}
}
}
示例12: setLogLevel
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
private void setLogLevel() {
String rawLevel = configReader.get(XMLUtils.buildXPath("//core/logLevel")).orElse("Info");
LogLevel level = LogLevel.valueOf(rawLevel);
DHT.setLogLevel(level);
}
示例13: TorrentFetcher
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
public TorrentFetcher(Collection<DHT> dhts) {
this.dhts = dhts;
timer = new LoggingScheduledThreadPoolExecutor(1, LoggingScheduledThreadPoolExecutor.namedDaemonFactory("TorrentFetcher Timer"), t -> DHT.log(t, LogLevel.Fatal));
timer.setKeepAliveTime(4, TimeUnit.SECONDS);
timer.allowCoreThreadTimeOut(true);
}
示例14: incomingConnection
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
boolean incomingConnection(SocketChannel chan) {
PullMetaDataConnection con = new PullMetaDataConnection(chan);
if(incomingConnections.get() > maxIncoming)
return false;
incomingConnections.incrementAndGet();
con.setListener(new MetaConnectionHandler() {
@Override
public void onTerminate() {
incomingConnections.decrementAndGet();
}
@Override
public void onStateChange(CONNECTION_STATE oldState, CONNECTION_STATE newState) {
if(newState == CONNECTION_STATE.STATE_IH_RECEIVED) {
Key ih = con.getInfohash();
try {
Optional<FetchTask> ft;
synchronized (TorrentFetcher.this) {
ft = tasks.stream()
.filter((t -> t.hash.equals(ih)))
.findAny();
}
if (!ft.isPresent()) {
con.terminate("currently not servicing infohash " + ih.toString(false), CloseReason.OTHER);
return;
}
ft.get().registerIncomingConnection(con);
} catch (IOException e) {
DHT.log(e, LogLevel.Error);
}
}
}
@Override
public void onConnect() {
// TODO Auto-generated method stub
}
});
conMan.register(con);
return true;
}
示例15: log
import lbms.plugins.mldht.kad.DHT.LogLevel; //导入依赖的package包/类
void log(Throwable t) {
DHT.log(t, LogLevel.Error);
}