Ejemplo n.º 1
0
  /**
   * Servlet initialisation: creates the connection to the erlang node and imports site information.
   */
  @Override
  public void init2(ServletConfig config) throws ServletException {
    super.init2(config);
    Properties properties = new Properties();
    try {
      InputStream fis =
          config.getServletContext().getResourceAsStream("/WEB-INF/scalaris.properties");
      if (fis != null) {
        properties.load(fis);
        properties.setProperty("PropertyLoader.loadedfile", "/WEB-INF/scalaris.properties");
        fis.close();
      } else {
        properties = null;
      }
    } catch (IOException e) {
      //            e.printStackTrace();
      properties = null;
    }

    ConnectionFactory cFactory;
    if (properties != null) {
      cFactory = new ConnectionFactory(properties);
    } else {
      cFactory = new ConnectionFactory();
      cFactory.setClientName("wiki");
    }
    Random random = new Random();
    String clientName = new BigInteger(128, random).toString(16);
    cFactory.setClientName(cFactory.getClientName() + '_' + clientName);
    cFactory.setClientNameAppendUUID(true);
    //        cFactory.setConnectionPolicy(new RoundRobinConnectionPolicy(cFactory.getNodes()));

    cPool = new ConnectionPool(cFactory, CONNECTION_POOL_SIZE);
    if (Options.getInstance().SCALARIS_NODE_DISCOVERY > 0) {
      nodeDiscovery = new NodeDiscovery(cPool);
      nodeDiscovery.startWithFixedDelay(Options.getInstance().SCALARIS_NODE_DISCOVERY);
    }
  }
Ejemplo n.º 2
0
 private void startImport(String dumpsPath, String req_import, int maxRevisions, Calendar maxTime)
     throws RuntimeException {
   currentImport = req_import;
   importLog = new CircularByteArrayOutputStream(1024 * 1024);
   PrintStream ps = new PrintStream(importLog);
   ps.println("starting import...");
   String fileName = dumpsPath + File.separator + req_import;
   if (fileName.endsWith(".db")) {
     importHandler =
         new WikiDumpPreparedSQLiteToScalaris(
             fileName, Options.getInstance(), 1, 1, cPool.getConnectionFactory());
   } else {
     importHandler =
         new WikiDumpToScalarisHandler(
             de.zib.scalaris.examples.wikipedia.data.xml.Main.blacklist,
             null,
             maxRevisions,
             null,
             maxTime,
             cPool.getConnectionFactory());
   }
   importHandler.setMsgOut(ps);
   this.new ImportThread(importHandler, fileName, ps).start();
 }