コード例 #1
0
 @Override
 public Object[] toArray() {
   return queue.toArray();
 }
コード例 #2
0
 @Override
 public <T> T[] toArray(T[] a) {
   return queue.toArray(a);
 }
コード例 #3
0
  public void start(String configFileName, Reporter reporter)
      throws PropertiesException, ConectionToExecNodesException, ChannelException,
          WorkerInstantiationException, TaskInstantiationException, StartFailureException {
    this.reporter = reporter;
    reporter.report(1, "MasterServant::start - Lendo configuracoes de " + configFileName);

    /* lê arquivo de configuração */
    if (!getProperties(configFileName)) {
      throw new PropertiesException();
    }
    reporter.report(1, "MasterServant::start - Arquivo de configuracao lido");

    /* cria objeto que inicializa workers e fila de tarefas */
    try {
      initializer = new WorkerInitializer(this);
    } catch (Exception e) {
      throw new WorkerInstantiationException();
    }
    reporter.report(1, "MasterServant::start - WorkerInitializer instanciado");

    /* conecta-se com os execution nodes dos workers*/
    reporter.report(1, "MasterServant::start - Conectando aos outros execution nodes");
    hashNodes = this.initializer.connectToExecNodes();
    if (hashNodes == null) {
      throw new ConectionToExecNodesException();
    }
    reporter.report(1, "MasterServant::start - Conectado ao execution node dos workers");

    /* cria canal de evento entre master e workers*/
    reporter.report(1, "MasterServant::start - Criando canal de evento entre master e workers");
    channel = initializer.buildChannel();
    if (channel == null) {
      throw new ChannelException();
    }

    /*instancia workers*/
    reporter.report(1, "MasterServant::start - Instanciando Workers");
    workerQueue = initializer.buildWorkerQueue();
    if (workerQueue == null) {
      throw new WorkerInstantiationException();
    }

    /*instancia tarefas*/
    reporter.report(1, "MasterServant::start - Instanciando Tarefas");
    ioformat = initializer.createIOFormatServant(ioformatClassName);
    if (ioformat == null) {
      throw new TaskInstantiationException();
    }

    taskQueue = initializer.buildTaskQueue();
    if ((taskQueue == null) || (taskQueue.toArray().length == 0)) {
      throw new TaskInstantiationException();
    }
    num_partitions = taskQueue.toArray().length;

    /* inicia escalonamento das tarefas map-reduce*/
    reporter.report(1, "MasterServant::start - Iniciando escalonamento");
    if (!schedule()) {
      initializer.finish();
      throw new StartFailureException();
    }
    initializer.finish();
  }