rename openzaly to windchat

This commit is contained in:
an.guoyue 2019-12-31 17:22:19 +08:00
parent d98575d0d2
commit 116a18b97a
9 changed files with 451 additions and 450 deletions

View File

@ -1,12 +1,12 @@
/** /**
* Copyright 2018-2028 Akaxin Group * Copyright 2018-2028 Akaxin Group
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -50,7 +50,7 @@ import com.windchat.im.storage.util.MigrateUtils;
public class DataSourceManager { public class DataSourceManager {
private static final Logger logger = LoggerFactory.getLogger(DataSourceManager.class); private static final Logger logger = LoggerFactory.getLogger(DataSourceManager.class);
private static final String OPENZALY_DATABASE_CONFIG = "openzaly-server.config"; private static final String WINDCHAT_DATABASE_CONFIG = "windchat-server.config";
private DataSourceManager() { private DataSourceManager() {
} }
@ -60,10 +60,10 @@ public class DataSourceManager {
throws InitDatabaseException, UpgradeDatabaseException, NeedInitMysqlException { throws InitDatabaseException, UpgradeDatabaseException, NeedInitMysqlException {
try { try {
DBType dbType = DBType.PERSONAL; DBType dbType = DBType.PERSONAL;
Properties pro = loadDatabaseConfig(OPENZALY_DATABASE_CONFIG); Properties pro = loadDatabaseConfig(WINDCHAT_DATABASE_CONFIG);
if (pro != null && pro.size() > 0) { if (pro != null && pro.size() > 0) {
// get edition from config file // get edition from config file
String edition = MysqlManager.trimToNull(pro, JdbcConst.OPENZALY_EDITION); String edition = MysqlManager.trimToNull(pro, JdbcConst.WINDCHAT_EDITION);
if (StringUtils.isNotEmpty(edition)) { if (StringUtils.isNotEmpty(edition)) {
dbType = DBType.getDBType(edition); dbType = DBType.getDBType(edition);
} }
@ -91,9 +91,9 @@ public class DataSourceManager {
// 初始化生成mysql的配置文件 // 初始化生成mysql的配置文件
public static void initMysqlConfig() throws FileNotFoundException, IOException { public static void initMysqlConfig() throws FileNotFoundException, IOException {
// 生成配置文件 // 生成配置文件
File configFile = new File(OPENZALY_DATABASE_CONFIG); File configFile = new File(WINDCHAT_DATABASE_CONFIG);
if (!configFile.exists()) { if (!configFile.exists()) {
FileUtils.writeResourceToFile("/" + OPENZALY_DATABASE_CONFIG, configFile); FileUtils.writeResourceToFile("/" + WINDCHAT_DATABASE_CONFIG, configFile);
} }
} }
@ -115,7 +115,7 @@ public class DataSourceManager {
// 迁移数据库把sqlite迁移至mysql数据库 // 迁移数据库把sqlite迁移至mysql数据库
public static void migrateDB() throws MigrateDatabaseException, NeedInitMysqlException { public static void migrateDB() throws MigrateDatabaseException, NeedInitMysqlException {
// 加载配置文件中的数据库配置 // 加载配置文件中的数据库配置
Properties prop = loadDatabaseConfig(OPENZALY_DATABASE_CONFIG); Properties prop = loadDatabaseConfig(WINDCHAT_DATABASE_CONFIG);
MigrateUtils.sqlite2Mysql(prop); MigrateUtils.sqlite2Mysql(prop);
} }
@ -127,7 +127,7 @@ public class DataSourceManager {
inputStream = new FileInputStream(configPath); inputStream = new FileInputStream(configPath);
properties.load(inputStream); properties.load(inputStream);
} catch (Exception e) { } catch (Exception e) {
logger.error("load database config fail,openzaly will use sqlite database,cause={}", e.getMessage()); logger.error("load database config fail,WindChat will use sqlite database,cause={}", e.getMessage());
} finally { } finally {
try { try {
if (inputStream != null) { if (inputStream != null) {

View File

@ -8,39 +8,39 @@ package com.windchat.im.storage.dao.config;
*/ */
public interface JdbcConst { public interface JdbcConst {
String OPENZALY_EDITION = "openzaly.edition"; String WINDCHAT_EDITION = "windchat.edition";
String SQLITE_URL = "openzaly.sqlite.url"; String SQLITE_URL = "windchat.sqlite.url";
// ----------------------MASTER-------------------- // ----------------------MASTER--------------------
String MYSQL_HOST = "openzaly.mysql.host"; String MYSQL_HOST = "windchat.mysql.host";
String MYSQL_PORT = "openzaly.mysql.port"; String MYSQL_PORT = "windchat.mysql.port";
String MYSQL_DB = "openzaly.mysql.database"; String MYSQL_DB = "windchat.mysql.database";
String MYSQL_USER_NAME = "openzaly.mysql.username"; String MYSQL_USER_NAME = "windchat.mysql.username";
String MYSQL_PASSWORD = "openzaly.mysql.password"; String MYSQL_PASSWORD = "windchat.mysql.password";
String MYSQL_INITIAL_SIZE = "openzaly.mysql.initial-size"; String MYSQL_INITIAL_SIZE = "windchat.mysql.initial-size";
String MYSQL_MAX_SIZE = "openzaly.mysql.max-size"; String MYSQL_MAX_SIZE = "windchat.mysql.max-size";
String MYSQL_MAX_IDLE = "openzaly.mysql.max-idle"; String MYSQL_MAX_IDLE = "windchat.mysql.max-idle";
String MYSQL_USE_UNICODE = "openzaly.mysql.useUnicode"; String MYSQL_USE_UNICODE = "windchat.mysql.useUnicode";
String MYSQL_CHARACTER_ENCODING = "openzaly.mysql.characterEncoding"; String MYSQL_CHARACTER_ENCODING = "windchat.mysql.characterEncoding";
String MYSQL_VERIFY_SERVER_CERTIFICATE = "openzaly.mysql.verifyServerCertificate"; String MYSQL_VERIFY_SERVER_CERTIFICATE = "windchat.mysql.verifyServerCertificate";
String MYSQL_USE_SSL = "openzaly.mysql.useSSL"; String MYSQL_USE_SSL = "windchat.mysql.useSSL";
// ----------------------SLAVE-------------------- // ----------------------SLAVE--------------------
String MYSQL_SLAVE_HOST = "openzaly.mysql.slave.host"; String MYSQL_SLAVE_HOST = "windchat.mysql.slave.host";
String MYSQL_SLAVE_PORT = "openzaly.mysql.slave.port"; String MYSQL_SLAVE_PORT = "windchat.mysql.slave.port";
String MYSQL_SLAVE_DB = "openzaly.mysql.slave.database"; String MYSQL_SLAVE_DB = "windchat.mysql.slave.database";
String MYSQL_SLAVE_USER_NAME = "openzaly.mysql.slave.username"; String MYSQL_SLAVE_USER_NAME = "windchat.mysql.slave.username";
String MYSQL_SLAVE_PASSWORD = "openzaly.mysql.slave.password"; String MYSQL_SLAVE_PASSWORD = "windchat.mysql.slave.password";
String MYSQL_SLAVE_INITIAL_SIZE = "openzaly.mysql.slave.initial-size"; String MYSQL_SLAVE_INITIAL_SIZE = "windchat.mysql.slave.initial-size";
String MYSQL_SLAVE_MAX_SIZE = "openzaly.mysql.slave.max-size"; String MYSQL_SLAVE_MAX_SIZE = "windchat.mysql.slave.max-size";
String MYSQL_SLAVE_MAX_IDLE = "openzaly.mysql.slave.max-idle"; String MYSQL_SLAVE_MAX_IDLE = "windchat.mysql.slave.max-idle";
String MYSQL_SLAVE_USE_UNICODE = "openzaly.mysql.slave.useUnicode"; String MYSQL_SLAVE_USE_UNICODE = "windchat.mysql.slave.useUnicode";
String MYSQL_SLAVE_CHARACTER_ENCODING = "openzaly.mysql.slave.characterEncoding"; String MYSQL_SLAVE_CHARACTER_ENCODING = "windchat.mysql.slave.characterEncoding";
String MYSQL_SLAVE_VERIFY_SERVER_CERTIFICATE = "openzaly.mysql.slave.verifyServerCertificate"; String MYSQL_SLAVE_VERIFY_SERVER_CERTIFICATE = "windchat.mysql.slave.verifyServerCertificate";
String MYSQL_SLAVE_USE_SSL = "openzaly.mysql.slave.useSSL"; String MYSQL_SLAVE_USE_SSL = "windchat.mysql.slave.useSSL";
} }

View File

@ -36,7 +36,7 @@ public class C3P0PoolManager extends AbstractPoolManager {
int maxIdle = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_MAX_IDLE, "60")); int maxIdle = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_MAX_IDLE, "60"));
cpds.setMaxIdleTime(maxIdle);// 最大空闲时间 cpds.setMaxIdleTime(maxIdle);// 最大空闲时间
SqlLog.info("openzaly init mysql master connection pool cpds={}", cpds); SqlLog.info("windchat init mysql master connection pool cpds={}", cpds);
} }
public static java.sql.Connection getConnection() throws SQLException { public static java.sql.Connection getConnection() throws SQLException {

View File

@ -54,7 +54,7 @@ public class C3P0PoolSlaveManager extends AbstractPoolManager {
cpdsList.add(cpds); cpdsList.add(cpds);
SqlLog.info("openzaly init mysql slave connection pool cpds={}", cpds.toString()); SqlLog.info("windchat init mysql slave connection pool cpds={}", cpds.toString());
} }
} }

View File

@ -24,7 +24,7 @@ import com.windchat.im.storage.util.SqlLog;
*/ */
public class InitDatabaseConnection extends AbstractPoolManager { public class InitDatabaseConnection extends AbstractPoolManager {
private static final String OPENZALY_MYSQL_SQL = "openzaly-mysql.sql"; private static final String WINDCHAT_MYSQL_SQL = "windchat-mysql.sql";
private static Connection conn; private static Connection conn;
public static void init(Properties prop) throws Exception { public static void init(Properties prop) throws Exception {
@ -68,8 +68,9 @@ public class InitDatabaseConnection extends AbstractPoolManager {
public static void closeInitConnection() { public static void closeInitConnection() {
try { try {
if (conn != null) if (conn != null) {
conn.close(); conn.close();
}
} catch (Exception e) { } catch (Exception e) {
SqlLog.error("close mysql init connection error", e); SqlLog.error("close mysql init connection error", e);
} }
@ -77,7 +78,7 @@ public class InitDatabaseConnection extends AbstractPoolManager {
private static void createAndUseDatabase(Connection conn, String dbName) throws SQLException { private static void createAndUseDatabase(Connection conn, String dbName) throws SQLException {
if (StringUtils.isEmpty(dbName)) { if (StringUtils.isEmpty(dbName)) {
throw new SQLException("openzaly team need designated database name,but now it's " + dbName); throw new SQLException("windchat team need designated database name,but now it's " + dbName);
} }
String createSql = "CREATE DATABASE IF NOT EXISTS " + dbName + " CHARACTER SET utf8mb4;"; String createSql = "CREATE DATABASE IF NOT EXISTS " + dbName + " CHARACTER SET utf8mb4;";
String useSql = "use " + dbName; String useSql = "use " + dbName;
@ -88,13 +89,13 @@ public class InitDatabaseConnection extends AbstractPoolManager {
private static void initDatabaseTable(Connection conn) throws SQLException { private static void initDatabaseTable(Connection conn) throws SQLException {
try { try {
// 生成临时sql文件加载数据库sql执行脚本, // 生成临时sql文件加载数据库sql执行脚本,
File sqlFile = new File(OPENZALY_MYSQL_SQL); File sqlFile = new File(WINDCHAT_MYSQL_SQL);
if (!sqlFile.exists()) { if (!sqlFile.exists()) {
FileUtils.writeResourceToFile("/" + OPENZALY_MYSQL_SQL, sqlFile); FileUtils.writeResourceToFile("/" + WINDCHAT_MYSQL_SQL, sqlFile);
} }
// 初始化数据库表 // 初始化数据库表
File file = new File(OPENZALY_MYSQL_SQL); File file = new File(WINDCHAT_MYSQL_SQL);
if (!file.exists()) { if (!file.exists()) {
throw new FileNotFoundException("init mysql with sql script file is not exists"); throw new FileNotFoundException("init mysql with sql script file is not exists");
} }
@ -102,7 +103,7 @@ public class InitDatabaseConnection extends AbstractPoolManager {
FileSystemResource rc = new FileSystemResource(file); FileSystemResource rc = new FileSystemResource(file);
EncodedResource encodeRes = new EncodedResource(rc, "GBK"); EncodedResource encodeRes = new EncodedResource(rc, "GBK");
ScriptUtils.executeSqlScript(conn, encodeRes); ScriptUtils.executeSqlScript(conn, encodeRes);
SqlLog.info("openzaly init mysql database with sql-script finish"); SqlLog.info("windchat init mysql database with sql-script finish");
file.delete(); file.delete();
} catch (Exception e) { } catch (Exception e) {

View File

@ -47,7 +47,7 @@ public class SQLiteJDBCManager {
private static int SITE_DB_VERSION = SQLConst.SITE_DB_VERSION_10; private static int SITE_DB_VERSION = SQLConst.SITE_DB_VERSION_10;
private static String sqliteDriverName = "org.sqlite.JDBC"; private static String sqliteDriverName = "org.sqlite.JDBC";
private static Connection sqlitConnection = null; private static Connection sqlitConnection = null;
private static final String DB_FILE_PATH = "openzalyDB.sqlite3"; private static final String DB_FILE_PATH = "windchatDB.sqlite3";
private SQLiteJDBCManager() { private SQLiteJDBCManager() {
@ -61,7 +61,7 @@ public class SQLiteJDBCManager {
loadDatabaseDriver(config.getDbDir()); loadDatabaseDriver(config.getDbDir());
if (getDbVersion() < SITE_DB_VERSION) { if (getDbVersion() < SITE_DB_VERSION) {
throw new UpgradeDatabaseException("openzaly-server need to upgrade before run it"); throw new UpgradeDatabaseException("windchat-server need to upgrade before run it");
} }
} }

View File

@ -36,8 +36,8 @@ import com.windchat.im.storage.util.SqlLog;
public class SQLiteUpgrade { public class SQLiteUpgrade {
private static final Logger logger = LoggerFactory.getLogger(SQLiteUpgrade.class); private static final Logger logger = LoggerFactory.getLogger(SQLiteUpgrade.class);
private static final String DB_FILE_PATH = "openzalyDB.sqlite3"; private static final String DB_FILE_PATH = "windchatDB.sqlite3";
private static final String OPENZALY_SQLITE_SQL = "openzaly-sqlite.sql"; private static final String WINDCHAT_SQLITE_SQL = "windchat-sqlite.sql";
private SQLiteUpgrade() { private SQLiteUpgrade() {
} }
@ -56,7 +56,7 @@ public class SQLiteUpgrade {
File file = new File(config.getDbDir(), DB_FILE_PATH); File file = new File(config.getDbDir(), DB_FILE_PATH);
if (!file.exists()) { if (!file.exists()) {
SqlLog.info("openzaly start with first init sqlite database"); SqlLog.info("windchat start with first init sqlite database");
SQLiteJDBCManager.loadDatabaseDriver(config.getDbDir()); SQLiteJDBCManager.loadDatabaseDriver(config.getDbDir());
doInitWork(SQLiteJDBCManager.getConnection()); doInitWork(SQLiteJDBCManager.getConnection());
SQLiteJDBCManager.setDbVersion(SQLConst.SITE_DB_VERSION_11); SQLiteJDBCManager.setDbVersion(SQLConst.SITE_DB_VERSION_11);
@ -80,13 +80,13 @@ public class SQLiteUpgrade {
private static void doInitWork(Connection conn) throws SQLException { private static void doInitWork(Connection conn) throws SQLException {
try { try {
// 生成临时sql文件加载数据库sql执行脚本, // 生成临时sql文件加载数据库sql执行脚本,
File sqlFile = new File(OPENZALY_SQLITE_SQL); File sqlFile = new File(WINDCHAT_SQLITE_SQL);
if (!sqlFile.exists()) { if (!sqlFile.exists()) {
FileUtils.writeResourceToFile("/" + OPENZALY_SQLITE_SQL, sqlFile); FileUtils.writeResourceToFile("/" + WINDCHAT_SQLITE_SQL, sqlFile);
} }
// 初始化数据库表 // 初始化数据库表
File file = new File(OPENZALY_SQLITE_SQL); File file = new File(WINDCHAT_SQLITE_SQL);
if (!file.exists()) { if (!file.exists()) {
throw new FileNotFoundException("init mysql with sql script file is not exists"); throw new FileNotFoundException("init mysql with sql script file is not exists");
} }
@ -94,7 +94,7 @@ public class SQLiteUpgrade {
FileSystemResource rc = new FileSystemResource(file); FileSystemResource rc = new FileSystemResource(file);
EncodedResource encodeRes = new EncodedResource(rc, "GBK"); EncodedResource encodeRes = new EncodedResource(rc, "GBK");
ScriptUtils.executeSqlScript(conn, encodeRes); ScriptUtils.executeSqlScript(conn, encodeRes);
SqlLog.info("openzaly init sqlite with sql-script finish"); SqlLog.info("windchat init sqlite with sql-script finish");
file.delete(); file.delete();
} catch (Exception e) { } catch (Exception e) {