Search in sources :

Example 6 with SystemConfig

use of com.actiontech.dble.config.model.SystemConfig in project dble by actiontech.

the class ShowSysParam method execute.

public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();
    // write header
    buffer = HEADER.write(buffer, c, true);
    // write fields
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }
    // write eof
    buffer = EOF.write(buffer, c, true);
    // write rows
    byte packetId = EOF.getPacketId();
    SystemConfig sysConfig = DbleServer.getInstance().getConfig().getSystem();
    List<String> paramValues = new ArrayList<>();
    paramValues.add(sysConfig.getProcessors() + "");
    paramValues.add(sysConfig.getBackendProcessors() + "");
    paramValues.add(sysConfig.getBufferPoolChunkSize() + "B");
    paramValues.add(sysConfig.getBufferPoolPageSize() + "B");
    paramValues.add(sysConfig.getBufferPoolPageNumber() + "B");
    paramValues.add(sysConfig.getProcessorExecutor() + "");
    paramValues.add(sysConfig.getBackendProcessorExecutor() + "");
    paramValues.add(sysConfig.getBindIp() + "");
    paramValues.add(sysConfig.getServerPort() + "");
    paramValues.add(sysConfig.getManagerPort() + "");
    paramValues.add(sysConfig.getFakeMySQLVersion());
    paramValues.add(sysConfig.getUsingAIO() + "");
    paramValues.add(sysConfig.getUseCompression() + "");
    paramValues.add(sysConfig.getServerNodeId() + "");
    paramValues.add(sysConfig.isUseZKSwitch() + "");
    paramValues.add(sysConfig.getSequnceHandlerType() > 4 || sysConfig.getSequnceHandlerType() < 1 ? "Incorrect Sequence Type" : SEQUENCES[sysConfig.getSequnceHandlerType()]);
    paramValues.add(sysConfig.getMaxPacketSize() / 1024 / 1024 + "M");
    paramValues.add(sysConfig.getServerBacklog() + "");
    paramValues.add(sysConfig.getIdleTimeout() / 1000 / 60 + " Minutes");
    paramValues.add(sysConfig.getCharset() + "");
    paramValues.add(sysConfig.getTxIsolation() > 4 || sysConfig.getTxIsolation() < 1 ? "Incorrect isolation" : ISOLATION_LEVELS[sysConfig.getTxIsolation()]);
    paramValues.add(sysConfig.getSqlExecuteTimeout() + " Seconds");
    paramValues.add(sysConfig.getProcessorCheckPeriod() / 1000 + " Seconds");
    paramValues.add(sysConfig.getDataNodeIdleCheckPeriod() / 1000 + " Seconds");
    paramValues.add(sysConfig.getDataNodeHeartbeatPeriod() / 1000 + " Seconds");
    paramValues.add(sysConfig.getBackSocketSoRcvbuf() + "B");
    paramValues.add(sysConfig.getBackSocketSoSndbuf() + "B");
    paramValues.add(sysConfig.getBackSocketNoDelay() + "");
    paramValues.add(sysConfig.getFrontSocketSoRcvbuf() + "B");
    paramValues.add(sysConfig.getFrontSocketSoSndbuf() + "B");
    paramValues.add(sysConfig.getFrontSocketNoDelay() + "");
    paramValues.add(sysConfig.getBufferUsagePercent() + "%");
    paramValues.add(sysConfig.getUseSqlStat() + "");
    paramValues.add(sysConfig.getClearBigSqLResultSetMapMs() + "ms");
    paramValues.add(sysConfig.getSqlRecordCount() + "");
    paramValues.add(sysConfig.getMaxResultSet() + "B");
    paramValues.add(sysConfig.getShowBinlogStatusTimeout() + "ms");
    paramValues.add(sysConfig.getCheckTableConsistency() + "");
    paramValues.add(sysConfig.getCheckTableConsistencyPeriod() + "ms");
    paramValues.add(sysConfig.getUseGlobleTableCheck() + "");
    paramValues.add(sysConfig.getGlableTableCheckPeriod() + "ms");
    paramValues.add(sysConfig.getDataNodeIdleCheckPeriod() + "ms");
    paramValues.add(sysConfig.getDataNodeHeartbeatPeriod() + "ms");
    paramValues.add(sysConfig.getRecordTxn() + "");
    paramValues.add(sysConfig.getTransactionLogBaseDir());
    paramValues.add(sysConfig.getTransactionLogBaseName());
    paramValues.add(sysConfig.getTransactionRatateSize() + "M");
    paramValues.add(sysConfig.getXaRecoveryLogBaseDir());
    paramValues.add(sysConfig.getXaRecoveryLogBaseName());
    paramValues.add(sysConfig.getXaSessionCheckPeriod() + "ms");
    paramValues.add(sysConfig.getXaLogCleanPeriod() + "ms");
    paramValues.add(sysConfig.isUseJoinStrategy() + "");
    paramValues.add(sysConfig.getNestLoopConnSize() + "");
    paramValues.add(sysConfig.getNestLoopRowsSize() + "");
    paramValues.add(sysConfig.getViewPersistenceConfBaseDir());
    paramValues.add(sysConfig.getViewPersistenceConfBaseName());
    paramValues.add(sysConfig.getComplexExecutor() + "");
    paramValues.add(sysConfig.getOtherMemSize() + "M");
    paramValues.add(sysConfig.getOrderMemSize() + "M");
    paramValues.add(sysConfig.getJoinMemSize() + "M");
    paramValues.add(sysConfig.getCostTimeStat() + "");
    paramValues.add(sysConfig.getMaxCostStatSize() + "");
    paramValues.add(sysConfig.getCostSamplePercent() + "");
    paramValues.add(sysConfig.getUseThreadUsageStat() + "");
    paramValues.add(sysConfig.getUsePerformanceMode() + "");
    for (int i = 0; i < PARAM_NAMES.length; i++) {
        RowDataPacket row = new RowDataPacket(FIELD_COUNT);
        row.add(StringUtil.encode(PARAM_NAMES[i], c.getCharset().getResults()));
        row.add(StringUtil.encode(paramValues.get(i), c.getCharset().getResults()));
        row.add(StringUtil.encode(PARAM_DESCRIPTION[i], c.getCharset().getResults()));
        row.setPacketId(++packetId);
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : SystemConfig(com.actiontech.dble.config.model.SystemConfig) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) ArrayList(java.util.ArrayList) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 7 with SystemConfig

use of com.actiontech.dble.config.model.SystemConfig in project dble by actiontech.

the class SystemConfigLoader method load.

public void load(Element root, XMLServerLoader xsl, boolean isLowerCaseTableNames) throws IllegalAccessException, InvocationTargetException {
    SystemConfig system = xsl.getSystem();
    NodeList list = root.getElementsByTagName("system");
    for (int i = 0, n = list.getLength(); i < n; i++) {
        Node node = list.item(i);
        if (node instanceof Element) {
            Map<String, Object> props = ConfigUtil.loadElements((Element) node);
            ParameterMapping.mapping(system, props);
        }
    }
    if (system.getFakeMySQLVersion() != null) {
        boolean validVersion = false;
        String majorMySQLVersion = system.getFakeMySQLVersion();
        int pos = majorMySQLVersion.indexOf(".") + 1;
        majorMySQLVersion = majorMySQLVersion.substring(0, majorMySQLVersion.indexOf(".", pos));
        for (String ver : SystemConfig.MYSQL_VERSIONS) {
            // version is x.y.z ,just compare the x.y
            if (majorMySQLVersion.equals(ver)) {
                validVersion = true;
            }
        }
        if (validVersion) {
            Versions.setServerVersion(system.getFakeMySQLVersion());
        } else {
            throw new ConfigException("The specified MySQL Version (" + system.getFakeMySQLVersion() + ") is not valid.");
        }
    }
}
Also used : SystemConfig(com.actiontech.dble.config.model.SystemConfig) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ConfigException(com.actiontech.dble.config.util.ConfigException)

Example 8 with SystemConfig

use of com.actiontech.dble.config.model.SystemConfig in project dble by actiontech.

the class DbleServer method startup.

public void startup() throws IOException {
    SystemConfig system = config.getSystem();
    // server startup
    LOGGER.info("===============================================");
    LOGGER.info(NAME + "Server is ready to startup ...");
    String inf = "Startup processors ...,total processors:" + system.getProcessors() + ",aio thread pool size:" + system.getProcessorExecutor() + "    \r\n each process allocated socket buffer pool " + " bytes ,a page size:" + system.getBufferPoolPageSize() + "  a page's chunk number(PageSize/ChunkSize) is:" + (system.getBufferPoolPageSize() / system.getBufferPoolChunkSize()) + "  buffer page's number is:" + system.getBufferPoolPageNumber();
    LOGGER.info(inf);
    LOGGER.info("sysconfig params:" + system.toString());
    backupLocked = new AtomicBoolean(false);
    // startup manager
    ManagerConnectionFactory mf = new ManagerConnectionFactory();
    ServerConnectionFactory sf = new ServerConnectionFactory();
    SocketAcceptor manager;
    SocketAcceptor server;
    aio = (system.getUsingAIO() == 1);
    // startup processors
    int frontProcessorCount = system.getProcessors();
    int backendProcessorCount = system.getBackendProcessors();
    frontProcessors = new NIOProcessor[frontProcessorCount];
    backendProcessors = new NIOProcessor[backendProcessorCount];
    // a page size
    int bufferPoolPageSize = system.getBufferPoolPageSize();
    // total page number
    short bufferPoolPageNumber = system.getBufferPoolPageNumber();
    // minimum allocation unit
    short bufferPoolChunkSize = system.getBufferPoolChunkSize();
    totalNetWorkBufferSize = bufferPoolPageSize * bufferPoolPageNumber;
    if (totalNetWorkBufferSize > Platform.getMaxDirectMemory()) {
        throw new IOException("Direct BufferPool size lager than MaxDirectMemory");
    }
    bufferPool = new DirectByteBufferPool(bufferPoolPageSize, bufferPoolChunkSize, bufferPoolPageNumber);
    businessExecutor = ExecutorUtil.createFixed("BusinessExecutor", system.getProcessorExecutor());
    backendBusinessExecutor = ExecutorUtil.createFixed("backendBusinessExecutor", system.getBackendProcessorExecutor());
    complexQueryExecutor = ExecutorUtil.createCached("complexQueryExecutor", system.getComplexExecutor());
    timerExecutor = ExecutorUtil.createFixed("Timer", 1);
    if (system.getUsePerformanceMode() == 1) {
        concurrentFrontHandlerQueue = new ConcurrentLinkedQueue<>();
        for (int i = 0; i < system.getProcessorExecutor(); i++) {
            businessExecutor.execute(new ConcurrentFrontEndHandlerRunnable(concurrentFrontHandlerQueue));
        }
        concurrentBackHandlerQueue = new ConcurrentLinkedQueue<>();
        for (int i = 0; i < system.getBackendProcessorExecutor(); i++) {
            backendBusinessExecutor.execute(new ConcurrentBackEndHandlerRunnable(concurrentBackHandlerQueue));
        }
    } else {
        frontHandlerQueue = new LinkedBlockingQueue<>();
        for (int i = 0; i < system.getProcessorExecutor(); i++) {
            businessExecutor.execute(new FrontEndHandlerRunnable(frontHandlerQueue));
        }
    }
    for (int i = 0; i < frontProcessorCount; i++) {
        frontProcessors[i] = new NIOProcessor("frontProcessor" + i, bufferPool);
    }
    for (int i = 0; i < backendProcessorCount; i++) {
        backendProcessors[i] = new NIOProcessor("backendProcessor" + i, bufferPool);
    }
    if (aio) {
        int processorCount = frontProcessorCount + backendProcessorCount;
        LOGGER.info("using aio network handler ");
        asyncChannelGroups = new AsynchronousChannelGroup[processorCount];
        // startup connector
        connector = new AIOConnector();
        for (int i = 0; i < processorCount; i++) {
            asyncChannelGroups[i] = AsynchronousChannelGroup.withFixedThreadPool(processorCount, new ThreadFactory() {

                private int inx = 1;

                @Override
                public Thread newThread(Runnable r) {
                    Thread th = new Thread(r);
                    // TODO
                    th.setName(DirectByteBufferPool.LOCAL_BUF_THREAD_PREX + "AIO" + (inx++));
                    LOGGER.info("created new AIO thread " + th.getName());
                    return th;
                }
            });
        }
        manager = new AIOAcceptor(NAME + "Manager", system.getBindIp(), system.getManagerPort(), 100, mf, this.asyncChannelGroups[0]);
        // startup server
        server = new AIOAcceptor(NAME + "Server", system.getBindIp(), system.getServerPort(), system.getServerBacklog(), sf, this.asyncChannelGroups[0]);
    } else {
        LOGGER.info("using nio network handler ");
        NIOReactorPool frontReactorPool = new NIOReactorPool(DirectByteBufferPool.LOCAL_BUF_THREAD_PREX + "NIO_REACTOR_FRONT", frontProcessorCount);
        NIOReactorPool backendReactorPool = new NIOReactorPool(DirectByteBufferPool.LOCAL_BUF_THREAD_PREX + "NIO_REACTOR_BACKEND", backendProcessorCount);
        connector = new NIOConnector(DirectByteBufferPool.LOCAL_BUF_THREAD_PREX + "NIOConnector", backendReactorPool);
        ((NIOConnector) connector).start();
        manager = new NIOAcceptor(DirectByteBufferPool.LOCAL_BUF_THREAD_PREX + NAME + "Manager", system.getBindIp(), system.getManagerPort(), 100, mf, frontReactorPool);
        server = new NIOAcceptor(DirectByteBufferPool.LOCAL_BUF_THREAD_PREX + NAME + "Server", system.getBindIp(), system.getServerPort(), system.getServerBacklog(), sf, frontReactorPool);
    }
    // start transaction SQL log
    if (config.getSystem().getRecordTxn() == 1) {
        txnLogProcessor = new TxnLogProcessor(bufferPool);
        txnLogProcessor.setName("TxnLogProcessor");
        txnLogProcessor.start();
    }
    pullVarAndMeta();
    // initialized the cache service
    cacheService = new CacheService(this.systemVariables.isLowerCaseTableNames());
    // initialized the router cache and primary cache
    routerService = new RouteService(cacheService);
    sequenceHandler = initSequenceHandler(config.getSystem().getSequnceHandlerType());
    // XA Init recovery Log
    LOGGER.info("===============================================");
    LOGGER.info("Perform XA recovery log ...");
    performXARecoveryLog();
    // manager start
    manager.start();
    LOGGER.info(manager.getName() + " is started and listening on " + manager.getPort());
    server.start();
    // server started
    LOGGER.info(server.getName() + " is started and listening on " + server.getPort());
    LOGGER.info("===============================================");
    long dataNodeIdleCheckPeriod = system.getDataNodeIdleCheckPeriod();
    scheduler.scheduleAtFixedRate(updateTime(), 0L, TIME_UPDATE_PERIOD, TimeUnit.MILLISECONDS);
    scheduler.scheduleWithFixedDelay(processorCheck(), 0L, system.getProcessorCheckPeriod(), TimeUnit.MILLISECONDS);
    scheduler.scheduleAtFixedRate(dataNodeConHeartBeatCheck(dataNodeIdleCheckPeriod), 0L, dataNodeIdleCheckPeriod, TimeUnit.MILLISECONDS);
    // dataHost heartBeat  will be influence by dataHostWithoutWR
    scheduler.scheduleAtFixedRate(dataNodeHeartbeat(), 0L, system.getDataNodeHeartbeatPeriod(), TimeUnit.MILLISECONDS);
    scheduler.scheduleAtFixedRate(dataSourceOldConsClear(), 0L, DEFAULT_OLD_CONNECTION_CLEAR_PERIOD, TimeUnit.MILLISECONDS);
    scheduler.scheduleWithFixedDelay(xaSessionCheck(), 0L, system.getXaSessionCheckPeriod(), TimeUnit.MILLISECONDS);
    scheduler.scheduleWithFixedDelay(xaLogClean(), 0L, system.getXaLogCleanPeriod(), TimeUnit.MILLISECONDS);
    scheduler.scheduleWithFixedDelay(resultSetMapClear(), 0L, system.getClearBigSqLResultSetMapMs(), TimeUnit.MILLISECONDS);
    if (system.getUseSqlStat() == 1) {
        // sql record detail timing clean
        scheduler.scheduleWithFixedDelay(recycleSqlStat(), 0L, DEFAULT_SQL_STAT_RECYCLE_PERIOD, TimeUnit.MILLISECONDS);
    }
    if (system.getUseGlobleTableCheck() == 1) {
        // will be influence by dataHostWithoutWR
        scheduler.scheduleWithFixedDelay(globalTableConsistencyCheck(), 0L, system.getGlableTableCheckPeriod(), TimeUnit.MILLISECONDS);
    }
    scheduler.scheduleAtFixedRate(threadStatRenew(), 0L, 1, TimeUnit.SECONDS);
    if (isUseZkSwitch()) {
        initZkDnindex();
    }
}
Also used : SystemConfig(com.actiontech.dble.config.model.SystemConfig) ManagerConnectionFactory(com.actiontech.dble.manager.ManagerConnectionFactory) ServerConnectionFactory(com.actiontech.dble.server.ServerConnectionFactory) CacheService(com.actiontech.dble.cache.CacheService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DirectByteBufferPool(com.actiontech.dble.buffer.DirectByteBufferPool) RouteService(com.actiontech.dble.route.RouteService) TxnLogProcessor(com.actiontech.dble.log.transaction.TxnLogProcessor)

Aggregations

SystemConfig (com.actiontech.dble.config.model.SystemConfig)8 VersionedFile (com.actiontech.dble.backend.mysql.xa.VersionedFile)1 DirectByteBufferPool (com.actiontech.dble.buffer.DirectByteBufferPool)1 CacheService (com.actiontech.dble.cache.CacheService)1 ServerConfig (com.actiontech.dble.config.ServerConfig)1 ConfigException (com.actiontech.dble.config.util.ConfigException)1 TxnLogProcessor (com.actiontech.dble.log.transaction.TxnLogProcessor)1 ManagerConnectionFactory (com.actiontech.dble.manager.ManagerConnectionFactory)1 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)1 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)1 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)1 RouteService (com.actiontech.dble.route.RouteService)1 ServerConnectionFactory (com.actiontech.dble.server.ServerConnectionFactory)1 ServerLoadDataInfileHandler (com.actiontech.dble.server.handler.ServerLoadDataInfileHandler)1 ServerPrepareHandler (com.actiontech.dble.server.handler.ServerPrepareHandler)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Element (org.w3c.dom.Element)1