CN119356896B - Method for interacting with computing hardware through application programming interface - Google Patents
Method for interacting with computing hardware through application programming interface Download PDFInfo
- Publication number
- CN119356896B CN119356896B CN202411957546.6A CN202411957546A CN119356896B CN 119356896 B CN119356896 B CN 119356896B CN 202411957546 A CN202411957546 A CN 202411957546A CN 119356896 B CN119356896 B CN 119356896B
- Authority
- CN
- China
- Prior art keywords
- hardware
- api
- task
- resource
- computing hardware
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention relates to the technical field of computers, in particular to a method for interacting with computing hardware through an application programming interface, which comprises the following steps of S1, establishing connection with the computing hardware through an API (application program interface), initializing a communication protocol, S2, obtaining hardware information, generating a resource list according to a hardware resource state, S3, distributing an application program task according to priority and hardware residual resources through the API according to the hardware resource list, S4, establishing a bidirectional data channel through the API, S5, triggering an exception handling mechanism through the API immediately if abnormality occurs in the process of data transmission or task execution, S6, after the task is completed, safely disconnecting communication with the hardware through the API, releasing occupied resources, and recording an interaction log. The invention obviously improves the utilization efficiency of the computing hardware resources and the fault tolerance of the system by dynamically adjusting the task allocation and the resource utilization and introducing a perfect exception handling mechanism.
Description
Technical Field
The present invention relates to the field of computer technology, and in particular, to a method for interacting with computing hardware through an application programming interface.
Background
With the rapid development of information technology, the interaction demands of computing hardware and application programs are increasing, particularly in a distributed computing environment, the application programs need to perform frequent data interaction with different types of computing hardware, the interactions generally depend on an Application Programming Interface (API) to perform management of hardware resources and scheduling of tasks, the application programs can send requests, receive responses, manage the hardware resources, transmit data and coordinate work among hardware units through the API, so that the efficiency of task processing and the resource utilization rate of a system are greatly improved, however, in actual operation, the conventional API interaction technology still has some technical bottlenecks, particularly in terms of how to efficiently and stably manage the resources, ensure the reliability of data transmission and optimize task scheduling, and still face many challenges.
Although the prior art can realize basic hardware resource scheduling and data interaction, the prior art has the problems of inaccurate task allocation, inflexible resource management, imperfect exception handling mechanism and the like, firstly, the resource allocation in the prior art cannot be regulated in real time according to the dynamic change of hardware state, so that the resource utilization is insufficient, or the conditions of resource competition and task execution delay occur, secondly, communication interruption or hardware failure easily occur in the data transmission process, the prior exception handling mechanism cannot timely and effectively react to influence the stability of the system, and furthermore, the prior task allocation method is mostly dependent on static configuration, and lacks the capability of dynamic scheduling according to the real-time resource state of hardware, so that the priority of task execution cannot be reasonably handled under the condition of high load.
Disclosure of Invention
Based on the above objects, the present invention provides a method for interacting with computing hardware through an application programming interface.
A method of interacting with computing hardware through an application programming interface, comprising the steps of:
S1, establishing connection with computing hardware through an API (application program interface), initializing a communication protocol, and setting a data transmission format, a data transmission rate and a data encryption mode;
S2, sending a device identification request through an API, acquiring hardware information, generating a resource list according to the hardware resource state, and providing a basis for subsequent task allocation;
S3, distributing the application program tasks according to the priority and the hardware residual resources through the API according to the hardware resource list;
S4, establishing a bidirectional data channel through an API, and supporting real-time transmission of data between an application program and computing hardware;
S5, in the process of data transmission or task execution, if hardware faults, communication interruption or task execution abnormality occur, an abnormality processing mechanism is immediately triggered through an API, so that the continuous operation of the system is ensured;
and S6, after the task is completed, the communication with the hardware is safely disconnected through the API, the occupied resources are released, and the interaction log is recorded.
Optionally, the S1 specifically includes:
S11, firstly, physically connecting an application programming interface with a network port of computing hardware, and using TCP/IP as a transmission layer protocol to establish communication connection;
s12, after connection is established, the API and the computing hardware carry out initialization of a handshake protocol, and a communication protocol compatible with both parties is selected to be supported, wherein the communication protocol comprises HTTP, HTTPS, webSocket or MQTT protocol;
S13, setting a data transmission format through an API, wherein the format comprises JSON, XML or Protocol Buffers;
s14, dynamically adjusting the data transmission rate according to the network bandwidth and task requirements of the computing hardware, and adopting a TCP flow control method, wherein the method comprises the steps of adjusting the size of a window and controlling the size of a receiving buffer zone, so that data loss or delay cannot occur due to insufficient bandwidth in the data transmission process;
S15, negotiating with the computing hardware through the API and selecting an encryption mode, wherein the encryption mode comprises an SSL/TLS protocol, a symmetric encryption algorithm or an asymmetric encryption algorithm.
Optionally, the step S14 specifically includes:
s141, monitoring the residual bandwidth of the current network through an API (application program interface), and acquiring network throughput between computing hardware and an application program, wherein the throughput is expressed as the data quantity capable of being transmitted in unit time;
S142, calculating the size of a congestion window by adopting a TCP flow control method according to the requirements of network bandwidth and transmission rate, and adjusting the data transmission rate, wherein the size of the congestion window is in direct proportion to the network bandwidth, and the calculation formula of the size of the congestion window is as follows: , wherein, For the current congestion window size,Indicating the desired amount of data transmission in a period of time,The maximum congestion window size is the maximum congestion window size, and B is the current bandwidth;
s143, calculating and adjusting the size of the receiving buffer zone according to the adjustment of the real-time bandwidth and the congestion window To maintain efficient data transmission;
s144 congestion window according to the above calculation And a receive bufferDynamically adjusting data transmission rateThe relationship with congestion window and network bandwidth is calculated by the following formula:。
optionally, the S2 specifically includes:
s21, sending a device identification request to computing hardware through an API, wherein the request contains a device unique identifier and is communicated by using a standardized network protocol;
S22, after receiving the equipment identification request, the computing hardware returns a hardware information response, wherein the response contains basic attribute data of the hardware, including the model number of the processor, the size of the memory, the storage capacity and the state of the network interface;
s23, after receiving the hardware response, the API analyzes the returned hardware information and extracts related information, wherein the related information comprises the type of a processor, the memory capacity, the storage space of a hard disk, the network bandwidth and the number of residual computing cores;
S24, based on the analyzed hardware information, evaluating the current state of the hardware resources, including indexes of the utilization rate of the processor, the occupancy rate of the memory, the residual amount of the memory and the utilization rate of the network bandwidth, so as to determine the actual residual condition of the resources;
And S25, according to the hardware resource state evaluation result, the API generates a hardware resource list which contains detailed resource information of each hardware unit, including CPU utilization rate, memory residual space, storage residual space and network bandwidth.
Optionally, the step S3 specifically includes:
S31, receiving a task list sent by an application program through an API, wherein each task in the task list comprises a priority identification and a resource demand parameter, and the priority identification comprises a processor core number, a memory capacity and a storage space demand;
s32, sorting the task list based on the priority identification in the task list;
S33, according to the ordered task list, matching the task list with resources in a hardware resource list through an API, determining a processor, a memory and storage resources required by each task, and calculating the feasibility of resource allocation;
and S34, sending a task allocation instruction to the selected computing hardware through the API, wherein the task allocation instruction comprises a task identifier, allocated resource parameters and an execution instruction, and ensuring that the task is correctly executed on the designated hardware according to an allocation result.
Optionally, the step S33 specifically includes:
s331, extracting resource requirement parameters of each task from the ordered task list, including the required processor core number Memory capacityAnd a storage space, wherein,Respectively represent tasksProcessor core number, memory capacity and storage space requirements;
s332 extracting the residual resource information of each hardware node from the hardware resource list, including the residual processor core number Remaining memory capacityAnd remaining storage space, wherein,Representing hardware respectivelyThe number of remaining processor cores, the remaining memory capacity, and the remaining memory space;
S333, calculating the matching degree of the resources according to the resource requirement of the tasks and the rest condition of the hardware resources, and for each task And hardware nodeThe degree of matching is calculated according to the following formula: , wherein, Representing tasksAnd hardware nodeResource matching degree of (2);
s334 for each task And hardware nodeJudging whether the feasibility of resource allocation is satisfied, if soThe hardware node can meet the resource requirement of the task and can send the taskDistribution to hardware nodesOtherwise, the allocation fails.
Optionally, the step S4 specifically includes:
S41, selecting a communication protocol suitable for bidirectional data transmission through an API, wherein the communication protocol of the bidirectional data transmission comprises a WebSocket protocol, an HTTP/2 protocol or an MQTT protocol;
s42, initiating an initial connection request with computing hardware through an API, and carrying out a handshake process by using a selected communication protocol to ensure that two parties can successfully establish a communication session;
s43, after establishing initial connection, executing authentication and authorization process through API;
s44, configuring related parameters of data transmission through an API, including data packet size, transmission buffer area size and data compression options;
And S45, simultaneously opening a channel for sending and receiving data between the application program and the computing hardware through the API, so as to ensure that the data can be transmitted and received in real time in two directions.
Optionally, the step S5 specifically includes:
S51, monitoring states of data transmission and task execution in real time through an API, and detecting occurrence of hardware faults, communication interruption or abnormal task execution by using monitoring parameters and threshold values;
s53, once an abnormal event is detected, an abnormal processing mechanism is immediately activated through an API;
S54, an exception notification is sent to a user or a system administrator through an API, the current system state and the processing result are informed, and exception information is provided.
Optionally, the step S53 includes:
s531, rolling back the states of the computing hardware and the application program to the last stable state through the API, and preventing data loss or task interruption;
s532, triggering a task restarting program through an API, automatically reallocating resources and continuously executing tasks from the abnormal node;
and S5323, recording detailed log information of the abnormal event through the API, wherein the detailed log information comprises occurrence time, abnormal type, related hardware components and abnormal codes.
Optionally, the step S6 specifically includes:
s61, sending a disconnection instruction through an API, notifying the computing hardware to terminate the current communication session, and preparing to close the bidirectional data channel;
s62, receiving a communication termination confirmation signal of the computing hardware through the API to confirm that the bidirectional data channel is successfully closed;
s63, sending a resource release request through an API (application program interface), and indicating the computing hardware to release the processor, the memory and the storage resources occupied in the task execution process;
S64, the computing hardware is instructed to clean up the cache and temporary data related to the current task through an API;
S65, automatically generating and storing an interaction log through the API, the interaction log including a time stamp of disconnection, released resource information, an event occurring during interaction, and status information.
The invention has the beneficial effects that:
By means of real-time monitoring and evaluation of hardware resources, an application program can intelligently select the priority and the resource allocation scheme of task execution according to available resources, so that resource competition and task delay phenomena are avoided, stable operation of a system in a multi-task environment is ensured, the overall performance of the system is improved by the dynamic resource allocation mechanism, faults caused by insufficient resources or unreasonable resource allocation are greatly reduced, and computing efficiency is optimized.
According to the invention, a perfect exception handling mechanism is introduced in the data transmission and task execution processes, so that the communication state and task execution condition can be monitored in real time, and the corresponding handling mechanism is triggered in time when hardware faults or communication interruption occurs, so that the continuous and stable operation of the system is ensured.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only of the invention and that other drawings can be obtained from them without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a method for interacting an application programming interface with computing hardware according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a triggering exception handling mechanism according to an embodiment of the present invention.
Detailed Description
The invention will now be described in detail with reference to the drawings and to specific embodiments. While the invention has been described herein in detail in order to make the embodiments more detailed, the following embodiments are preferred and can be embodied in other forms as well known to those skilled in the art, and the accompanying drawings are only for the purpose of describing the embodiments more specifically and are not intended to limit the invention to the specific forms disclosed herein.
It should be noted that references in the specification to "one embodiment," "an example embodiment," "some embodiments," etc., indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may not necessarily include the particular feature, structure, or characteristic. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the relevant art to effect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.
Generally, the terminology may be understood, at least in part, from the use of context. For example, the term "one or more" as used herein may be used to describe any feature, structure, or characteristic in a singular sense, or may be used to describe a combination of features, structures, or characteristics in a plural sense, depending at least in part on the context. In addition, the term "based on" may be understood as not necessarily intended to convey an exclusive set of factors, but may instead, depending at least in part on the context, allow for other factors that are not necessarily explicitly described.
1-2, A method of interacting with computing hardware through an application programming interface, comprising the steps of:
s1, establishing connection with computing hardware through an API (application programming interface), initializing a communication protocol, setting a data transmission format, a data transmission rate and an encryption mode, and ensuring stable operation of the interface;
S2, sending a device identification request through an API, acquiring hardware information, generating a resource list according to hardware resource states (such as processing capacity, memory and storage), and providing a basis for subsequent task allocation;
S3, according to the hardware resource list, distributing the application program tasks according to the priority and the hardware residual resources through the API, and ensuring effective scheduling of the tasks;
S4, establishing a bidirectional data channel through an API, supporting real-time transmission of data between an application program and computing hardware, and ensuring the integrity of data transmission;
S5, in the process of data transmission or task execution, if hardware faults, communication interruption or task execution abnormality occur, an abnormality processing mechanism is immediately triggered through an API, so that the continuous operation of the system is ensured;
And S6, after the task is completed, the communication with the hardware is safely disconnected through the API, occupied resources are released, an interaction log is recorded, and data support is provided for subsequent optimization.
S1 specifically comprises:
S11, firstly, physically connecting an Application Programming Interface (API) with a network port of computing hardware, and using TCP/IP as a transport layer protocol to establish communication connection;
s12, after connection is established, an API and computing hardware carry out initialization of a handshake protocol, and a communication protocol compatible with both parties is selected to be supported, wherein the communication protocol comprises HTTP, HTTPS, webSocket or MQTT protocol, so that stability and safety of data transmission are ensured;
S13, setting a data transmission format comprising JSON, XML or Protocol Buffers through an API so as to facilitate analysis, transmission and exchange of data and ensure the high efficiency and compatibility of the data;
s14, dynamically adjusting the data transmission rate according to the network bandwidth and task requirements of the computing hardware, and adopting a TCP flow control method, wherein the method comprises the steps of adjusting the size of a window and controlling the size of a receiving buffer zone, so that data loss or delay cannot occur due to insufficient bandwidth in the data transmission process;
S15, negotiating with the computing hardware through the API and selecting an encryption mode, wherein the encryption mode comprises an SSL/TLS protocol, a symmetric encryption algorithm or an asymmetric encryption algorithm, wherein the SSL/TLS protocol is used for guaranteeing the safety and the data integrity of a transmission layer, the symmetric encryption algorithm (such as AES) is suitable for a scene needing quick encryption and decryption, the asymmetric encryption algorithm (such as RSA) is suitable for encrypting sensitive data or key exchange, and the connection between the API and the computing hardware can be guaranteed to have high-efficiency and safe data transmission capability through the steps.
The TCP flow control method in S14 specifically comprises the following steps:
S141, monitoring the residual bandwidth of the current network through an API, acquiring network throughput between computing hardware and an application program, wherein the throughput is expressed as data quantity capable of being transmitted in unit time, and calculating the bandwidth by adopting the following formula: , wherein, In order to transfer the data amount,For the time used for transmission, B is the current bandwidth, i.e. the actual throughput rate of the network transmission;
S142, calculating the size of a congestion window by adopting a TCP flow control method according to the requirements of network bandwidth and transmission rate, and adjusting the data transmission rate, wherein the size of the congestion window is in direct proportion to the network bandwidth, and the calculation formula of the size of the congestion window is as follows: , wherein, For the current congestion window size,Indicating the desired amount of data transmission in a period of time,The maximum congestion window size is ensured not to excessively occupy bandwidth or cause network congestion;
s143, calculating and adjusting the size of the receiving buffer zone according to the adjustment of the real-time bandwidth and the congestion window To maintain efficient data transmission, the size of the receive buffer can be dynamically adjusted by the following formula, wherein,Is a constant that is adjusted according to specific hardware capabilities and data transmission requirements;
s144 congestion window according to the above calculation And a receive bufferDynamically adjusting data transmission rateThe relationship with congestion window and network bandwidth is calculated by the following formula: the method can realize the dynamic adjustment of the data transmission rate, adopts a TCP flow control method, can monitor the network bandwidth in real time, and properly adjusts according to the calculated bandwidth, congestion window, receiving buffer size and other parameters, ensures the flow control and the maximization of bandwidth utilization in the data transmission process, and avoids the transmission bottleneck or overload phenomenon caused by the change of the network bandwidth or the limitation of hardware, thereby improving the data transmission efficiency.
S2 specifically comprises:
S21, sending a device identification request to computing hardware through an API, wherein the request contains a device unique identifier (such as a MAC address, a device ID or a serial number), and communicating by using a standardized network protocol (such as HTTP, HTTPS or WebSocket), so as to ensure that the identification request can accurately reach the hardware and obtain a response;
s22, after receiving the equipment identification request, the computing hardware returns a hardware information response, wherein the response comprises basic attribute data of the hardware, including a processor model, a memory size, a storage capacity and a network interface state, and the response is returned to the application program through an API, and the data format adopts a JSON or XML standard format, so that the data can be efficiently analyzed and processed;
S23, after receiving the hardware response, the API analyzes the returned hardware information and extracts related information, including the type of a processor, the memory capacity, the storage space of a hard disk, the network bandwidth and the number of remaining computing cores, wherein the analysis process is realized through a JSON or XML analysis library, so that the accurate extraction of the information is ensured;
S24, based on the analyzed hardware information, evaluating the current state of the hardware resources, including indexes of the utilization rate of the processor, the occupancy rate of the memory, the residual amount of the memory and the utilization rate of the network bandwidth, so as to determine the actual residual condition of the resources;
And S25, generating a hardware resource list by the API according to the hardware resource state evaluation result, wherein the list contains detailed resource information of each hardware unit, including CPU utilization rate, memory residual space, storage residual space and network bandwidth, so as to ensure that the subsequent task can reasonably allocate the hardware resources according to the list.
S3 specifically comprises:
S31, receiving a task list sent by an application program through an API, wherein each task in the task list comprises a priority identifier and a resource demand parameter, and the priority identifier comprises a processor core number, a memory capacity and a storage space demand;
S32, sorting the task list based on the priority identification in the task list, and ensuring that the high-priority task is preferentially subjected to resource allocation in preference to the low-priority task;
S33, according to the ordered task list, matching the resources in the hardware resource list through an API (application program interface), determining the processor, the memory and the storage resources required by each task, and calculating the feasibility of resource allocation;
and S34, sending a task allocation instruction to the selected computing hardware through the API, wherein the task allocation instruction comprises a task identifier, allocated resource parameters and an execution instruction, and ensuring that the task is correctly executed on the designated hardware according to an allocation result.
S33 specifically comprises:
s331, extracting resource requirement parameters of each task from the ordered task list, including the required processor core number Memory capacityAnd a storage space, wherein,Respectively represent tasksProcessor core number, memory capacity and storage space requirements;
s332 extracting the residual resource information of each hardware node from the hardware resource list, including the residual processor core number Remaining memory capacityAnd remaining storage space, wherein,Representing hardware respectivelyThe number of remaining processor cores, the remaining memory capacity, and the remaining memory space;
S333, calculating the matching degree of the resources according to the resource requirement of the tasks and the rest condition of the hardware resources, and for each task And hardware nodeThe degree of matching is calculated according to the following formula: , wherein, Representing tasksAnd hardware nodeThe method for calculating the matching degree is the minimum value of the ratio of the resources required by the task to the available resources of the hardware, and ensures that the hardware node resources allocated by each task cannot exceed the requirements of the hardware node resources;
s334 for each task And hardware nodeJudging whether the feasibility of resource allocation is satisfied, if soThe hardware node can meet the resource requirement of the task and can send the taskDistribution to hardware nodesOtherwise, the allocation fails; by the aid of the method, the feasibility of resource allocation of each task on different hardware nodes can be calculated accurately according to the matching relation between task demands and hardware resources, excessive allocation or failure of the resources is avoided, the efficiency of resource allocation is improved through accurate resource matching degree calculation, and the use of calculation resources is optimized.
S4 specifically comprises the following steps:
S41, selecting a communication protocol suitable for bidirectional data transmission through an API, wherein the communication protocol of the bidirectional data transmission comprises a WebSocket protocol, an HTTP/2 protocol or an MQTT protocol so as to ensure the real-time performance and stability of the data transmission;
s42, initiating an initial connection request with computing hardware through an API, and carrying out a handshake process by using a selected communication protocol to ensure that two parties can successfully establish a communication session;
s43, after the initial connection is established, executing authentication and authorization processes through an API, and adopting a token-based authentication mechanism (such as OAuth 2.0) or a certificate verification method to ensure the security and validity of a data channel;
s44, configuring related parameters of data transmission through an API, including data packet size, transmission buffer area size and data compression options, and optimizing data transmission efficiency and bandwidth utilization rate;
And S45, opening a channel for transmitting and receiving data between the application program and the computing hardware through the API at the same time, so as to ensure that the data can be transmitted and received in real time in two directions.
S5 specifically comprises the following steps:
s51, monitoring states of data transmission and task execution in real time through an API, and detecting hardware faults, communication interruption or abnormal task execution by using monitoring parameters and thresholds (such as CPU temperature, memory use rate, network delay and the like), so as to ensure that abnormal conditions of a system can be timely identified;
s53, once an abnormal event is detected, an abnormal processing mechanism is immediately activated through an API;
S54, an exception notification is sent to a user or a system administrator through an API, the current system state and the processing result are informed, and exception information is provided.
The exception handling mechanism in S53 includes:
s531, rolling back the states of the computing hardware and the application program to the last stable state through the API, and preventing data loss or task interruption;
s532, triggering a task restarting program through an API, automatically reallocating resources and continuously executing tasks from the abnormal node;
S5323, recording detailed log information of abnormal events through the API, including occurrence time, abnormal types, related hardware components and abnormal codes, so as to facilitate subsequent analysis and optimization, timely detecting and processing hardware faults, communication interruption or task execution abnormality in the process of data transmission or task execution, ensuring continuous and stable operation of the system, and rapidly rolling back the system state, restarting the task and recording error logs by an API-triggered abnormal processing mechanism when the abnormality occurs, thereby providing guarantee for system recovery.
S6 specifically comprises the following steps:
s61, sending a disconnection instruction through an API, notifying the computing hardware to terminate the current communication session, and preparing to close the bidirectional data channel;
s62, receiving a communication termination confirmation signal of the computing hardware through the API, and confirming that the bidirectional data channel is closed successfully, so as to ensure that no data transmission activity exists;
S63, sending a resource release request through an API (application program interface), and indicating the computing hardware to release the processor, the memory and the storage resources occupied in the task execution process, so as to ensure that the resources can be reused by other tasks;
S64, the computing hardware is instructed through an API to clean the cache and temporary data related to the current task, so that data leakage or resource waste is prevented, and the high efficiency of hardware operation is maintained;
The method comprises the steps of S65, automatically generating and storing an interaction log through an API, wherein the interaction log comprises a time stamp for disconnecting, released resource information and event and state information occurring during interaction for subsequent audit and system optimization, after the task is completed, the communication with computing hardware can be safely disconnected through the API, occupied resources are thoroughly released, the interaction log is recorded in detail, and after the task is completed, the system can be stably restored to an idle state and is ready to receive a new task.
The invention is intended to cover any alternatives, modifications, equivalents, and variations that fall within the spirit and scope of the invention. In the following description of preferred embodiments of the invention, specific details are set forth in order to provide a thorough understanding of the invention, and the invention will be fully understood to those skilled in the art without such details. In other instances, well-known methods, procedures, flows, components, circuits, and the like have not been described in detail so as not to unnecessarily obscure aspects of the present invention.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.
Claims (7)
1. A method of interacting with computing hardware via an application programming interface, comprising the steps of:
S1, establishing connection with computing hardware through an API, initializing a communication protocol, and setting a data transmission format, a data transmission rate and a data transmission encryption mode, wherein the method specifically comprises the following steps:
S11, firstly, physically connecting an application programming interface with a network port of computing hardware, and using TCP/IP as a transmission layer protocol to establish communication connection;
s12, after connection is established, the API and the computing hardware carry out initialization of a handshake protocol, and a communication protocol compatible with both parties is selected to be supported, wherein the communication protocol comprises HTTP, HTTPS, webSocket or MQTT protocol;
S13, setting a data transmission format through an API, wherein the format comprises JSON, XML or Protocol Buffers;
s14, dynamically adjusting the data transmission rate according to the network bandwidth and task requirements of the computing hardware, and adopting a TCP flow control method, wherein the method comprises the steps of adjusting the size of a window and controlling the size of a receiving buffer zone, so that data loss or delay cannot occur due to insufficient bandwidth in the data transmission process;
S15, negotiating with computing hardware through an API and selecting an encryption mode, wherein the encryption mode comprises an SSL/TLS protocol, a symmetric encryption algorithm or an asymmetric encryption algorithm;
S2, sending a device identification request through an API, acquiring hardware information, generating a resource list according to the hardware resource state, and providing a basis for subsequent task allocation;
s3, distributing the application program task according to the priority and the hardware residual resources through the API according to the hardware resource list, wherein the method specifically comprises the following steps:
S31, receiving a task list sent by an application program through an API, wherein each task in the task list comprises a priority identification and a resource demand parameter, and the priority identification comprises a processor core number, a memory capacity and a storage space demand;
s32, sorting the task list based on the priority identification in the task list;
S33, according to the ordered task list, matching the task list with resources in a hardware resource list through an API, determining a processor, a memory and storage resources required by each task, and calculating the feasibility of resource allocation;
s34, sending a task allocation instruction to the selected computing hardware through an API, wherein the task allocation instruction comprises a task identifier, allocated resource parameters and an execution instruction, and ensuring that the task is correctly executed on the designated hardware according to an allocation result;
S4, establishing a bidirectional data channel through an API, and supporting real-time transmission of data between an application program and computing hardware;
S5, in the process of data transmission or task execution, if hardware faults, communication interruption or task execution abnormality occur, immediately triggering an abnormality processing mechanism through an API to ensure continuous operation of the system, wherein the abnormality processing mechanism comprises:
the state of the computing hardware and the state of the application program are rolled back to the last stable state through the API, so that data loss or task interruption is prevented;
triggering a task restarting program through an API, automatically reallocating resources and continuously executing tasks from the abnormal nodes;
recording detailed log information of abnormal events through an API, wherein the detailed log information comprises occurrence time, abnormal type, related hardware components and abnormal codes;
and S6, after the task is completed, the communication with the hardware is safely disconnected through the API, the occupied resources are released, and the interaction log is recorded.
2. A method for interacting with computing hardware via an application programming interface according to claim 1, wherein S14 comprises:
s141, monitoring the residual bandwidth of the current network through an API (application program interface), and acquiring network throughput between computing hardware and an application program, wherein the throughput is expressed as the data quantity capable of being transmitted in unit time;
S142, calculating the size of a congestion window by adopting a TCP flow control method according to the requirements of network bandwidth and transmission rate, and adjusting the data transmission rate, wherein the size of the congestion window is in direct proportion to the network bandwidth, and the calculation formula of the size of the congestion window is as follows: , wherein, For the current congestion window size,Indicating the desired amount of data transmission in a period of time,The maximum congestion window size is the maximum congestion window size, and B is the current bandwidth;
s143, calculating and adjusting the size of the receiving buffer zone according to the adjustment of the real-time bandwidth and the congestion window To maintain efficient data transmission;
s144 congestion window according to the above calculation And a receive bufferDynamically adjusting data transmission rateThe relationship with congestion window and network bandwidth is calculated by the following formula:。
3. a method for interacting with computing hardware via an application programming interface according to claim 1, wherein S2 comprises:
s21, sending a device identification request to computing hardware through an API, wherein the request contains a device unique identifier and is communicated by using a standardized network protocol;
S22, after receiving the equipment identification request, the computing hardware returns a hardware information response, wherein the response contains basic attribute data of the hardware, including the model number of the processor, the size of the memory, the storage capacity and the state of the network interface;
s23, after receiving the hardware response, the API analyzes the returned hardware information and extracts related information, wherein the related information comprises the type of a processor, the memory capacity, the storage space of a hard disk, the network bandwidth and the number of residual computing cores;
S24, based on the analyzed hardware information, evaluating the current state of the hardware resources, including indexes of the utilization rate of the processor, the occupancy rate of the memory, the residual amount of the memory and the utilization rate of the network bandwidth, so as to determine the actual residual condition of the resources;
And S25, according to the hardware resource state evaluation result, the API generates a hardware resource list which contains detailed resource information of each hardware unit, including CPU utilization rate, memory residual space, storage residual space and network bandwidth.
4. A method for interacting with computing hardware via an application programming interface according to claim 1, wherein S33 comprises:
s331, extracting resource requirement parameters of each task from the ordered task list, including the required processor core number Memory capacityAnd a storage space, wherein,Respectively representing the number of processor cores, the memory capacity and the storage space requirements of the task t;
s332 extracting the residual resource information of each hardware node from the hardware resource list, including the residual processor core number Remaining memory capacityAnd remaining storage space, wherein,The number of remaining processor cores, the remaining memory capacity and the remaining memory space of the hardware h are respectively represented;
s333, calculating the matching degree of the resources according to the resource requirement of the task and the residual condition of the hardware resources, and calculating the matching degree according to the following formula for each task t and each hardware node h: , wherein, The resource matching degree of the task t and the hardware node h is represented;
S334, judging whether the feasibility of the resource allocation is satisfied for each task t and hardware node h, if so The hardware node can meet the resource requirement of the task, the task t can be distributed to the hardware node h, and if not, the distribution fails.
5. A method for interacting with computing hardware via an application programming interface according to claim 1, wherein S4 comprises:
S41, selecting a communication protocol suitable for bidirectional data transmission through an API, wherein the communication protocol of the bidirectional data transmission comprises a WebSocket protocol, an HTTP/2 protocol or an MQTT protocol;
s42, initiating an initial connection request with computing hardware through an API, and carrying out a handshake process by using a selected communication protocol to ensure that two parties can successfully establish a communication session;
s43, after establishing initial connection, executing authentication and authorization process through API;
s44, configuring related parameters of data transmission through an API, including data packet size, transmission buffer area size and data compression options;
And S45, simultaneously opening a channel for sending and receiving data between the application program and the computing hardware through the API, so as to ensure that the data can be transmitted and received in real time in two directions.
6. A method for interacting with computing hardware via an application programming interface according to claim 1, wherein S5 comprises:
S51, monitoring states of data transmission and task execution in real time through an API, and detecting occurrence of hardware faults, communication interruption or abnormal task execution by using monitoring parameters and threshold values;
s53, once an abnormal event is detected, an abnormal processing mechanism is immediately activated through an API;
S54, an exception notification is sent to a user or a system administrator through an API, the current system state and the processing result are informed, and exception information is provided.
7. A method for interacting with computing hardware via an application programming interface according to claim 1, wherein S6 comprises:
s61, sending a disconnection instruction through an API, notifying the computing hardware to terminate the current communication session, and preparing to close the bidirectional data channel;
s62, receiving a communication termination confirmation signal of the computing hardware through the API to confirm that the bidirectional data channel is successfully closed;
s63, sending a resource release request through an API (application program interface), and indicating the computing hardware to release the processor, the memory and the storage resources occupied in the task execution process;
S64, the computing hardware is instructed to clean up the cache and temporary data related to the current task through an API;
S65, automatically generating and storing an interaction log through the API, the interaction log including a time stamp of disconnection, released resource information, an event occurring during interaction, and status information.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411957546.6A CN119356896B (en) | 2024-12-30 | 2024-12-30 | Method for interacting with computing hardware through application programming interface |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411957546.6A CN119356896B (en) | 2024-12-30 | 2024-12-30 | Method for interacting with computing hardware through application programming interface |
Publications (2)
Publication Number | Publication Date |
---|---|
CN119356896A CN119356896A (en) | 2025-01-24 |
CN119356896B true CN119356896B (en) | 2025-05-23 |
Family
ID=94310944
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202411957546.6A Active CN119356896B (en) | 2024-12-30 | 2024-12-30 | Method for interacting with computing hardware through application programming interface |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN119356896B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105900391A (en) * | 2013-02-28 | 2016-08-24 | 微软技术许可有限责任公司 | Real-time communications using RESTLIKE API |
CN119180054A (en) * | 2024-09-18 | 2024-12-24 | 成都虚谷伟业科技有限公司 | Time sequence database lightweight API interface oriented to intelligent equipment |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9430259B2 (en) * | 2013-03-15 | 2016-08-30 | Centurylink Intellectual Property Llc | Virtualization congestion control framework for modifying execution of applications on virtual machine based on mass congestion indicator in host computing system |
KR20220073221A (en) * | 2020-11-26 | 2022-06-03 | (주)알앤비소프트 | System and Method for Monitoring Web Service Server |
CN117931481B (en) * | 2024-02-06 | 2025-09-26 | 南京邮电大学 | A method for rapid data exchange between real-time and time-sharing systems |
CN118966350A (en) * | 2024-07-12 | 2024-11-15 | 安徽工业大学 | A collaborative reasoning method for deep learning models on mobile multiprocessors |
CN119172051A (en) * | 2024-09-24 | 2024-12-20 | 安徽聚谦网络科技有限公司 | Internet of things gateway and gateway control method |
-
2024
- 2024-12-30 CN CN202411957546.6A patent/CN119356896B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105900391A (en) * | 2013-02-28 | 2016-08-24 | 微软技术许可有限责任公司 | Real-time communications using RESTLIKE API |
CN119180054A (en) * | 2024-09-18 | 2024-12-24 | 成都虚谷伟业科技有限公司 | Time sequence database lightweight API interface oriented to intelligent equipment |
Also Published As
Publication number | Publication date |
---|---|
CN119356896A (en) | 2025-01-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111818159B (en) | Management method, device, equipment and storage medium of data processing node | |
US8977886B2 (en) | Method and apparatus for rapid disaster recovery preparation in a cloud network | |
JP7234402B2 (en) | Secondary link monitoring method for vehicle communication, vehicle communication terminal, electronic device and computer program | |
US20090024994A1 (en) | Monitoring System for Virtual Application Environments | |
RU2471301C2 (en) | Functioning of network subjects in communication system comprising control network with levels of agents and control | |
JP2010204876A (en) | Distributed system | |
JP2018508072A (en) | Method and apparatus for pushing messages | |
CN110213338A (en) | A kind of clustering acceleration calculating method and system based on cryptographic calculation | |
US9621438B2 (en) | Network traffic management | |
CN107168853A (en) | A kind of server performance information acquisition method, system and substrate control manager | |
CN118474797A (en) | Application method and system for cloud acquisition of 5G gateway twin digits | |
CN115150460B (en) | Node security registration method, device, equipment and readable storage medium | |
CN119356896B (en) | Method for interacting with computing hardware through application programming interface | |
CN119025236A (en) | Task scheduling method, device, equipment and medium | |
CN109347760B (en) | Data sending method and device | |
CN118200376A (en) | Link switching method, device, equipment and storage medium | |
CN117896445A (en) | Multi-network protocol switching transmission method and device, electronic equipment and storage medium | |
US20240272929A1 (en) | Information processing device, job execution system, and control method | |
KR20240048227A (en) | Method and device for monitoring video service | |
WO2021077797A1 (en) | Quality of service measurement method and device, and user plane function | |
CN117478600B (en) | Flow control method and system for serving high concurrency multi-center business center | |
US12341675B2 (en) | Strategy to ensure continual user experience and system performance if an Uplink is stuck | |
CN120234225B (en) | Controller processing method, device, electronic device and medium | |
WO2025022446A1 (en) | System and method for network congestion management | |
KR20240069471A (en) | Method and device for video storage processing |
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 |