// -------------------------------------------------------------------
  public SearchExecutionMain() throws IOException {
    P2pOrchestrator.setSimulationPortType(SimulatorPort.class);

    // create
    Component bootstrapServer = create(BootstrapServer.class);
    Component p2pOrchestrator = create(P2pOrchestrator.class);
    Component simulator = create(SearchSimulator.class);
    Component web = create(JettyWebServer.class);

    // loading component configurations
    final BootstrapConfiguration bootConfiguration =
        BootstrapConfiguration.load(System.getProperty("bootstrap.configuration"));
    final CyclonConfiguration cyclonConfiguration =
        CyclonConfiguration.load(System.getProperty("cyclon.configuration"));
    final SearchConfiguration searchConfiguration =
        SearchConfiguration.load(System.getProperty("search.configuration"));
    final TManConfiguration tmanConfiguration =
        TManConfiguration.load(System.getProperty("tman.configuration"));

    trigger(new BootstrapServerInit(bootConfiguration), bootstrapServer.getControl());
    trigger(
        new SimulatorInit(
            bootConfiguration, cyclonConfiguration, tmanConfiguration, searchConfiguration),
        simulator.getControl());

    // connect
    connect(
        bootstrapServer.getNegative(Network.class),
        p2pOrchestrator.getPositive(Network.class),
        new MessageDestinationFilter(bootConfiguration.getBootstrapServerAddress()));
    connect(bootstrapServer.getNegative(Timer.class), p2pOrchestrator.getPositive(Timer.class));
    connect(simulator.getNegative(Network.class), p2pOrchestrator.getPositive(Network.class));
    connect(simulator.getNegative(Timer.class), p2pOrchestrator.getPositive(Timer.class));
    connect(
        simulator.getNegative(SimulatorPort.class),
        p2pOrchestrator.getPositive(SimulatorPort.class));
    connect(simulator.getPositive(Web.class), web.getNegative(Web.class));

    InetAddress ip = InetAddress.getLocalHost();
    int webPort = 9999;
    String webServerAddr = "http://" + ip.getHostAddress() + ":" + webPort;
    final JettyWebServerConfiguration webConfiguration =
        new JettyWebServerConfiguration(ip, webPort, 30 * 1000, 2, webServerAddr);
    trigger(new JettyWebServerInit(webConfiguration), web.getControl());
    System.out.println("Webserver Started. Address=" + webServerAddr + "/1/search");

    trigger(new P2pOrchestratorInit(scenario, new KingLatencyMap()), p2pOrchestrator.getControl());
  }
示例#2
0
  public Configuration(long seed) throws IOException {
    this.seed = seed;
    searchConfiguration = new SearchConfiguration(seed);
    cyclonConfiguration =
        new CyclonConfiguration(
            seed, 5, 10, 1000, 500000, (long) (Integer.MAX_VALUE - Integer.MIN_VALUE), 20);

    String c = File.createTempFile("bootstrap.", ".conf").getAbsolutePath();
    bootConfiguration.store(c);
    System.setProperty("bootstrap.configuration", c);

    c = File.createTempFile("cyclon.", ".conf").getAbsolutePath();
    cyclonConfiguration.store(c);
    System.setProperty("cyclon.configuration", c);

    c = File.createTempFile("search.", ".conf").getAbsolutePath();
    searchConfiguration.store(c);
    System.setProperty("search.configuration", c);
  }