Search in sources :

Example 1 with CacheStatic

use of com.actiontech.dble.cache.CacheStatic in project dble by actiontech.

the class ShowCache 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();
    CacheService cacheService = DbleServer.getInstance().getCacheService();
    for (Map.Entry<String, CachePool> entry : cacheService.getAllCachePools().entrySet()) {
        String cacheName = entry.getKey();
        CachePool cachePool = entry.getValue();
        if (cachePool != null) {
            if (cachePool instanceof LayerCachePool) {
                for (Map.Entry<String, CacheStatic> staticsEntry : ((LayerCachePool) cachePool).getAllCacheStatic().entrySet()) {
                    RowDataPacket row = getRow(cacheName + '.' + staticsEntry.getKey(), staticsEntry.getValue(), c.getCharset().getResults());
                    row.setPacketId(++packetId);
                    buffer = row.write(buffer, c, true);
                }
            } else {
                RowDataPacket row = getRow(cacheName, cachePool.getCacheStatic(), 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 : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) CachePool(com.actiontech.dble.cache.CachePool) LayerCachePool(com.actiontech.dble.cache.LayerCachePool) CacheStatic(com.actiontech.dble.cache.CacheStatic) LayerCachePool(com.actiontech.dble.cache.LayerCachePool) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) Map(java.util.Map) CacheService(com.actiontech.dble.cache.CacheService)

Aggregations

CachePool (com.actiontech.dble.cache.CachePool)1 CacheService (com.actiontech.dble.cache.CacheService)1 CacheStatic (com.actiontech.dble.cache.CacheStatic)1 LayerCachePool (com.actiontech.dble.cache.LayerCachePool)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 ByteBuffer (java.nio.ByteBuffer)1 Map (java.util.Map)1