⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddbaseimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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:   DDBaseImpl.java

package org.gudy.azureus2.pluginsimpl.local.ddb;

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.util.CopyOnWriteList;
import com.aelitis.azureus.plugins.dht.*;
import java.net.InetSocketAddress;
import java.util.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.PluginManager;
import org.gudy.azureus2.plugins.ddb.*;

// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.ddb:
//			DDBaseContactImpl, DDBaseHelpers, DDBaseKeyImpl, DDBaseTTTorrent, 
//			DDBaseValueImpl

public class DDBaseImpl
	implements DistributedDatabase
{
	protected class dbEvent
		implements DistributedDatabaseEvent
	{

		private int type;
		private DistributedDatabaseKey key;
		private DistributedDatabaseKeyStats key_stats;
		private DistributedDatabaseValue value;
		private DDBaseContactImpl contact;
		final DDBaseImpl this$0;

		public int getType()
		{
			return type;
		}

		public DistributedDatabaseKey getKey()
		{
			return key;
		}

		public DistributedDatabaseKeyStats getKeyStats()
		{
			return key_stats;
		}

		public DistributedDatabaseValue getValue()
		{
			return value;
		}

		public DistributedDatabaseContact getContact()
		{
			return contact;
		}

		protected dbEvent(int _type)
		{
			this$0 = DDBaseImpl.this;
			super();
			type = _type;
		}

		protected dbEvent(int _type, DistributedDatabaseKey _key)
		{
			this$0 = DDBaseImpl.this;
			super();
			type = _type;
			key = _key;
		}

		protected dbEvent(int _type, DistributedDatabaseKey _key, DHTPluginContact _contact, DHTPluginValue _value)
		{
			this$0 = DDBaseImpl.this;
			super();
			type = _type;
			key = _key;
			contact = new DDBaseContactImpl(DDBaseImpl.this, _contact);
			value = new DDBaseValueImpl(contact, _value.getValue(), _value.getCreationTime(), _value.getVersion());
		}

		protected dbEvent(int _type, DistributedDatabaseKey _key, DHTPluginContact _contact, DistributedDatabaseKeyStats _key_stats)
		{
			this$0 = DDBaseImpl.this;
			super();
			type = _type;
			key = _key;
			contact = new DDBaseContactImpl(DDBaseImpl.this, _contact);
			key_stats = _key_stats;
		}

		protected dbEvent(int _type, DistributedDatabaseKey _key, DHTPluginContact _contact, byte _value[], long _ct, 
				long _v)
		{
			this$0 = DDBaseImpl.this;
			super();
			type = _type;
			key = _key;
			contact = new DDBaseContactImpl(DDBaseImpl.this, _contact);
			value = new DDBaseValueImpl(contact, _value, _ct, _v);
		}
	}

	protected class listenerMapper
		implements DHTPluginOperationListener
	{

		private DistributedDatabaseListener listener;
		private int type;
		private DistributedDatabaseKey key;
		private byte key_bytes[];
		private long timeout;
		private boolean complete_disabled;
		private boolean exhaustive;
		private boolean high_priority;
		private int continuation_num;
		final DDBaseImpl this$0;

		public void diversified()
		{
		}

		public void starts(byte _key[])
		{
			listener.event(new dbEvent(7, key));
		}

		public void valueRead(DHTPluginContact originator, DHTPluginValue _value)
		{
			if (type == 6)
			{
				if ((_value.getFlags() & 8) == 0)
					return;
				try
				{
					final DHTPluginKeyStats stats = getDHT().decodeStats(_value);
					DistributedDatabaseKeyStats ddb_stats = new DistributedDatabaseKeyStats() {

						final DHTPluginKeyStats val$stats;
						final listenerMapper this$1;

						public int getEntryCount()
						{
							return stats.getEntryCount();
						}

						public int getSize()
						{
							return stats.getSize();
						}

						public int getReadsPerMinute()
						{
							return stats.getReadsPerMinute();
						}

						public byte getDiversification()
						{
							return stats.getDiversification();
						}

				
				{
					this$1 = listenerMapper.this;
					stats = dhtpluginkeystats;
					super();
				}
					};
					listener.event(new dbEvent(type, key, originator, ddb_stats));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			} else
			{
				byte value[] = _value.getValue();
				if (_value.getFlags() == 4)
				{
					int pos = 1;
					do
					{
						if (pos >= value.length)
							break;
						int len = (value[pos++] << 8 & 0xff00) + (value[pos++] & 0xff);
						if (len > value.length - pos)
						{
							Debug.out((new StringBuilder()).append("Invalid length: len = ").append(len).append(", remaining = ").append(value.length - pos).toString());
							break;
						}
						byte d[] = new byte[len];
						System.arraycopy(value, pos, d, 0, len);
						listener.event(new dbEvent(type, key, originator, d, _value.getCreationTime(), _value.getVersion()));
						pos += len;
					} while (true);
					if (value[0] == 1)
					{
						byte next_key_bytes[] = (new SHA1Simple()).calculateHash(key_bytes);
						complete_disabled = true;
						grabDHT().get(next_key_bytes, (new StringBuilder()).append(key.getDescription()).append(" [continuation ").append(continuation_num).append("]").toString(), (byte)0, 256, timeout, exhaustive, high_priority, new listenerMapper(listener, 2, key, next_key_bytes, timeout, continuation_num + 1));
					}
				} else
				{
					listener.event(new dbEvent(type, key, originator, _value));
				}
			}
		}

		public void valueWritten(DHTPluginContact target, DHTPluginValue value)
		{
			listener.event(new dbEvent(type, key, target, value));
		}

		public void complete(byte timeout_key[], boolean timeout_occurred)
		{
			if (!complete_disabled)
				listener.event(new dbEvent(timeout_occurred ? 5 : 4, key));
		}

		protected listenerMapper(DistributedDatabaseListener _listener, int _type, DistributedDatabaseKey _key, long _timeout, boolean _exhaustive, 
				boolean _high_priority)
		{
			this$0 = DDBaseImpl.this;
			super();
			listener = _listener;
			type = _type;
			key = _key;
			key_bytes = ((DDBaseKeyImpl)key).getBytes();
			timeout = _timeout;
			exhaustive = _exhaustive;
			high_priority = _high_priority;
			continuation_num = 1;
		}

		private listenerMapper(DistributedDatabaseListener _listener, int _type, DistributedDatabaseKey _key, byte _key_bytes[], long _timeout, 
				int _continuation_num)
		{
			this$0 = DDBaseImpl.this;
			super();
			listener = _listener;
			type = _type;
			key = _key;
			key_bytes = _key_bytes;
			timeout = _timeout;
			continuation_num = _continuation_num;
		}
	}


	private static DDBaseImpl singleton;
	protected static AEMonitor class_mon = new AEMonitor("DDBaseImpl:class");
	protected static Map transfer_map = new HashMap();
	private static DDBaseTTTorrent torrent_transfer;
	private AzureusCore azureus_core;
	private DHTPlugin dht_use_accessor;
	private CopyOnWriteList listeners;

	public static DDBaseImpl getSingleton(AzureusCore azureus_core)
	{
		class_mon.enter();
		if (singleton == null)
			singleton = new DDBaseImpl(azureus_core);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_41;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		return singleton;
	}

	protected DDBaseImpl(AzureusCore _azureus_core)
	{
		listeners = new CopyOnWriteList();
		azureus_core = _azureus_core;
		torrent_transfer = new DDBaseTTTorrent(_azureus_core, this);
		grabDHT();
	}

	public DDBaseTTTorrent getTTTorrent()
	{
		return torrent_transfer;
	}

	protected DHTPlugin grabDHT()
	{
		if (dht_use_accessor != null)
			return dht_use_accessor;
		class_mon.enter();
		if (dht_use_accessor == null)
		{
			PluginInterface dht_pi = azureus_core.getPluginManager().getPluginInterfaceByClass(com/aelitis/azureus/plugins/dht/DHTPlugin);
			if (dht_pi != null)
			{
				dht_use_accessor = (DHTPlugin)dht_pi.getPlugin();
				if (dht_use_accessor.isEnabled())
				{
					dht_use_accessor.addListener(new DHTPluginListener() {

						final DDBaseImpl this$0;

						public void localAddressChanged(DHTPluginContact local_contact)
						{
							List l = listeners.getList();
							dbEvent ev = new dbEvent(10);
							for (int i = 0; i < l.size(); i++)
								((DistributedDatabaseListener)l.get(i)).event(ev);

						}

			
			{
				this$0 = DDBaseImpl.this;
				super();
			}
					});
					try
					{
						addTransferHandler(torrent_transfer, torrent_transfer);
					}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -