亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? distributedsearch.java

?? Lucene+nuctch一書的全部源碼 測試源碼 和幾個簡單的項目
?? JAVA
字號:
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package chapter10;import org.apache.nutch.searcher;import java.net.InetSocketAddress;import java.io.*;import java.util.*;import java.lang.reflect.Method;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.nutch.parse.ParseData;import org.apache.nutch.parse.ParseText;import org.apache.nutch.crawl.Inlinks;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.ipc.RPC;import org.apache.hadoop.ipc.VersionedProtocol;import org.apache.hadoop.fs.Path;import org.apache.hadoop.fs.FileSystem;import org.apache.nutch.util.NutchConfiguration;/** Implements the search API over IPC connnections. */public class DistributedSearch {  public static final Log LOG = LogFactory.getLog(DistributedSearch.class);  private DistributedSearch() {}                  // no public ctor  /** The distributed search protocol. */  public static interface Protocol    extends Searcher, HitDetailer, HitSummarizer, HitContent, HitInlinks, VersionedProtocol {    /** The name of the segments searched by this node. */    String[] getSegmentNames();  }  /** The search server. */  public static class Server  {    private Server() {}    /** Runs a search server. */    public static void main(String[] args) throws Exception {      String usage = "DistributedSearch$Server <port> <index dir>";      if (args.length == 0 || args.length > 2) {        System.err.println(usage);        System.exit(-1);      }      int port = Integer.parseInt(args[0]);      Path directory = new Path(args[1]);      Configuration conf = NutchConfiguration.create();      org.apache.hadoop.ipc.Server server = getServer(conf, directory, port);      server.start();      server.join();    }        static org.apache.hadoop.ipc.Server getServer(Configuration conf, Path directory, int port) throws IOException{      NutchBean bean = new NutchBean(conf, directory);      return RPC.getServer(bean, "0.0.0.0", port, 10, true, conf);    }  }  /** The search client. */  public static class Client extends Thread    implements Searcher, HitDetailer, HitSummarizer, HitContent, HitInlinks,               Runnable {    private InetSocketAddress[] defaultAddresses;    private boolean[] liveServer;    private HashMap segmentToAddress = new HashMap();        private boolean running = true;    private Configuration conf;    /** Construct a client talking to servers listed in the named file.     * Each line in the file lists a server hostname and port, separated by     * whitespace.      */    public Client(Path file, Configuration conf) throws IOException {      this(readConfig(file, conf), conf);    }    private static InetSocketAddress[] readConfig(Path path, Configuration conf)      throws IOException {      FileSystem fs = FileSystem.get(conf);      BufferedReader reader =        new BufferedReader(new InputStreamReader(fs.open(path)));      try {        ArrayList addrs = new ArrayList();        String line;        while ((line = reader.readLine()) != null) {          StringTokenizer tokens = new StringTokenizer(line);          if (tokens.hasMoreTokens()) {            String host = tokens.nextToken();            if (tokens.hasMoreTokens()) {              String port = tokens.nextToken();              addrs.add(new InetSocketAddress(host, Integer.parseInt(port)));              if (LOG.isInfoEnabled()) {                LOG.info("Client adding server "  + host + ":" + port);              }            }          }        }        return (InetSocketAddress[])          addrs.toArray(new InetSocketAddress[addrs.size()]);      } finally {        reader.close();      }    }    /** Construct a client talking to the named servers. */    public Client(InetSocketAddress[] addresses, Configuration conf) throws IOException {      this.conf = conf;      this.defaultAddresses = addresses;      this.liveServer = new boolean[addresses.length];      updateSegments();      setDaemon(true);      start();    }        private static final Method GET_SEGMENTS;    private static final Method SEARCH;    private static final Method DETAILS;    private static final Method SUMMARY;    static {      try {        GET_SEGMENTS = Protocol.class.getMethod          ("getSegmentNames", new Class[] {});        SEARCH = Protocol.class.getMethod          ("search", new Class[] { Query.class, Integer.TYPE, String.class,                                   String.class, Boolean.TYPE});        DETAILS = Protocol.class.getMethod          ("getDetails", new Class[] { Hit.class});        SUMMARY = Protocol.class.getMethod          ("getSummary", new Class[] { HitDetails.class, Query.class});      } catch (NoSuchMethodException e) {        throw new RuntimeException(e);      }    }    /** Updates segment names.     *      * @throws IOException     */    public void updateSegments() throws IOException {            int liveServers=0;      int liveSegments=0;            // Create new array of flags so they can all be updated at once.      boolean[] updatedLiveServer = new boolean[defaultAddresses.length];            // build segmentToAddress map      Object[][] params = new Object[defaultAddresses.length][0];      String[][] results =        (String[][])RPC.call(GET_SEGMENTS, params, defaultAddresses, this.conf);      for (int i = 0; i < results.length; i++) {  // process results of call        InetSocketAddress addr = defaultAddresses[i];        String[] segments = results[i];        if (segments == null) {          updatedLiveServer[i] = false;          if (LOG.isWarnEnabled()) {            LOG.warn("Client: no segments from: " + addr);          }          continue;        }        for (int j = 0; j < segments.length; j++) {          if (LOG.isTraceEnabled()) {            LOG.trace("Client: segment "+segments[j]+" at "+addr);          }          segmentToAddress.put(segments[j], addr);        }        updatedLiveServer[i] = true;        liveServers++;        liveSegments+=segments.length;      }      // Now update live server flags.      this.liveServer = updatedLiveServer;      if (LOG.isInfoEnabled()) {        LOG.info("STATS: "+liveServers+" servers, "+liveSegments+" segments.");      }    }    /** Return the names of segments searched. */    public String[] getSegmentNames() {      return (String[])        segmentToAddress.keySet().toArray(new String[segmentToAddress.size()]);    }    public Hits search(final Query query, final int numHits,                       final String dedupField, final String sortField,                       final boolean reverse) throws IOException {      // Get the list of live servers.  It would be nice to build this      // list in updateSegments(), but that would create concurrency issues.      // We grab a local reference to the live server flags in case it      // is updated while we are building our list of liveAddresses.      boolean[] savedLiveServer = this.liveServer;      int numLive = 0;      for (int i = 0; i < savedLiveServer.length; i++) {        if (savedLiveServer[i])          numLive++;      }      InetSocketAddress[] liveAddresses = new InetSocketAddress[numLive];      int[] liveIndexNos = new int[numLive];      int k = 0;      for (int i = 0; i < savedLiveServer.length; i++) {        if (savedLiveServer[i]) {          liveAddresses[k] = defaultAddresses[i];          liveIndexNos[k] = i;          k++;        }      }      Object[][] params = new Object[liveAddresses.length][5];      for (int i = 0; i < params.length; i++) {        params[i][0] = query;        params[i][1] = new Integer(numHits);        params[i][2] = dedupField;        params[i][3] = sortField;        params[i][4] = Boolean.valueOf(reverse);      }      Hits[] results = (Hits[])RPC.call(SEARCH, params, liveAddresses, this.conf);      TreeSet queue;                              // cull top hits from results      if (sortField == null || reverse) {        queue = new TreeSet(new Comparator() {            public int compare(Object o1, Object o2) {              return ((Comparable)o2).compareTo(o1); // reverse natural order            }          });      } else {        queue = new TreeSet();      }            long totalHits = 0;      Comparable maxValue = null;      for (int i = 0; i < results.length; i++) {        Hits hits = results[i];        if (hits == null) continue;        totalHits += hits.getTotal();        for (int j = 0; j < hits.getLength(); j++) {          Hit h = hits.getHit(j);          if (maxValue == null ||              ((reverse || sortField == null)               ? h.getSortValue().compareTo(maxValue) >= 0               : h.getSortValue().compareTo(maxValue) <= 0)) {            queue.add(new Hit(liveIndexNos[i], h.getIndexDocNo(),                              h.getSortValue(), h.getDedupValue()));            if (queue.size() > numHits) {         // if hit queue overfull              queue.remove(queue.last());         // remove lowest in hit queue              maxValue = ((Hit)queue.last()).getSortValue(); // reset maxValue            }          }        }      }      return new Hits(totalHits, (Hit[])queue.toArray(new Hit[queue.size()]));    }        // version for hadoop-0.5.0.jar    public static final long versionID = 1L;        private Protocol getRemote(Hit hit) throws IOException {      return (Protocol)        RPC.getProxy(Protocol.class, versionID, defaultAddresses[hit.getIndexNo()], conf);    }    private Protocol getRemote(HitDetails hit) throws IOException {      InetSocketAddress address =        (InetSocketAddress)segmentToAddress.get(hit.getValue("segment"));      return (Protocol)RPC.getProxy(Protocol.class, versionID, address, conf);    }    public String getExplanation(Query query, Hit hit) throws IOException {      return getRemote(hit).getExplanation(query, hit);    }        public HitDetails getDetails(Hit hit) throws IOException {      return getRemote(hit).getDetails(hit);    }        public HitDetails[] getDetails(Hit[] hits) throws IOException {      InetSocketAddress[] addrs = new InetSocketAddress[hits.length];      Object[][] params = new Object[hits.length][1];      for (int i = 0; i < hits.length; i++) {        addrs[i] = defaultAddresses[hits[i].getIndexNo()];        params[i][0] = hits[i];      }      return (HitDetails[])RPC.call(DETAILS, params, addrs, conf);    }    public Summary getSummary(HitDetails hit, Query query) throws IOException {      return getRemote(hit).getSummary(hit, query);    }    public Summary[] getSummary(HitDetails[] hits, Query query)      throws IOException {      InetSocketAddress[] addrs = new InetSocketAddress[hits.length];      Object[][] params = new Object[hits.length][2];      for (int i = 0; i < hits.length; i++) {        HitDetails hit = hits[i];        addrs[i] =          (InetSocketAddress)segmentToAddress.get(hit.getValue("segment"));        params[i][0] = hit;        params[i][1] = query;      }      return (Summary[])RPC.call(SUMMARY, params, addrs, conf);    }        public byte[] getContent(HitDetails hit) throws IOException {      return getRemote(hit).getContent(hit);    }        public ParseData getParseData(HitDetails hit) throws IOException {      return getRemote(hit).getParseData(hit);    }          public ParseText getParseText(HitDetails hit) throws IOException {      return getRemote(hit).getParseText(hit);    }          public String[] getAnchors(HitDetails hit) throws IOException {      return getRemote(hit).getAnchors(hit);    }    public Inlinks getInlinks(HitDetails hit) throws IOException {      return getRemote(hit).getInlinks(hit);    }    public long getFetchDate(HitDetails hit) throws IOException {      return getRemote(hit).getFetchDate(hit);    }          public static void main(String[] args) throws Exception {      String usage = "DistributedSearch$Client query <host> <port> ...";      if (args.length == 0) {        System.err.println(usage);        System.exit(-1);      }      Query query = Query.parse(args[0], NutchConfiguration.create());            InetSocketAddress[] addresses = new InetSocketAddress[(args.length-1)/2];      for (int i = 0; i < (args.length-1)/2; i++) {        addresses[i] =          new InetSocketAddress(args[i*2+1], Integer.parseInt(args[i*2+2]));      }      Client client = new Client(addresses, NutchConfiguration.create());      //client.setTimeout(Integer.MAX_VALUE);      Hits hits = client.search(query, 10, null, null, false);      System.out.println("Total hits: " + hits.getTotal());      for (int i = 0; i < hits.getLength(); i++) {        System.out.println(" "+i+" "+ client.getDetails(hits.getHit(i)));      }    }    public void run() {      while (running){        try{          Thread.sleep(10000);        } catch (InterruptedException ie){          if (LOG.isInfoEnabled()) {            LOG.info("Thread sleep interrupted.");          }        }        try{          if (LOG.isInfoEnabled()) {            LOG.info("Querying segments from search servers...");          }          updateSegments();        } catch (IOException ioe) {          if (LOG.isWarnEnabled()) { LOG.warn("No search servers available!"); }          liveServer = new boolean[defaultAddresses.length];        }      }    }        /**     * Stops the watchdog thread.     */    public void close() {      running = false;      interrupt();    }  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久久久99999| 久久激情综合网| 欧美一区二区精美| 日韩久久久精品| 中文字幕一区二区三中文字幕| 亚洲欧美日韩久久| 中文字幕日本不卡| 美女网站色91| 欧美成人三级电影在线| 国产一区二区三区免费观看| 国产亚洲欧美激情| 91在线视频观看| 亚洲午夜久久久| 日韩欧美国产三级电影视频| 国产精品69毛片高清亚洲| 国产精品久久久久久久久搜平片| 色综合久久久久综合体桃花网| 亚洲成a人在线观看| 精品国产乱码久久久久久1区2区| 国产成人福利片| 亚洲高清视频中文字幕| 精品国产乱子伦一区| 99精品国产热久久91蜜凸| 一区二区三区高清| 精品裸体舞一区二区三区| av高清不卡在线| 日本人妖一区二区| 国产精品久久久99| 欧美丰满美乳xxx高潮www| 国产一区二区日韩精品| 亚洲激情综合网| 精品国产91九色蝌蚪| 色综合婷婷久久| 日本不卡一二三| 中文字幕在线播放不卡一区| 51精品久久久久久久蜜臀| 成人在线视频首页| 免费xxxx性欧美18vr| 亚洲免费电影在线| 精品成人一区二区三区| 欧美视频三区在线播放| 丰满岳乱妇一区二区三区| 日韩影院在线观看| 亚洲免费毛片网站| 国产视频在线观看一区二区三区| 亚洲国产欧美在线| 欧美亚洲尤物久久| 狠狠色伊人亚洲综合成人| 日韩欧美高清一区| 麻豆精品视频在线观看视频| 欧美一区二区三区啪啪| 黄一区二区三区| 久久九九久精品国产免费直播| 国产一区二区三区国产| 国产精品三级在线观看| 欧美一级午夜免费电影| 亚洲一区二区三区四区在线观看 | 欧美日本在线播放| 91亚洲精品一区二区乱码| 韩国女主播成人在线| 日本欧美在线观看| 亚洲超碰精品一区二区| 一区二区三区中文字幕电影| 国产精品美女久久久久久2018 | 国产精品久久毛片| 精品88久久久久88久久久| 欧美日韩午夜在线视频| 91性感美女视频| 成人avav在线| 粉嫩蜜臀av国产精品网站| 国产在线看一区| 久久99国产精品久久99| 美女高潮久久久| 久久精品国产亚洲5555| 爽爽淫人综合网网站| 午夜精品123| 一级做a爱片久久| 亚洲欧美日韩一区二区| 最新中文字幕一区二区三区| 国产精品国产三级国产| 欧美激情综合在线| 久久久久久久久久看片| 精品国产百合女同互慰| 日韩欧美国产精品| 在线91免费看| 日韩欧美亚洲另类制服综合在线| 日韩一区二区高清| 久久午夜老司机| 中文字幕的久久| 亚洲精品va在线观看| 午夜精品国产更新| 麻豆一区二区三区| 粉嫩久久99精品久久久久久夜| 国产v综合v亚洲欧| 91亚洲精品久久久蜜桃网站 | 欧美精品欧美精品系列| 亚洲素人一区二区| 欧美日本韩国一区| 制服丝袜中文字幕一区| 日韩欧美久久久| 久久精品水蜜桃av综合天堂| 欧美国产日韩精品免费观看| 亚洲黄色免费电影| 天天操天天综合网| 国产一区二区精品久久91| 国产1区2区3区精品美女| 91污在线观看| 欧美一级午夜免费电影| 国产欧美精品一区二区色综合朱莉| 国产精品美女视频| 亚洲r级在线视频| 国产成人免费在线视频| 91麻豆文化传媒在线观看| 欧美一区二区三区日韩| 日本一区二区免费在线| 午夜欧美大尺度福利影院在线看| 国产原创一区二区| 在线观看国产精品网站| 精品国产一区二区三区忘忧草| 中文字幕精品—区二区四季| 天堂蜜桃一区二区三区| 成人精品一区二区三区四区 | 国产人久久人人人人爽| 一个色综合av| 国产精品一级二级三级| 欧美日韩国产免费| 国产精品久久久久久久久图文区| 日本亚洲免费观看| 色乱码一区二区三区88| 久久精品网站免费观看| 日产精品久久久久久久性色 | 欧美性欧美巨大黑白大战| 久久久久久久免费视频了| 丝袜亚洲另类欧美| 色综合视频在线观看| 国产视频一区在线观看| 欧美a级理论片| 日本韩国一区二区三区视频| 欧美经典一区二区| 久久电影网站中文字幕| 在线亚洲一区二区| 亚洲国产精品ⅴa在线观看| 日本欧美肥老太交大片| 91女厕偷拍女厕偷拍高清| 久久久噜噜噜久久中文字幕色伊伊 | 9l国产精品久久久久麻豆| 日韩亚洲国产中文字幕欧美| 夜夜精品视频一区二区 | 色偷偷成人一区二区三区91| 久久久久久久综合| 精品影视av免费| 欧美一区二区精品在线| 亚洲成人黄色小说| 色成人在线视频| 中文字幕中文字幕一区| 国产精品资源在线看| 日韩欧美国产系列| 免费成人你懂的| 国产伦精品一区二区三区在线观看| 欧美激情一区二区三区全黄| 老色鬼精品视频在线观看播放| 色综合久久天天| 亚洲婷婷综合久久一本伊一区| 韩国三级电影一区二区| 欧美电影免费提供在线观看| 日韩国产高清在线| 欧美高清视频在线高清观看mv色露露十八| 亚洲男人电影天堂| 色噜噜狠狠色综合中国| 亚洲综合网站在线观看| 色狠狠一区二区| 一区二区三区在线观看视频| 色婷婷国产精品久久包臀 | 精品国产sm最大网站| 久草在线在线精品观看| 欧美电视剧在线看免费| 久久91精品国产91久久小草| 欧美电视剧免费观看| 国产原创一区二区| 国产亚洲欧洲997久久综合| 成人丝袜视频网| 亚洲人亚洲人成电影网站色| 在线视频一区二区三| 视频一区欧美日韩| 337p日本欧洲亚洲大胆色噜噜| 日韩三级免费观看| 欧美午夜电影在线播放| 亚洲国产精品精华液网站| 欧美亚洲一区二区在线观看| 亚洲国产成人高清精品| 日韩一区二区三区四区| 国产91色综合久久免费分享| 综合自拍亚洲综合图不卡区| 欧美三级电影网站| 久久成人免费电影| 国产精品夫妻自拍| 欧美日韩国产一二三| 国产精品一区二区在线观看不卡 | 国产拍欧美日韩视频二区| 成人h精品动漫一区二区三区|