Package eu.stratosphere.nephele.client

Examples of eu.stratosphere.nephele.client.JobClient


    final String exceptionClassName = ExceptionTask.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(exceptionClassName);

      // 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(ExceptionTask.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 + exceptionClassName + ".jar")
        .toURI()));

      // Create job client and launch job
      jobClient = new JobClient(jg, configuration);
     
      // deactivate logging of expected test exceptions
      Logger rtLogger = Logger.getLogger(Task.class);
      Level rtLevel = rtLogger.getEffectiveLevel();
      rtLogger.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(ExceptionTask.ERROR_MESSAGE)) {
          fail("JobExecutionException does not contain the expected error message");
        }

        return;
      }
      finally {
        rtLogger.setLevel(rtLevel);
      }

      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


      // submit job
      final JobGraph jobGraph = getJobGraph(plan);

      final long startingTime = System.currentTimeMillis();
      long cancelTime = -1L;
      final JobClient client = this.executor.getJobClient(jobGraph);
      final JobSubmissionResult submissionResult = client.submitJob();
      if (submissionResult.getReturnCode() != AbstractJobResult.ReturnCode.SUCCESS) {
        throw new IllegalStateException(submissionResult.getDescription());
      }

      final int interval = client.getRecommendedPollingInterval();
      final long sleep = interval * 1000L;

      Thread.sleep(sleep / 2);

      long lastProcessedEventSequenceNumber = -1L;

      while (true) {

        if (Thread.interrupted()) {
          throw new IllegalStateException("Job client has been interrupted");
        }

        final long now = System.currentTimeMillis();

        if (cancelTime < 0L) {

          // Cancel job
          if (startingTime + msecsTillCanceling < now) {

            LOG.info("Issuing cancel request");

            final JobCancelResult jcr = client.cancelJob();

            if (jcr == null) {
              throw new IllegalStateException("Return value of cancelJob is null!");
            }

            if (jcr.getReturnCode() != AbstractJobResult.ReturnCode.SUCCESS) {
              throw new IllegalStateException(jcr.getDescription());
            }

            // Save when the cancel request has been issued
            cancelTime = now;
          }
        } else {

          // Job has already been canceled
          if (cancelTime + maxTimeTillCanceled < now) {
            throw new IllegalStateException("Cancelling of job took " + (now - cancelTime)
              + " milliseconds, only " + maxTimeTillCanceled + " milliseconds are allowed");
          }
        }

        final JobProgressResult jobProgressResult = client.getJobProgress();

        if (jobProgressResult == null) {
          throw new IllegalStateException("Returned job progress is unexpectedly null!");
        }

View Full Code Here

     */
    @Override
    public void run() {
      try {
        // submit failing job
        JobClient client = this.executor.getJobClient(this.failingJob);
        client.setConsoleStreamForReporting(AbstractTestBase.getNullPrintStream());
        client.submitJobAndWait();
       
        this.error = new Exception("The job did not fail.");
      } catch(JobExecutionException jee) {
        // as expected
      } catch (Exception e) {
        this.error = e;
      }
     
     
      try {
        // submit working job
        JobClient client = this.executor.getJobClient(this.job);
        client.setConsoleStreamForReporting(AbstractTestBase.getNullPrintStream());
        client.submitJobAndWait();
      } catch (Exception e) {
        this.error = e;
      }
     
      // interrupt timeout thread
View Full Code Here

    JobGraph job = getJobGraph(compiledPlan, libraries);
    return run(job, wait);
  }

  public JobExecutionResult run(JobGraph jobGraph, boolean wait) throws ProgramInvocationException {
    JobClient client;
    try {
      client = new JobClient(jobGraph, configuration);
    }
    catch (IOException e) {
      throw new ProgramInvocationException("Could not open job manager: " + e.getMessage());
    }
   
    client.setConsoleStreamForReporting(this.printStatusDuringExecution ? System.out : null);

    try {
      if (wait) {
        return client.submitJobAndWait();
      }
      else {
        JobSubmissionResult result = client.submitJob();
       
        if (result.getReturnCode() != ReturnCode.SUCCESS) {
          throw new ProgramInvocationException("The job was not successfully submitted to the nephele job manager"
            + (result.getDescription() == null ? "." : ": " + result.getDescription()));
        }
View Full Code Here

        OptimizedPlan op = pc.compile(plan);
       
        NepheleJobGraphGenerator jgg = new NepheleJobGraphGenerator();
        JobGraph jobGraph = jgg.compileJobGraph(op);
       
        JobClient jobClient = this.nephele.getJobClient(jobGraph);
        JobExecutionResult result = jobClient.submitJobAndWait();
        return result;
      }
      finally {
        if (shutDownAtEnd) {
          stop();
View Full Code Here

 
  public JobClient getJobClient(JobGraph jobGraph) throws Exception {
    Configuration configuration = jobGraph.getJobConfiguration();
    configuration.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, "localhost");
    configuration.setInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, jobManagerRpcPort);
    return new JobClient(jobGraph, configuration);
  }
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.