@Override public int getEntryCount() { return( current_filter.getEntryCount()); }
int filter_entries = current_filter.getEntryCount(); if ( current_filter.getEntryCount() > limit ){
protected void print() { int entries; if ( ip_count_bloom_filter == null ){ entries = 0; }else if ( ip_count_bloom_filter instanceof byte[] ){ entries = 1; }else{ entries = ((BloomFilter)ip_count_bloom_filter).getEntryCount(); } System.out.println( ByteFormatter.encodeString( key.getBytes()) + ": " + "dir=" + (direct_originator_map_may_be_null==null?0:direct_originator_map_may_be_null.size()) + "," + "indir=" + indirect_originator_value_map.size() + "," + "bloom=" + entries ); System.out.println( " indirect" ); Iterator<DHTDBValueImpl> it = getIndirectValues(); while( it.hasNext()){ DHTDBValueImpl val = (DHTDBValueImpl)it.next(); System.out.println( " " + val.getOriginator().getString() + ": " + new String( val.getValue())); } }
@Override public void sentTo( DHTTransportContact contact ) { BloomFilter filter = sent_to_bloom; if ( filter == null || filter.getEntryCount() > 100 ){ filter = BloomFilterFactory.createAddOnly(500); sent_to_bloom = filter; } filter.add( contact.getID()); } }
if ( all_bloom.getEntryCount() >= KEY_BLOOM_MAX_ENTRIES ){ if ( non_dht_bloom.getEntryCount() < KEY_BLOOM_MAX_ENTRIES ){ if ( all_bloom.getEntryCount() >= KEY_BLOOM_MAX_ENTRIES ){ all_bloom.getSize() + "/" + all_bloom.getEntryCount() +", " + non_dht_bloom.getSize() + "/" + non_dht_bloom.getEntryCount() + ": rcm=" + cc.related_content.size() + ", trans=" + RelatedContentManager.transient_info_cache.size() + ", dht=" + dht_infos.size());
@Override public void deactivateRequest( InetSocketAddress address ) { BloomFilter bloom = activation_bloom; if ( bloom != null ){ byte[] address_bytes = AddressUtils.getAddressBytes( address ); int count = bloom.count( address_bytes); for (int i=0;i<count;i++){ bloom.remove( address_bytes ); } activation_count = bloom.getEntryCount(); } }
protected void addPersistentlyDeleted( RelatedContent[] content ) { if ( content.length == 0 ){ return; } List<byte[]> entries = loadPersistentlyDeleted(); List<byte[]> new_keys = new ArrayList<>(content.length); for ( RelatedContent rc: content ){ byte[] key = getPermDelKey( rc ); new_keys.add( key ); entries.add( key ); } Map<String,Object> map = new HashMap<>(); map.put( "entries", entries ); FileUtil.writeResilientConfigFile( PERSIST_DEL_FILE, map ); if ( persist_del_bloom != null ){ if ( persist_del_bloom.getSize() / ( persist_del_bloom.getEntryCount() + content.length ) < 10 ){ persist_del_bloom = BloomFilterFactory.createAddOnly( Math.max( PD_BLOOM_INITIAL_SIZE, persist_del_bloom.getSize() *10 + PD_BLOOM_INCREMENT_SIZE + content.length )); for ( byte[] k: entries ){ persist_del_bloom.add( k ); } }else{ for ( byte[] k: new_keys ){ persist_del_bloom.add( k ); } } } }
protected void findContacts() { DHTTransportContact[] reachables = dht.getTransport().getReachableContacts(); for (int i=0;i<reachables.length;i++){ DHTTransportContact contact = reachables[i]; byte[] address = contact.getAddress().getAddress().getAddress(); if ( tried_bloom == null || tried_bloom.getEntryCount() > 500 ){ tried_bloom = BloomFilterFactory.createAddOnly( 4096 ); } if ( !tried_bloom.contains( address )){ tried_bloom.add( address ); synchronized( pending_contacts ){ potentialPing ping = new potentialPing( contact, DHTNetworkPositionManager.estimateRTT( contact.getNetworkPositions(), dht.getTransport().getLocalContact().getNetworkPositions())); pending_contacts.add( 0, ping ); if ( pending_contacts.size() > 60 ){ pending_contacts.removeLast(); } } } } }
int size = negative_result_bloom.getEntryCount();
protected void incrementValueAdds( DHTTransportContact contact ) { // assume a node stores 1000 values at 20 (K) locations -> 20,000 values // assume a DHT size of 100,000 nodes // that is, on average, 1 value per 5 nodes // assume NAT of up to 30 ports per address // this gives 6 values per address // with a factor of 10 error this is still only 60 per address // However, for CVS DHTs we can have sizes of 1000 or less. byte[] bloom_key = contact.getBloomKey(); int hit_count = ip_count_bloom_filter.add( bloom_key ); if ( DHTLog.GLOBAL_BLOOM_TRACE ){ System.out.println( "direct add from " + contact.getAddress() + ", hit count = " + hit_count ); } // allow up to 10% bloom filter utilisation if ( ip_count_bloom_filter.getSize() / ip_count_bloom_filter.getEntryCount() < 10 ){ rebuildIPBloomFilter( true ); } if ( hit_count > 64 ){ // obviously being spammed, drop all data originated by this IP and ban it banContact( contact, "global flood" ); } }
logger.log( "Rebuilt global IP bloom filter, size=" + new_filter.getSize() + ", entries=" + new_filter.getEntryCount()+", max hits=" + max_hits );
if ( incoming_bloom.getSize() / incoming_bloom.getEntryCount() < 10 ){
request.put( "s", new Long( f_bloom.getFilter().getEntryCount()));
if ( generate_bloom.getSize() / generate_bloom.getEntryCount() < 10 ){
if ( bad_ip_bloom_filter.getEntryCount() >= BAD_IP_BLOOM_FILTER_SIZE/10 ){
if ( filter.getEntryCount() < PREFER_UDP_BLOOM_SIZE / 10 ){
if ( generate_bloom.getSize() / generate_bloom.getEntryCount() < 10 ){
int ip_entries = ip_bloom_filter.getEntryCount();
if ( filter.getSize() / filter.getEntryCount() < 10 ){
activation_count = bloom.getEntryCount();