Package org.apache.flink.client.program

Examples of org.apache.flink.client.program.PackagedProgram


      testMiniCluster.start();
     
      String jarFile = JAR_FILE;
      String testData = getClass().getResource(TEST_DATA_FILE).toString();
     
      PackagedProgram program = new PackagedProgram(new File(jarFile), new String[] { testData });
           
      Client c = new Client(new InetSocketAddress("localhost", testMiniCluster.getJobManagerRpcPort()), new Configuration(), program.getUserCodeClassLoader());
      c.run(program, 4, true);
    }
    catch (Throwable t) {
      System.err.println(t.getMessage());
      t.printStackTrace();
View Full Code Here


    return c.run(p, -1, true);
  }

  public JobExecutionResult executeJar(String jarPath, String assemblerClass, String[] args) throws Exception {
    File jarFile = new File(jarPath);
    PackagedProgram program = new PackagedProgram(jarFile, assemblerClass, args);
   
    Client c = new Client(this.address, new Configuration(), program.getUserCodeClassLoader());
    return c.run(program.getPlanWithJars(), -1, true);
  }
View Full Code Here

     
      CliFrontend frontend = new CliFrontend();
      Object result = frontend.buildProgram(line);
      assertTrue(result instanceof PackagedProgram);
     
      PackagedProgram prog = (PackagedProgram) result;
     
      Assert.assertArrayEquals(new String[] {"some", "program", "arguments"}, prog.getArguments());
      Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName());
    }
    catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
      fail("Program caused an exception: " + e.getMessage());
View Full Code Here

     
      CliFrontend frontend = new CliFrontend();
      Object result = frontend.buildProgram(line);
      assertTrue(result instanceof PackagedProgram);
     
      PackagedProgram prog = (PackagedProgram) result;
     
      Assert.assertArrayEquals(new String[] {"some", "program", "arguments"}, prog.getArguments());
      Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName());
    }
    catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
      fail("Program caused an exception: " + e.getMessage());
View Full Code Here

     
      CliFrontend frontend = new CliFrontend();
      Object result = frontend.buildProgram(line);
      assertTrue(result instanceof PackagedProgram);
     
      PackagedProgram prog = (PackagedProgram) result;
     
      Assert.assertArrayEquals(new String[] {"some", "program", "arguments"}, prog.getArguments());
      Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName());
    }
    catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
      fail("Program caused an exception: " + e.getMessage());
View Full Code Here

      printHelpForRun();
      return 0;
    }
   
    try {
      PackagedProgram program = buildProgram(line);
      if (program == null) {
        printHelpForRun();
        return 1;
      }
     
      Client client = getClient(line, program.getUserCodeClassLoader());
      if (client == null) {
        printHelpForRun();
        return 1;
      }
   
View Full Code Here

      return 1;
    }

    // -------- build the packaged program -------------
   
    PackagedProgram program;
    try {
      program = buildProgram(line);
    } catch (Throwable t) {
      return handleError(t);
    }
   
    if (program == null) {
      printHelpForInfo();
      return 1;
    }
   
    int parallelism = -1;
    if (line.hasOption(PARALLELISM_OPTION.getOpt())) {
      String parString = line.getOptionValue(PARALLELISM_OPTION.getOpt());
      try {
        parallelism = Integer.parseInt(parString);
      } catch (NumberFormatException e) {
        System.out.println("The value " + parString + " is invalid for the degree of parallelism.");
        printHelpForRun();
        return 1;
      }
     
      if (parallelism <= 0) {
        System.out.println("Invalid value for the degree-of-parallelism. Parallelism must be greater than zero.");
        printHelpForRun();
        return 1;
      }
    }
   
    try {
      // check for description request
      if (description) {
        String descr = program.getDescription();
       
        if (descr != null) {
          System.out.println("-------------------- Program Description ---------------------");
          System.out.println(descr);
          System.out.println("--------------------------------------------------------------");
        } else {
          System.out.println("No description available for this program.");
        }
      }
     
      // check for json plan request
      if (plan) {
        Client client = getClient(line, program.getUserCodeClassLoader());
        String jsonPlan = client.getOptimizedPlanAsJson(program, parallelism);
       
        if (jsonPlan != null) {
          System.out.println("----------------------- Execution Plan -----------------------");
          System.out.println(jsonPlan);
          System.out.println("--------------------------------------------------------------");
        } else {
          System.out.println("JSON plan could not be compiled.");
        }
      }
     
      return 0;
    }
    catch (Throwable t) {
      return handleError(t);
    }
    finally {
      program.deleteExtractedLibraries();
    }
  }
View Full Code Here

     
      CliFrontend frontend = new CliFrontend();
      Object result = frontend.buildProgram(line);
      assertTrue(result instanceof PackagedProgram);
     
      PackagedProgram prog = spy((PackagedProgram) result);

      ClassLoader testClassLoader = new ClassLoader(prog.getUserCodeClassLoader()) {
        @Override
        public Class<?> loadClass(String name) throws ClassNotFoundException {
          if ("org.apache.hadoop.hive.ql.io.RCFileInputFormat".equals(name)) {
            callme[0] = true;
            return String.class; // Intentionally return the wrong class.
          } else {
            return super.loadClass(name);
          }
        }
      };
      when(prog.getUserCodeClassLoader()).thenReturn(testClassLoader);

      Assert.assertArrayEquals(new String[]{"some", "program"}, prog.getArguments());
      Assert.assertEquals(TEST_JAR_CLASSLOADERTEST_CLASS, prog.getMainClassName());

      Configuration c = new Configuration();
      c.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, "devil");
      Client cli = new Client(c, getClass().getClassLoader());
     
View Full Code Here

        line.getOptionValue(CLASS_OPTION.getOpt()) :
        null;
       
    try {
      return entryPointClass == null ?
          new PackagedProgram(jarFile, programArgs) :
          new PackagedProgram(jarFile, entryPointClass, programArgs);
    } catch (ProgramInvocationException e) {
      handleError(e);
      return null;
    }
  }
View Full Code Here

public class PackagedProgramTest {

  @Test
  public void testGetPreviewPlan() {
    try {
      PackagedProgram prog = new PackagedProgram(new File(CliFrontendTestUtils.getTestJarPath()));
      Assert.assertNotNull(prog.getPreviewPlan());
    }
    catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
      Assert.fail("Test is erroneous: " + e.getMessage());
View Full Code Here

TOP

Related Classes of org.apache.flink.client.program.PackagedProgram

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.