Search in sources :

Example 1 with TempStorageContext

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);
}
Also used : TempStorage(com.facebook.presto.spi.storage.TempStorage) LocalTempStorage(com.facebook.presto.spiller.LocalTempStorage) TempStorageFactory(com.facebook.presto.spi.storage.TempStorageFactory) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TempStorageContext(com.facebook.presto.spi.storage.TempStorageContext) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

TempStorage (com.facebook.presto.spi.storage.TempStorage)1 TempStorageContext (com.facebook.presto.spi.storage.TempStorageContext)1 TempStorageFactory (com.facebook.presto.spi.storage.TempStorageFactory)1 LocalTempStorage (com.facebook.presto.spiller.LocalTempStorage)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1