Search in sources :

Example 1 with CmppActiveTestRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage in project SMSGate by Lihuanghe.

the class CmppActiveTestRequestMessageCodec method decode.

@Override
protected void decode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
    int commandId = msg.getHeader().getCommandId();
    if (packetType.getCommandId() != commandId) {
        // 不解析,交给下一个codec
        out.add(msg);
        return;
    }
    CmppActiveTestRequestMessage requestMessage = new CmppActiveTestRequestMessage(msg.getHeader());
    out.add(requestMessage);
}
Also used : CmppActiveTestRequestMessage(com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage)

Example 2 with CmppActiveTestRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage in project SMSGate by Lihuanghe.

the class TestCmppActiveTestRequestMessageCodec method createMsg.

protected CmppActiveTestRequestMessage createMsg() {
    Header header = new DefaultHeader();
    header.setSequenceId(0X761ae);
    CmppActiveTestRequestMessage msg = new CmppActiveTestRequestMessage(header);
    return msg;
}
Also used : DefaultHeader(com.zx.sms.codec.cmpp.msg.DefaultHeader) Header(com.zx.sms.codec.cmpp.msg.Header) CmppActiveTestRequestMessage(com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage) DefaultHeader(com.zx.sms.codec.cmpp.msg.DefaultHeader)

Example 3 with CmppActiveTestRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage in project SMSGate by Lihuanghe.

the class CmppServerIdleStateHandler method userEventTriggered.

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof IdleStateEvent) {
        IdleStateEvent e = (IdleStateEvent) evt;
        if (e.state() == IdleState.ALL_IDLE) {
            // 如果是CMPP连接未建立,直接关闭
            if (ctx.channel().attr(GlobalConstance.attributeKey).get() != SessionState.Connect) {
                logger.warn("connectting time out. ");
                ctx.close();
            } else {
                ctx.channel().writeAndFlush(new CmppActiveTestRequestMessage());
            }
        }
    } else {
        ctx.fireUserEventTriggered(evt);
    }
}
Also used : IdleStateEvent(io.netty.handler.timeout.IdleStateEvent) CmppActiveTestRequestMessage(com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage)

Example 4 with CmppActiveTestRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage in project SMSGate by Lihuanghe.

the class TestLevelDBQuque method testLevelDB.

@Test
public void testLevelDB() throws Exception {
    Options options = new Options();
    options.createIfMissing(true);
    final DB db = factory.open(new File("d:\\example"), options);
    Thread d = new Thread() {

        @Override
        public void run() {
            while (true) {
                ReadOptions opt = new ReadOptions();
                opt.snapshot(db.getSnapshot());
                int cnt = 0;
                for (DBIterator iter = db.iterator(opt); iter.hasNext(); ) {
                    Map.Entry<byte[], byte[]> entry = iter.next();
                    cnt++;
                }
                System.out.println("size:" + cnt);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
        }
    };
    d.start();
    try {
        // Use the db in here....
        long start = System.currentTimeMillis();
        int i = 10000;
        while (i-- > 0) {
            db.put(bytes(UUID.randomUUID().toString()), SerializationUtils.serialize(new CmppActiveTestRequestMessage()));
            if (i % 100 == 0) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
        }
        System.out.println("testLevelDB");
        System.out.println(System.currentTimeMillis() - start);
        int cnt = 0;
        for (DBIterator iter = db.iterator(); iter.hasNext(); ) {
            Map.Entry<byte[], byte[]> entry = iter.next();
            cnt++;
        }
        System.out.println("size:" + cnt);
    } finally {
        // Make sure you close the db to shutdown the
        // database and avoid resource leaks.
        db.close();
    }
}
Also used : ReadOptions(org.iq80.leveldb.ReadOptions) Options(org.iq80.leveldb.Options) DBIterator(org.iq80.leveldb.DBIterator) CmppActiveTestRequestMessage(com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage) ReadOptions(org.iq80.leveldb.ReadOptions) File(java.io.File) Map(java.util.Map) DB(org.iq80.leveldb.DB) Test(org.junit.Test)

Example 5 with CmppActiveTestRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage in project SMSGate by Lihuanghe.

the class TestLevelDBQuque method teststoreMap.

public void teststoreMap() {
    Map<Serializable, VersionObject> map = BDBStoredMapFactoryImpl.INS.buildMap("abc", "abc");
    // Use the db in here....
    long start = System.currentTimeMillis();
    int i = 10000;
    long l = 0;
    while (i-- > 0) {
        map.put(l++, new VersionObject(new CmppActiveTestRequestMessage()));
    }
    System.out.println("teststoreMap");
    System.out.println(System.currentTimeMillis() - start);
}
Also used : VersionObject(com.zx.sms.common.storedMap.VersionObject) Serializable(java.io.Serializable) CmppActiveTestRequestMessage(com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage)

Aggregations

CmppActiveTestRequestMessage (com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage)6 Test (org.junit.Test)2 DefaultHeader (com.zx.sms.codec.cmpp.msg.DefaultHeader)1 Header (com.zx.sms.codec.cmpp.msg.Header)1 VersionObject (com.zx.sms.common.storedMap.VersionObject)1 ByteBuf (io.netty.buffer.ByteBuf)1 IdleStateEvent (io.netty.handler.timeout.IdleStateEvent)1 File (java.io.File)1 Serializable (java.io.Serializable)1 Map (java.util.Map)1 DB (org.iq80.leveldb.DB)1 DBIterator (org.iq80.leveldb.DBIterator)1 Options (org.iq80.leveldb.Options)1 ReadOptions (org.iq80.leveldb.ReadOptions)1