WO2012109915A1 - 一种保存话务数据的方法及系统 - Google Patents

一种保存话务数据的方法及系统 Download PDF

Info

Publication number
WO2012109915A1
WO2012109915A1 PCT/CN2011/081262 CN2011081262W WO2012109915A1 WO 2012109915 A1 WO2012109915 A1 WO 2012109915A1 CN 2011081262 W CN2011081262 W CN 2011081262W WO 2012109915 A1 WO2012109915 A1 WO 2012109915A1
Authority
WO
WIPO (PCT)
Prior art keywords
traffic data
temporary file
instant
instant traffic
parsed
Prior art date
Application number
PCT/CN2011/081262
Other languages
English (en)
French (fr)
Inventor
鲁胜虎
詹荣国
范畅
吴春明
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012109915A1 publication Critical patent/WO2012109915A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M3/00Automatic or semi-automatic exchanges
    • H04M3/22Arrangements for supervision, monitoring or testing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M15/00Arrangements for metering, time-control or time indication ; Metering, charging or billing arrangements for voice wireline or wireless communications, e.g. VoIP
    • H04M15/58Arrangements for metering, time-control or time indication ; Metering, charging or billing arrangements for voice wireline or wireless communications, e.g. VoIP based on statistics of usage or network monitoring

Definitions

  • the present invention relates to a method and system for saving traffic data in a Java environment. Background technique
  • Instant traffic statistics is an important tool for field service personnel and testers. It can instantly and intuitively reflect the traffic conditions in the switch system and the reasons for the failure of call loss.
  • Call loss is a situation in which calls can't be connected in soft handsover. There are many reasons for call loss: business, data, protocols, and so on.
  • the size of the call loss affects the calculation of the softswitch network management connection rate, and the connection rate indicator is an important evaluation indicator of the softswitch. As a result, field, test, and developer often need to analyze the cause of the call loss and resolve the failure of the call to continue.
  • the instant traffic statistics are reported to the background network management system by the front-end service system after the call ends.
  • the network management system displays the operation on the operation and maintenance interface.
  • the information displayed on these interfaces will be of great help to field personnel and test personnel to troubleshoot and solve problems in the first place.
  • due to the large amount of tracking traffic it has a certain impact on system performance.
  • the impact on the system is very large, so the instant traffic is not written into the database, only processed in the memory, the interface displays The data is also limited. But sometimes, in order to analyze the positioning problem, the site needs to save the data for the most recent period of time. Through the network management system, you can save real-time traffic data to disk files.
  • the technical problem to be solved by the present invention is to provide a method and system for storing traffic data in a Java environment, so as to achieve high efficiency in occupying small memory and writing traffic data in most of the operation of the network management system.
  • the present invention provides a method for saving traffic data, including: after receiving the instant traffic data, the network management system writes the instant traffic data into a non-formatted temporary file on the hard disk.
  • the parsed instant traffic data is stored in a corresponding format.
  • the step of the network management system writing the instant traffic data to the unformatted temporary file includes:
  • the network management system writes the instant transaction data to the temporary file using a cached file output stream class in the Java standard class library.
  • the foregoing method further has the following features: after the network management system reads and parses the instant traffic data from the temporary file, the step of storing the parsed instant traffic data in a corresponding format includes:
  • the network management system determines that the number of the instant traffic data recorded in the first temporary file exceeds the preset maximum number of records N, reads and parses the instant in the order of recording time in units of N pieces of instant traffic data. Traffic data.
  • the foregoing method further has the following features: after the network management system reads and parses the instant traffic data from the temporary file, the step of storing the parsed instant traffic data in a corresponding format further includes:
  • the network management system determines that the number of unread real-time traffic data in the first temporary file is less than N, creating a second temporary file, and writing the received instant traffic data into the second temporary Document
  • the recording time sequence reads and parses the instant traffic data from the first temporary file and the second temporary file, and stores the parsed instant traffic data in a corresponding format.
  • the foregoing method further has the following features: after the network management system reads and parses the instant traffic data from the temporary file, the step of storing the parsed instant traffic data in a corresponding format further includes:
  • the network management system determines that the predetermined time has elapsed, it reads and parses all the instant traffic data in the temporary file, and stores the parsed instant traffic data in a corresponding format.
  • the present invention further provides a system for saving traffic data, comprising: a data receiving device, configured to write the instant traffic data into a hard disk without formatting after receiving the instant traffic data Temporary documents;
  • the background writing device is configured to store the parsed instant traffic data in a corresponding format after reading and parsing the instant traffic data from the temporary file.
  • the above system also has the following features: After receiving the instant traffic data, the data receiving device writes the instant traffic data into the temporary file by using a cached file output stream class in the Java standard class library.
  • the background writing device includes:
  • a judging unit configured to determine whether the number of real-time traffic data recorded in the first temporary file exceeds a preset maximum number of records N;
  • a writing unit configured to read and parse the instant traffic data in units of N pieces of instant traffic data in units of N pieces of instant traffic data, and to parse the instants in the case where the determining unit determines that the value exceeds N Traffic data is stored in the appropriate format.
  • the background writing device further includes: a creating unit, wherein the determining unit is further configured to determine whether the number of unread real-time traffic data in the first temporary file is less than N ;
  • the creating unit is configured to: when the determining unit determines that the number of the unregistered instant traffic data in the first temporary file is less than N, create the instant traffic data received after the writing Second temporary document; The determining unit is further configured to: determine whether the total number of unregistered instant traffic data in the first temporary file and the total number of recorded instant traffic data in the second temporary file exceeds
  • the writing unit is further configured to, when the determining unit determines that the total number of pieces exceeds N, from the first temporary file and the second in order of recording time in units of N pieces of real-time traffic data
  • the instant traffic data is read and parsed in the temporary file, and the parsed instant traffic data is stored in a corresponding format.
  • the above system also has the following features:
  • the determining unit is further configured to determine whether a predetermined time is reached
  • the writing unit is further configured to: when the determining unit determines that the predetermined time has arrived, read and parse all the instant traffic data in the temporary file, and press the parsed instant traffic data according to the corresponding The format is stored.
  • the above method and system for saving traffic data has the following advantages: By writing instant traffic data into a common unformatted text file, it can ensure that the network management system is efficient and low in memory during the instant traffic observation time. Instant traffic data is saved without loss. Make the network management system better adapt to the situation of large traffic; use the standard Java API with cached write files, without requiring users to write cache code, improve software development efficiency and code quality; only at individual time points ( Waiting time is up, the number of records exceeds the maximum recorded data; the end of the observation time) writes the file, and the large amount of memory is only instantaneous. After the file is written, the large amount of memory occupied can be immediately recovered by the garbage collector.
  • FIG. 1 is a flowchart of a method for saving traffic data according to the present invention
  • FIG. 2 is a flowchart of operation of a data receiving thread according to an embodiment of the present invention
  • 3 is a flowchart of operation of a background write thread according to an embodiment of the present invention
  • 4 is a schematic diagram of a system for saving traffic data according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a method for saving traffic data according to an embodiment of the present invention, which mainly includes the following steps:
  • Step S10 After receiving the instant traffic data, the network management system writes the instant traffic data into an unformatted temporary file on the hard disk;
  • Step S20 After the network management system reads and parses the instant traffic data from the temporary file, the parsed instant traffic data is stored in a corresponding format.
  • the invention directly stores the instant traffic data in the unformatted temporary file, and ensures that the memory usage of the network management system is small and the instant traffic data is efficiently written without loss in the instant traffic observation time.
  • step S10 after receiving the instant traffic data, the network management system can use the cached file output stream class (BufferedWriter) in the Java standard class library to write the instant traffic data into the temporary file.
  • BufferedWriter the cached file output stream class
  • the user does not need to write the cache code, which improves the software development efficiency and the code quality.
  • step S20 if the network management system determines that the number of real-time traffic data recorded in the first temporary file exceeds the preset maximum number of records N, the N-time real-time traffic data is read in units of recording time. And parsing the real-time traffic data, and storing the parsed instant traffic data in a corresponding format.
  • the network management system may further determine whether the number of unread instant traffic data in the first temporary file is less than N, and if not, create a new temporary file (second temporary file). In this way, the received instant traffic data can be written into the second temporary file.
  • the network management system determines that the total number of unregistered instant traffic data in the first temporary file and the total number of recorded instantaneous traffic data in the second temporary file exceeds N, then The pieces of real-time traffic data are in units, from the first temporary file and the second temporary in order of recording time The instant traffic data is read and parsed in the file, and the parsed instant traffic data is stored in a corresponding format.
  • This embodiment can use multiple temporary files to write real-time traffic data, which can prevent a single temporary file from being too large.
  • the background write thread cycle starts, the background write thread will determine whether the temporary file reaches the number of records written in the Excel file. If it is exceeded, it will start to write Excel file. Although the number of records has been written into Excel, it is still stored in the temporary file. After each judgment, the temporary file data is read, and the data is read sequentially. The single temporary file is too large. Generate unnecessary disk input and output (10), affecting performance.
  • the network management system may further determine whether the predetermined time is reached, and may only read and parse the instant traffic data in the temporary file only after the predetermined time is reached, and the parsed instant traffic will be parsed.
  • the data is stored in the appropriate format.
  • the temporary file in the embodiment of the present invention may be a text file, a binary file, or the like.
  • the parsed instant traffic data can be written into the database, and the data can be used.
  • the observation time of the instant traffic is saved; a data receiving thread is opened, including a file write stream encapsulated by a BufferedWriter of the ordinary text file, and the buffer specified by the BufferedWriter is, for example, 8 kb; Write the thread, its maximum running time is the observation time, immediately enter the wait state, and set the maximum waiting time.
  • the waiting time is up, the background writing thread is woken up to refresh the buffer specified by the BufferedWriter. It can be configured according to actual needs, such as 5s or lmin, or automatically adjusted according to the amount of data.
  • FIG. 2 is a flowchart of operation of a data receiving thread according to an embodiment of the present invention, and the implementation process thereof is described in detail as follows:
  • Step 101 After the network element counts the instant traffic data, send the instant traffic data to the network management system.
  • the instant traffic data is sent to the network management system, but the number is not saved. According to.
  • Step 102 The network management system displays the instant traffic data, and simultaneously calls the data receiving thread to write a temporary file;
  • Step 103 The data receiving thread counts the number of records of the instant traffic data, and the counter for recording the number of the instant traffic data is incremented by one;
  • Step 104 Using BufferedWriter in the data receiving thread to add the real-time traffic data to the temporary file output stream.
  • the receiving thread processes the data, assembles the real-time traffic data into a character string in a prescribed format, and writes the character string into the temporary file output stream, but does not refresh the BufferedWriter to prevent the frequent disk 10.
  • the data in the cache specified by BufferedWriter needs to be refreshed by the background write thread into the temporary file.
  • the instant traffic data is added to the specified cache, or the file is written only after the specified cache is full, so that the writing process can be quickly ended, so that the instant traffic data is saved to the network management system.
  • Performance and memory impact are minimized. Comparing the situation when the network management system does not save the real-time traffic data, the maximum increment of memory is 8kb of the size of the cache.
  • the existence of the cache minimizes the number of I/Os (input/output), and the efficiency of the ordinary text file output stream is better than that of java.
  • the excel API is much higher, so that the processing of saving data minimizes the impact on the performance of the network management system.
  • FIG. 3 is a flowchart of running a background write thread according to an embodiment of the present invention, and the implementation process thereof is described in detail as follows:
  • Step 201 After the network management system defines that the instant traffic task is successful, the background write thread is started; the background write thread is responsible for writing the instant traffic data in the specified cache to the text file; and is also responsible for reading and parsing the text file.
  • the data is generated in an Excel file.
  • Step 202 The background write thread enters a wait state.
  • the background write thread calls the wait method of the thread, so that the thread itself enters the wait state, and sets a wait maximum timeout period to ensure that the data in the specified cache can be written into the file in time, after the observation time is over, Timely detection by the background write thread.
  • Step 203 Waiting time is up, the background writing thread ends the waiting state;
  • Step 204 The background write thread refreshes the specified cache.
  • the background write thread writes the real-time traffic data in the specified cache to the text file.
  • the amount of instant traffic data arriving may be large at some point, and some time may not have real-time traffic data, and the background write thread will wait for the arrival time to arrive.
  • the instant traffic data in the specified cache is refreshed and written to the text file, so that in the case of a large amount of data, a large amount of CPU resources are not taken up, and the number of I/Os is further reduced.
  • Step 205 The background write thread determines whether the number of records of the instant traffic data in the text file reaches a preset maximum number of records (for example, a maximum number of records of an Excel file) (for example, 20,000), and if so, Go to step 206; otherwise, go directly to step 207.
  • a preset maximum number of records for example, a maximum number of records of an Excel file
  • Step 206 Read the real-time traffic data in the text file, and write the Excel file; read the real-time traffic data in the text file according to the number of statistical records, and parse and restore the original instant traffic data structure. Call the Java Excel API to write instant traffic data to an Excel file.
  • the background write thread determines that the number of records of the current traffic data in the current text file reaches the preset maximum number of records, the file is read and parsed in the order of recording time. The same number of real-time traffic data is written into the Excel file, and the background writing thread writes the instant traffic data parsed each time into an Excel file.
  • the background write thread determines that the number of unread real-time traffic data in the current text file is less than the maximum number of records
  • the used text file is switched to another text file, and the new BufferedWriter is also replaced, and the next reception is performed.
  • the data thread After receiving the data, the data thread writes the instant traffic data into the switched new text file, and then determines the number of unread instant traffic data in the previous text file and the instant message recorded in the new text file.
  • the background write thread determines that the number of unread real-time traffic data in the new text file is less than the maximum number of records, then switches to the previous text file or another text file, if switching to the previous text In the file, it is written from the beginning, overwriting the original data.
  • Step 207 The background write thread determines the observation time, and determines whether the instant traffic observation ends according to the current time. If the observation time has not expired, the process returns to step 202; if the observation time is up, the process proceeds to step 208.
  • Step 208 Read the real-time traffic data in the current text file, and write the Excel file.
  • Step 209 The background write thread ends the operation.
  • the present invention also provides a system for storing traffic data.
  • the system of the embodiment is a network management system, and includes: a data receiving device and a background writing device, where
  • the data receiving device 401 is configured to: after receiving the real-time traffic data, write the instant traffic data into an unformatted temporary file on the hard disk;
  • the background writing device 402 is configured to store the parsed instant traffic data in a corresponding format after reading and parsing the instant traffic data from the temporary file.
  • the data receiving device after receiving the instant traffic data, writes the instant traffic data into the temporary file by using a cached file output stream class in the Java standard class library.
  • the background writing device includes:
  • a judging unit configured to: determine whether the number of real-time traffic data recorded in the first temporary file exceeds a preset maximum number of records N;
  • the writing unit is configured to: when the determining unit determines that the value exceeds N, the N pieces of real-time traffic data are read and parsed in the order of recording time, and the parsed instant traffic data is stored in a corresponding format.
  • the background writing device may further include: a creating unit, wherein
  • the determining unit is further configured to: determine whether the number of unread real-time traffic data in the first temporary file is less than N; and determine the number of instant traffic data that is not read in the first temporary file Whether the total number of pieces of real-time traffic data recorded in the second temporary file exceeds N;
  • the creating unit is configured to: when the determining unit determines that the number of unread real-time traffic data in the first temporary file is less than N, creating a second temporary file;
  • the writing unit is further configured to: when the determining unit determines that the total number of strips exceeds N, read and parse N pieces from the first temporary file and the second temporary file in order of recording time
  • the instant traffic data stores the parsed instant traffic data in a corresponding format.
  • the determining unit is further configured to: determine whether a predetermined time is reached; and the writing unit is further configured to: when the determining unit determines that the predetermined time is reached, read and analyze the The instant traffic data in the temporary file stores the parsed instant traffic data in a corresponding format.
  • the foregoing method and system for saving traffic data have the following advantages: By writing instant traffic data into a common unformatted text file, it can ensure that the network management system is high-efficiency and low-cost most of the time in the instant traffic observation time. Instant traffic data is saved without loss. Make the network management system better adapt to the situation of large traffic; use the standard Java API with cached write files, without requiring users to write cache code, improve software development efficiency and code quality; only at individual time points ( Waiting time is up, the number of records exceeds the maximum recorded data; the end of the observation time) writes the file, and the large amount of memory is only instantaneous. After the file is written, the large amount of memory occupied can be immediately recovered by the garbage collector.

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明提供一种保存话务数据的方法及网管系统,该方法包括:网管系统接收到即时话务数据后,将所述即时话务数据写入硬盘中无格式的临时文件,从所述临时文件读取并解析所述即时话务数据后,将解析出的即时话务数据按相应的格式进行存储。该网管系统包括:数据接收装置,用于接收到即时话务数据后,将所述即时话务数据写入硬盘中无格式的临时文件;后台写入装置,用于从所述临时文件读取并解析所述即时话务数据后,将解析出的即时话务数据按相应的格式进行存储。根据本发明可以实现在网管系统运行的大部分时间内占用内存小、写入话务数据的效率高。

Description

一种保存话务数据的方法及系统
技术领域
本发明涉及一种 Java环境中保存话务数据的方法及系统。 背景技术
即时话务统计是现场用服人员和测试人员的重要工具, 其可以即时、 直 观的反映交换机系统中的话务情况, 以及呼损的失败原因。 呼损是引起软交 换中呼叫无法接续的情况, 造成呼损的原因很多: 业务、 数据、 协议等等。 呼损的大小影响软交换网管接通率的计算, 而接通率指标是软交换的一项重 要的评测指标。 因此, 现场、 测试和开发人员常常需要分析呼损原因, 解决 呼叫无法接续的故障。
即时话务统计一般在通话结束后由前台业务系统上报给后台网管系统, 由网管在操作维护界面上显示出来。 这些界面上显示的信息, 对于现场人员 和测试人员第一时间排查故障、 解决问题将会有很大的帮助。 但由于跟踪话 务量大, 对系统性能产生一定影响, 特别是大话务量情况下, 对系统的影响 非常大, 因而即时话务并不写入数据库, 只在内存中进行处理, 界面显示的 数据也有限制。 但有时, 现场为了分析定位问题, 需要保存最近一段时间的 数据。 通过网管系统, 可以保存即时话务数据到磁盘文件, 这些磁盘文件一 般都具有各自相应的格式, 可能影响数据的写入速度。 例如把这些数据保存 到 Excel格式文件中, 利用 Excel的功能, 比把数据保存到普通的文本文件中 更容易分析、 使用。 目前较成熟的开源项目 POI和 JXL都实现了 Excel格式 文件的导入导出, 但都需要把所有内容读入内存再写入文件, 占用内存量大, 读写效率也比普通文本差很多。 即时话务数据输出是一种在观察时间内持续 输出的数据流, 持续时间为几个小时甚至几天, 内存中设置的緩冲区如果太 大, 会导致系统内存居高不下, 如果太小, 需要频繁的写文件, 而且随着数 据的增多, 使用以上 Java Excel API ( Application Programming Interface , 应用 程序编程接口)写 Excel文件更耗时, 尤其是在大话务量的情况下, 可能导 致数据緩存队列溢出、 数据丟失。 发明内容
本发明要解决的技术问题是提供一种 Java环境中保存话务数据的方法及 系统, 以实现在网管系统运行的大部分时间内占用内存小、 写入话务数据的 效率高。
为了解决上述技术问题, 本发明提供了一种保存话务数据的方法, 包括: 网管系统接收到即时话务数据后, 将所述即时话务数据写入硬盘中无格 式的临时文件,
从所述临时文件读取并解析所述即时话务数据后, 将解析出的即时话务 数据按相应的格式进行存储。
上述方法还具有下面特点: 所述网管系统将所述即时话务数据写入无格 式的临时文件的步骤包括:
所述网管系统使用 Java标准类库中带緩存的文件输出流类将所述即时话 务数据写入所述临时文件。 上述方法还具有下面特点: 所述网管系统从所述临时文件读取并解析所 述即时话务数据后, 将解析出的即时话务数据按相应的格式进行存储的步骤 包括:
所述网管系统若判断第一临时文件中记录的即时话务数据条数超过预设 的最大记录数 N, 则以 N条即时话务数据为单位, 按记录时间顺序读取并解 析所述即时话务数据。
上述方法还具有下面特点: 所述网管系统从所述临时文件读取并解析所 述即时话务数据后, 将解析出的即时话务数据按相应的格式进行存储的步骤 还包括:
所述网管系统若判断所述第一临时文件中未读取的即时话务数据的条数 小于 N, 则创建第二临时文件, 将之后接收到的即时话务数据写入所述第二 临时文件;
若判断所述第一临时文件中未读取的即时话务数据与所述第二临时文件 中记录的即时话务数据的总条数超过 N, 则以 N条即时话务数据为单位, 按 记录时间顺序从所述第一临时文件和所述第二临时文件中读取并解析所述即 时话务数据, 将该解析出的即时话务数据按相应的格式进行存储。
上述方法还具有下面特点: 所述网管系统从所述临时文件读取并解析所 述即时话务数据后, 将解析出的即时话务数据按相应的格式进行存储的步骤 还包括:
所述网管系统若判断达到预定时间, 则读取并解析所述临时文件中所有 的即时话务数据, 将该解析出的即时话务数据按相应的格式进行存储。
为了解决上述问题, 本发明还提供了一种保存话务数据的系统, 包括: 数据接收装置, 其设置为接收到即时话务数据后, 将所述即时话务数据 写入硬盘中无格式的临时文件; 以及
后台写入装置, 其设置为从所述临时文件读取并解析所述即时话务数据 后, 将解析出的即时话务数据按相应的格式进行存储。
上述系统还具有下面特点: 所述数据接收装置接收到即时话务数据后, 是通过使用 Java标准类库中带緩存的文件输出流类将所述即时话务数据写入 所述临时文件的。
上述系统还具有下面特点: 所述后台写入装置包括:
判断单元, 其设置为判断第一临时文件中记录的即时话务数据条数是否 超过预设的最大记录数 N; 以及
写入单元, 其设置为在所述判断单元判断超过 N的情况下, 以 N条即时 话务数据为单位, 按记录时间顺序读取并解析所述即时话务数据, 将该解析 出的即时话务数据按相应的格式进行存储。
上述系统还具有下面特点: 所述后台写入装置还包括: 创建单元, 其中, 所述判断单元, 还设置为判断所述第一临时文件中未读取的即时话务数 据条数是否小于 N;
所述创建单元, 设置为在所述判断单元判断所述第一临时文件中未读取 的即时话务数据条数小于 N的情况下, 创建用于写入之后接收到的即时话务 数据的第二临时文件; 所述判断单元还设置为: 判断所述第一临时文件中未读取的即时话务数 据条数与所述第二临时文件中已记录的即时话务数据条数的总条数是否超过
N;
所述写入单元, 还设置为在所述判断单元判断总条数超过 N的情况下, 以 N条即时话务数据为单位, 按记录时间顺序从所述第一临时文件和所述第 二临时文件中读取并解析所述即时话务数据, 将该解析出的即时话务数据按 相应的格式进行存储。
上述系统还具有下面特点:
所述判断单元, 还设置为判断是否到达预定时间;
所述写入单元, 还设置为在所述判断单元判断到达预定时间的情况下, 读取并解析所述临时文件中所有的即时话务数据, 将该解析出的即时话务数 据按相应的格式进行存储。
上述保存话务数据的方法及系统, 具有以下优点: 通过写即时话务数据 入普通的无格式的文本文件, 可以保证在即时话务观察时间内, 大多数时间 网管系统是高效率、 低内存、 无丟失的保存了即时话务数据。 使得网管系统 能够更好的适应大话务量的情况; 使用标准的 Java API带有緩存的写文件, 不需要用户编写緩存代码, 提高了软件的开发效率和代码质量; 只是在个别 时间点 (等待时间到, 记录数超过最大记录数据; 观察时间结束)写文件, 对内存的大量占用只是瞬时的, 写文件结束后, 占用的大量内存可以立即被 垃圾回收器回收。
附图概述
附图用来提供对本发明的进一步理解, 并且构成说明书的一部分, 用于 解释本发明, 并不构成对本发明的限制。 在附图中:
图 1为本发明提供的一种保存话务数据的方法的流程图;
图 2为本发明实施例的数据接收线程的运行流程图;
图 3为本发明实施例的后台写入线程的运行流程图; 图 4为本发明实施例的保存话务数据的系统的示意图。
本发明的较佳实施方式
下文中将结合附图对本发明的实施例进行详细说明。 需要说明的是, 在 不冲突的情况下, 本申请中的实施例及实施例中的特征可以相互任意组合。
图 1为本发明实施方式提供的一种保存话务数据的方法的流程图, 主要 包括下面步骤:
步骤 S10、 网管系统接收到即时话务数据后, 将所述即时话务数据写入 硬盘中无格式的临时文件;
步骤 S20、 网管系统从所述临时文件读取并解析所述即时话务数据后, 将解析出的即时话务数据按相应的格式进行存储。
本发明直接将即时话务数据存储在无格式的临时文件, 可以保证在即时 话务观察时间内, 网管系统的内存占用小、 即时话务数据高效率写入且无丟 失。
在步骤 S10中, 网管系统接收到即时话务数据后, 可以使用 Java标准类 库中带緩存的文件输出流类 ( BufferedWriter )将所述即时话务数据写入临时 文件。 通过使用标准的 Java API的 BufferedWriter来写入所述即时话务数据, 不需要用户编写緩存代码, 提高了软件的开发效率和代码质量。
在步骤 S20中、 网管系统若判断所述第一临时文件中记录的即时话务数 据条数超过预设的最大记录数 N, 则以 N条即时话务数据为单位, 按记录时 间顺序读取并解析即时话务数据, 将该解析出的即时话务数据按相应的格式 进行存储。
在一优选实施例中, 所述网管系统可以进一步判断所述第一临时文件中 未读取的即时话务数据条数是否小于 N, 若小于, 则创建新的临时文件(第 二临时文件), 这样可以将接收到的即时话务数据写入所述第二临时文件中。
所述网管系统若判断所述第一临时文件中未读取的即时话务数据条数与 所述第二临时文件中已记录的即时话务数据条数的总条数超过 N, 则以 N条 即时话务数据为单位, 按记录时间顺序从所述第一临时文件和所述第二临时 文件中读取并解析所述即时话务数据, 将该解析出的即时话务数据按相应的 格式进行存储。
该实施例可以釆用多个临时文件来写即时话务数据, 可以防止单个临时 文件太大, 在后台写入线程周期启动时, 后台写入线程将判断临时文件是否 达到写 Excel文件的记录数, 如果超过, 则开始写 Excel文件, 虽然这批记录 数已经写入 Excel, 但仍然存放在临时文件中, 之后的每次判断读取临时文件 数据, 都顺序读这些数据, 单个临时文件太大将产生不必要的磁盘输入输出 ( 10 ) , 影响性能。
在另一优选实施例中, 网管系统可以进一步判断是否达到预定时间, 可 以是仅在达到预定时间,才进行读取并解析所述临时文件中的即时话务数据 , 将解析出的即时话务数据按相应的格式进行存储。
本发明实施例中的临时文件可以是文本文件、 二进制文件等。
本发明实施例中的可以将解析出的即时话务数据写入数据库、 可以用
Excel、 PDF格式进行存储。
为了更好地理解本发明, 下面结合附图和具体实施例对本发明作进一步 地描述。
首先, 网管系统定义即时话务任务后, 保存即时话务的观察时间; 打开 一个数据接收线程, 包括普通文本文件的 BufferedWriter封装的文件写入流, 该 BufferedWriter指定的緩存例如为 8kb; 启动一个后台写入线程, 其最大运 行时间为观察时间, 立即进入 wait (等待)状态, 并设置最大的等待时间, 等待时间一到即唤醒后台写入线程, 以刷新所述 BufferedWriter指定的緩存, 该等待时间可根据实际需要进行配置, 如 5s或 lmin等, 或根据数据量的情 况自动调整。
图 2为本发明实施例的数据接收线程的运行流程图, 对其实现流程详细 描述如下:
步骤 101、 网元统计到即时话务数据后, 给网管系统发送所述即时话务 数据;
网元统计到即时话务后, 将即时话务数据发送给网管系统, 但不保存数 据。
步骤 102、 网管系统显示该即时话务数据, 同时调用数据接收线程写临 时文件;
步骤 103、 数据接收线程统计即时话务数据的记录数, 记录即时话务数 据个数的计数器加 1 ;
步骤 104、 在数据接收线程中使用 BufferedWriter把即时话务数据加入临 时文件输出流中。
具体地, 接收线程处理数据, 把即时话务数据按规定的格式组装成字符 串, 再把字符串写入临时文件输出流中, 但不刷新 BufferedWriter, 以防止频 繁的磁盘 10。
BufferedWriter指定的緩存中的数据需要由后台写入线程负责刷新到临 时文件中。
在该流程中, 只是把即时话务数据添加到指定緩存中, 或只在指定緩存 满后才写入文件, 这样写流程可以很快的结束, 从而使即时话务数据的保存 对网管系统的性能、 内存影响达到最小。 对比网管系统不保存即时话务数据 时的情况, 内存最大增量为緩存的大小 8kb,緩存的存在使得 I/O (输入 /输出 ) 的次数最小化, 而普通文本文件输出流的效率比 java excel API高很多, 从而 使得保存数据的处理对网管系统性能影响最小化。
图 3为本发明实施例的后台写入线程的运行流程图, 对其实现流程详细 描述如下:
步骤 201、 网管系统定义即时话务任务成功后, 启动后台写入线程; 后台写入线程负责把上述指定緩存中的即时话务数据写入到文本文件 中; 也负责读取、 解析文本文件中的数据, 生成 Excel文件。
步骤 202、 后台写入线程进入等待状态;
后台写入线程调用该线程的等待方法, 使该线程自身进入等待状态, 同 时设置一个等待最大超时时间, 以保证所述指定緩存中的数据可以及时地写 入文件, 在观察时间结束后, 可以及时的被后台写入线程检测到。
步骤 203、 等待时间到, 后台写入线程结束等待状态; 步骤 204、 后台写入线程刷新所述指定緩存;
具体地, 后台写入线程把所述指定緩存中的即时话务数据, 写入到文本 文件中。 因考虑到在即时话务观察时间内, 某一时刻, 到达的即时话务数据 量可能很大, 而有些时间可能没有即时话务数据, 后台写入线程在等待时间 到达后, 再将所述指定緩存中的即时话务数据刷新写入文本文件, 这样在大 数据量的情况, 就不会占用大量 CPU资源, 进一步减小 I/O的次数。
步骤 205、 后台写入线程判断所述文本文件中即时话务数据的记录数是 否到达预设的最大记录数(例如, 一个 Excel文件的最大记录数) (例如, 2 万条) , 若是, 则进入步骤 206; 否则, 直接进入步骤 207。
步骤 206、 读取所述文本文件中的即时话务数据, 写入 Excel文件; 根据统计的记录数, 读取文本文件中的即时话务数据, 解析、 还原为原 来的即时话务数据结构, 调用 Java Excel API把即时话务数据写入到 Excel文 件中。
如果记录数太多, 可以分多个 Excel文件分别写入, 记录已经写入的数 据条数。更换文本文件,之后的即时话务数据写入新的文本文件,再次写 Excel 文件时, 根据记录的已写条数, 判断读取上一个文本文件中剩余的记录数, 与新文本文件中的数据一起写 Excel文件。
例如, 本实施例中可以有两个文本文件, 后台写入线程若判断当前文本 文件中即时话务数据的记录数达到预设的最大记录数, 则按记录时间顺序读 取并解析与最大记录数同数目条数的即时话务数据, 将该解析出的即时话务 数据写入一 Excel文件, 后台写入线程将每次解析出的即时话务数据分别写 入一 Excel文件。
当后台写入线程判断当前文本文件中未读取的即时话务数据的条数小于 所述最大记录数, 则使用的文本文件切换到另一个文本文件, 同时也更换新 的 BufferedWriter, 在下次接收数据线程接收到数据后, 将即时话务数据写入 切换后的新的文本文件中, 然后判断上一个文本文件中未读取的即时话务数 据条数与新的文本文件中记录的即时话务数据条数的总条数是否超过所述最 大记录数, 若超过, 则按记录时间顺序从上一个文本文件和新文本文件中读 取并解析与最大记录数同数目条数的的即时话务数据, 调用 Java Excel API 将该解析出的即时话务数据写入新的 Excel文件。
若后台写入线程判断该新的文本文件中未读取的即时话务数据的条数小 于所述最大记录数, 则再切换到上一个文本文件或另一个文本文件, 若切换 到上一个文本文件中, 则从头开始写, 覆盖原有的数据。
步骤 207、 后台写入线程判断观察时间, 根据当前的时间, 判断即时话 务观察是否结束, 如果观察时间未到, 则重返步骤 202; 如果观察时间到, 进入步骤 208。
步骤 208、 读取当前文本文件中的即时话务数据, 写入 Excel文件。
读取所述文本文件中的数据, 不需要判断, 全部写入到 Excel文件中。 步骤 209、 后台写入线程结束运行。
本发明还提供一种保存话务数据的系统, 如图 4所示, 本实施例的系统 为网管系统, 包括: 数据接收装置和后台写入装置, 其中,
数据接收装置 401 , 用于接收到即时话务数据后, 将所述即时话务数据 写入硬盘中无格式的临时文件;
后台写入装置 402 , 用于从所述临时文件读取并解析所述即时话务数据 后, 将解析出的即时话务数据按相应的格式进行存储。
在一优选实施例中, 所述数据接收装置接收到即时话务数据后, 是通过 使用 Java标准类库中带緩存的文件输出流类将所述即时话务数据写入所述临 时文件的。
在一优选实施例中, 所述后台写入装置包括:
判断单元, 设置为: 判断所述第一临时文件中记录的即时话务数据条数 是否超过预设的最大记录数 N;
写入单元, 设置为: 在所述判断单元判断超过 N的情况下, 按记录时间 顺序读取并解析 N条即时话务数据, 将该解析出的即时话务数据按相应的格 式进行存储。 所述后台写入装置还可以包括: 创建单元, 其中,
所述判断单元, 还设置为: 判断所述第一临时文件中未读取的即时话务 数据条数是否小于 N; 以及判断所述第一临时文件中未读取的即时话务数据 条数与所述第二临时文件中已记录的即时话务数据条数的总条数是否超过 N;
所述创建单元, 设置为: 在所述判断单元判断所述第一临时文件中未读 取的即时话务数据条数小于 N的情况下, 创建第二临时文件;
所述写入单元,还设置为:在所述判断单元判断总条数超过 N的情况下, 按记录时间顺序从所述第一临时文件和所述第二临时文件中读取并解析 N条 即时话务数据, 将该解析出的即时话务数据按相应的格式进行存储。
在一优选实施例中, 所述判断单元, 还设置为: 判断是否到达预定时间; 所述写入单元,还设置为: 在所述判断单元判断到达预定时间的情况下, 读取并解析所述临时文件中的即时话务数据, 将该解析出的即时话务数据按 相应的格式进行存储。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序 来指令相关硬件完成, 所述程序可以存储于计算机可读存储介质中, 如只读 存储器、 磁盘或光盘等。 可选地, 上述实施例的全部或部分步骤也可以使用 一个或多个集成电路来实现。 相应地, 上述实施例中的各模块 /单元可以釆用 硬件的形式实现, 也可以釆用软件功能模块的形式实现。 本发明不限制于任 何特定形式的硬件和软件的结合。
以上仅为本发明的优选实施例, 当然, 本发明还可有其他多种实施例, 在不背离本发明精神及其实质的情况下, 熟悉本领域的技术人员当可根据本 发明作出各种相应的改变和变形, 但这些相应的改变和变形都应属于本发明 所附的权利要求的保护范围。
工业实用性 上述保存话务数据的方法及系统, 具有以下优点: 通过写即时话务数据 入普通的无格式的文本文件, 可以保证在即时话务观察时间内, 大多数时间 网管系统是高效率、 低内存、 无丟失的保存了即时话务数据。 使得网管系统 能够更好的适应大话务量的情况; 使用标准的 Java API带有緩存的写文件, 不需要用户编写緩存代码, 提高了软件的开发效率和代码质量; 只是在个别 时间点 (等待时间到, 记录数超过最大记录数据; 观察时间结束)写文件, 对内存的大量占用只是瞬时的, 写文件结束后, 占用的大量内存可以立即被 垃圾回收器回收。

Claims

权 利 要 求 书
1、 一种保存话务数据的方法, 其包括:
网管系统接收到即时话务数据后, 将所述即时话务数据写入硬盘中无格 式的临时文件; 以及
从所述临时文件读取并解析所述即时话务数据后, 将解析出的即时话务 数据按相应的格式进行存储。
2、 如权利要求 1所述的方法, 其中: 所述网管系统将所述即时话务数据 写入无格式的临时文件的步骤包括:
所述网管系统使用 Java标准类库中带緩存的文件输出流类将所述即时话 务数据写入所述临时文件。
3、 如权利要求 1所述的方法, 其中: 所述网管系统从所述临时文件读取 并解析所述即时话务数据后, 将解析出的即时话务数据按相应的格式进行存 储的步骤包括:
所述网管系统若判断第一临时文件中记录的即时话务数据条数超过预设 的最大记录数 N, 则以 N条即时话务数据为单位, 按记录时间顺序读取并解 析所述即时话务数据。
4、如权利要求 3所述的方法, 其中所述网管系统从所述临时文件读取并 解析所述即时话务数据后, 将解析出的即时话务数据按相应的格式进行存储 的步骤还包括:
所述网管系统若判断所述第一临时文件中未读取的即时话务数据的条数 小于 N, 则创建第二临时文件, 将之后接收到的即时话务数据写入所述第二 临时文件;
若判断所述第一临时文件中未读取的即时话务数据与所述第二临时文件 中记录的即时话务数据的总条数超过 N, 则以 N条即时话务数据为单位, 按 记录时间顺序从所述第一临时文件和所述第二临时文件中读取并解析所述即 时话务数据, 将该解析出的即时话务数据按相应的格式进行存储。
5、 如权利要求 1或 2所述的方法, 其中: 所述网管系统从所述临时文件 读取并解析所述即时话务数据后, 将解析出的即时话务数据按相应的格式进 行存储的步骤包括:
所述网管系统若判断达到预定时间, 则读取并解析所述临时文件中所有 的即时话务数据, 将该解析出的即时话务数据按相应的格式进行存储。
6、 一种保存话务数据的系统, 其包括:
数据接收装置, 其设置为: 接收到即时话务数据后, 将所述即时话务数 据写入硬盘中无格式的临时文件; 以及
后台写入装置, 其设置为: 从所述临时文件读取并解析所述即时话务数 据后, 将解析出的即时话务数据按相应的格式进行存储。
7、 如权利要求 6所述的系统, 其中:
所述数据接收装置是设置为: 接收到即时话务数据后, 通过使用 Java标 准类库中带緩存的文件输出流类将所述即时话务数据写入所述临时文件的。
8、 如权利要求 7所述的系统, 其中: 所述后台写入装置包括: 判断单元, 其设置为: 判断第一临时文件中记录的即时话务数据条数是 否超过预设的最大记录数 N; 以及
写入单元, 其设置为: 在所述判断单元判断第一临时文件中记录的即时 话务数据条数超过 N的情况下, 以 N条即时话务数据为单位, 按记录时间顺 序读取并解析所述即时话务数据, 将该解析出的即时话务数据按相应的格式 进行存储。
9、 如权利要求 8所述的系统, 其中: 所述后台写入装置还包括: 创建单 元, 其中,
所述判断单元还设置为: 判断所述第一临时文件中未读取的即时话务数 据条数是否小于 N;
所述创建单元设置为: 在所述判断单元判断所述第一临时文件中未读取 的即时话务数据条数小于 N的情况下, 创建用于写入之后接收到的即时话务 数据的第二临时文件;
所述判断单元还设置为: 判断所述第一临时文件中未读取的即时话务数 据条数与所述第二临时文件中已记录的即时话务数据条数的总条数是否超过 N;
所述写入单元还设置为: 在所述判断单元判断所述第一临时文件中未读 取的即时话务数据条数与所述第二临时文件中已记录的即时话务数据条数的 总条数超过 N的情况下, 以 N条即时话务数据为单位, 按记录时间顺序从所 述第一临时文件和所述第二临时文件中读取并解析所述即时话务数据, 将该 解析出的即时话务数据按相应的格式进行存储。
10、 如权利要求 6所述的系统, 其中:
所述判断单元还设置为: 判断是否到达预定时间;
所述写入单元还设置为: 在所述判断单元判断到达预定时间的情况下, 读取并解析所述临时文件中所有的即时话务数据, 将该解析出的即时话务数 据按相应的格式进行存储。
PCT/CN2011/081262 2011-02-18 2011-10-25 一种保存话务数据的方法及系统 WO2012109915A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2011100409310A CN102118268A (zh) 2011-02-18 2011-02-18 一种保存话务数据的方法及系统
CN201110040931.0 2011-02-18

Publications (1)

Publication Number Publication Date
WO2012109915A1 true WO2012109915A1 (zh) 2012-08-23

Family

ID=44216872

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/081262 WO2012109915A1 (zh) 2011-02-18 2011-10-25 一种保存话务数据的方法及系统

Country Status (2)

Country Link
CN (1) CN102118268A (zh)
WO (1) WO2012109915A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102118268A (zh) * 2011-02-18 2011-07-06 中兴通讯股份有限公司 一种保存话务数据的方法及系统
CN108694187A (zh) * 2017-04-07 2018-10-23 北京国双科技有限公司 实时流数据的存储方法及装置
CN108710661B (zh) * 2018-05-11 2020-10-27 武汉轻工大学 一种基于内存顺序表实现文本文件的数据管理方法和装置
CN111193833B (zh) * 2020-01-02 2021-06-08 中国银行股份有限公司 一种话务类报表系统测试方法、装置、服务器及存储介质
CN112947859A (zh) * 2021-02-26 2021-06-11 拉卡拉支付股份有限公司 临时文件处理方法、装置、电子设备、介质及程序产品
CN113919283A (zh) * 2021-09-26 2022-01-11 用友网络科技股份有限公司 文件在线预览方法及系统、计算机设备、可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1932812A (zh) * 2005-09-16 2007-03-21 腾讯科技(深圳)有限公司 一种日志保存方法及装置
CN101087210A (zh) * 2007-05-22 2007-12-12 网御神州科技(北京)有限公司 高性能的Syslog日志处理和存储方法
CN101321089A (zh) * 2008-07-07 2008-12-10 中兴通讯股份有限公司 一种电信网管系统中性能数据的入库方法
CN102118268A (zh) * 2011-02-18 2011-07-06 中兴通讯股份有限公司 一种保存话务数据的方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1932812A (zh) * 2005-09-16 2007-03-21 腾讯科技(深圳)有限公司 一种日志保存方法及装置
CN101087210A (zh) * 2007-05-22 2007-12-12 网御神州科技(北京)有限公司 高性能的Syslog日志处理和存储方法
CN101321089A (zh) * 2008-07-07 2008-12-10 中兴通讯股份有限公司 一种电信网管系统中性能数据的入库方法
CN102118268A (zh) * 2011-02-18 2011-07-06 中兴通讯股份有限公司 一种保存话务数据的方法及系统

Also Published As

Publication number Publication date
CN102118268A (zh) 2011-07-06

Similar Documents

Publication Publication Date Title
WO2012109915A1 (zh) 一种保存话务数据的方法及系统
US7249024B2 (en) Resource saving preemption
US20100223446A1 (en) Contextual tracing
WO2021190087A1 (zh) 任务执行方法、装置、系统和服务器
CN108600053B (zh) 一种基于零拷贝技术的无线网络数据包捕获方法
CN108564463B (zh) 一种银行异常交易冲正方法及系统
EP2432155B1 (en) Call list transmission processing method and system of charging system
WO2012159484A1 (zh) 一种日志记录管理方法和系统
WO2020228289A1 (zh) 日志获取方法、装置、终端及存储介质
CN111953568B (zh) 丢包信息管理方法与装置
CN112527879A (zh) 基于Kafka的实时数据抽取方法及相关设备
US7870257B2 (en) Enhancing real-time performance for java application serving
US9176783B2 (en) Idle transitions sampling with execution context
CN110417892B (zh) 基于报文解析的数据复制链路优化方法及装置
CN114020529B (zh) 一种流表数据的备份方法、装置、网络设备和存储介质
WO2024152609A1 (zh) 一种消息处理方法、装置、电子设备和存储介质
CN112181277B (zh) 一种数据存储空间管理方法、装置、存储介质及电子设备
WO2012139462A1 (zh) 一种实现信令跟踪的方法、装置及系统
CN113392081B (zh) 数据处理系统及方法
CN113010852B (zh) 数据的计量统计方法、装置、电子设备及存储介质
CN114443585A (zh) 一种日志收集方法、装置、设备及介质
WO2019028988A1 (zh) 数据处理方法、电子设备及计算机可读存储介质
CN114036179A (zh) 慢查询操作的处理方法及装置
CN112084048A (zh) Kafka同步刷盘方法、装置及消息服务器
CN101908924A (zh) 一种光信号的性能数据采集方法及其系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11858676

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11858676

Country of ref document: EP

Kind code of ref document: A1