Package org.apache.twill.filesystem

Examples of org.apache.twill.filesystem.Location


    printOutput(makeInstall.getInputStream());
    if (makeInstall.waitFor() != 0) {
      throw new RuntimeException("Failed to compile SQL Library. Make process exited with exit value " +
                                   makeInstall.exitValue());
    }
    Location target = new LocalLocationFactory().create(System.getProperty("user.dir") + "/tigon-sql/target");
    target.mkdirs();
    target.append("classes").mkdirs();
    ProcessBuilder createTarBuilder = new ProcessBuilder("tar",
                                                         "cvfz", "target/classes/" + Platform.libraryResource(),
                                                         "bin", "lib", "include", "cfg").redirectErrorStream(true);
    createTarBuilder.directory(new File(System.getProperty("user.dir") + "/tigon-sql/"));
    LOG.info("Creating tar ball");
View Full Code Here


    // Setup temporary directory structure
    tmpFolder = Files.createTempDir();
    LocationFactory locationFactory = new LocalLocationFactory(tmpFolder);

    Location baseDir = locationFactory.create("baseDir");
    baseDir.mkdirs();

    InputFlowletConfiguration inputFlowletConfiguration = new LocalInputFlowletConfiguration(baseDir, spec);
    Location binDir = inputFlowletConfiguration.createStreamEngineProcesses();

    healthInspector = new HealthInspector(this);
    metricsRecorder = new MetricsRecorder(metrics);

    //Initiating AbstractInputFlowlet Components
    recordQueue = new GDATRecordQueue();

    //Initiating Netty TCP I/O ports
    inputFlowletService = new InputFlowletService(binDir, spec, healthInspector, metricsRecorder, recordQueue,
                                                  dataIngestionPortsMap, this);
    inputFlowletService.startAndWait();

    //Starting health monitor service
    healthInspector.startAndWait();

    //Initializing methodsDriver
    Map<String, StreamSchema> schemaMap = MetaInformationParser.getSchemaMap(new File(binDir.toURI()));
    methodsDriver = new MethodsDriver(this, schemaMap);

    //Initialize stopwatch and retry counter
    stopwatch = new Stopwatch();
    retryCounter = 0;
View Full Code Here

    this.dir = dir;
    this.spec = spec;
  }

  public Location createStreamProcesses() {
    Location configDir = null;
    try {
      configDir = createStreamLibrary(dir);
      CompileStreamBinaries compileBinaries = new CompileStreamBinaries(configDir);
      StreamConfigGenerator generator = new StreamConfigGenerator(spec);
      Location outputSpec = createFile(configDir, "output_spec.cfg");
      Location packetSchema = createFile(configDir, "packet_schema.txt");
      Location ifresXml = createFile(configDir, "ifres.xml");
      Map.Entry<String, String> ifqContent = generator.generateHostIfq();
      String ifqFile = String.format("%s.ifq", ifqContent.getKey());
      Location hostIfq = createFile(configDir, ifqFile);

      writeToLocation(outputSpec, generator.generateOutputSpec());
      writeToLocation(packetSchema, generator.generatePacketSchema());
      writeToLocation(ifresXml, generator.generateIfresXML());
      writeToLocation(hostIfq, generator.generateHostIfq().getValue());

      Map<String, String> gsqlFiles = generator.generateQueryFiles();
      Collection<String> fileContent = gsqlFiles.values();
      Location file = createFile(configDir, Constants.GSQL_FILE);
      writeToLocation(file, Joiner.on(";\n").join(fileContent));

      compileBinaries.generateBinaries();
    } catch (Throwable t) {
      LOG.error(t.getMessage(), t);
View Full Code Here

      dir.mkdirs();
    }

    //Get the library zip, copy it to temp dir, unzip it
    String libFile = Platform.libraryResource();
    Location libZip = dir.append(libFile);
    libZip.createNew();
    copyResourceFileToDir(libFile, libZip);
    unzipFile(libZip);

    //Create directory structure to place the Stream Engine Config Files
    Location workDir = dir.append("work");
    workDir.mkdirs();
    Location queryDir = workDir.append("query");
    queryDir.mkdirs();
    File qDir = new File(queryDir.toURI().getPath());
    FileUtils.copyFileToDirectory(new File(dir.append("cfg").append("external_fcns.def").toURI().getPath()), qDir);
    FileUtils.copyFileToDirectory(new File(dir.append("cfg").append("internal_fcn.def").toURI().getPath()), qDir);
    return queryDir;
  }
View Full Code Here

    FileUtils.copyFileToDirectory(new File(dir.append("cfg").append("internal_fcn.def").toURI().getPath()), qDir);
    return queryDir;
  }

  private Location createFile(Location dir, String name) throws IOException {
    Location file = dir.append(name);
    file.createNew();
    return file;
  }
View Full Code Here

  public CompileStreamBinaries(Location dir) {
    this.dir = dir;
  }

  public void generateBinaries() throws Exception {
    Location rootTmpDir = Locations.getParent(Locations.getParent(dir));
    Location shell = new LocalLocationFactory(new File("/")).create("/").append("bin").append("sh");

    ExternalProgramExecutor copyGSEXIT = new ExternalProgramExecutor("Copy GSEXIT", dir, shell, "-c",
                                                                     "cp ../../bin/gsexit ./GSEXIT");
    copyGSEXIT.startAndWait();
    LOG.info("Copying GSEXIT: {}", copyGSEXIT);
View Full Code Here

      String flowName = program.getSpecification().getName();
      if (listAllFlows().contains(flowName)) {
        throw new Exception("Flow with the same name is running! Stop or Delete the Flow before starting again");
      }

      Location jarInHDFS = location.append(flowName);
      //Delete any existing JAR with the same flowName.
      jarInHDFS.delete();
      jarInHDFS.createNew();

      //Copy the JAR to HDFS.
      ByteStreams.copy(Locations.newInputSupplier(program.getJarLocation()), Locations.newOutputSupplier(jarInHDFS));
      //Start the Flow.
      deployClient.startFlow(program, userArgs);
View Full Code Here

    stopFlow(flowName);
    try {
      //Delete the Queues
      queueAdmin.clearAllForFlow(flowName, flowName);
      //Delete the JAR in HDFS
      Location jarinHDFS = location.append(flowName);
      jarinHDFS.delete();
    } catch (Exception e) {
      LOG.warn(e.getMessage(), e);
    }
  }
View Full Code Here

  protected static FlowManager deployFlow(Class<? extends Flow> flowClz, Map<String, String> runtimeArgs,
                                   File...bundleEmbeddedJars) {
    Preconditions.checkNotNull(flowClz, "Flow class cannot be null");
    try {
      Location deployJar = deployClient.jarForTestBase(flowClz, bundleEmbeddedJars);
      ProgramController controller = deployClient.startFlow(new File(deployJar.toURI()), flowClz.getName(),
                                                            tmpFolder.newFolder(), runtimeArgs);
      return new DefaultFlowManager(controller);
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
View Full Code Here

      public InputStream getInput() throws IOException {
        return program.getJarLocation().getInputStream();
      }
    }, tempJar);

    final Location jarLocation = new LocalLocationFactory().create(tempJar.toURI());
    return Programs.createWithUnpack(jarLocation, programDir);
  }
View Full Code Here

TOP

Related Classes of org.apache.twill.filesystem.Location

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.