Package net.yacy.peers

Examples of net.yacy.peers.Seed


        } else {
            port = env.getConfigLong("port", 8090); //this allows a low port, but it will only get one, if the user edits the config himself.
        }

        // check if peer name already exists
        final Seed oldSeed = sb.peers.lookupByName(peerName);
        if (oldSeed == null &&
            !peerName.equals(sb.peers.mySeed().getName()) &&
            Pattern.compile("[A-Za-z0-9\\-_]{3,80}").matcher(peerName).matches()) {
            sb.peers.setMyName(peerName);
            sb.peers.saveMySeed();
View Full Code Here


                            templatePatterns.put(servletProperties.PEER_STAT_VERSION, yacyBuildProperties.getVersion());
                            templatePatterns.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() -  serverCore.startupTime) / 1000) / 60); // uptime in minutes
                            templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTNAME, sb.peers.mySeed().getName());
                            templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTID, ((Switchboard) switchboard).peers.myID());
                            templatePatterns.put(servletProperties.PEER_STAT_MYTIME, GenericFormatter.SHORT_SECOND_FORMATTER.format());
                            final Seed myPeer = sb.peers.mySeed();
                            templatePatterns.put("newpeer", myPeer.getAge() >= 1 ? 0 : 1);
                            templatePatterns.putHTML("newpeer_peerhash", myPeer.hash);
                            //System.out.println("respond props: " + ((tp == null) ? "null" : tp.toString())); // debug
                        } catch (final InvocationTargetException e) {
                            if (e.getCause() instanceof InterruptedException) {
                                throw new InterruptedException(e.getCause().getMessage());
View Full Code Here

       
        // create other peer crawl table using YaCyNews
        Iterator<NewsDB.Record> recordIterator = sb.peers.newsPool.recordIterator(NewsPool.INCOMING_DB, true);
        int showedCrawl = 0;
        NewsDB.Record record;
        Seed peer;
        String peername;
        while (recordIterator.hasNext()) {
            record = recordIterator.next();
            if (record == null) {
                continue;
            }
            if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
                peer = sb.peers.get(record.originator());
                peername = (peer == null) ? record.originator() : peer.getName();

                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_dark", dark ? "1" : "0");
                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_cre", record.created().toString());
                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_peername", peername);
                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_startURL", record.attributes().get("startURL").toString());
                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_intention", record.attributes().get("intention").toString());
                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_generalDepth", record.attributes().get("generalDepth"));
                prop.put("otherCrawlStartInProgress_" + showedCrawl + "_crawlingQ", ("true".equals(record.attributes().get("crawlingQ"))) ? "1" : "0");
                showedCrawl++;
                if (showedCrawl > 20) {
                    break;
                }
            }
        }
        prop.put("otherCrawlStartInProgress", showedCrawl);
       
        // finished remote crawls
        recordIterator = sb.peers.newsPool.recordIterator(NewsPool.PROCESSED_DB, true);
        showedCrawl = 0;
        while (recordIterator.hasNext()) {
            record = recordIterator.next();
            if (record == null) {
                continue;
            }
            if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
                peer = sb.peers.get(record.originator());
                peername = (peer == null) ? record.originator() : peer.getName();

                prop.put("otherCrawlStartFinished_" + showedCrawl + "_dark", dark ? "1" : "0");
                prop.put("otherCrawlStartFinished_" + showedCrawl + "_cre", record.created().toString());
                prop.putHTML("otherCrawlStartFinished_" + showedCrawl + "_peername", peername);
                prop.putHTML("otherCrawlStartFinished_" + showedCrawl + "_startURL", record.attributes().get("startURL").toString());
View Full Code Here

            int peerCount = 0;
            try {
                final TreeMap<String, String> hostList = new TreeMap<String, String>();
                final Iterator<Seed> e = sb.peers.seedsConnected(true, false, null, (float) 0.0);
                while (e.hasNext()) {
                    final Seed seed = e.next();
                    if (seed != null) hostList.put(seed.get(Seed.NAME, "nameless"),seed.hash);
                }

                String peername;
                while ((peername = hostList.firstKey()) != null) {
                    final String Hash = hostList.get(peername);
View Full Code Here

            prop.put("crawler-queue", "1");
            final List<Request> crawlerList = sb.crawlQueues.noticeURL.top(NoticedURL.StackType.REMOTE, showLimit);
           
            Request urle;
            boolean dark = true;
            Seed initiator;
            String profileHandle;
            CrawlProfile profileEntry;
            int i, showNum = 0;
            for (i = 0; (i < crawlerList.size()) && (showNum < showLimit); i++) {
                urle = crawlerList.get(i);
                if (urle != null && urle.url() != null) {
                    initiator = sb.peers.getConnected((urle.initiator() == null) ? "" : ASCII.String(urle.initiator()));
                    profileHandle = urle.profileHandle();
                    profileEntry = profileHandle == null ? null : sb.crawler.getActive(profileHandle.getBytes());
                    prop.put("crawler-queue_list_" + showNum + "_dark", dark ? "1" : "0");
                    prop.putHTML("crawler-queue_list_" + showNum + "_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
                    prop.put("crawler-queue_list_" + showNum + "_profile", ((profileEntry == null) ? "unknown" : profileEntry.name()));
                    prop.put("crawler-queue_list_" + showNum + "_depth", urle.depth());
                    prop.put("crawler-queue_list_" + showNum + "_modified", daydate(urle.appdate()) );
                    prop.putHTML("crawler-queue_list_" + showNum + "_anchor", urle.name());
                    prop.putHTML("crawler-queue_list_" + showNum + "_url", urle.url().toString());
View Full Code Here

            final double otherqpm = sb.peers.countActiveQPM();
            long myppm = 0;
            double myqph = 0d;

            // create own peer info
            final Seed seed = sb.peers.mySeed();
            if (sb.peers.mySeed() != null){ //our Peer
                // update seed info
                sb.updateMySeed();

                final long LCount = seed.getLinkCount();
                final long ICount = seed.getWordCount();
                final long RCount = seed.getLong(Seed.RCOUNT, 0L);

                // my-info
                prop.putHTML("table_my-name", seed.get(Seed.NAME, "-") );
                prop.put("table_my-hash", seed.hash );
                if (sb.peers.mySeed().isVirgin()) {
                    prop.put("table_my-info", 0);
                } else if(sb.peers.mySeed().isJunior()) {
                    prop.put("table_my-info", 1);
                    accPotLinks += LCount;
                    accPotWords += ICount;
                } else if(sb.peers.mySeed().isSenior()) {
                    prop.put("table_my-info", 2);
                    accActLinks += LCount;
                    accActWords += ICount;
                } else if(sb.peers.mySeed().isPrincipal()) {
                    prop.put("table_my-info", 3);
                    accActLinks += LCount;
                    accActWords += ICount;
                }
                prop.put("table_my-acceptcrawl", seed.getFlagAcceptRemoteCrawl() ? 1 : 0);
                prop.put("table_my-dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0);


                myppm = sb.currentPPM();
                myqph = 60d * sb.averageQPM();
                prop.put("table_my-version", seed.get(Seed.VERSION, "-"));
                prop.put("table_my-utc", seed.get(Seed.UTC, "-"));
                prop.put("table_my-uptime", PeerActions.formatInterval(60000 * seed.getLong(Seed.UPTIME, 0)));
                prop.putNum("table_my-LCount", LCount);
                prop.putNum("table_my-ICount", ICount);
                prop.putNum("table_my-RCount", RCount);
                prop.putNum("table_my-sI", seed.getLong(Seed.INDEX_OUT, 0L));
                prop.putNum("table_my-sU", seed.getLong(Seed.URL_OUT, 0L));
                prop.putNum("table_my-rI", seed.getLong(Seed.INDEX_IN, 0L));
                prop.putNum("table_my-rU", seed.getLong(Seed.URL_IN, 0L));
                prop.putNum("table_my-ppm", myppm);
                prop.putNum("table_my-qph", Math.round(100d * myqph) / 100d);
                prop.putNum("table_my-qph-publocal", Math.round(6000d * sb.averageQPMPublicLocal()) / 100d);
                prop.putNum("table_my-qph-pubremote", Math.round(6000d * sb.averageQPMGlobal()) / 100d);
                prop.putNum("table_my-seeds", seed.getLong(Seed.SCOUNT, 0L));
                prop.putNum("table_my-connects", seed.getFloat(Seed.CCOUNT, 0F));
                prop.put("table_my-url", seed.get(Seed.SEEDLISTURL, ""));

                // generating the location string
                prop.putHTML("table_my-location", ClientIdentification.generateLocation());
            }

            // overall results: Network statistics
            if (iAmActive) conCount++; else if (mySeedType.equals(Seed.PEERTYPE_JUNIOR)) potCount++;
            final int activeLastMonth = sb.peers.sizeActiveSince(30 * 1440);
            final int activeLastWeek = sb.peers.sizeActiveSince(7 * 1440);
            final int activeLastDay = sb.peers.sizeActiveSince(1440);
            final int activeSwitch =
                (activeLastDay <= conCount) ? 0 :
                (activeLastWeek <= activeLastDay) ? 1 :
                (activeLastMonth <= activeLastWeek) ? 2 : 3;
            prop.putNum("table_active-switch", activeSwitch);
            prop.putNum("table_active-switch_last-month", activeLastMonth);
            prop.putNum("table_active-switch_last-week", activeLastWeek);
            prop.putNum("table_active-switch_last-day", activeLastDay);
            prop.putNum("table_active-count", conCount);
            prop.putNum("table_active-links", accActLinks);
            prop.putNum("table_active-words", accActWords);
            prop.putNum("table_passive-count", disconCount);
            prop.putNum("table_passive-links", accPassLinks);
            prop.putNum("table_passive-words", accPassWords);
            prop.putNum("table_potential-count", potCount);
            prop.putNum("table_potential-links", accPotLinks);
            prop.putNum("table_potential-words", accPotWords);
            prop.putNum("table_all-count", conCount + disconCount + potCount);
            prop.putNum("table_all-links", accActLinks + accPassLinks + accPotLinks);
            prop.putNum("table_all-words", accActWords + accPassWords + accPotWords);

            prop.putNum("table_gppm", otherppm + ((iAmActive) ? myppm : 0));
            prop.putNum("table_gqph", Math.round(6000d * otherqpm + 100d * ((iAmActive) ? myqph : 0d)) / 100d);
            prop.put("table", 2); // triggers overview
            prop.put("page", 0);
        } else if (post != null && post.getInt("page", 1) == 4) {
            prop.put("table", 4); // triggers overview
            prop.put("page", 4);

            if (sb.peers.mySeed() != null) {
              prop.put("table_my-hash", sb.peers.mySeed().hash );
              prop.put("table_my-ip", sb.peers.mySeed().getIP() );
              prop.put("table_my-port", sb.peers.mySeed().getPort() );
            }

            if (post.containsKey("addPeer")) {

                // AUTHENTICATE
                if (!requestHeader.containsKey(RequestHeader.AUTHORIZATION)) {
                    prop.putHTML("AUTHENTICATE","log-in");
                    return prop;
                }

                final ConcurrentMap<String, String> map = new ConcurrentHashMap<String, String>();
                map.put(Seed.IP, post.get("peerIP"));
                map.put(Seed.PORT, post.get("peerPort"));
                Seed peer = new Seed(post.get("peerHash"), map);

                sb.updateMySeed();
                final int added = Protocol.hello(sb.peers.mySeed(), sb.peers.peerActions, peer.getPublicAddress(), peer.hash, peer.getName());

                if (added <= 0) {
                    prop.put("table_comment",1);
                    prop.putHTML("table_comment_status","publish: disconnected peer '" + peer.getName() + "/" + post.get("peerHash") + "' from " + peer.getPublicAddress());
                } else {
                    peer = sb.peers.getConnected(peer.hash);
                    if (peer == null) {
                        prop.put("table_comment",1);
                        prop.putHTML("table_comment_status","publish: disconnected peer 'UNKNOWN/" + post.get("peerHash") + "' from UNKNOWN");
                    } else {
                        prop.put("table_comment",2);
                        prop.putHTML("table_comment_status","publish: handshaked " + peer.get(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR) + " peer '" + peer.getName() + "' at " + peer.getPublicAddress());
                        prop.putHTML("table_comment_details",peer.toString());
                    }
                }

                prop.putHTML("table_peerHash",post.get("peerHash"));
                prop.putHTML("table_peerIP",post.get("peerIP"));
                prop.putHTML("table_peerPort",post.get("peerPort"));
            } else {
                prop.put("table_peerHash","");
                prop.put("table_peerIP","");
                prop.put("table_peerPort","");

                prop.put("table_comment",0);
            }
        } else {
            // generate table
            final int page = (post == null ? 1 : post.getInt("page", 1));
            final int maxCount = (post == null ? 9000 : post.getInt("maxCount", 9000));
            int conCount = 0;
            if (sb.peers == null) {
                prop.put("table", 0);//no remote senior/principal proxies known"
            } else {
                int size = 0;
                switch (page) {
                    case 1 : size = sb.peers.sizeConnected(); break;
                    case 2 : size = sb.peers.sizeDisconnected(); break;
                    case 3 : size = sb.peers.sizePotential(); break;
                    default: break;
                }
                if (size == 0) {
                    prop.put("table", 0);//no remote senior/principal proxies known"
                } else {
                    // add temporary the own seed to the database
                    if (iAmActive) {
                        sb.updateMySeed();
                        sb.peers.addConnected(sb.peers.mySeed());
                    }

                    // find updated Information using YaCyNews
                    final HashSet<String> updatedProfile = new HashSet<String>();
                    final HashMap<String, Map<String, String>> updatedWiki = new HashMap<String, Map<String, String>>();
                    final HashMap<String, Map<String, String>> updatedBlog = new HashMap<String, Map<String, String>>();
                    final HashMap<String, String> isCrawling = new HashMap<String, String>();
                    NewsDB.Record record;
                    final Iterator<NewsDB.Record> recordIterator = sb.peers.newsPool.recordIterator(NewsPool.INCOMING_DB, true);
                    while (recordIterator.hasNext()) {
                        record = recordIterator.next();
                        if (record == null) {
                            continue;
                        } else if (record.category().equals(NewsPool.CATEGORY_PROFILE_UPDATE)) {
                            updatedProfile.add(record.originator());
                        } else if (record.category().equals(NewsPool.CATEGORY_WIKI_UPDATE)) {
                            updatedWiki.put(record.originator(), record.attributes());
                        } else if (record.category().equals(NewsPool.CATEGORY_BLOG_ADD)) {
                            updatedBlog.put(record.originator(), record.attributes());
                        } else if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
                            isCrawling.put(record.originator(), record.attributes().get("startURL"));
                        }
                    }

                    boolean dark = true;
                    Seed seed;
                    final boolean complete = (post != null && post.containsKey("ip"));
                    Iterator<Seed> e = null;
                    final boolean order = (post != null && post.get("order", "down").equals("up"));
                    final String sort = (post == null ? null : post.get("sort", null));
                    switch (page) {
                        case 1 : e = sb.peers.seedsSortedConnected(order, (sort == null ? Seed.LCOUNT : sort)); break;
                        case 2 : e = sb.peers.seedsSortedDisconnected(order, (sort == null ? Seed.LASTSEEN : sort)); break;
                        case 3 : e = sb.peers.seedsSortedPotential(order, (sort == null ? Seed.LASTSEEN : sort)); break;
                        default: break;
                    }
                    String startURL;
                    Map<String, String> wikiMap;
                    Map<String, String> blogMap;
                    String userAgent, location;
                    int PPM;
                    double QPM;
                    Pattern peerSearchPattern = null;
                    prop.put("regexerror", 0);
                    prop.put("regexerror_wrongregex", (String)null);
                    if (post != null && post.containsKey("search")) {
                        try {
                            peerSearchPattern = Pattern.compile(post.get("match", ""), Pattern.CASE_INSENSITIVE);
                        } catch (final PatternSyntaxException pse){
                            prop.put("regexerror", 1);
                            prop.putHTML("regexerror_wrongregex", pse.getPattern());
                        }
                    }
                    if (e != null) {
                    while (e.hasNext() && conCount < maxCount) {
                        seed = e.next();
                        assert seed != null;
                        if (seed != null) {
                            if((post != null && post.containsKey("search"))  && peerSearchPattern != null /*(wrongregex == null)*/) {
                                boolean abort = true;
                                Matcher m = peerSearchPattern.matcher (seed.getName());
                                if (m.find ()) {
                                    abort = false;
                                }
                                m = peerSearchPattern.matcher (seed.hash);
                                if (m.find ()) {
                                    abort = false;
                                }
                                if (abort) continue;
                            }
                            prop.put(STR_TABLE_LIST + conCount + "_updatedProfile", 0);
                            prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", 0);
                            prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
                            prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
                            if (conCount >= maxCount) { break; }
                            if (sb.peers != null && sb.peers.mySeed() != null && seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) {
                                prop.put(STR_TABLE_LIST + conCount + "_dark", 2);
                            } else {
                                prop.put(STR_TABLE_LIST + conCount + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
                            }
                            if (updatedProfile.contains(seed.hash)) {
                                prop.put(STR_TABLE_LIST + conCount + "_updatedProfile", 1);
                                prop.put(STR_TABLE_LIST + conCount + "_updatedProfile_hash", seed.hash);
                            }
                            if ((wikiMap = updatedWiki.get(seed.hash)) == null) {
                                prop.put(STR_TABLE_LIST + conCount + "_updatedWiki", 0);
                            } else {
                                prop.put(STR_TABLE_LIST + conCount + "_updatedWiki", 1);
                                prop.putHTML(STR_TABLE_LIST + conCount + "_updatedWiki_page", wikiMap.get("page"));
                                prop.put(STR_TABLE_LIST + conCount + "_updatedWiki_address", seed.getPublicAddress());
                            }
                            if ((blogMap = updatedBlog.get(seed.hash)) == null) {
                                prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
                            } else {
                                prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 1);
                                prop.putHTML(STR_TABLE_LIST + conCount + "_updatedBlog_page", blogMap.get("page"));
                                prop.putHTML(STR_TABLE_LIST + conCount + "_updatedBlog_subject", blogMap.get("subject"));
                                prop.put(STR_TABLE_LIST + conCount + "_updatedBlog_address", seed.getPublicAddress());
                            }
                            PPM = seed.getPPM();
                            QPM = seed.getQPM();
                            if (((startURL = isCrawling.get(seed.hash)) != null) && (PPM >= 4)) {
                                prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 1);
                                prop.put(STR_TABLE_LIST + conCount + "_isCrawling_page", startURL);
                            }
                            prop.put(STR_TABLE_LIST + conCount + "_hash", seed.hash);
                            String shortname = seed.get(Seed.NAME, "deadlink");
                            if (shortname.length() > 20) {
                                shortname = shortname.substring(0, 20) + "...";
                            }
                            prop.putHTML(STR_TABLE_LIST + conCount + "_shortname", shortname);
                            prop.putHTML(STR_TABLE_LIST + conCount + "_fullname", seed.get(Seed.NAME, "deadlink"));
                            userAgent = null;
                            if (seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) {
                                userAgent = ClientIdentification.getUserAgent();
                                location = ClientIdentification.generateLocation();
                            } else {
                               userAgent = sb.peers.peerActions.getUserAgent(seed.getIP());
                               location = ClientIdentification.parseLocationInUserAgent(userAgent);
                            }
                            prop.put(STR_TABLE_LIST + conCount + "_location", location);
                            if (complete) {
                                prop.put(STR_TABLE_LIST + conCount + "_complete", 1);
                                prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.getIP() );
                                prop.put(STR_TABLE_LIST + conCount + "_complete_port", seed.get(Seed.PORT, "-") );
                                prop.put(STR_TABLE_LIST + conCount + "_complete_hash", seed.hash);
                                prop.put(STR_TABLE_LIST + conCount + "_complete_age", seed.getAge());
                                prop.putNum(STR_TABLE_LIST + conCount + "_complete_seeds", seed.getLong(Seed.SCOUNT, 0L));
                                prop.putNum(STR_TABLE_LIST + conCount + "_complete_connects", seed.getFloat(Seed.CCOUNT, 0F));
                                prop.putHTML(STR_TABLE_LIST + conCount + "_complete_userAgent", userAgent);
                            } else {
                                prop.put(STR_TABLE_LIST + conCount + "_complete", 0);
                            }


                            if (seed.isJunior()) {
                                prop.put(STR_TABLE_LIST + conCount + "_type", 0);
                            } else if(seed.isSenior()){
                                prop.put(STR_TABLE_LIST + conCount + "_type", 1);
                            } else if(seed.isPrincipal()) {
                                prop.put(STR_TABLE_LIST + conCount + "_type", 2);
                            }
                            prop.putHTML(STR_TABLE_LIST + conCount + "_type_url", seed.get(Seed.SEEDLISTURL, "http://nowhere/"));

                            final long lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
                            if (page == 1 && lastseen > 720) {
                              continue;
                            }
                            if (page == 2 || (page == 1 && lastseen > 360)) { // Passive Peers should be passive, also Peers without contact greater than 6 hours
                                // principal/senior/junior: red/red=offline
                                prop.put(STR_TABLE_LIST + conCount + "_type_direct", 2);
                            } else {
                                // principal/senior: green/green=direct or yellow/yellow=passive
                                // junior: red/green=direct or red/yellow=passive
                                prop.put(STR_TABLE_LIST + conCount + "_type_direct", seed.getFlagDirectConnect() ? 1 : 0);
                            }

                            if (page == 1) {
                                prop.put(STR_TABLE_LIST + conCount + "_acceptcrawl", seed.getFlagAcceptRemoteCrawl() ? 1 : 0); // green=on or red=off
                                prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0)// green=on or red=off
                            } else { // Passive, Potential Peers
                                if (seed.getFlagAcceptRemoteCrawl()) {
                                    prop.put(STR_TABLE_LIST + conCount + "_acceptcrawl", 2); // red/green: offline, was on
                                } else {
                                    prop.put(STR_TABLE_LIST + conCount + "_acceptcrawl", 0); // red/red; offline was off
                                }
                                if (seed.getFlagAcceptRemoteIndex()) {
                                    prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", 2)// red/green: offline, was on
                                } else {
                                    prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", 0)// red/red; offline was off
                                }
                            }
                            if (seed.getFlagAcceptRemoteIndex()) {
                                prop.put(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", "");
                            } else {
                                final String peertags = MapTools.set2string(seed.getPeerTags(), ",", false);
                                prop.putHTML(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", ((peertags == null) || (peertags.length() == 0)) ? "no tags given" : ("tags = " + peertags));
                            }
                            prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname));
                            prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen);
                            prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(Seed.UTC, "-"));
                            prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", PeerActions.formatInterval(60000 * seed.getLong(Seed.UPTIME, 0)));
                            prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLinkCount());
                            prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getWordCount());
                            prop.putNum(STR_TABLE_LIST + conCount + "_RCount", seed.getLong(Seed.RCOUNT, 0));
                            prop.putNum(STR_TABLE_LIST + conCount + "_sI", seed.getLong(Seed.INDEX_OUT, 0));
                            prop.putNum(STR_TABLE_LIST + conCount + "_sU", seed.getLong(Seed.URL_OUT, 0));
                            prop.putNum(STR_TABLE_LIST + conCount + "_rI", seed.getLong(Seed.INDEX_IN, 0));
                            prop.putNum(STR_TABLE_LIST + conCount + "_rU", seed.getLong(Seed.URL_IN, 0));
                            prop.putNum(STR_TABLE_LIST + conCount + "_ppm", PPM);
                            prop.putNum(STR_TABLE_LIST + conCount + "_qph", Math.round(6000d * QPM) / 100d);
                            conCount++;
                        } // seed != null
                    } // while
View Full Code Here

            if (this.log.isFine()) this.log.logFine("remoteCrawlLoaderJob: a local crawl is running, omitting processing");
            return false;
        }

        // check if we have an entry in the provider list, otherwise fill the list
        Seed seed;
        if (this.remoteCrawlProviderHashes.isEmpty()) {
            if (this.sb.peers != null && this.sb.peers.sizeConnected() > 0) {
                final Iterator<Seed> e = PeerSelection.getProvidesRemoteCrawlURLs(this.sb.peers);
                while (e.hasNext()) {
                    seed = e.next();
View Full Code Here

            int peerCount = 0;
            try {
                final TreeMap<String, String> hostList = new TreeMap<String, String>();
                final Iterator<Seed> e = sb.peers.seedsConnected(true, false, null, (float) 0.0);
                while (e.hasNext()) {
                    final Seed seed = e.next();
                    if (seed != null) hostList.put(seed.get(Seed.NAME, "nameless"),seed.hash);
                }

                String peername;
                while ((peername = hostList.firstKey()) != null) {
                    final String Hash = hostList.get(peername);
View Full Code Here

        networkPicture.arc(width / 2, height / 2, innerradius - 20, innerradius + 20, 100);

        //System.out.println("Seed Maximum distance is       " + yacySeed.maxDHTDistance);
        //System.out.println("Seed Minimum distance is       " + yacySeed.minDHTNumber);

        Seed seed;
        long lastseen;
        // start processes that actually draw the peers
        //final BlockingQueue<drawNetworkPicturePeerJob> drawQueue = new LinkedBlockingDeque<drawNetworkPicturePeerJob>();
        //final drawNetworkPicturePeerJob poison = new drawNetworkPicturePeerJob();
        /*
        final Thread[] drawThreads = new Thread[Runtime.getRuntime().availableProcessors()];
        for (int i = 0; i < drawThreads.length; i++) {
            drawThreads[i] = new Thread() {
                public void run() {
                    try {
                        drawNetworkPicturePeerJob job;
                        while ((job = drawQueue.take()) != poison) job.draw();
                    } catch (final InterruptedException e) {
                    }
                }
            };
            drawThreads[i].start();
        }
         */

        // draw connected senior and principals
        int count = 0;
        int totalCount = 0;
        Iterator<Seed> e = seedDB.seedsConnected(true, false, null, (float) 0.0);
        while (e.hasNext() && count < maxCount) {
            seed = e.next();
            if (seed == null) {
                Log.logWarning("NetworkGraph", "connected seed == null");
                continue;
            }
            if (seed.hash.startsWith("AD")) {//temporary patch
                continue;
            }
            //Log.logInfo("NetworkGraph", "drawing peer " + seed.getName());
            new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_ACTIVE_DOT, COL_ACTIVE_LINE, COL_ACTIVE_TEXT, coronaangle, cyc).draw();
            count++;
        }
        totalCount += count;

        // draw disconnected senior and principals that have been seen lately
        count = 0;
        e = seedDB.seedsSortedDisconnected(false, Seed.LASTSEEN);
        while (e.hasNext() && count < maxCount) {
            seed = e.next();
            if (seed == null) {
                Log.logWarning("NetworkGraph", "disconnected seed == null");
                continue;
            }
            lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
            if (lastseen > passiveLimit) {
                break; // we have enough, this list is sorted so we don't miss anything
            }
            new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_PASSIVE_DOT, COL_PASSIVE_LINE, COL_PASSIVE_TEXT, coronaangle, cyc).draw();
            count++;
        }
        totalCount += count;

        // draw juniors that have been seen lately
        count = 0;
        e = seedDB.seedsSortedPotential(false, Seed.LASTSEEN);
        while (e.hasNext() && count < maxCount) {
            seed = e.next();
            if (seed == null) {
                Log.logWarning("NetworkGraph", "potential seed == null");
                continue;
            }
            lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
            if (lastseen > potentialLimit) {
                break; // we have enough, this list is sorted so we don't miss anything
            }
            new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_POTENTIAL_DOT, COL_POTENTIAL_LINE, COL_POTENTIAL_TEXT, coronaangle, cyc).draw();
            count++;
View Full Code Here

        // write network list
        final String STR_TABLE_LIST = "list_";
        int conCount = 0;

        boolean dark = true;
        Seed seed;
        Iterator<Seed> e = null;
        e = sb.peers.seedsSortedConnected(false, Seed.RCOUNT);
        //e = sb.peers.seedsSortedConnected(false, yacySeed.LCOUNT);
        Pattern peerSearchPattern = null;
        while (e.hasNext() && conCount < 300) {
            seed = e.next();
            assert seed != null;
            if (seed != null) {
                final long lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
                if (lastseen > 720) continue;
                long rcount = seed.getLong(Seed.RCOUNT, 0);
                if (rcount == 0) continue;
                if ((post != null && post.containsKey("search"))  && peerSearchPattern != null /*(wrongregex == null)*/) {
                    boolean abort = true;
                    Matcher m = peerSearchPattern.matcher (seed.getName());
                    if (m.find ()) {
                        abort = false;
                    }
                    m = peerSearchPattern.matcher (seed.hash);
                    if (m.find ()) {
                        abort = false;
                    }
                    if (abort) continue;
                }
                prop.put(STR_TABLE_LIST + conCount + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
                String shortname = seed.get(Seed.NAME, "deadlink");
                if (shortname.length() > 20) shortname = shortname.substring(0, 20) + "...";
                prop.putHTML(STR_TABLE_LIST + conCount + "_shortname", shortname);
                prop.putHTML(STR_TABLE_LIST + conCount + "_fullname", seed.get(Seed.NAME, "deadlink"));
                prop.put(STR_TABLE_LIST + conCount + "_age", seed.getAge());
                prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname));
                prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen);
                prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(Seed.UTC, "-"));
                prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", PeerActions.formatInterval(60000 * seed.getLong(Seed.UPTIME, 0L)));
                prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLinkCount());
                prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getWordCount());
                prop.putNum(STR_TABLE_LIST + conCount + "_RCount", rcount);
                prop.putNum(STR_TABLE_LIST + conCount + "_ppm", seed.getPPM());
                prop.putNum(STR_TABLE_LIST + conCount + "_qph", Math.round(6000d * seed.getQPM()) / 100d);
                conCount++;
            } // seed != null
        } // while
        prop.putNum("list", conCount);
       
View Full Code Here

TOP

Related Classes of net.yacy.peers.Seed

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.