Package io.druid.segment.loading

Examples of io.druid.segment.loading.SegmentLoadingException


    final S3Coords s3Coords = new S3Coords(segment);

    log.info("Pulling index at path[%s] to outDir[%s]", s3Coords, outDir);

    if (!isObjectInBucket(s3Coords)) {
      throw new SegmentLoadingException("IndexFile[%s] does not exist.", s3Coords);
    }

    if (!outDir.exists()) {
      outDir.mkdirs();
    }

    if (!outDir.isDirectory()) {
      throw new ISE("outDir[%s] must be a directory.", outDir);
    }

    try {
      S3Utils.retryS3Operation(
          new Callable<Void>()
          {
            @Override
            public Void call() throws Exception
            {
              long startTime = System.currentTimeMillis();
              S3Object s3Obj = null;

              try {
                s3Obj = s3Client.getObject(s3Coords.bucket, s3Coords.path);

                try (InputStream in = s3Obj.getDataInputStream()) {
                  final String key = s3Obj.getKey();
                  if (key.endsWith(".zip")) {
                    CompressionUtils.unzip(in, outDir);
                  } else if (key.endsWith(".gz")) {
                    final File outFile = new File(outDir, toFilename(key, ".gz"));
                    ByteStreams.copy(new GZIPInputStream(in), Files.newOutputStreamSupplier(outFile));
                  } else {
                    ByteStreams.copy(in, Files.newOutputStreamSupplier(new File(outDir, toFilename(key, ""))));
                  }
                  log.info(
                      "Pull of file[%s/%s] completed in %,d millis",
                      s3Obj.getBucketName(),
                      s3Obj.getKey(),
                      System.currentTimeMillis() - startTime
                  );
                  return null;
                }
                catch (IOException e) {
                  throw new IOException(String.format("Problem decompressing object[%s]", s3Obj), e);
                }
              }
              finally {
                S3Utils.closeStreamsQuietly(s3Obj);
              }
            }
          }
      );
    }
    catch (Exception e) {
      try {
        FileUtils.deleteDirectory(outDir);
      }
      catch (IOException ioe) {
        log.warn(
            ioe,
            "Failed to remove output directory for segment[%s] after exception: %s",
            segment.getIdentifier(),
            outDir
        );
      }
      throw new SegmentLoadingException(e, e.getMessage());
    }
  }
View Full Code Here


            }
          }
      );
    }
    catch (S3ServiceException | IOException e) {
      throw new SegmentLoadingException(e, "S3 fail! Key[%s]", coords);
    }
    catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
View Full Code Here

          }
      );
      return objDetails.getLastModifiedDate().getTime();
    }
    catch (S3ServiceException | IOException e) {
      throw new SegmentLoadingException(e, e.getMessage());
    }
    catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
View Full Code Here

        log.info("Removing descriptor file[s3://%s/%s] from s3!", s3Bucket, s3DescriptorPath);
        s3Client.deleteObject(s3Bucket, s3DescriptorPath);
      }
    }
    catch (ServiceException e) {
      throw new SegmentLoadingException(e, "Couldn't kill segment[%s]", segment.getIdentifier());
    }
  }
View Full Code Here

    try {
      if (path.getName().endsWith(".zip")) {
        // delete the parent directory containing the zip file and the descriptor
        fs.delete(path.getParent(), true);
      } else {
        throw new SegmentLoadingException("Unknown file type[%s]", path);
      }
    }
    catch (IOException e) {
      throw new SegmentLoadingException(e, "Unable to kill segment");
    }
  }
View Full Code Here

    FileSystem fs;
    try {
      fs = path.getFileSystem(config);

      if (!fs.exists(path)) {
        throw new SegmentLoadingException("Path[%s] doesn't exist.", path);
      }

      return fs;
    }
    catch (IOException e) {
      throw new SegmentLoadingException(e, "Problems interacting with filesystem[%s].", path);
    }
  }
View Full Code Here

        try (FSDataInputStream in = fs.open(path)) {
          CompressionUtils.unzip(in, dir);
        }
      }
      catch (IOException e) {
        throw new SegmentLoadingException(e, "Some IOException");
      }
    } else {
      throw new SegmentLoadingException("Unknown file type[%s]", path);
    }
  }
View Full Code Here

    try {
      return fs.getFileStatus(path).getModificationTime();
    }
    catch (IOException e) {
      throw new SegmentLoadingException(e, "Problem loading status of path[%s]", path);
    }
  }
View Full Code Here

    FileSystem fs;
    try {
      fs = path.getFileSystem(config);

      if (!fs.exists(path)) {
        throw new SegmentLoadingException("Path[%s] doesn't exist.", path);
      }

      return fs;
    }
    catch (IOException e) {
      throw new SegmentLoadingException(e, "Problems interacting with filesystem[%s].", path);
    }
  }
View Full Code Here

TOP

Related Classes of io.druid.segment.loading.SegmentLoadingException

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.