create-eggroll-meta-tables.sql 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. -- create database if not exists, default database is eggroll_meta
  2. -- CREATE DATABASE IF NOT EXISTS `eggroll_meta`;
  3. -- all operation under this database
  4. -- USE `eggroll_meta`;
  5. -- store_locator
  6. CREATE TABLE IF NOT EXISTS `store_locator` (
  7. `store_locator_id` SERIAL PRIMARY KEY,
  8. `store_type` VARCHAR(255) NOT NULL,
  9. `namespace` VARCHAR(2000) NOT NULL DEFAULT 'DEFAULT',
  10. `name` VARCHAR(2000) NOT NULL,
  11. `path` VARCHAR(2000) NOT NULL DEFAULT '',
  12. `total_partitions` INT UNSIGNED NOT NULL,
  13. `partitioner` VARCHAR(2000) NOT NULL DEFAULT 'BYTESTRING_HASH',
  14. `serdes` VARCHAR(2000) NOT NULL DEFAULT '',
  15. `version` INT UNSIGNED NOT NULL DEFAULT 0,
  16. `status` VARCHAR(255) NOT NULL,
  17. `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  18. `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  19. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  20. CREATE UNIQUE INDEX `idx_u_store_loinsert-node.sqlcator_ns_n` ON `store_locator` (`namespace`(120), `name`(640));
  21. CREATE INDEX `idx_store_locator_st` ON `store_locator` (`store_type`(255));
  22. CREATE INDEX `idx_store_locator_ns` ON `store_locator` (`namespace`(767));
  23. CREATE INDEX `idx_store_locator_n` ON `store_locator` (`name`(767));
  24. CREATE INDEX `idx_store_locator_s` ON `store_locator` (`status`(255));
  25. CREATE INDEX `idx_store_locator_v` ON `store_locator` (`version`);
  26. -- store (option)
  27. CREATE TABLE IF NOT EXISTS `store_option` (
  28. `store_option_id` SERIAL PRIMARY KEY,
  29. `store_locator_id` BIGINT UNSIGNED NOT NULL,
  30. `name` VARCHAR(255) NOT NULL,
  31. `data` VARCHAR(2000) NOT NULL DEFAULT '',
  32. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  33. `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  34. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  35. CREATE INDEX `idx_store_option_si` ON `store_option` (`store_locator_id`);
  36. -- store_partition
  37. CREATE TABLE IF NOT EXISTS `store_partition` (
  38. `store_partition_id` SERIAL PRIMARY KEY, -- self-increment sequence
  39. `store_locator_id` BIGINT UNSIGNED NOT NULL,
  40. `node_id` BIGINT UNSIGNED NOT NULL,
  41. `partition_id` INT UNSIGNED NOT NULL, -- partition id of a store
  42. `status` VARCHAR(255) NOT NULL,
  43. `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  44. `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  45. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  46. CREATE UNIQUE INDEX `idx_u_store_partition_si_spi_ni` ON `store_partition` (`store_locator_id`, `store_partition_id`, `node_id`);
  47. CREATE INDEX `idx_store_partition_sli` ON `store_partition` (`store_locator_id`);
  48. CREATE INDEX `idx_store_partition_ni` ON `store_partition` (`node_id`);
  49. CREATE INDEX `idx_store_partition_s` ON `store_partition` (`status`(255));
  50. -- node
  51. CREATE TABLE IF NOT EXISTS `server_node` (
  52. `server_node_id` SERIAL PRIMARY KEY,
  53. `name` VARCHAR(2000) NOT NULL DEFAULT '',
  54. `server_cluster_id` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  55. `host` VARCHAR(1000) NOT NULL,
  56. `port` INT NOT NULL,
  57. `node_type` VARCHAR(255) NOT NULL,
  58. `status` VARCHAR(255) NOT NULL,
  59. `last_heartbeat_at` DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  60. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  61. `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  62. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  63. CREATE INDEX `idx_server_node_h_p_nt` ON `server_node` (`host`(600), `port`, `node_type`(100));
  64. CREATE INDEX `idx_server_node_h` ON `server_node` (`host`(767));
  65. CREATE INDEX `idx_server_node_sci` ON `server_node` (`server_cluster_id`);
  66. CREATE INDEX `idx_server_node_nt` ON `server_node` (`node_type`(255));
  67. CREATE INDEX `idx_server_node_s` ON `server_node` (`status`(255));
  68. -- session (main)
  69. CREATE TABLE IF NOT EXISTS `session_main` (
  70. `session_id` VARCHAR(767) PRIMARY KEY,
  71. `name` VARCHAR(2000) NOT NULL DEFAULT '',
  72. `status` VARCHAR(255) NOT NULL,
  73. `tag` VARCHAR(255),
  74. `total_proc_count` INT,
  75. `active_proc_count` INT,
  76. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  77. `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  78. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  79. CREATE INDEX `idx_session_main_s` ON `session_main` (`status`);
  80. -- session (option)
  81. CREATE TABLE IF NOT EXISTS `session_option` (
  82. `session_option_id` SERIAL PRIMARY KEY,
  83. `session_id` VARCHAR(2000),
  84. `name` VARCHAR(255) NOT NULL,
  85. `data` VARCHAR(2000) NOT NULL DEFAULT '',
  86. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  87. `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  88. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  89. CREATE INDEX `idx_session_option_si` ON `session_option` (`session_id`(767));
  90. -- session (processor)
  91. CREATE TABLE IF NOT EXISTS `session_processor` (
  92. `processor_id` SERIAL PRIMARY KEY,
  93. `session_id` VARCHAR(767),
  94. `server_node_id` INT NOT NULL,
  95. `processor_type` VARCHAR(255) NOT NULL,
  96. `status` VARCHAR(255),
  97. `tag` VARCHAR(255),
  98. `command_endpoint` VARCHAR(255),
  99. `transfer_endpoint` VARCHAR(255),
  100. `pid` INT NOT NULL DEFAULT -1,
  101. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  102. `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  103. ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  104. CREATE INDEX `idx_session_processor_si` ON `session_processor` (`session_id`(767));