public SegmentLoader manufacturate(File storageDir) { return loader.withConfig( new SegmentLoaderConfig().withLocations(Collections.singletonList(new StorageLocationConfig().setPath(storageDir))) ); } }
new BackgroundSegmentAnnouncer(announcer, exec, config.getAnnounceIntervalMillis())) { loadingExecutor = Execs.multiThreaded(config.getNumBootstrapThreads(), "Segment-Load-Startup-%s");
@Override public void run() { try { synchronized (segmentDeleteLock) { if (segmentsToDelete.remove(segment)) { segmentManager.dropSegment(segment); File segmentInfoCacheFile = new File(config.getInfoDir(), segment.getId().toString()); if (!segmentInfoCacheFile.delete()) { log.warn("Unable to delete segmentInfoCacheFile[%s]", segmentInfoCacheFile); } } } } catch (Exception e) { log.makeAlert(e, "Failed to remove segment! Possible resource leak!") .addData("segment", segment) .emit(); } } };
public SegmentLoaderConfig withLocations(List<StorageLocationConfig> locations) { SegmentLoaderConfig retVal = new SegmentLoaderConfig(); retVal.locations = Lists.newArrayList(locations); retVal.deleteOnRemove = this.deleteOnRemove; retVal.infoDir = this.infoDir; return retVal; }
@Inject public DruidSysMonitor( SegmentLoaderConfig config ) { final List<StorageLocationConfig> locs = config.getLocations(); List<String> dirs = Lists.newArrayListWithExpectedSize(locs.size()); for (StorageLocationConfig loc : locs) { dirs.add(loc.getPath().toString()); } addDirectoriesToMonitor(dirs.toArray(new String[0])); } }
"Completely removing [%s] in [%,d] millis", segment.getId(), config.getDropSegmentDelayMillis() ); exec.schedule( runnable, config.getDropSegmentDelayMillis(), TimeUnit.MILLISECONDS );
new SegmentLoaderConfig(), EasyMock.createNiceMock(DataSegmentAnnouncer.class), EasyMock.createNiceMock(DataSegmentServerAnnouncer.class),
@Inject public SegmentLoaderLocalCacheManager( IndexIO indexIO, SegmentLoaderConfig config, @Json ObjectMapper mapper ) { this.indexIO = indexIO; this.config = config; this.jsonMapper = mapper; this.locations = new ArrayList<>(); for (StorageLocationConfig locationConfig : config.getLocations()) { locations.add(new StorageLocation( locationConfig.getPath(), locationConfig.getMaxSize(), locationConfig.getFreeSpacePercent() )); } }
"Completely removing [%s] in [%,d] millis", segment.getIdentifier(), config.getDropSegmentDelayMillis() ); exec.schedule( runnable, config.getDropSegmentDelayMillis(), TimeUnit.MILLISECONDS );
.toInstance(new SegmentLoaderConfig().withLocations(Collections.emptyList())); binder.bind(CoordinatorClient.class).in(LazySingleton.class);
public SegmentLoaderConfig withLocations(List<StorageLocationConfig> locations) { SegmentLoaderConfig retVal = new SegmentLoaderConfig(); retVal.locations = Lists.newArrayList(locations); retVal.deleteOnRemove = this.deleteOnRemove; retVal.infoDir = this.infoDir; return retVal; }
new BackgroundSegmentAnnouncer(announcer, exec, config.getAnnounceIntervalMillis())) { loadingExecutor = Execs.multiThreaded(config.getNumBootstrapThreads(), "Segment-Load-Startup-%s");
File segmentInfoCacheFile = new File(config.getInfoDir(), segment.getId().toString()); if (!segmentInfoCacheFile.exists()) { try {
@Inject public DruidSysMonitor( SegmentLoaderConfig config ) { final List<StorageLocationConfig> locs = config.getLocations(); List<String> dirs = Lists.newArrayListWithExpectedSize(locs.size()); for (StorageLocationConfig loc : locs) { dirs.add(loc.getPath().toString()); } addDirectoriesToMonitor(dirs.toArray(new String[0])); } }
@Before public void setUp() throws Exception { EmittingLogger.registerEmitter(new NoopServiceEmitter()); localSegmentCacheFolder = tmpFolder.newFolder("segment_cache_folder"); final List<StorageLocationConfig> locations = new ArrayList<>(); final StorageLocationConfig locationConfig = new StorageLocationConfig(); locationConfig.setPath(localSegmentCacheFolder); locationConfig.setMaxSize(10000000000L); locations.add(locationConfig); manager = new SegmentLoaderLocalCacheManager( TestHelper.getTestIndexIO(), new SegmentLoaderConfig().withLocations(locations), jsonMapper ); }
private void loadLocalCache() File baseDir = config.getInfoDir(); if (!baseDir.isDirectory()) { if (baseDir.exists()) {
@Inject public SegmentLoaderLocalCacheManager( IndexIO indexIO, SegmentLoaderConfig config, @Json ObjectMapper mapper ) { this.indexIO = indexIO; this.config = config; this.jsonMapper = mapper; this.locations = Lists.newArrayList(); for (StorageLocationConfig locationConfig : config.getLocations()) { locations.add(new StorageLocation( locationConfig.getPath(), locationConfig.getMaxSize(), locationConfig.getFreeSpacePercent() )); } }
new SegmentLoaderConfig().withLocations(locations), jsonMapper );
File segmentInfoCacheFile = new File(config.getInfoDir(), segment.getIdentifier()); if (!segmentInfoCacheFile.exists()) { try {
new SegmentLoaderConfig().withLocations(locations), jsonMapper );