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);
}
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;
}
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);
}
}
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();
}
}
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);
}
Aggregations