Package com.cloudera.recordbreaker.analyzer

Examples of com.cloudera.recordbreaker.analyzer.PageHistory


     * when there is a valid FID and a valid filesystem
     */
    public FilePageDisplay(String name, final String fidStr) {
      super(name);
      FishEye fe = FishEye.getInstance();
      final PageHistory history = PageHistory.get();
      final List<JoinPair> joinPairs = new ArrayList<JoinPair>();
      List<Long> historyFids = history.getRecentFids();
      List<String> historyPaths = history.getRecentPaths();
      for (int i = 0; i < historyFids.size(); i++) {
        joinPairs.add(new JoinPair("" + historyFids.get(i), historyPaths.get(i)));
      }

      if (fe.hasFSAndCrawl()) {
        if (fidStr != null) {
          try {
            this.fid = Long.parseLong(fidStr);
            final FileSummary fs = new FileSummary(fe.getAnalyzer(), fid);
            final long fsFid = fid;
            final String fsPath = fs.getPath().toString();
           
            FSAnalyzer fsa = fe.getAnalyzer();
            FileSummaryData fsd = fsa.getFileSummaryData(fid);
            DataDescriptor dd = fsd.getDataDescriptor();
            List<TypeGuessSummary> tgses = fs.getTypeGuesses();
           
            add(new Label("filetitle", fs.getFname()));
            add(new ExternalLink("filesubtitlelink", urlFor(FilesPage.class, new PageParameters("targetdir=" + fs.getPath().getParent().toString())).toString(), fs.getPath().getParent().toString()));
            // Set up the download file link
            IResourceStream hadoopfsStream = new AbstractResourceStreamWriter() {
                public void write(Response output) {
                  WebResponse weboutput = (WebResponse) output;
                  try {
                    BufferedInputStream in = new BufferedInputStream(new FileSummary(FishEye.getInstance().getAnalyzer(), fid).getRawBytes());
                    try {
                      byte buf[] = new byte[4096];
                      int contentLen = -1;
                      while ((contentLen = in.read(buf)) >= 0) {
                        weboutput.write(buf, 0, contentLen);
                      }
                    } finally {
                      try {
                        in.close();
                      } catch (IOException iex) {
                      }
                    }
                  } catch (IOException iex) {
                    iex.printStackTrace();
                  }
                }
                public Bytes length() {
                  return Bytes.bytes(new FileSummary(FishEye.getInstance().getAnalyzer(), fid).getSize());
                }
              };
            ResourceStreamResource resourceStream = new ResourceStreamResource(hadoopfsStream);
            resourceStream.setContentDisposition(ContentDisposition.ATTACHMENT);
            resourceStream.setFileName(fs.getFname());
            add(new ResourceLink<File>("downloadlink", resourceStream));

            // querySupported container holds queryform
            // queryUnsupported container holds an error message
            final boolean querySupported = dd.isHiveSupported() && fe.isQueryServerAvailable(false);
            final boolean hasJoins = joinPairs.size() > 0;
            add(new WebMarkupContainer("querySupported") {
                {
                  setOutputMarkupPlaceholderTag(true);
                  setVisibilityAllowed(querySupported);
                  add(new QueryForm("queryform", new ValueMap(), fid));
                  history.visitNewPage(fsFid, fsPath);

                  // Add support for join-choices here
                  add(new WebMarkupContainer("hasJoins") {
                      {
                        setOutputMarkupPlaceholderTag(true);
View Full Code Here

TOP

Related Classes of com.cloudera.recordbreaker.analyzer.PageHistory

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.