Exemple #1
0
  public void initialize(Configuration conf, int nodeMonitorInternalPort)
      throws UnknownHostException {
    String mode = conf.getString(SparrowConf.DEPLYOMENT_MODE, "unspecified");
    if (mode.equals("standalone")) {
      state = new StandaloneNodeMonitorState();
    } else if (mode.equals("configbased")) {
      state = new ConfigNodeMonitorState();
    } else if (mode.equals("production")) {
      state = new StateStoreNodeMonitorState();
    } else {
      throw new RuntimeException("Unsupported deployment mode: " + mode);
    }
    try {
      state.initialize(conf);
    } catch (IOException e) {
      LOG.fatal("Error initializing node monitor state.", e);
    }
    capacity = new TResourceVector();
    int mem = Resources.getSystemMemoryMb(conf);
    capacity.setMemory(mem);
    LOG.info("Using memory allocation: " + mem);

    ipAddress = Network.getIPAddress(conf);

    int cores = Resources.getSystemCPUCount(conf);
    capacity.setCores(cores);
    LOG.info("Using core allocation: " + cores);

    String task_scheduler_type = conf.getString(SparrowConf.NM_TASK_SCHEDULER_TYPE, "fifo");
    if (task_scheduler_type.equals("round_robin")) {
      scheduler = new RoundRobinTaskScheduler(cores);
    } else if (task_scheduler_type.equals("fifo")) {
      scheduler = new FifoTaskScheduler(cores);
    } else if (task_scheduler_type.equals("priority")) {
      scheduler = new PriorityTaskScheduler(cores);
    } else {
      throw new RuntimeException("Unsupported task scheduler type: " + mode);
    }
    scheduler.initialize(capacity, conf, nodeMonitorInternalPort);
    taskLauncherService = new TaskLauncherService();
    taskLauncherService.initialize(conf, scheduler, nodeMonitorInternalPort);
  }