Package eu.stratosphere.nephele.client

Examples of eu.stratosphere.nephele.client.JobClient


        OptimizedPlan op = compileProgram(jobName);
       
        NepheleJobGraphGenerator jgg = new NepheleJobGraphGenerator();
        JobGraph jobGraph = jgg.compileJobGraph(op);

        JobClient client = this.executor.getJobClient(jobGraph);
        client.setConsoleStreamForReporting(AbstractTestBase.getNullPrintStream());
        JobExecutionResult result = client.submitJobAndWait();
       
        this.latestResult = result;
        return result;
      }
      catch (Exception e) {
View Full Code Here


    }
   
    Assert.assertNotNull("Obtained null JobGraph", jobGraph);
   
    try {
      JobClient client = this.executor.getJobClient(jobGraph);
      client.setConsoleStreamForReporting(getNullPrintStream());
      this.jobExecutionResult = client.submitJobAndWait();
    }
    catch(Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
      Assert.fail("Job execution failed!");
View Full Code Here

  private JobGraphUtils() {
  }

  public static void submit(JobGraph graph, Configuration nepheleConfig) throws IOException, JobExecutionException {
    JobClient client = new JobClient(graph, nepheleConfig);
    client.submitJobAndWait();
  }
View Full Code Here

    final String runtimeExceptionClassName = RuntimeExceptionTask.class.getSimpleName();
    File inputFile = null;
    File outputFile = null;
    File jarFile = null;
    JobClient jobClient = null;

    try {

      inputFile = ServerTestUtils.createInputFile(0);
      outputFile = new File(ServerTestUtils.getTempDir() + File.separator + ServerTestUtils.getRandomFilename());
      jarFile = ServerTestUtils.createJarFile(runtimeExceptionClassName);

      // Create job graph
      final JobGraph jg = new JobGraph("Job Graph for Exception Test");

      // input vertex
      final JobFileInputVertex i1 = new JobFileInputVertex("Input 1", jg);
      i1.setFileInputClass(FileLineReader.class);
      i1.setFilePath(new Path(inputFile.toURI()));

      // task vertex 1
      final JobTaskVertex t1 = new JobTaskVertex("Task with Exception", jg);
      t1.setTaskClass(RuntimeExceptionTask.class);

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex("Output 1", jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));

      t1.setVertexToShareInstancesWith(i1);
      o1.setVertexToShareInstancesWith(i1);

      // connect vertices
      i1.connectTo(t1, ChannelType.IN_MEMORY);
      t1.connectTo(o1, ChannelType.IN_MEMORY);

      // add jar
      jg.addJar(new Path(new File(ServerTestUtils.getTempDir() + File.separator + runtimeExceptionClassName
        + ".jar").toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
     
      // deactivate logging of expected test exceptions
      Logger jcLogger = Logger.getLogger(JobClient.class);
      Level jcLevel = jcLogger.getEffectiveLevel();
      jcLogger.setLevel(Level.OFF);
      try {
        jobClient.submitJobAndWait();
      } catch (JobExecutionException e) {

        // Check if the correct error message is encapsulated in the exception
        if (e.getMessage() == null) {
          fail("JobExecutionException does not contain an error message");
        }
        if (!e.getMessage().contains(RuntimeExceptionTask.RUNTIME_EXCEPTION_MESSAGE)) {
          fail("JobExecutionException does not contain the expected error message");
        }

        // Check if the correct error message is encapsulated in the exception
        return;
      }
      finally {
        jcLogger.setLevel(jcLevel);
      }

      fail("Expected exception but did not receive it");

    } catch (JobGraphDefinitionException jgde) {
      fail(jgde.getMessage());
    } catch (IOException ioe) {
      fail(ioe.getMessage());
    } finally {

      // Remove temporary files
      if (inputFile != null) {
        inputFile.delete();
      }
      if (outputFile != null) {
        outputFile.delete();
      }
      if (jarFile != null) {
        jarFile.delete();
      }

      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

   * @param limit
   *        the upper bound for the sequence of numbers to be generated
   */
  private void test(final int limit) {

    JobClient jobClient = null;

    try {

      // Get name of the forward class
      final String forwardClassName = ForwardTask.class.getSimpleName();

      // Create input and jar files
      final File inputFile = ServerTestUtils.createInputFile(limit);
      final File outputFile = new File(ServerTestUtils.getTempDir() + File.separator
        + ServerTestUtils.getRandomFilename());
      final File jarFile = ServerTestUtils.createJarFile(forwardClassName);

      // Create job graph
      final JobGraph jg = new JobGraph("Job Graph 1");

      // input vertex
      final JobFileInputVertex i1 = new JobFileInputVertex("Input 1", jg);
      i1.setFileInputClass(FileLineReader.class);
      i1.setFilePath(new Path(inputFile.toURI()));

      // task vertex 1
      final JobTaskVertex t1 = new JobTaskVertex("Task 1", jg);
      t1.setTaskClass(ForwardTask.class);

      // task vertex 2
      final JobTaskVertex t2 = new JobTaskVertex("Task 2", jg);
      t2.setTaskClass(ForwardTask.class);

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex("Output 1", jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));

      t1.setVertexToShareInstancesWith(i1);
      t2.setVertexToShareInstancesWith(i1);
      o1.setVertexToShareInstancesWith(i1);

      // connect vertices
      try {
        i1.connectTo(t1, ChannelType.NETWORK);
        t1.connectTo(t2, ChannelType.IN_MEMORY);
        t2.connectTo(o1, ChannelType.IN_MEMORY);
      } catch (JobGraphDefinitionException e) {
        e.printStackTrace();
      }

      // add jar
      jg.addJar(new Path(new File(ServerTestUtils.getTempDir() + File.separator + forwardClassName + ".jar")
        .toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
     
      try {
        jobClient.submitJobAndWait();
      } catch (JobExecutionException e) {
        fail(e.getMessage());
      }

      // Finally, compare output file to initial number sequence
      final BufferedReader bufferedReader = new BufferedReader(new FileReader(outputFile));
      for (int i = 0; i < limit; i++) {
        final String number = bufferedReader.readLine();
        try {
          assertEquals(i, Integer.parseInt(number));
        } catch (NumberFormatException e) {
          fail(e.getMessage());
        }
      }

      bufferedReader.close();

      // Remove temporary files
      inputFile.delete();
      outputFile.delete();
      jarFile.delete();

    } catch (IOException ioe) {
      ioe.printStackTrace();
      fail(ioe.getMessage());
    } finally {
      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

  public void testExecutionDoubleConnection() {

    File inputFile = null;
    File outputFile = null;
    File jarFile = new File(ServerTestUtils.getTempDir() + File.separator + "doubleConnection.jar");
    JobClient jobClient = null;

    try {

      inputFile = ServerTestUtils.createInputFile(0);
      outputFile = new File(ServerTestUtils.getTempDir() + File.separator + ServerTestUtils.getRandomFilename());

      // Create required jar file
      JarFileCreator jfc = new JarFileCreator(jarFile);
      jfc.addClass(DoubleSourceTask.class);
      jfc.addClass(DoubleTargetTask.class);
      jfc.createJarFile();

      // Create job graph
      final JobGraph jg = new JobGraph("Job Graph for Double Connection Test");

      // input vertex
      final JobFileInputVertex i1 = new JobFileInputVertex("Input with two Outputs", jg);
      i1.setFileInputClass(DoubleSourceTask.class);
      i1.setFilePath(new Path(inputFile.toURI()));

      // task vertex 1
      final JobTaskVertex t1 = new JobTaskVertex("Task with two Inputs", jg);
      t1.setTaskClass(DoubleTargetTask.class);

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex("Output 1", jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));

      t1.setVertexToShareInstancesWith(i1);
      o1.setVertexToShareInstancesWith(i1);

      // connect vertices
      i1.connectTo(t1, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
      i1.connectTo(t1, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
      t1.connectTo(o1, ChannelType.IN_MEMORY);

      // add jar
      jg.addJar(new Path(jarFile.toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
      jobClient.submitJobAndWait();

    } catch (JobExecutionException e) {
      fail(e.getMessage());
    } catch (JobGraphDefinitionException jgde) {
      fail(jgde.getMessage());
    } catch (IOException ioe) {
      fail(ioe.getMessage());
    } finally {

      // Remove temporary files
      if (inputFile != null) {
        inputFile.delete();
      }
      if (outputFile != null) {
        outputFile.delete();
      }
      if (jarFile != null) {
        jarFile.delete();
      }

      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

  public void testEmptyTaskNames() {

    File inputFile = null;
    File outputFile = null;
    File jarFile = new File(ServerTestUtils.getTempDir() + File.separator + "emptyNames.jar");
    JobClient jobClient = null;

    try {

      inputFile = ServerTestUtils.createInputFile(0);
      outputFile = new File(ServerTestUtils.getTempDir() + File.separator + ServerTestUtils.getRandomFilename());

      // Create required jar file
      JarFileCreator jfc = new JarFileCreator(jarFile);
      jfc.addClass(DoubleSourceTask.class);
      jfc.addClass(DoubleTargetTask.class);
      jfc.createJarFile();

      // Create job graph
      final JobGraph jg = new JobGraph();

      // input vertex
      final JobFileInputVertex i1 = new JobFileInputVertex(jg);
      i1.setFileInputClass(FileLineReader.class);
      i1.setFilePath(new Path(inputFile.toURI()));

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex(jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));

      o1.setVertexToShareInstancesWith(i1);

      // connect vertices
      i1.connectTo(o1, ChannelType.IN_MEMORY);

      // add jar
      jg.addJar(new Path(jarFile.toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
      jobClient.submitJobAndWait();

    } catch (JobExecutionException e) {
      fail(e.getMessage());
    } catch (JobGraphDefinitionException jgde) {
      fail(jgde.getMessage());
    } catch (IOException ioe) {
      fail(ioe.getMessage());
    } finally {

      // Remove temporary files
      if (inputFile != null) {
        inputFile.delete();
      }
      if (outputFile != null) {
        outputFile.delete();
      }
      if (jarFile != null) {
        jarFile.delete();
      }

      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

    File inputFile1 = null;
    File inputFile2 = null;
    File outputFile = null;
    File jarFile = new File(ServerTestUtils.getTempDir() + File.separator + "unionWithEmptyInput.jar");
    JobClient jobClient = null;

    try {

      inputFile1 = ServerTestUtils.createInputFile(limit);
      inputFile2 = ServerTestUtils.createInputFile(limit);
      outputFile = new File(ServerTestUtils.getTempDir() + File.separator + ServerTestUtils.getRandomFilename());

      // Create required jar file
      JarFileCreator jfc = new JarFileCreator(jarFile);
      jfc.addClass(UnionTask.class);
      jfc.createJarFile();

      // Create job graph
      final JobGraph jg = new JobGraph("Union job " + limit);

      // input vertex 1
      final JobFileInputVertex i1 = new JobFileInputVertex("Input 1", jg);
      i1.setFileInputClass(FileLineReader.class);
      i1.setFilePath(new Path(inputFile1.toURI()));

      // input vertex 2
      final JobFileInputVertex i2 = new JobFileInputVertex("Input 2", jg);
      i2.setFileInputClass(FileLineReader.class);
      i2.setFilePath(new Path(inputFile2.toURI()));

      // union task
      final JobTaskVertex u1 = new JobTaskVertex("Union", jg);
      u1.setTaskClass(UnionTask.class);

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex("Output", jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));

      i1.setVertexToShareInstancesWith(o1);
      i2.setVertexToShareInstancesWith(o1);
      u1.setVertexToShareInstancesWith(o1);

      // connect vertices
      i1.connectTo(u1, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
      i2.connectTo(u1, ChannelType.IN_MEMORY);
      u1.connectTo(o1, ChannelType.IN_MEMORY);

      // add jar
      jg.addJar(new Path(jarFile.toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);

      try {
        jobClient.submitJobAndWait();
      } catch (JobExecutionException e) {
        fail(e.getMessage());
      }

      // Finally, check the output
      final Map<Integer, Integer> expectedNumbers = new HashMap<Integer, Integer>();
      final Integer two = Integer.valueOf(2);
      for (int i = 0; i < limit; ++i) {
        expectedNumbers.put(Integer.valueOf(i), two);
      }

      final BufferedReader bufferedReader = new BufferedReader(new FileReader(outputFile));
      String line = bufferedReader.readLine();
      while (line != null) {

        final Integer number = Integer.valueOf(Integer.parseInt(line));
        Integer val = expectedNumbers.get(number);
        if (val == null) {
          fail("Found unexpected number in union output: " + number);
        } else {
          val = Integer.valueOf(val.intValue() - 1);
          if (val.intValue() < 0) {
            fail(val + " occurred more than twice in union output");
          }
          if (val.intValue() == 0) {
            expectedNumbers.remove(number);
          } else {
            expectedNumbers.put(number, val);
          }
        }

        line = bufferedReader.readLine();
      }

      bufferedReader.close();

      if (!expectedNumbers.isEmpty()) {
        final StringBuilder str = new StringBuilder();
        str.append("The following numbers have not been found in the union output:\n");
        final Iterator<Map.Entry<Integer, Integer>> it = expectedNumbers.entrySet().iterator();
        while (it.hasNext()) {
          final Map.Entry<Integer, Integer> entry = it.next();
          str.append(entry.getKey().toString());
          str.append(" (");
          str.append(entry.getValue().toString());
          str.append("x)\n");
        }

        fail(str.toString());
      }

    } catch (JobGraphDefinitionException jgde) {
      fail(jgde.getMessage());
    } catch (IOException ioe) {
      fail(ioe.getMessage());
    } finally {

      // Remove temporary files
      if (inputFile1 != null) {
        inputFile1.delete();
      }
      if (inputFile2 != null) {
        inputFile2.delete();
      }
      if (outputFile != null) {
        outputFile.delete();
      }
      if (jarFile != null) {
        jarFile.delete();
      }

      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

    File inputFile1 = null;
    File inputFile2 = null;
    File outputFile = null;
    File jarFile = new File(ServerTestUtils.getTempDir() + File.separator + "largeDoP.jar");
    JobClient jobClient = null;

    try {

      inputFile1 = ServerTestUtils.createInputFile(0);
      inputFile2 = ServerTestUtils.createInputFile(0);
      outputFile = new File(ServerTestUtils.getTempDir() + File.separator + ServerTestUtils.getRandomFilename());

      // Create required jar file
      JarFileCreator jfc = new JarFileCreator(jarFile);
      jfc.addClass(UnionTask.class);
      jfc.createJarFile();

      // Create job graph
      final JobGraph jg = new JobGraph("Job with large DoP (" + numberOfSubtasks + ")");

      // input vertex 1
      final JobFileInputVertex i1 = new JobFileInputVertex("Input 1", jg);
      i1.setFileInputClass(FileLineReader.class);
      i1.setFilePath(new Path(inputFile1.toURI()));
      i1.setNumberOfSubtasks(numberOfSubtasks);
      i1.setNumberOfSubtasksPerInstance(numberOfSubtasks);

      // input vertex 2
      final JobFileInputVertex i2 = new JobFileInputVertex("Input 2", jg);
      i2.setFileInputClass(FileLineReader.class);
      i2.setFilePath(new Path(inputFile2.toURI()));
      i2.setNumberOfSubtasks(numberOfSubtasks);
      i2.setNumberOfSubtasksPerInstance(numberOfSubtasks);

      // union task
      final JobTaskVertex f1 = new JobTaskVertex("Forward 1", jg);
      f1.setTaskClass(DoubleTargetTask.class);
      f1.setNumberOfSubtasks(numberOfSubtasks);
      f1.setNumberOfSubtasksPerInstance(numberOfSubtasks);

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex("Output", jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));
      o1.setNumberOfSubtasks(numberOfSubtasks);
      o1.setNumberOfSubtasksPerInstance(numberOfSubtasks);

      i1.setVertexToShareInstancesWith(o1);
      i2.setVertexToShareInstancesWith(o1);
      f1.setVertexToShareInstancesWith(o1);

      // connect vertices
      i1.connectTo(f1, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
      i2.connectTo(f1, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
      f1.connectTo(o1, ChannelType.NETWORK, DistributionPattern.BIPARTITE);

      // add jar
      jg.addJar(new Path(jarFile.toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
     
      // disable logging for the taskmanager and the client, as they will have many
      // expected test errors they will log.
     
      Logger tmLogger = Logger.getLogger(TaskManager.class);
      Logger jcLogger = Logger.getLogger(JobClient.class);
      Level tmLevel = tmLogger.getEffectiveLevel();
      Level jcLevel = jcLogger.getEffectiveLevel();
     
      tmLogger.setLevel(Level.OFF);
      jcLogger.setLevel(Level.OFF);
      try {
       
        jobClient.submitJobAndWait();
      } catch (JobExecutionException e) {
        // Job execution should lead to an error due to lack of resources
        return;
      }
      finally {
        tmLogger.setLevel(tmLevel);
        jcLogger.setLevel(jcLevel);
      }

      fail("Undetected lack of resources");

    } catch (JobGraphDefinitionException jgde) {
      fail(jgde.getMessage());
    } catch (IOException ioe) {
      fail(ioe.getMessage());
    } finally {

      // Remove temporary files
      if (inputFile1 != null) {
        inputFile1.delete();
      }
      if (inputFile2 != null) {
        inputFile2.delete();
      }
      if (outputFile != null) {
        if (outputFile.isDirectory()) {
          final String[] files = outputFile.list();
          final String outputDir = outputFile.getAbsolutePath();
          for (final String file : files) {
            new File(outputDir + File.separator + file).delete();
          }
        }
        outputFile.delete();
      }
      if (jarFile != null) {
        jarFile.delete();
      }

      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

    File inputFile1 = null;
    File inputFile2 = null;
    File outputFile = null;
    File jarFile = null;
    JobClient jobClient = null;

    try {
      // Get name of the forward class
      final String forwardClassName = ForwardTask.class.getSimpleName();

      // Create input and jar files
      inputFile1 = ServerTestUtils.createInputFile(INPUT_DIRECTORY, 0);
      inputFile2 = ServerTestUtils.createInputFile(INPUT_DIRECTORY, sizeOfInput);
      outputFile = new File(ServerTestUtils.getTempDir() + File.separator + ServerTestUtils.getRandomFilename());
      jarFile = ServerTestUtils.createJarFile(forwardClassName);

      // Create job graph
      final JobGraph jg = new JobGraph("Job Graph 1");

      // input vertex
      final JobFileInputVertex i1 = new JobFileInputVertex("Input 1", jg);
      i1.setFileInputClass(FileLineReader.class);
      i1.setFilePath(new Path(new File(testDirectory).toURI()));

      // task vertex 1
      final JobTaskVertex t1 = new JobTaskVertex("Task 1", jg);
      t1.setTaskClass(ForwardTask.class);

      // task vertex 2
      final JobTaskVertex t2 = new JobTaskVertex("Task 2", jg);
      t2.setTaskClass(ForwardTask.class);

      // output vertex
      JobFileOutputVertex o1 = new JobFileOutputVertex("Output 1", jg);
      o1.setFileOutputClass(FileLineWriter.class);
      o1.setFilePath(new Path(outputFile.toURI()));

      t1.setVertexToShareInstancesWith(i1);
      t2.setVertexToShareInstancesWith(i1);
      o1.setVertexToShareInstancesWith(i1);

      // connect vertices
      try {
        i1.connectTo(t1, ChannelType.NETWORK);
        t1.connectTo(t2, ChannelType.IN_MEMORY);
        t2.connectTo(o1, ChannelType.IN_MEMORY);
      } catch (JobGraphDefinitionException e) {
        e.printStackTrace();
      }

      // add jar
      jg.addJar(new Path(new File(ServerTestUtils.getTempDir() + File.separator + forwardClassName + ".jar").toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
      jobClient.submitJobAndWait();

      // Finally, compare output file to initial number sequence
      final BufferedReader bufferedReader = new BufferedReader(new FileReader(outputFile));
      for (int i = 0; i < sizeOfInput; i++) {
        final String number = bufferedReader.readLine();
        try {
          assertEquals(i, Integer.parseInt(number));
        } catch (NumberFormatException e) {
          fail(e.getMessage());
        }
      }

      bufferedReader.close();

    } catch (NumberFormatException e) {
      e.printStackTrace();
      fail(e.getMessage());
    } catch (JobExecutionException e) {
      e.printStackTrace();
      fail(e.getMessage());
    } catch (IOException ioe) {
      ioe.printStackTrace();
      fail(ioe.getMessage());
    } finally {
      // Remove temporary files
      if (inputFile1 != null) {
        inputFile1.delete();
      }
      if (inputFile2 != null) {
        inputFile2.delete();
      }
      if (outputFile != null) {
        outputFile.delete();
      }
      if (jarFile != null) {
        jarFile.delete();
      }

      // Remove test directory
      if (td != null) {
        td.delete();
      }

      if (jobClient != null) {
        jobClient.close();
      }
    }
  }
View Full Code Here

TOP

Related Classes of eu.stratosphere.nephele.client.JobClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.