/** Constructs a new test instance manager */
  public TestInstanceManager() {

    final HardwareDescription hd = HardwareDescriptionFactory.construct(1, 1L, 1L);

    this.allocatedResources = new ArrayList<AllocatedResource>();
    try {
      final InstanceConnectionInfo ici =
          new InstanceConnectionInfo(Inet4Address.getLocalHost(), 1, 1);
      final NetworkTopology nt = new NetworkTopology();
      this.testInstance = new TestInstance(ici, nt.getRootNode(), nt, hd, 1);
      this.allocatedResources.add(new AllocatedResource(testInstance, new AllocationID()));
    } catch (UnknownHostException e) {
      throw new RuntimeException(StringUtils.stringifyException(e));
    }
  }
示例#2
0
  /**
   * Attempts to load the current network topology from the slave file. If locating or reading the
   * slave file fails, the method will return an empty network topology.
   *
   * @return the network topology as read from the slave file
   */
  private NetworkTopology loadNetworkTopology() {

    // Check if slave file exists
    final String configDir = GlobalConfiguration.getString(CONFIG_DIR_KEY, null);
    if (configDir == null) {
      LOG.info(
          "Cannot find configuration directory to load network topology. Using flat topology.");
      return NetworkTopology.createEmptyTopology();
    }

    final File slaveFile = new File(configDir + File.separator + SLAVE_FILE_NAME);
    if (!slaveFile.exists()) {
      LOG.error("Cannot access slave file to load network topology, using flat topology instead");
      return NetworkTopology.createEmptyTopology();
    }

    try {
      return NetworkTopology.fromFile(slaveFile);
    } catch (IOException ioe) {
      LOG.error("Error while loading the network topology: " + StringUtils.stringifyException(ioe));
    }

    return NetworkTopology.createEmptyTopology();
  }