Exemple #1
0
  public void dropSegment(DataSegment segment, LoadPeonCallback callback) {
    synchronized (lock) {
      if ((currentlyLoading != null)
          && currentlyLoading.getSegmentIdentifier().equals(segment.getIdentifier())) {
        if (callback != null) {
          currentlyLoading.addCallback(callback);
        }
        return;
      }
    }

    SegmentHolder holder = new SegmentHolder(segment, DROP, Arrays.asList(callback));

    synchronized (lock) {
      if (segmentsToDrop.contains(holder)) {
        if (callback != null) {
          currentlyLoading.addCallback(callback);
        }
        return;
      }
    }

    log.info("Asking server peon[%s] to drop segment[%s]", basePath, segment);
    segmentsToDrop.add(holder);
    doNext();
  }
  private void deleteSegmentFromCache(final DataSegment segment) throws IOException {
    File segmentInfoCacheFile = new File(cacheDir, segment.getIdentifier());
    if (segmentInfoCacheFile.exists()) {
      segmentInfoCacheFile.delete();
    }

    Assert.assertTrue(!segmentInfoCacheFile.exists());
  }
  private void writeSegmentToCache(final DataSegment segment) throws IOException {
    if (!cacheDir.exists()) {
      cacheDir.mkdir();
    }

    File segmentInfoCacheFile = new File(cacheDir, segment.getIdentifier());
    try {
      jsonMapper.writeValue(segmentInfoCacheFile, segment);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    Assert.assertTrue(segmentInfoCacheFile.exists());
  }
Exemple #4
0
 public String getSegmentIdentifier() {
   return segment.getIdentifier();
 }