[ 
https://issues.apache.org/jira/browse/TAJO-1616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14593001#comment-14593001
 ] 

ASF GitHub Bot commented on TAJO-1616:
--------------------------------------

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

    https://github.com/apache/tajo/pull/602#discussion_r32801573
  
    --- 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 --
    
    I haven't implemented format handlers (i.e., scanner and appender) in 
TablespaceManager yet. This patch still keeps SCANNER_HANDLER and 
APPENDER_HANDLER in OldStorageManager, which is old one. In the following 
issues, I'll implement format handlers and then I'll remove OldStorageManager.


> Implement TablespaceManager to load Tablespaces
> -----------------------------------------------
>
>                 Key: TAJO-1616
>                 URL: https://issues.apache.org/jira/browse/TAJO-1616
>             Project: Tajo
>          Issue Type: Sub-task
>          Components: storage
>            Reporter: Hyunsik Choi
>            Assignee: Hyunsik Choi
>             Fix For: 0.11.0
>
>
> TablespaceManager should load Tablespace according to storage-default.json 
> and storage-site.json.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to