Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/602#discussion_r32791060
  
    --- Diff: 
tajo-storage/tajo-storage-common/src/main/java/org/apache/tajo/storage/TableSpaceManager.java
 ---
    @@ -19,236 +19,372 @@
     package org.apache.tajo.storage;
     
     import com.google.common.annotations.VisibleForTesting;
    +import com.google.common.base.Optional;
    +import com.google.common.base.Preconditions;
     import com.google.common.collect.Maps;
    -import org.apache.hadoop.conf.Configuration;
    -import org.apache.hadoop.fs.FileSystem;
    +import net.minidev.json.JSONObject;
    +import net.minidev.json.parser.JSONParser;
    +import net.minidev.json.parser.ParseException;
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
     import org.apache.hadoop.fs.Path;
    -import org.apache.tajo.TaskAttemptId;
    -import org.apache.tajo.catalog.Schema;
    -import org.apache.tajo.catalog.TableMeta;
    +import org.apache.tajo.TajoConstants;
     import org.apache.tajo.conf.TajoConf;
     import org.apache.tajo.storage.fragment.Fragment;
    +import org.apache.tajo.util.FileUtil;
    +import org.apache.tajo.util.Pair;
     
    +import javax.annotation.Nullable;
     import java.io.IOException;
     import java.lang.reflect.Constructor;
    +import java.net.URI;
     import java.util.Map;
    -import java.util.concurrent.ConcurrentHashMap;
    +import java.util.TreeMap;
    +import java.util.UUID;
    +
    +import static org.apache.tajo.storage.StorageConstants.LOCAL_FS_URI;
     
     /**
      * It handles available table spaces and cache TableSpace instances.
    + *
    + * Default tablespace must be a filesystem-based one.
    + * HDFS and S3 can be a default tablespace if a Tajo cluster is in fully 
distributed mode.
    + * Local file system can be a default tablespace if a Tajo cluster runs on 
a single machine.
      */
    -public class TableSpaceManager {
    +public class TableSpaceManager implements StorageService {
    +  private static final Log LOG = 
LogFactory.getLog(TableSpaceManager.class);
     
    -  /**
    -   * Cache of scanner handlers for each storage type.
    -   */
    -  protected static final Map<String, Class<? extends Scanner>> 
SCANNER_HANDLER_CACHE
    -      = new ConcurrentHashMap<String, Class<? extends Scanner>>();
    -  /**
    -   * Cache of appender handlers for each storage type.
    -   */
    -  protected static final Map<String, Class<? extends Appender>> 
APPENDER_HANDLER_CACHE
    -      = new ConcurrentHashMap<String, Class<? extends Appender>>();
    -  private static final Class<?>[] DEFAULT_SCANNER_PARAMS = {
    -      Configuration.class,
    -      Schema.class,
    -      TableMeta.class,
    -      Fragment.class
    -  };
    -  private static final Class<?>[] DEFAULT_APPENDER_PARAMS = {
    -      Configuration.class,
    -      TaskAttemptId.class,
    -      Schema.class,
    -      TableMeta.class,
    -      Path.class
    -  };
    -  /**
    -   * Cache of Tablespace.
    -   * Key is manager key(warehouse path) + store type
    -   */
    -  private static final Map<String, Tablespace> storageManagers = 
Maps.newHashMap();
    -  /**
    -   * Cache of constructors for each class. Pins the classes so they
    -   * can't be garbage collected until ReflectionUtils can be collected.
    -   */
    -  private static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE =
    -      new ConcurrentHashMap<Class<?>, Constructor<?>>();
    +  public static final String DEFAULT_CONFIG_FILE = "storage-default.json";
    +  public static final String SITE_CONFIG_FILE = "storage-site.json";
    +
    +  /** default tablespace name */
    +  public static final String DEFAULT_TABLESPACE_NAME = "default";
    +
    +  private final static TajoConf systemConf = new TajoConf();
    +  private final static JSONParser parser = new 
JSONParser(JSONParser.MODE_JSON_SIMPLE | JSONParser.IGNORE_CONTROL_CHAR);
    +
    +  // The relation ship among name, URI, Tablespaces must be kept 1:1:1.
    +  protected static final Map<String, URI> SPACES_URIS_MAP = 
Maps.newHashMap();
    +  protected static final TreeMap<URI, Tablespace> TABLE_SPACES = 
Maps.newTreeMap();
     
    +  protected static final Map<Class<?>, Constructor<?>> CONSTRUCTORS = 
Maps.newHashMap();
    +  protected static final Map<String, Class<? extends Tablespace>> 
TABLE_SPACE_HANDLERS = Maps.newHashMap();
    +
    +  public static final Class [] TABLESPACE_PARAM = new Class [] 
{String.class, URI.class};
    +
    +  static {
    +    instance = new TableSpaceManager();
    +  }
       /**
    -   * Clear all class cache
    +   * Singleton instance
        */
    -  @VisibleForTesting
    -  protected synchronized static void clearCache() {
    -    CONSTRUCTOR_CACHE.clear();
    -    SCANNER_HANDLER_CACHE.clear();
    -    APPENDER_HANDLER_CACHE.clear();
    -    storageManagers.clear();
    +  private static final TableSpaceManager instance;
    --- End diff --
    
    TablespaceManager looks to be more appropriate.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to