/** * @param connector SQL metadata connector to the metadata storage * @param metadataStorageTablesConfig Table config * * @return all the active data sources in the metadata storage */ static Collection<String> getAllDataSourceNames(SQLMetadataConnector connector, final MetadataStorageTablesConfig metadataStorageTablesConfig) { return connector.getDBI() .withHandle((HandleCallback<List<String>>) handle -> handle.createQuery(String.format( "SELECT DISTINCT(datasource) FROM %s WHERE used = true", metadataStorageTablesConfig.getSegmentsTable())) .fold(Lists.<String>newArrayList(), (druidDataSources, stringObjectMap, foldController, statementContext) -> { druidDataSources.add(MapUtils.getString(stringObjectMap, "datasource")); return druidDataSources; })); }
private void setProperties( final Map<Interval, Map<String, Map<String, Object>>> retVal, ImmutableDruidDataSource dataSource, DataSegment dataSegment ) { Map<String, Object> properties = retVal.get(dataSegment.getInterval()).get(dataSource.getName()); if (properties == null) { properties = Maps.newHashMap(); properties.put("size", dataSegment.getSize()); properties.put("count", 1); retVal.get(dataSegment.getInterval()).put(dataSource.getName(), properties); } else { properties.put("size", MapUtils.getLong(properties, "size", 0L) + dataSegment.getSize()); properties.put("count", MapUtils.getInt(properties, "count", 0) + 1); } } }
public static long getLong(Map<String, Object> in, String key) { return getLong(in, key, null); }
public static int getInt(Map<String, Object> in, String key) { return getInt(in, key, null); }
public static double getDouble(Map<String, Object> in, String key) { return getDouble(in, key, null); }
public static List<Object> getList(Map<String, Object> in, String key) { return getList(in, key, null); }
public static Map<String, Object> getMap(Map<String, Object> in, String key) { return getMap(in, key, null); }
long segmentSize = MapUtils.getLong(tierStats, "size", 0L); tierStats.put("size", segmentSize + dataSourceSegmentSize);
@Override public String apply(Map<String, Object> map) { return MapUtils.getString(map, key); } };
public static String getString(Map<String, Object> in, String key) { return getString(in, key, null); }
properties.put("size", MapUtils.getLong(properties, "size", 0L) + dataSegment.getSize()); properties.put("count", MapUtils.getInt(properties, "count", 0) + 1); for (DataSegment dataSegment : dataSource.getSegments()) { if (theInterval.contains(dataSegment.getInterval())) { retVal.put("size", MapUtils.getLong(retVal, "size", 0L) + dataSegment.getSize()); retVal.put("count", MapUtils.getInt(retVal, "count", 0) + 1);
private File getPath(DataSegment segment) throws SegmentLoadingException { return new File(MapUtils.getString(segment.getLoadSpec(), PATH_KEY)); } }
public static <RetVal> RetVal lookupStringValInMap(Map<String, Object> map, String key, Map<String, RetVal> lookupMap) { String lookupKey = getString(map, key); RetVal retVal = lookupMap.get(lookupKey); if (retVal == null) { throw new IAE("Unknown %s[%s], known values are%s", key, lookupKey, lookupMap.keySet()); } return retVal; }
private DataSegmentMover getMover(DataSegment segment) throws SegmentLoadingException { String type = MapUtils.getString(segment.getLoadSpec(), "type"); DataSegmentMover mover = movers.get(type); if (mover == null) { throw new SegmentLoadingException("Unknown loader type[%s]. Known types are %s", type, movers.keySet()); } return mover; } }
private DataSegmentArchiver getArchiver(DataSegment segment) throws SegmentLoadingException { String type = MapUtils.getString(segment.getLoadSpec(), "type"); DataSegmentArchiver archiver = archivers.get(type); if (archiver == null) { throw new SegmentLoadingException("Unknown loader type[%s]. Known types are %s", type, archivers.keySet()); } return archiver; } }
private File getFile(DataSegment segment) throws SegmentLoadingException { final Map<String, Object> loadSpec = segment.getLoadSpec(); final File path = new File(MapUtils.getString(loadSpec, "path")); if (!path.exists()) { throw new SegmentLoadingException("Asked to load path[%s], but it doesn't exist.", path); } return path; } }