Code Monkey home page Code Monkey logo

modis's Introduction

Modis

Modis implements access layer and data struct layer for OBKV, compatible with Redis protocol.

Quick Start

Build Modis

bash build_modis.sh

Create table in the OceanBase database:

-- string
create table modis_string_table(
  db bigint not null,
  rkey varbinary(16384) not null, # 16K
  value varbinary(1048576) not null, # 1M
  expire_ts timestamp(6) default null,
  primary key(db, rkey)) 
  TTL(expire_ts + INTERVAL 0 SECOND) 
  partition by key(db, rkey) partitions 3;

-- hash
CREATE TABLE modis_hash_table(
  db bigint not null,
  rkey varbinary(8192) not null, # 8K
  is_data tinyint(1) default 1,
  insert_ts timestamp(6) DEFAULT NULL,
  expire_ts timestamp(6) default null,
  field varbinary(8192) not null, # 8K
  value varbinary(1048576) default null, # 1M
  PRIMARY KEY(db, rkey, is_data, field))
  KV_ATTRIBUTES ='{"Redis": {"isTTL": true, "model": "hash"}}'
  PARTITION BY KEY(db, rkey) PARTITIONS 3;

-- set
CREATE TABLE modis_set_table(
  db bigint not null,
  rkey varbinary(1024) not null, # 1K
  is_data tinyint(1) default 1,
  insert_ts timestamp(6) DEFAULT NULL,
  expire_ts timestamp(6) default null,
  member varbinary(15360) not null, # 15K
  PRIMARY KEY(db, rkey, is_data, member))
  KV_ATTRIBUTES ='{"Redis": {"isTTL": true, "model": "zset"}}'
  PARTITION BY KEY(db, rkey) PARTITIONS 3;

-- list
CREATE TABLE modis_list_table(
  db BIGINT NOT NULL,
  rkey VARBINARY(16384) NOT NULL, # 16K
  is_data tinyint(1) default 1,
  insert_ts TIMESTAMP(6) DEFAULT NULL, 
  expire_ts timestamp(6) default null,
  value VARBINARY(1048576) DEFAULT NULL, # 1M
  `index` BIGINT NOT NULL,             
  PRIMARY KEY(db, rkey, is_data, `index`)
)
KV_ATTRIBUTES ='{"Redis": {"isTTL": true, "model": "list"}}'
PARTITION BY KEY(db, rkey)            
PARTITIONS 3;

-- zset
CREATE TABLE modis_zset_table(
  db bigint not null,
  rkey varbinary(1024) not null, # 1K 
  is_data tinyint(1) default 1,
  insert_ts timestamp(6) DEFAULT NULL,
  expire_ts timestamp(6) default null,
  member varbinary(15360) not null, # 15k
  score double default null,
  index index_score(db, rkey, score) local,
  PRIMARY KEY(db, rkey, is_data, member))
  KV_ATTRIBUTES ='{"Redis": {"isTTL": true, "model": "zset"}}'
  PARTITION BY KEY(db, rkey) PARTITIONS 3;

config.yaml file exmaple:

{
  "server": {
    "listen": ":8085",
    "max-connection": 1000, # limit 10000
    "password": "",
    "databases": 256, # databases idx range [0, databases)
    "channel-size": 10,
    "supervised": "no",
    "TLS": {
      "ssl-cert-file": "",
      "ssl-key-file": ""
    }
  },
  "log": {
    "filepath": "./", # filename is fixed as modis.log
    "single-file-max-size": 256, # MB
    "max-backup-file-size": 10, # 0 is not delete
    "max-age-file-rem": 30, # 30 day
    "compress": false,
    "level": "info" # info/error/warn/debug
  },
  "storage": {
    "backend": "obkv",
    "obkv": {
      "config-server-url": "",
      "full-user-name": "",
      "password": "",
      "sys-user-name": "root",
      "sys-password": "",
      "connection-pool-size": 64
    }
  }
}

NOTE:

  1. config-server-url is generated by ConfigServer, which format is config_url&database={database_name}
  2. full-user-name: the user for accessing obkv, which format is user_name@tenant_name#cluster_name
  3. passWord: the password of user in fullUserName.
  4. sys-user-name: root or proxy, which have privileges to access routing system view
  5. sys-password: the password of sys user in sysUserName.

Documentation

[TODO]

Licencing

Modis is under Apache License, Version 2.0 licence. For details, see the LICENSE file.

Contributing

Contributions are warmly welcomed and greatly appreciated. Here are a few ways you can contribute:

Support

In case you have any problems when using OceanBase Database, welcome reach out for help:

modis's People

Contributors

eemjwu avatar lyxiong0 avatar weixinchan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modis's Issues

[Bug]: The clientNum type should be of an atomic type.

conn, err := s.Listener.Accept()
if err != nil {
log.Error("server", nil, "fail to accept connection", log.Errors(err), log.String("addr", s.Listener.Addr().String()))
return err
}
if s.clientNum+1 > servCfg.MaxConnection {
log.Warn("server", nil, "exceed max connection num", log.Errors(err), log.String("addr", s.Listener.Addr().String()))
conn.Close()
continue
}
s.clientNum += 1

The accept event should increment by 1, and the connection close event should decrement by 1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.