CN112948337A - 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
CN112948337A
CN112948337A CN202110134394.XA CN202110134394A CN112948337A CN 112948337 A CN112948337 A CN 112948337A CN 202110134394 A CN202110134394 A CN 202110134394A CN 112948337 A CN112948337 A CN 112948337A
Authority
CN
China
Prior art keywords
time
client
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.)
Granted
Application number
CN202110134394.XA
Other languages
Chinese (zh)
Other versions
CN112948337B (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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

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 by taking 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, the connection between the windows client and the file system server can be established. After the connection is created, a network hard disk Z is added to the local disk, and the hard disk Z is a file share provided by the file system.
In the existing scheme, a user establishes a connection between a client and a server through an SMB2 protocol, but the time for maintaining the connection 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;
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;
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 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 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.
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:
an acquisition module configured to acquire a connection number corresponding to an IP of a client in response to detecting that the client establishes a tree connection with a server;
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, in response to the number of connections reduced by one being a first preset value, end the timer to take the current time as an end time, and determine a shared 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 storing a computer program operable on the processor, wherein the processor executes the program to perform any of the file sharing duration statistics method steps as 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 establishing a connection between a client and a server based on the 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 and presentation layer and the 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 data packet distinguishes between 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 tree connection between the client and the server, and acquiring the connection number corresponding to the IP of the client;
s2, 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;
s3, in response to the fact that the client is detected to be disconnected from the tree connection of the server, subtracting one from the connection number corresponding to the IP of the client;
and S4, in response to the connection number after being subtracted by one being a 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.
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 client to the server using the SMB2 protocol may include the steps of new, session _ setup, and tree _ connect, where the tree _ connect completes the specific sharing that a specific session on the client is connected to the SMB2 protocol server, indicating that the connection is completed, and therefore the tree _ connect request is used as the reporting time point of the client connection, and similarly, the tree connection is disconnected. 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 time of the client to the same node of the server.
Specifically, when a user accesses 2 shared directories dir1 and dir2 sequentially through a domain name through the same windows client, it is desirable that the two durations are not overlapped, but the beginning duration and the end duration 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 desirable to map to a node, otherwise it is difficult to calculate the usage duration. The user accesses the storage through the domain name, the stored ip is not specified, the existing load balance randomly allocates the ip according to the load condition, so that the path for accessing dir1 is \ \100.7.44.21\ dir1, and the path for accessing dir2 is \ \100.7.44.22\ dir 1. 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 can be ensured that the user can use a plurality of shares at the same time, and the service end corresponds to the same node.
In some embodiments, the number of connections is set from 0 to 1 and the timer starts after the user mounts dir1, then the number of connections is set to 2 after dir2 is mounted, at which time the timer is not started, the number of connections becomes 1 after dir1 is unloaded, at which time the timer is not ended, and the number of connections changes from 1 to 0 after dir2 is unloaded, and the timer is ended. Therefore, the dir1 and the dir2 can be mounted in sequence, the use duration is not overlapped, and the comprehensive use duration is ensured.
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 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.
Specifically, when the same user (i.e., uid is the same) uses different clients (corresponding to different client _ ips) to mount the directory, mapping needs to be performed on different nodes at the server side. 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 user1, the client _ ip1 and the client _ ip2 can confirm the respective time lengths of the client 1 and the client _ ip1 and the client _ ip2 to perform 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 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, 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 disclosed embodiments of the present invention.
The foregoing is an exemplary embodiment 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 of 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, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention 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 (10)

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;
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.
2. The method of claim 1, 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.
3. The method of claim 2, further comprising:
and mapping the directory to be mounted at the time of the client to the same node of the server.
4. The method of claim 1, 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.
5. 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.
6. A file sharing duration statistic system is characterized by comprising:
an acquisition module configured to acquire a connection number corresponding to an IP of a client in response to detecting that the client establishes a tree connection with a server;
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, in response to the number of connections reduced by one being a first preset value, end the timer to take the current time as an end time, and determine a shared duration according to the start time and the end time.
7. The system of claim 6, 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.
8. The system of claim 6, 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.
9. 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-5.
10. 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-5.
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 true CN112948337A (en) 2021-06-11
CN112948337B 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
CN112948337B (en) 2022-12-13

Similar Documents

Publication Publication Date Title
CN109315004B (en) PDU type setting method and related entity
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
US8140647B1 (en) System and method for accelerated data uploading
CN112261172B (en) Service addressing access method, device, system, equipment and medium
US8341285B2 (en) Method and system for transferring files
WO2017161965A1 (en) Method, device, and system for dynamic domain name system (dns) redirection
CN108260150A (en) A kind of network communication problem determination processing method and device
US10027577B2 (en) Methods, systems, and computer readable media for peer aware load distribution
CN112948337B (en) File sharing duration statistical method, system, device and medium
WO2012000455A1 (en) Client terminal and load balancing method
CN113612811B (en) Method, system, equipment and medium for client mounting in multiple channels
US11638134B2 (en) Methods, systems, and computer readable media for resource cleanup in communications networks
WO2022235372A1 (en) Methods, systems, and computer readable media for platform firewall management by network function (nf) repository function (nrf) or service communications proxy (scp)
JP2004240641A (en) Time limit-equipped communication control system device, method, processing program and recording medium recorded with same program
US20050198302A1 (en) Multi-client support
CN102843255B (en) Peer-to-peer based network management method and proxy selection server
US10505894B2 (en) Active and passive method to perform IP to name resolution in organizational environments
CN106936938B (en) Domain name resolution method and system
CN110838967A (en) Virtual private network connection method, server, client and storage medium
JP4339894B2 (en) Mobile connection broker
US7577742B1 (en) Account creation method and apparatus
CN117155933B (en) Multi-cluster nano-tube method, platform, equipment and storage medium
CN116647538B (en) Connecting device capable of accessing different intranet services
JP2014519672A (en) Method and virtual IDM server for implementing cloud-based ID management (C-IDM)

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