Esempio n. 1
0
  public static void main(String[] args) throws ErrorException {
    // TODO Auto-generated method stub
    Message m =
        new Message("add", null, null, 0, 1, (new BF("111110111101", 4)).getFragment(1).toInt());

    System.out.println(m.toString());
  }
Esempio n. 2
0
  @Override
  public boolean execute() {
    // TODO Auto-generated method stub

    Node n;

    if (ok) {
      System.out.println("Création de l'index");
      Message message = new Message();

      n = Network.get(23);
      message.setType("createIndex");
      message.setIndexName("dcs");
      message.setSource(23);
      message.setDestinataire(23);

      ok = false;
      EDSimulator.add(0, message, n, pid);
    } else if (ok2) {
      System.out.println("Lecture n°1");
      n = Network.get(23);
      try (BufferedReader reader =
          new BufferedReader(new FileReader("/Users/dcs/vrac/test/wikiDocs<60"))) {
        while (true) {
          String s = new String();
          s = reader.readLine();
          if (s == null) break;
          String[] tmp = s.split(";");

          if (tmp.length >= 2 && tmp[1].length() > 2) {
            @SuppressWarnings("static-access")
            BFP2P bf_tmp =
                new BFP2P(config_log.sizeOfBF, config_log.sizeOfBF / config_log.numberOfFragment);
            bf_tmp.addAll(tmp[1]);
            // bf_tmp.add("/" + line);
            Message message = new Message();

            message.setType("add");
            message.setIndexName("dcs");
            message.setPath("/");
            message.setData(bf_tmp);
            message.setDestinataire(23);
            line++;
            ControlerNw.config_log.addTotalFilterCreated(1);
            ;
            EDSimulator.add(0, message, n, pid);
          }

          if (line == 1600000) break;
        }
        reader.close();
        ok2 = false;

        /** *********** */
        ok3 = true;
        //	Config.ObserverNw_OK = true;
        /** *********** */
        System.out.println("Fini de lecture " + line + " lignes");
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else if (ok3) {
      System.out.println("Lecture les dernières lignes");

      n = Network.get(23);
      try (BufferedReader reader =
          new BufferedReader(new FileReader("/Users/dcs/vrac/test/wikiDocs<60"))) {
        for (int i = 0; i < line; i++) reader.readLine();

        while (true) {
          String s = new String();
          s = reader.readLine();
          if (s == null) break;
          String[] tmp = s.split(";");

          if (tmp.length >= 2 && tmp[1].length() > 2) {
            @SuppressWarnings("static-access")
            BFP2P bf_tmp =
                new BFP2P(config_log.sizeOfBF, config_log.sizeOfBF / config_log.numberOfFragment);

            bf_tmp.addAll(tmp[1]);
            Message message = new Message();

            message.setType("add");
            message.setIndexName("dcs");
            message.setPath("/");
            message.setData(bf_tmp);
            message.setDestinataire(23);
            line++;
            ControlerNw.config_log.addTotalFilterCreated(1);
            ;
            EDSimulator.add(0, message, n, pid);
          }
        }
        reader.close();
        ok3 = false;
        System.out.println("Fini de lecture " + line + " lignes");
        Config.ObserverNw_OK = true;
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    return false;
  }