CN102694775A - Campus information machine terminal authentication method based on asynchronous communication mode - Google Patents

Campus information machine terminal authentication method based on asynchronous communication mode Download PDF

Info

Publication number
CN102694775A
CN102694775A CN2011100705174A CN201110070517A CN102694775A CN 102694775 A CN102694775 A CN 102694775A CN 2011100705174 A CN2011100705174 A CN 2011100705174A CN 201110070517 A CN201110070517 A CN 201110070517A CN 102694775 A CN102694775 A CN 102694775A
Authority
CN
China
Prior art keywords
incident
event
asynchronous communication
server
netty
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2011100705174A
Other languages
Chinese (zh)
Inventor
刘本中
司震
郑国松
胡明慧
宋炜伟
魏阳
陈翔宇
胡俊
孙立强
刘洋
王庆典
王文波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NANJING SITONG TECHNOLOGY Co Ltd
Original Assignee
NANJING SITONG TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NANJING SITONG TECHNOLOGY Co Ltd filed Critical NANJING SITONG TECHNOLOGY Co Ltd
Priority to CN2011100705174A priority Critical patent/CN102694775A/en
Publication of CN102694775A publication Critical patent/CN102694775A/en
Pending legal-status Critical Current

Links

Abstract

NETTY3 NIO asynchronous communication technology of JBOSS is applied in the invention, an application event driven model replaces a traditional sending and receiving thread separation mode, an authentication information congestion problem from a campus attendance terminal to a server end in a high concurrent condition is solved, and server processing performance and rational use of resources are raised comprehensively.

Description

A kind of campus pager terminal verification method based on asynchronous communication mode
1, technical field
The logical RTU of school news that the present invention relates to the IT application in education sector industry is to the server end verification technique, especially under the concurrent situation of height, and the campus pager terminal verification method of NETTY NIO asynchronous communication mode.
2, background technology
Popularization along with IT application in education sector; Rely on terminal, digitlization campus; Utilize multiple means such as note, voice, the Internet; For the parents of student provides information interaction, attendance management, emotional affection phone, the business of location-based service has obtained numerous teachers, the head of a family's acceptance and approval, and terminal, digitlization campus is increasingly high in the coverage rate of school.At present, each moves branch company all in that existing digitlization campus business is carried out the demand integration, and the unified platform is provided, and the centralized digitlization campus of carrying out is professional.We suppose 4 attendance record terminal machines of every school, 10,000 schools of every province, and the remote terminal of economizing the same time Collective qualification of platform so will reach 40,000.Because attendance record terminal machine and server adopt long ways of connecting all the time, server-side processes pressure is very big.
Traditional logical terminal equipment of school news is the communication mode of the block type Socket IO of employing standard to the way of server-side certificate, and server end is opened the port of intercepting, and is responsible for this connection once there being the client connection to create two new threads at least.The information that responsible client is sent, another is responsible for sending data through this Socket.If 40,000 station terminals arrive server-side certificate simultaneously, then the server end process need derive from 80,000 processing threads.The treatable client-requested of process is limited.When the concurrent client of height connects, server end occurs through regular meeting and connect overtime situation, the Time Attendance Device situation of going offline happens occasionally, and has influenced user's perception largely.
General way all is to adopt the cluster scheme, through the means of linearity increase server hardware quantity, promotes the disposal ability of service end.Perhaps, launch the request that different ports comes the customer in response end respectively in the identical server side authentication program of the many covers of server deploy.Because client to server side authentication, needs the server address and the port of explicit state registration.No matter be the scheme that adopts the scheme of server hardware dilatation or adopt the adjustment of application software deployment strategy, connect, can only manual work show up and carry out parameter configuration by station terminal and upgrade because remote terminal can't self adaptation switches.The difficulty that administers and maintains of attendance record terminal has strengthened a lot.Bypass server hardware dilatation cost and do not talk, more than 2 kinds of schemes obviously do not possess the autgmentability on the scale.
3, summary of the invention
The present invention seeks in order to solve under the high concurrent situation, the campus pager rises to server process performance and extended capability to the information obstructing problem of server end registration.
Technical solution of the present invention is: the asynchronous communication mechanism that adopts the NETTY3 NIO of JBOSS (JBOSS is the application server that meets the J2EE standard that one in SUN company increases income); Promote the disposal ability and the extended capability of service end, the boss thread is responsible for the connect incident of nio socket, after the successful connection; Carry out read by the worker thread; Write handles, because the bottom core has been used the epoll of linux 2.6, the repeating query incident of having practiced thrift socket greatly; Memcache and message queue in Business Processing, have been launched simultaneously; Strengthened the performance of Business Processing, thereby, practiced thrift the memory consumption of server end as long as use a small amount of thread just can serve a large amount of clients.We are based on asynchronous, and network and event driven NETTY application framework are developed, and for the lifting of digitlization campus information terminal to the authentication capability of server end, can adapt to high concurrent service feature demand not through the hardware capabilities expansion.Protocol server and protocol client have the characteristics of quick agility, high-performance, high flexibility.
The Netty framework mainly is ChannelFactory and ChannelPipelineFactory.ChannelFactory is relevant Channel instance and the ChannelSink instance of production network service mainly; ChannelPipelineFactory pays close attention to the processing of concrete transmission data; Also comprise simultaneously otherwise contents such as abnormality processing, can inwardly add corresponding handler according to actual needs, general ChannelPipelineFactory needs oneself to realize; Because the processing of transmission data and other operations and business association are tightr, need the handler of self-defined processing.
The first step: BootStrap of instantiation, and through ChannelFactory realization of building method appointment
Second step: to ChannelPipelineFactory who oneself realizes of bootstrap instance registration
The 3rd step: bootstrap.bind (new InetSocketAddress (port)); Wait for that then the client brings in connection; After connecting completion; Can initiate type is the ChannelStateEvent of CONNECTED, and beginning is in self-defining Pipeline the inside circulation, if the handler of registration has the response method of this incident will call this method so.After this be exactly the transmission of data.
Netty NIO mainly waits for the access of link through a BOSS thread process; Several WORKER threads (from the worker thread pool, select a tax and give the Channel instance, because the Channel instance is held real java network object) are taken over CHANNEL that the BOSS thread submits and are carried out reading and writing data and trigger corresponding event passing to pipeline and carrying out data processing.If the incident of a BlueDrama least significant end such as messageRecieve, possibly just directly finish whole session in certain handler the inside so; And give upper layer application data; But if the incident midway of BlueDrama, such as the connect incident, so when triggering the connect incident; Through the pipeline circulation; Finally can arrive in the lowermost ChannelSink instance of carry pipeline, it is exactly request of sending and reception request that this type instance mainly acts on, and the data write operation.
We have used the abundant buffer technology ByteBuffer of Netty encapsulation.ByteBuffer system externally unified interface is exactly ChannelBuffer, and this interface has overall defined two class methods, and a kind of is similar getXXX (int index ...); SetXXX (int index ...) need specify the original position that begins to operate buffer; Simple point is exactly direct control bottom buffer, does not use the distinctive high reusability buffer characteristic of Netty, and a kind of in addition is similar readXXX (); WriteXXX () does not need the buffer operation of assigned address; These class methods realize being placed on AbstractChannelBuffer, and its main characteristic is exactly to keep the positional information of buffer, comprises readerIndex; WriterIndex; And the markedReaderIndex and the markedWriterIndex that recall effect, when the user called readXXX () or writeXXX () method, AbstractChannelBuffer can be according to the readerIndex that safeguards; WriterIndex calculates and reads the position; Call getXXX (the int index of the ChannelBuffer that inherits oneself then ...) or setXXX (int index ...) the method return results, these class methods are called in Netty inside in a large number, because the maximum benefit of this characteristic is exactly to reuse buffer easily and needn't go to take a lot of trouble to require great effort and safeguard index or newly-built a large amount of ByteBuffer.
We have done one deck encapsulation through the channel system to the java network, have added SEDA characteristic (based on event response, asynchronous, multithreading etc.).Java network api under its final network service still relies on.From the definition of channel, write, bind, connect; Disconnect, unbind, close; Even comprising that methods such as setInterestOps all can return a channelFuture, these these method calls all can trigger the network of relation incident, and in pipeline, circulate.The a lot of method calls of Channel can just not implement the bottom basically, but trigger event takes a round in pipeline at once; Just in channelsink, carry out associative operation at last,, so finally call and to get back among the Channel if relate to network operation; Serversocketchannel just; Socketchannel, serversocket, the primary network api of java such as socket calls.
Netty provides comprehensive and abundant network event type, and it divides the network event among the java for two types of Upstream and Downstream.In general, the incident of Upstream type mainly feeds back to Netty by network bottom layer, such as messageReceived; Incidents such as channelConnected, and the incident of Downstream type is initiated by framework oneself, such as bind; Write, connect, incidents such as close.Implementation is that certain concrete Handler distinguishes through inheriting ChannelUpstreamHandler and ChannelDownstreamHandler class.When PipeLine takes place at the network event of Downstream or Upstream type, can call this calling of Handler response of match event type.ChannelPipeline has kept all handler sequential chained lists; And by handler self control whether continuing to circulate next handler (ctx.sendDownstream (e); Being designed with a benefit like this is exactly to stop circulation at any time, and business purpose reaches and need not to continue to circulate next handler).
4, embodiment
Below be based on netty nio technology and realize the code sample of news general examination diligent pager in school to the server end registration.
PhoneSession has safeguarded the client state information that connects on the current service.
PhoneDecoder mainly is owing to resolve emotional affection phone data packet protocol
PhoneEncoder says that business object converts emotional affection phone data packet protocol into
KeepOnlineMonitor sends heartbeat packet through the client that traversal current service end connects to keep connection.
PhoneServerHandler mainly is that the java object after decode is resolved carries out the operational divisional processing of sending.
Figure BSA00000457373300061
Figure BSA00000457373300081
Figure BSA00000457373300091
For the coding and decoding of request protocol, according to the byte data among the protocol format operation ChannelBuffer.The FrameDecoder internal maintenance DynamicChannelBuffer member store the data that receive, it has been finished writing whole decode procedure template just as individual abstract template, subclass only need realize that the decode function gets final product.
Figure BSA00000457373300101
Figure BSA00000457373300111
Figure BSA00000457373300121
Figure BSA00000457373300131

Claims (2)

1. based on height campus pager terminal verification method concurrent, NETTY NIO asynchronous communication mode; It is the client-service end Socket Communications service of a cover stability and high efficiency; It is characterized in that using unblock formula IO mode to substitute the mode of operation of traditional Socket IO; Solve under the high concurrent client certificate request situation problem of server-side processes efficient.Its method is:
(1) network data of using new buffer Type C hannelBuffer class to store and operate read-write is relied on the own buffer system of NETTY framework, the memory consumption that reduces in the reproduction process to be brought;
(2) in event handling, come control event stream through ChannelPipeline, come processing events through calling a series of ChannelHandler that register on it.Realization is based on process circulation and the whole network event response and the expansion of incident.
(3) process of service end processing request mainly is decoding request, business logic processing, coded responses.
The steps include:
The first step: BootStrap of instantiation, and through ChannelFactory realization of building method appointment
Second step: to ChannelPipelineFactory who oneself realizes of bootstrap instance registration
The 3rd step: bootstrap.bind (new InetSocketAddress (port)); Wait for that then the client brings in connection; After connecting completion; Can initiate type is the ChannelStateEvent of CONNECTED, and beginning is in self-defining Pipeline the inside circulation, if the handler of registration has the response method of this incident will call this method so.After this be exactly the transmission of data.
Under the concurrent situation of height 2. according to claim 1, based on pager terminal, the campus verification technique of NETTY NIO asynchronous communication mode, it is characterized in that realizing the processing of server end network event response process mechanism.Comprise bind->accept->read->write process, when taking place, trigger the pipeline instance that generates when corresponding event is given initialization and handle in each stage of network interaction.Event handling all is that the static method through the Channels class calls beginning; Incident, channel are passed to the Pipeline that channel holds to be handled; The nearly all method of Channels class all is static; The effect (no matter when and where can call its static method in the whole engineering and trigger fixing incident circulation, but itself does not pay close attention to concrete handling process) of a kind of Proxy is provided.
CN2011100705174A 2011-03-23 2011-03-23 Campus information machine terminal authentication method based on asynchronous communication mode Pending CN102694775A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011100705174A CN102694775A (en) 2011-03-23 2011-03-23 Campus information machine terminal authentication method based on asynchronous communication mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011100705174A CN102694775A (en) 2011-03-23 2011-03-23 Campus information machine terminal authentication method based on asynchronous communication mode

Publications (1)

Publication Number Publication Date
CN102694775A true CN102694775A (en) 2012-09-26

Family

ID=46860062

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011100705174A Pending CN102694775A (en) 2011-03-23 2011-03-23 Campus information machine terminal authentication method based on asynchronous communication mode

Country Status (1)

Country Link
CN (1) CN102694775A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108111578A (en) * 2017-11-28 2018-06-01 国电南瑞科技股份有限公司 The method of distribution terminal data acquisition platform access terminal equipment based on NIO
CN108737397A (en) * 2018-05-09 2018-11-02 烽火通信科技股份有限公司 A kind of method for realizing data interaction between business and protocol stack in router
CN112202927A (en) * 2020-11-13 2021-01-08 深圳市和讯华谷信息技术有限公司 Long connection establishing method and device, computer equipment and storage medium
CN112559146A (en) * 2020-12-07 2021-03-26 河南中烟工业有限责任公司 Communication method between client and data terminal server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
GUIDEJBOSS.ORG: "The Netty Project 3.1 User Guide", 《HTTP://DOCS.JBOSS.ORG/NETTY/3.1/DUIDE/》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108111578A (en) * 2017-11-28 2018-06-01 国电南瑞科技股份有限公司 The method of distribution terminal data acquisition platform access terminal equipment based on NIO
CN108737397A (en) * 2018-05-09 2018-11-02 烽火通信科技股份有限公司 A kind of method for realizing data interaction between business and protocol stack in router
CN108737397B (en) * 2018-05-09 2021-02-02 烽火通信科技股份有限公司 Method for realizing data interaction between service and protocol stack in router
CN112202927A (en) * 2020-11-13 2021-01-08 深圳市和讯华谷信息技术有限公司 Long connection establishing method and device, computer equipment and storage medium
CN112202927B (en) * 2020-11-13 2023-01-10 深圳市和讯华谷信息技术有限公司 Long connection establishing method and device, computer equipment and storage medium
CN112559146A (en) * 2020-12-07 2021-03-26 河南中烟工业有限责任公司 Communication method between client and data terminal server
CN112559146B (en) * 2020-12-07 2023-04-18 河南中烟工业有限责任公司 Communication method between client and data terminal server

Similar Documents

Publication Publication Date Title
CN107222645B (en) A kind of method and system of workflow access
CN106303359A (en) The processing method of a kind of network conversion and equipment
US9749072B2 (en) End point parameterization management of generic devices
CN105072297B (en) The speech-sound intelligent adapting system of call center
CN103269344A (en) Pure IP calling system based on a cloud computing platform and IMS network architecture
CN108073402A (en) Kafka clusters automatic deployment method and device based on linux system
CN104144202B (en) Access method, system and the device of Hadoop distributed file system
CN104660997B (en) Service-oriented multi-source heterogeneous video monitoring adaptation method and system
CN103139157A (en) Network communication method based on socket, device and system
CN106528272B (en) A kind of data processing equipment, method and terminal
CN102694775A (en) Campus information machine terminal authentication method based on asynchronous communication mode
US20170034311A1 (en) Method for selecting between multiple RPC frameworks during a TCP/IP session
CN101001290A (en) System for multi-media integrated accessing
CN113382033B (en) Central control adaptation method, device, equipment and storage medium
CN104835004A (en) Guest room information management method and system
CN102299849B (en) Service capability calling system and method
CN102932484B (en) IOT (Internet of Things) operation billing middleware system aiming at accounting system of telecom operator
CN104796328B (en) The gateway host of the data communication equipment of multiplex roles or agreement based on KNX/EIB buses
CN101902455A (en) Open multimedia conference service system and implementing method thereof
CN101959143B (en) Method for selectively recording during group calling of dispatching desk in digital trunking system
CN110532305A (en) A kind of business datum method for cutting over and system
CN102833357A (en) Interface platform communicating with third party
CN108880831A (en) A kind of apparatus for processing multimedia data and method
CN113553048A (en) Low-code fusion communication integrated system
CN111711672A (en) Big data sharing method and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20120926