扩展-实现自定义存储引擎接口

系统默认选择HBase作为存储引擎(存储引擎的读写效率和稳定性将会直接影响XL-LightHouse服务的运行),如果您希望替换存储引擎需要实现自定义实现相应扩展类

1、增加com.dtstep.lighthouse.core.storage.engine.StorageEngine接口的实现类

public interface StorageEngine {

    /**
    *
    * namespace是便于表的管理,请根据自身数据引擎的特性选择是否启用namespace。
    * 如果启用,则自定义创建相应namespace即可;
    * 如果不想启用,则可以置位空;
    */
    String getDefaultNamespace();

    /**
    * 同上,如果不启用Namespace置为空即可。
    */
    void createNamespaceIfNotExist(String namespace) throws Exception;

    /**
    * 创建表结构接口
    */
    void createTable(String tableName) throws Exception;

   /**
    * 判断表结构是否存在接口
    */
    boolean isTableExist(String tableName) throws Exception;

    /**
    * 删除表结构接口
    */
    void dropTable(String tableName) throws Exception;

    /**
    * put数据写入接口
    */
    void put(String tableName, LdpPut ldpPut) throws Exception;

    /**
    * 批量put数据写入接口
    */
    void puts(String tableName, List<LdpPut> ldpPuts) throws Exception;

    /**
    * 数值字段自增接口
    */
    void increment(String tableName, LdpIncrement ldpIncrement) throws Exception;

   /**
    * 批量数值字段自增接口
    */
    void increments(String tableName,List<LdpIncrement> ldpIncrements) throws Exception;

   /**
    * 数值字段compareAndPut接口,需要保证线程安全
    */
    void putsWithCompare(String tableName, CompareOperator compareOperator,List<LdpPut> ldpPuts) throws Exception;

   /**
    * get查询
    */
    <R> LdpResult<R> get(String tableName, LdpGet ldpGet, Class<R> clazz) throws Exception;

    /**
    * 批量get查询
    */
    <R> List<LdpResult<R>> gets(String tableName, List<LdpGet> ldpGets, Class<R> clazz) throws Exception;

    /**
    * scan查询,scan查询用于查询筛选条件时所需显示的维度值,
    */
    <R> List<LdpResult<R>> scan(String tableName, String startRow, String endRow, int limit,Class<R> clazz) throws Exception;

    /**
    * 按key删除数据
    */
    void delete(String tableName,String key) throws Exception;

    /**
    * 获取单表所能存储的最大记录条数,单位:行,目的是为了防止单表数据量过大对存储服务产生影响,请根据所选择的存储引擎特性确定。
    */
    long getMaxRecordSize();

    /**
    * 获取单表所能存储的最大记录条数,单位:Byte ,目的是为了防止单表数据量过大对存储服务产生影响,请根据所选择的存储引擎特性确定。
    */
    long getMaxContentSize();

    /**
    * 获取单表使用最大的时间周期,请根据自身业务设定,系统默认每一个统计结果表最多使用3个月,3个月后则创建新的结果表,防止单表数据量过大
    */
    long getMaxTimeInterval();

    /**
    * 获取指定表的记录行数
    */
    long getRecordSize(String tableName);

    /**
    * 获取指定表的字节数
    */
    long getContentSize(String tableName);

}

2、修改com.dtstep.lighthouse.core.storage.engine.StorageEngineProxy

将StorageEngine storageEngine = new HBaseStorageEngine(); 替换为自定义存储即可。

3、其他说明 LdpPut、LdpIncrement、LdpGet等实体是按照hbase的存储逻辑,key + column => value即key和column组合对应一个value,如果您所选择的存储引擎没有column属性,为key => value则可以自定义key生成逻辑。 然后将column置空即可。

results matching ""

    No results matching ""