use of com.facebook.presto.spi.storage.TempStorageContext in project presto by prestodb.
the class TempStorageManager method loadTempStorage.
protected void loadTempStorage(String name, Map<String, String> properties) {
requireNonNull(name, "name is null");
requireNonNull(properties, "properties is null");
log.info("-- Loading temp storage %s --", name);
String tempStorageFactoryName = null;
ImmutableMap.Builder<String, String> tempStorageProperties = ImmutableMap.builder();
for (Map.Entry<String, String> entry : properties.entrySet()) {
if (entry.getKey().equals(TEMP_STORAGE_FACTORY_NAME)) {
tempStorageFactoryName = entry.getValue();
} else {
tempStorageProperties.put(entry.getKey(), entry.getValue());
}
}
checkState(tempStorageFactoryName != null, "Configuration for tempStorage %s does not contain temp-storage-factory.name", name);
TempStorageFactory factory = tempStorageFactories.get(tempStorageFactoryName);
checkState(factory != null, "Temp Storage Factory %s is not registered", tempStorageFactoryName);
TempStorage tempStorage = factory.create(tempStorageProperties.build(), new TempStorageContext(nodeManager));
if (loadedTempStorages.putIfAbsent(name, tempStorage) != null) {
throw new IllegalArgumentException(format("Temp Storage '%s' is already loaded", name));
}
log.info("-- Loaded temp storage %s --", name);
}
Aggregations