CN112948337B - File sharing duration statistical method, system, device and medium - Google Patents

File sharing duration statistical method, system, device and medium Download PDF

Info

Publication number
CN112948337B
CN112948337B CN202110134394.XA CN202110134394A CN112948337B CN 112948337 B CN112948337 B CN 112948337B CN 202110134394 A CN202110134394 A CN 202110134394A CN 112948337 B CN112948337 B CN 112948337B
Authority
CN
China
Prior art keywords
client
time
response
preset value
connection
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.)
Active
Application number
CN202110134394.XA
Other languages
Chinese (zh)
Other versions
CN112948337A (en
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202110134394.XA priority Critical patent/CN112948337B/en
Publication of CN112948337A publication Critical patent/CN112948337A/en
Application granted granted Critical
Publication of CN112948337B publication Critical patent/CN112948337B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management

Abstract

The invention discloses a file sharing duration statistical method, which comprises the following steps: responding to the detection that the client establishes tree connection with the server, and acquiring the connection number corresponding to the IP of the client; responding to the fact that the connection number is a first preset value, setting the connection number from the first preset value to the first preset value and adding one, and starting a timer to take the current time as starting time; in response to detecting that the client breaks tree connection with the server, subtracting one from the number of connections corresponding to the IP of the client; and in response to the number of connections after the one-step reduction being the first preset value, ending the timer to take the current time as the termination time, and determining the shared time length according to the start time and the termination time. The invention also discloses a system, a computer device and a readable storage medium. According to the scheme provided by the invention, the time length of the file shared by the client can be accurately recorded by taking the tree connection establishment as the starting time of the time length and taking the tree connection disconnection as the ending time of the time length.

Description

File sharing duration statistical method, system, device and medium
Technical Field
The invention relates to the field of files, in particular to a method, a system, equipment and a storage medium for counting file sharing duration.
Background
When a user opens a 'mapping network driver' through a windows as a client, inputs a driver name Z:, a folder name \ \100.7.44.21\ \ dir1, and then inputs a user name and a password, a connection between the windows client and a file system server can be created. After the connection is created, one more network hard disk Z is added to the local disk, and the network hard disk Z is the file share provided by the file system.
In the existing scheme, a user establishes connection between a client and a server through an SMB2 protocol, but the connection maintaining time cannot be accurately counted.
Disclosure of Invention
In view of this, in order to overcome at least one aspect of the above problem, an embodiment of the present invention provides a file sharing duration statistics method, including the following steps:
responding to the detection that a client establishes tree connection with a server, and acquiring the connection number corresponding to the IP of the client;
in response to the fact that the connection number is a first preset value, setting the connection number from the first preset value to the first preset value and adding one, and starting a timer to take the current time as starting time;
in response to detecting that the client breaks tree connection with the server, subtracting one from the number of connections corresponding to the IP of the client;
and in response to the connection number after the one-off is the first preset value, ending the timer to take the current time as the termination time, and determining the sharing time length according to the starting time and the termination time.
In some embodiments, further comprising:
and in response to the connection number being greater than a first preset value, only adding one to the connection number, and not starting the timer.
In some embodiments, further comprising:
and mapping the directory to be mounted at the current time of the client to the same node of the server.
In some embodiments, further comprising:
and in response to the number of connections after the one is subtracted is not the first preset value, only subtracting one from the number of connections.
In some embodiments, determining the shared duration based on the start time and the end time further comprises:
and responding to the fact that the user corresponding to the client mounts the catalog on the server through other clients, and overlapping the sharing duration of the user mounting the catalog on the server through each client to serve as the final sharing duration.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a file sharing duration statistic system, including:
the system comprises an acquisition module, a service end and a service end, wherein the acquisition module is configured to respond to the detection that a client establishes tree connection with the service end and acquire the connection number corresponding to the IP of the client;
the first response module is configured to respond to the fact that the connection number is a first preset value, set the connection number to be the first preset value plus one from the first preset value, and start a timer to take the current time as the starting time;
a second response module configured to reduce the number of connections corresponding to the IP of the client by one in response to detecting that the client disconnects from the tree with the server;
a third response module, configured to end the timer to take the current time as an end time in response to the number of connections after being decremented by one being a first preset value, and determine a sharing duration according to the start time and the end time.
In some embodiments, further comprising a fourth response module configured to:
in response to the connection number being greater than a first preset value, only adding one to the connection number, and not starting the timer;
and mapping the directory to be mounted at the time of the client to the same node of the server.
In some embodiments, further comprising a fifth response module configured to:
and in response to the number of connections after the one is subtracted is not the first preset value, only subtracting one from the number of connections.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer apparatus, including:
at least one processor; and
a memory, said memory storing a computer program operable on said processor, wherein said processor executes said program to perform any of the file sharing duration statistical methods described above.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program performs the steps of any one of the file sharing duration statistics methods described above.
The invention has one of the following beneficial technical effects: according to the scheme provided by the invention, the time length of the file shared by the client can be accurately recorded by taking the tree connection establishment as the starting time of the time length and taking the tree connection disconnection as the ending time of the time length.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a file sharing duration statistical method according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a connection establishment between a client and a server based on an SMB2 protocol according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a file sharing duration statistics system according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a computer device provided in an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and they are not described in any more detail in the following embodiments.
In some embodiments, the SMB2 (Server Message Block) communication protocol is a protocol established by Microsoft (Microsoft) and Intel (Intel) in 1987, primarily as a communication protocol for Microsoft networks. SMB2 is a protocol at the session layer (session layer) and presentation layer (presentation layer) and the application layer (application layer). The client uses this protocol to request files and print services from the server system over the network, stateful protocols, where the client establishes a connection with the server, establishes an authenticated context over the connection, and then issues various requests to access files, printers, and named pipes for interprocess communication.
Tree connection refers to connecting a particular session on an SMB2 protocol client to a particular share on an SMB2 protocol server over an SMB2 protocol connection. There may be multiple tree connections through a single SMB2 protocol connection. The TreeId field in the SMB2 packet header distinguishes the various tree connections.
According to an aspect of the present invention, an embodiment of the present invention provides a file sharing duration statistical method, as shown in fig. 1, which may include the steps of:
s1, responding to the fact that a client establishes tree connection with a server, and acquiring the number of connections corresponding to the IP of the client;
s2, in response to the fact that the connection number is a first preset value, setting the connection number from the first preset value to the first preset value and adding one, and starting a timer to take the current time as starting time;
s3, in response to the fact that the client is detected to be disconnected from the tree connection with the server, subtracting one from the number of connections corresponding to the IP of the client;
and S4, in response to the fact that the connection number after the subtraction is the first preset value, ending the timer to take the current time as the termination time, and determining the shared time length according to the starting time and the termination time.
According to the scheme provided by the invention, the time length of the file shared by the client can be accurately recorded by taking the tree connection establishment as the starting time of the time length and taking the tree connection disconnection as the ending time of the time length.
In some embodiments, as shown in fig. 2, the whole process of connecting the server using the SMB2 protocol client may include the steps of new, session _ setup, and tree _ connect, where the tree _ connect completes a specific session on the client to connect to a specific share on the SMB2 protocol server, indicating that the connection has been completed, and thus the tree _ connect request is used as the reporting time point of the client connection, and similarly, the tree connection is disconnected, which is used as the reporting time point of the client disconnection. The time points of connection and disconnection are then stored in a database.
In some embodiments, further comprising:
and in response to the connection number being greater than a first preset value, only adding one to the connection number, and not starting the timer.
In some embodiments, further comprising:
and mapping the directory to be mounted at the current time of the client to the same node of the server.
Specifically, when a user accesses 2 shared directories dir1 and dir2 successively through a domain name through the same windows client, it is desirable that the two durations are not overlapped, but the head-to-tail durations are used. I.e. the time duration from the first directory mount to the last directory exit is counted.
In some embodiments, the same windows client mounts dir1 and dir2 in sequence, and it is expected to map to a node, otherwise it is difficult to calculate the usage duration. A user accesses the storage through a domain name, the stored ip is not specified, the existing load balance randomly allocates the ip according to the load condition, and then the path of accessing dir1 is \ \100.7.44.21\ \ dir1, and the path of accessing dir2 is \ \100.7.44.22\ \ dir1. Therefore, if it is desired to map dir1 and dir2 to a node, the load balancing policy needs to be adjusted. When the user already has a mount connection, load balancing will continue to map the mount connection of the client to the same node. It is guaranteed that the user can use multiple shares at the same time, and the server corresponds to the same node.
In some embodiments, the number of connections is set from 0 to 1 and timing is started after the user mounts dir1, then the number of connections is set to 2 after mounting dir2, at which time the timer is not started, the number of connections is set to 1 after dismounting dir1, at which time timing is not ended, and the number of connections is set from 1 to 0 after dismounting dir2, and the timer is ended. Therefore, the dir1 and the dir2 can be mounted in sequence, the use duration is not overlapped, and the use duration is comprehensive.
In some embodiments, further comprising:
and in response to the number of connections after the one is subtracted is not the first preset value, only the number of connections is subtracted by one.
In some embodiments, determining a shared duration based on the start time and the end time further comprises:
and responding to the fact that the user corresponding to the client mounts the catalog on the server through other clients, and overlapping the sharing duration of the user mounting the catalog on the server through each client to serve as the final sharing duration.
Specifically, when the same user (i.e., uid is the same) uses different clients (corresponding to different client _ ips) to mount the directory, at the server side, mapping needs to be performed on different nodes. That is, the same client corresponds to the same node no matter how many directories are mounted, and different clients correspond to different nodes. Therefore, the respective time lengths of the user1, the client _ ip1 and the client _ ip2 can be confirmed for superposition.
According to the scheme provided by the invention, the time length of the file shared by the client can be accurately recorded by taking the tree connection establishment as the starting time of the time length and taking the tree connection disconnection as the ending time of the time length. And the method can also realize that the use duration is not overlapped when the same user accesses a plurality of directories, and the use durations are overlapped when the same user logs in different clients.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a file sharing duration statistic system 400, as shown in fig. 3, including:
an obtaining module 401, where the obtaining module 401 is configured to respond to a detection that a client establishes a tree connection with a server, and obtain a connection number corresponding to an IP of the client;
a first response module 402, where the first response module 402 is configured to respond that the connection number is a first preset value, set the connection number to the first preset value plus one from the first preset value, and start a timer to take a current time as a start time;
a second response module 403, where the second response module 403 is configured to reduce the number of connections corresponding to the IP of the client by one in response to detecting that the client disconnects from the tree of the server;
a third response module 404, where the third response module 404 is configured to end the timer to take the current time as the end time in response to the number of connections reduced by one being the first preset value, and determine the sharing duration according to the start time and the end time.
In some embodiments, further comprising a fourth response module configured to:
in response to the connection number being greater than a first preset value, only adding one to the connection number, and not starting the timer;
and mapping the directory to be mounted at the time of the client to the same node of the server.
In some embodiments, further comprising a fifth response module configured to:
and in response to the number of connections after the one is subtracted is not the first preset value, only subtracting one from the number of connections.
According to the scheme provided by the invention, the time length of the file shared by the client can be accurately recorded by taking the tree connection establishment as the starting time of the time length and taking the tree connection disconnection as the ending time of the time length. And moreover, when multiple directories are accessed at the same time, the use time length is not overlapped, and the use time length is overlapped when the same user logs in different clients.
Based on the same inventive concept, according to another aspect of the present invention, as shown in fig. 4, an embodiment of the present invention further provides a computer apparatus 501, including:
at least one processor 520; and
the memory 510, the memory 510 stores a computer program 511 that can be executed on the processor, and the processor 520 executes the program to perform the steps of any of the above methods for counting the file sharing time.
Based on the same inventive concept, according to another aspect of the present invention, as shown in fig. 5, an embodiment of the present invention further provides a computer-readable storage medium 601, where the computer-readable storage medium 601 stores computer program instructions 610, and the computer program instructions 610, when executed by a processor, perform the steps of any of the above file sharing duration statistics methods.
Finally, it should be noted that, as will be understood by those skilled in the art, all or part of the processes of the methods of the above embodiments may be implemented by a computer program, which may be stored in a computer-readable storage medium, and when executed, may include the processes of the embodiments of the methods described above.
Further, it should be appreciated that the computer-readable storage media (e.g., memory) herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The foregoing are exemplary embodiments of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, where the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant only to be exemplary, and is not intended to intimate that the scope of the disclosure, including the claims, is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.

Claims (7)

1. A file sharing duration statistical method is characterized by comprising the following steps:
responding to the detection that a client establishes tree connection with a server, and acquiring the connection number corresponding to the IP of the client;
responding to the fact that the connection number is a first preset value, setting the connection number to be the first preset value plus one from the first preset value, and starting a timer to take the current time as the starting time;
in response to detecting that the client breaks tree connection with the server, subtracting one from the number of connections corresponding to the IP of the client;
in response to the fact that the connection number after the one-off is the first preset value, ending the timer to take the current time as the termination time, and determining the shared duration according to the starting time and the termination time;
in response to the connection number being greater than a first preset value, only adding one to the connection number, and not starting the timer;
and in response to the connection number after the one is subtracted is not the first preset value, only subtracting one from the connection number, and not closing the timer.
2. The method of claim 1, further comprising:
and mapping the directory to be mounted at the time of the client to the same node of the server.
3. The method of claim 1, wherein determining a shared duration based on the start time and the end time, further comprises:
and in response to the fact that the user corresponding to the client mounts the catalogs on the server through other clients, overlapping the sharing duration of the user mounting the catalogs on the server through each client to serve as the final sharing duration.
4. A file sharing duration statistic system is characterized by comprising:
the system comprises an acquisition module, a service end and a service end, wherein the acquisition module is configured to respond to the detection that a client establishes tree connection with the service end and acquire the connection number corresponding to the IP of the client;
a first response module, configured to, in response to the connection number being a first preset value, set the connection number from the first preset value to the first preset value plus one, and start a timer to take a current time as a start time;
a second response module configured to reduce the number of connections corresponding to the IP of the client by one in response to detecting that the client disconnects from the tree with the server;
a third response module, configured to end the timer to take the current time as an end time in response to the number of connections reduced by one being a first preset value, and determine a sharing duration according to the start time and the end time;
a fourth response module configured to, in response to the connection number being greater than the first preset value, only increment the connection number by one without starting the timer;
a fifth response module configured to, in response to the connection number after subtracting by one not being the first preset value, only subtract by one the connection number without turning off the timer.
5. The system of claim 4, wherein the fourth response module is further configured to:
and mapping the directory to be mounted at the current time of the client to the same node of the server.
6. A computer device, comprising:
at least one processor; and
memory storing a computer program operable on the processor, characterized in that the processor executes the program to perform the steps of the method according to any of claims 1-3.
7. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, is adapted to carry out the steps of the method according to any one of claims 1-3.
CN202110134394.XA 2021-01-29 2021-01-29 File sharing duration statistical method, system, device and medium Active CN112948337B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110134394.XA CN112948337B (en) 2021-01-29 2021-01-29 File sharing duration statistical method, system, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110134394.XA CN112948337B (en) 2021-01-29 2021-01-29 File sharing duration statistical method, system, device and medium

Publications (2)

Publication Number Publication Date
CN112948337A CN112948337A (en) 2021-06-11
CN112948337B true CN112948337B (en) 2022-12-13

Family

ID=76240439

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110134394.XA Active CN112948337B (en) 2021-01-29 2021-01-29 File sharing duration statistical method, system, device and medium

Country Status (1)

Country Link
CN (1) CN112948337B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108683633A (en) * 2018-04-10 2018-10-19 新华三技术有限公司成都分公司 access control method and device
CN112000466A (en) * 2020-07-24 2020-11-27 周志燕 Database pressure testing method, device and system
CN112148678A (en) * 2020-09-18 2020-12-29 苏州浪潮智能科技有限公司 File access method, system, device and medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108683633A (en) * 2018-04-10 2018-10-19 新华三技术有限公司成都分公司 access control method and device
CN112000466A (en) * 2020-07-24 2020-11-27 周志燕 Database pressure testing method, device and system
CN112148678A (en) * 2020-09-18 2020-12-29 苏州浪潮智能科技有限公司 File access method, system, device and medium

Also Published As

Publication number Publication date
CN112948337A (en) 2021-06-11

Similar Documents

Publication Publication Date Title
WO2022033121A1 (en) Method and system for resource exposure in kubernetes, and device and medium
US7272649B1 (en) Automatic hardware failure detection and recovery for distributed max sessions server
CN108737473B (en) Data processing method, device and system
US8140647B1 (en) System and method for accelerated data uploading
WO2022098404A1 (en) Methods, systems, and computer readable media for ingress message rate limiting
CN108712516B (en) Method, device, equipment and storage medium for acquiring SIP server address
WO2006094909A1 (en) Method for communication between an application and a client
US11528253B2 (en) Security platform for service provider network environments
US6668283B1 (en) ISDN B-channel count limitation
US10027577B2 (en) Methods, systems, and computer readable media for peer aware load distribution
US20080118043A1 (en) Call Control Apparatus and Method for Controlling Call Control Apparatus
CN112948337B (en) File sharing duration statistical method, system, device and medium
WO2012000455A1 (en) Client terminal and load balancing method
CN105191226B (en) For adjusting the method and arrangement of the service quality of dedicated channel based on service awareness
US11638134B2 (en) Methods, systems, and computer readable media for resource cleanup in communications networks
JP5778862B2 (en) Method and virtual IDM server for implementing cloud-based ID management (C-IDM)
JP2004240641A (en) Time limit-equipped communication control system device, method, processing program and recording medium recorded with same program
US10505894B2 (en) Active and passive method to perform IP to name resolution in organizational environments
CN106936938B (en) Domain name resolution method and system
US20050198302A1 (en) Multi-client support
EP3149902B1 (en) Technique for obtaining a policy for routing requests emitted by a software module running on a client device
CN116708041B (en) Camouflage proxy method, device, equipment and medium
CN115190162B (en) Proxy service configuration method and proxy service system in block chain
US20230229539A1 (en) Methods, systems, and computer readable media for health checking involving common application programming interface framework
CN100542104C (en) The method and the data handling system that are used for user's particular network use of definite network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant