CN112698930B - Method, device, equipment and medium for obtaining server identification - Google Patents

Method, device, equipment and medium for obtaining server identification Download PDF

Info

Publication number
CN112698930B
CN112698930B CN202011637165.1A CN202011637165A CN112698930B CN 112698930 B CN112698930 B CN 112698930B CN 202011637165 A CN202011637165 A CN 202011637165A CN 112698930 B CN112698930 B CN 112698930B
Authority
CN
China
Prior art keywords
class
application
initialization
server
implementation
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
CN202011637165.1A
Other languages
Chinese (zh)
Other versions
CN112698930A (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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202011637165.1A priority Critical patent/CN112698930B/en
Publication of CN112698930A publication Critical patent/CN112698930A/en
Application granted granted Critical
Publication of CN112698930B publication Critical patent/CN112698930B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application provides a method for acquiring a WebSphere server identifier. When a Spring application container is started, loading a service container initialization class, calling a service container initialization class starting method containing specified class objects to obtain specified class implementation classes, instantiating the class implementation classes of the class objects, adding the instance of the class implementation class of the specified class object into a queue, calling the starting method of the instance in the queue, and acquiring the server identifier of the server where the container is located from the application context, thereby being capable of automatically acquiring the server identifier, and reducing the labor cost and the operation maintenance cost.

Description

Method, device, equipment and medium for obtaining server identification
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a computer readable storage medium for obtaining a server identifier.
Background
WebSphere is a widely used software platform in the industry. The software platform includes the entire middleware infrastructure, such as servers, services, and tools, required to write, run, and monitor on-demand Web applications and cross-platform, cross-product solutions.
The WebSphere operation architecture is shown in fig. 1, and the node usually corresponds to a real virtual machine, such as a Linux virtual machine, has an IP belonging to itself, and operates on a physical machine of a data center. In turn, multiple WAS servers (servers) may be built on each node, each server may independently manage its own internal Java applications, and each WAS server may own its own Java virtual machine (Java virtual machine, JVM) process. A cluster (cluster) is a collection of multiple WAS servers that participate in workload management. Servers as cluster members can be located on different node nodes to realize cross-node server management, and the servers are generally grouped and configured by taking the cluster as a unit in practical application.
One application is typically deployed in each server to achieve isolation between different applications. With the increase of project systems, demands for WAS resources are increasing, so that in order to better realize resource utilization, multiple servers inevitably appear in the development, test and production environments, namely, more than one server exists on each node. There is a need for a way to uniquely identify different applications located at different servers.
In the prior art, JVM parameters can be set in each server by the WebSphere console, and the server name can be written as a unique identifier of the server. Specifically, in the general JVM parameter box, a server name variable is added, and a server name is set. So far, the server name can be obtained in the code by obtaining the JVM system attribute and used as the unique identifier of the server. If each server adds a JVM parameter to set the server name, then the labor and operating costs would be increased.
Disclosure of Invention
The application provides a method for acquiring a server identifier. According to the method, the service container initialization class is loaded through the container of the deployment application, then the starting method of the service container initialization class containing the specified class object is called, the implementation class of the specified class is obtained, the instance of the implementation class of the specified class object is added into the queue, the starting method of the instance in the queue is called, and the identification of the server where the container is located is acquired from the application context, so that the identification of the server can be automatically acquired, and the labor cost and the operation maintenance cost are reduced. The application also provides a device, equipment and medium corresponding to the method.
In a first aspect, the present application provides a method for obtaining a server identifier. The method comprises the following steps:
when the application is started, the container for deploying the application loads a service container initialization class, and the annotation of the service container initialization class comprises a specified class object which is used as a starting method for transmitting the parameter to the service container initialization class;
calling a starting method of a service container initialization class to obtain an implementation class of a specified class object;
instantiating the implementation class of the specified class object, and adding the instance of the implementation class of the specified class object into a queue;
and calling an example starting method in the queue, and acquiring a server identification of a server where the container is located from the application context.
In some possible implementations, the method further includes:
the server identification is written to a system parameter of the virtual machine to reference the server identification according to the system parameter.
In some possible implementations, specifying the class object includes applying an initialization class object.
In some possible implementations, instantiating the implementation class of the specified class object includes:
traversing the application initialization class set when the application initialization class set is not empty;
when the implementation class of the application initialization class object in the application initialization class set is not an interface and abstract class, the implementation class of the application initialization class object is instantiated through reflection.
In some possible implementations, the method for starting the instance in the call queue obtains, from the application context, a server identifier of a server where the container is located, including:
and circularly calling a starting method in the queue, and when the starting method of the instance of the implementation class of the self-defined application initialization class object is called, acquiring the server identification of the server where the container is located from the application context.
In some possible implementations, the implementation class of the application-initialization class object includes a loading order annotation in which a priority of the implementation class of the application-initialization class object is specified, and the priority of the implementation class of the application-initialization class object is higher than a priority of the framework initiator.
In a second aspect, the present application provides an apparatus for obtaining a server identifier. The device comprises:
the loading module is used for loading the service container initialization class when the application is started, and the annotation of the service container initialization class comprises a specified class object which is used as a starting method of the parameter to be transmitted to the service container initialization class;
the calling module is used for calling a starting method of the service container initialization class to obtain an implementation class of the specified class object;
the instantiation module is used for instantiating the implementation class of the specified class object and adding the instance of the implementation class of the specified class object into the queue;
the calling module is also used for calling the starting method of the instance in the queue and obtaining the server identification of the server where the container is located from the application context.
In some possible implementations, the apparatus further includes:
and the writing module is used for writing the server identifier into the system parameters of the virtual machine so as to refer to the server identifier according to the system parameters.
In some possible implementations, specifying the class object includes applying an initialization class object.
In some possible implementations, the instantiation module is specifically configured to:
traversing the application initialization class set when the application initialization class set is not empty;
when the implementation class of the application initialization class object in the application initialization class set is not an interface and abstract class, the implementation class of the application initialization class object is instantiated through reflection.
In some possible implementations, the calling module is specifically configured to:
and circularly calling a starting method in the queue, and when the starting method of the instance of the implementation class of the self-defined application initialization class object is called, acquiring the server identification of the server where the container is located from the application context.
In some possible implementations, the implementation class of the application-initialization class object includes a loading order annotation in which a priority of the implementation class of the application-initialization class object is specified, and the priority of the implementation class of the application-initialization class object is higher than a priority of the framework initiator.
In a third aspect, the present application provides an apparatus comprising a processor and a memory. The processor and the memory communicate with each other. The processor is configured to execute instructions stored in the memory to cause the apparatus to perform a method of obtaining a server identity as in the first aspect or any implementation of the first aspect.
In a fourth aspect, the present application provides a computer readable storage medium, where instructions are stored to instruct a device to perform the method for obtaining a server identifier according to the first aspect or any implementation manner of the first aspect.
In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a device, cause the device to perform the method of obtaining a server identity as described in the first aspect or any implementation of the first aspect.
Further combinations of the present application may be made to provide further implementations based on the implementations provided in the above aspects.
From the above technical solutions, the embodiment of the present application has the following advantages:
the application provides a method for automatically obtaining a server identifier, which comprises the steps of loading a service container initialization class when an application is started by deploying an application container, then calling a starting method of the service container initialization class, obtaining an implementation class of a specified class object according to the specified class object contained in the starting method, instantiating the implementation class, adding an instance into a queue, and finally calling the starting method of the instance in the queue by the container, thereby obtaining the server identifier of the server where the container is located from the application context. Therefore, the unique identification of the server can be automatically acquired, and the labor cost and the operation and maintenance cost are reduced.
Further, the container for deploying the application writes the acquired server identifier into the system parameter of the virtual machine, so that the server identifier is referenced according to the system parameter, and the application can use the server identifier like other environment configuration items.
Drawings
In order to more clearly illustrate the technical method of the embodiments of the present application, the drawings required for the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is a schematic diagram of a WebSphere operation architecture according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for obtaining a server identifier according to an embodiment of the present application;
FIG. 3 is a flowchart of another method for obtaining a server identifier according to an embodiment of the present application;
fig. 4 is a UML class diagram of a method for obtaining a server identifier according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a device for obtaining a server identifier according to an embodiment of the present application.
Detailed Description
The embodiments of the present application will be described below with reference to the drawings.
The terms "first", "second" in embodiments of the application are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature.
Some technical terms related to the embodiments of the present application will be described first.
WebSphere is a software platform that contains the on-demand Web applications that write, run and monitor all-weather industry strengths and the entire middleware infrastructure required for cross-platform, cross-product solutions. WebSphere can provide a secure, scalable, resilient application infrastructure that helps build, run, integrate, and manage dynamic, on-demand business applications.
WebSphere is widely cited in development test and production of Java applications, and an operation architecture includes a node (node), a server, a cluster (cluster), etc., as shown in fig. 1, where the node usually corresponds to a real virtual machine (such as a Linux virtual machine), has an internet protocol address (Internet protocol address, IP address) of the node, and runs on a physical machine of a data center. In turn, multiple servers can be built on each node, each server can independently manage its own internal Java applications, and each server has its own Java virtual machine (Java virtual machine, JVM) processes. A cluster is a collection of multiple servers participating in workload management, and servers that are members of the cluster may be located on different node nodes, so as to implement cross-node server management, and typically, group management and configuration are performed on servers in units of the cluster.
One application is typically deployed in each server to achieve isolation between different applications. With the increase of project systems, the demands for WebSphere resources are increasing, so that in order to better realize resource utilization, multiple service scenarios of servers inevitably occur in development, test and production environments, namely, more than one server exists on each node. There is therefore a need for a way to uniquely identify different applications located at different servers.
In general, JVM parameters can be set for servers in each node respectively by using a WebSphere console, and a server name can be written as a unique identifier of the server. Specifically, a server name variable is added in a general JVM parameter frame, and a server name is set, so that the server name can be obtained in a code in a mode of obtaining JVM system attributes and used as a unique identifier of a server.
In practical applications, because most applications use multiple servers for deployment, if each server uses a manual method to add a JVM parameter to set a server name, huge labor cost and operation and maintenance cost are required.
In view of this, the present application provides a method capable of automatically acquiring a server identifier, which is performed by a container for deploying an application, and automatically acquiring a unique identifier of a server where the container is located during an application start-up process.
Specifically, when the application is started, the container for deploying the application loads the service container initialization class, then invokes a starting method of the service container initialization class containing the specified class object to obtain the implementation class of the specified class object, instantiates the implementation class of the specified class object, adds the instance of the implementation class of the specified class object into the queue, invokes the starting method of the instance in the queue, and acquires the server identifier of the server where the container is located from the application context, thereby being capable of automatically acquiring the identifier of the server, and reducing the labor cost and the operation maintenance cost.
For easy understanding, the method for obtaining the server identifier according to the embodiment of the present application is specifically described below with reference to the accompanying drawings.
Referring to the flowchart of the method for obtaining a server identifier shown in fig. 2, the method includes:
s202: the container deploying the application loads the service container initialization class when the application is started.
Wherein the annotation of the service container initialization class includes a specified class object, which may initialize the class object for the application. In this embodiment, the specified class object is passed as a parameter to the service container initialization class initiation method.
In some possible implementations, some initialization operations need to be performed in advance to implement the solution, such as registering servlets, which are implemented in the Servlet specification by the servletContainerInitializer.
When the application is started, a service container initialization class servletContainerInitiazer instance of all jar packets in the current application is created, and the implementation of the servletContainerInitiazer is placed under the META-INF/service folder of the jar packets. In the Servlet specification, the @ HandlersTypes annotation enables loading of specified classes at the time of application launch. The server name can be obtained by realizing an application initialization class object interface on the premise that the application initialization class object class is specified by @ HandlersTypes.
Taking a Servlet container as an example, when an application is started, the Servlet container for deploying the application discovers and loads a Servlet container initialization class servletContainerInitializer based on a service discovery mechanism (service provider interface, SPI). The Servlet container of the deployment application acquires the specified class object in the annotation of the servletContainerInitiazer and passes the specified class object as a parameter to the startup method of the servletContainerInitiazer.
Because the Servlet container discovers and loads the servletContainerInitializer based on the SPI mechanism, the implementation class of the servletContainerInitializer can write the full class name of the implementation class in the META-INF/services/servlet.servlet.servletContainerInitializer file of the corresponding Jar package, so that the implementation class provided by the Spring Web can be seen in the file of the corresponding Jar of the Spring Web as follows: org. Thus, the Servlet container deploying the application loads all servletContainerInitializer implementation classes by the load method in Java API ServiceLoader.
The service container initialization class can implement a service container initialization class interface, and annotations on the class can pass specified class objects as parameters into the startup method of the service container initialization class.
Taking a Servlet container as an example, the SpringServerContainerInitiazer Class implements a Servlet servletContainerInitiazer interface, and notes @ Handles types on the Class can transfer specified Class (Class) objects as parameters to an onStartup method.
S204: the container for deploying the application calls a starting method of the service container initialization class to obtain the realization class of the specified class object.
Because the annotation of the service container initialization class includes a specified class object, the specified class object is passed as a parameter to the method for starting the service container initialization class, and the container deploying the application can call the method for starting the service container initialization class, obtain a specific implementation class of the specified class object from the method, and call a specific method in the implementation class.
In practical application, a Servlet container for deploying application calls a startup (onStartup) method of a SpringServerContainerInitiazer, and a specific implementation Class of a specified Class object is acquired in the onStartup method, so that a specific method in the implementation Class is called.
The @ HandlerTypes Class in the SpringServerContainerInitializer Class specifies that the Class object is an application initialization Class object (WebApplationInitializer). By utilizing the mechanism, the WebAplicationInitializer can be regarded as an extended interface, and when the WebAplicationInitializer interface is realized, a user can inject servlets through customization.
S206: the container of the deployment application instantiates the implementation class of the specified class object and adds the instance of the implementation class of the specified class object to the queue.
Specifically, a container for deploying an application checks whether an application initialization set is empty, when an application initialization class set is not empty, the application initialization class set is traversed, and when an implementation class of an application initialization class object in the application initialization class set is not an interface and abstract class, the container for deploying the application instantiates the implementation class of the application initialization class object through reflection, and then the instance of the implementation class of the specified class object is added into a queue.
For example, when the Servlet container checks that webappinit policies (implementation classes of all webappinit analyzers) are not empty, it is determined whether webappinit policies are interfaces or abstract classes by traversing all implementation classes of webappinit analyzers, and when the implementation classes of webappinit analyzers are not interfaces and implementation classes, the Servlet container instantiates those implementation classes of webappinit policies by reflection and then adds the instantiations of the implementation classes of webappinit to the queue.
S208: the method for starting the instance in the container call queue of the deployment application acquires the server identification of the server where the container is located from the application context.
Context is a collection of stored key-value pairs, typically as an information gathering relay for the whole tool. For example, the WebSphere starts up by writing the server name in ServletContext, so the server name can be obtained from ServletContext. In this embodiment, the method for starting an instance in the container call queue of the deployment application can obtain the server identifier of the server where the container is located from the application context.
In some possible implementations, the launch method in the container loop call queue of the application is deployed, and when the launch method to the instance of the implementation class of the custom application initialization class object is invoked, the server identification of the server where the container is located is obtained from the application context.
Specifically, the Servlet container circularly calls the onStartup method in the webapplication initiator queue, and when the onStartup method of the custom webapplication initiator implementation class mywebapplication initiator is called, the Servlet container acquires the server name from the ServletContext. Since the server name is written in ServletContext at the time of startup of the container, the server name can be acquired from ServletContext.
The embodiment of the application provides a method for automatically acquiring a server identifier, which comprises the steps of loading a service container initialization class when an application is started by deploying a container of an application, then calling a starting method of the service container initialization class containing a specified class object to acquire an implementation class of the specified class object, instantiating the implementation class of the class object, adding an instance of the implementation class of the specified class object into a queue, calling the starting method of the instance in the queue, and acquiring the server identifier of a server where the container is located from an application context, thereby automatically acquiring the identifier of the server, and reducing labor cost and operation maintenance cost.
The method for automatically obtaining the server identifier provided by the application is specifically described above, and another method for automatically obtaining the server identifier provided by the embodiment of the application is described below with reference to fig. 3.
S302: the container deploying the application loads the service container initialization class when the application is started.
The annotation of the service container initialization class includes a specified class object, which is passed as a parameter to the startup method of the service container initialization class.
S304: the container for deploying the application calls a starting method of the service container initialization class to obtain the realization class of the specified class object.
S306: the container deploying the application checks if the application initialization set is empty and traverses the application initialization class set when the application initialization class set is not empty.
S308: when the implementation class of the application initialization class object in the application initialization class set is not an interface and abstract class, a container for deploying the application instantiates the implementation class of the application initialization class object by reflection, and then adds the instance of the implementation class of the specified class object to the queue.
S310: the container deploying the application orders the application initialization class object queue.
The implementation class of the application initialization class object includes a loading order annotation in which a priority of the implementation class of the application initialization class object is specified, and the priority of the implementation class of the application initialization class object is higher than a priority of a frame initiator (swing boot). If it is desired that the startup method be loaded preferentially, the loading Order needs to be adjusted by adding @ Order annotations to the application initialization class object implementation class.
S312: and when the starting method of the instance of the implementation class of the custom application initialization class object is called, the server identification of the server where the container is located is acquired from the application context.
S314: the container deploying the application writes the server identification to a system parameter of the virtual machine to reference the server identification according to the system parameter.
Specifically, the acquired server name is written into the JVM system parameter, a starting method of a war package application project starting class father class (such as SpringBootServertInitializer) is called in the implementation class of all application initializing class objects, a createRootApplicification Context method is called in the method, a configuration method of callback rewriting is performed through the this configuration, and finally a run method is called to enter a starting flow of SpringIOC.
Specific modeling language of Servlet referring to fig. 4, fig. 4 is a unified modeling language (unified modeling language, UML) class diagram of the above-mentioned key classes.
Therefore, the method and the device automatically acquire the unique identifier of the server where the application container is located, and write the acquired server identifier into the system parameters of the virtual machine through the application deployment container, so that the application refers to the server identifier according to the system parameters, and the application can use the server identifier like using other environment configuration items.
Corresponding to the above method embodiment, the present application further provides an apparatus for obtaining a server identifier, referring to fig. 5, where the apparatus 500 includes: a load module 502, a call module 504, and an instantiation module 506.
The loading module 502 is configured to load a service container initialization class when the application is started, where the annotation of the service container initialization class includes a specified class object, and the specified class object is used as a parameter to be transferred to a starting method of the service container initialization class;
a calling module 504, configured to call a startup method of a service container initialization class to obtain an implementation class of a specified class object;
an instantiation module 506, configured to instantiate an implementation class of the specified class object, and add an instance of the implementation class of the specified class object to the queue;
the calling module 504 is further configured to call a method for starting an instance in the queue, and obtain a server identifier of a server where the container is located from the application context.
In some possible implementations, the apparatus 500 further includes:
and the writing module is used for writing the server identifier into the system parameters of the virtual machine so as to refer to the server identifier according to the system parameters.
In some possible implementations, specifying the class object includes applying an initialization class object.
In some possible implementations, the instantiation module 506 is specifically configured to:
traversing the application initialization class set when the application initialization class set is not empty;
when the implementation class of the application initialization class object in the application initialization class set is not an interface and abstract class, the implementation class of the application initialization class object is instantiated through reflection.
In some possible implementations, the calling module 504 is specifically configured to:
and circularly calling a starting method in the queue, and when the starting method of the instance of the implementation class of the self-defined application initialization class object is called, acquiring the server identification of the server where the container is located from the application context.
In some possible implementations, the implementation class of the application-initialization class object includes a loading order annotation in which a priority of the implementation class of the application-initialization class object is specified, and the priority of the implementation class of the application-initialization class object is higher than a priority of the framework initiator.
The application provides equipment for realizing a safety verification method. The apparatus includes a processor and a memory. The processor and the memory communicate with each other. The processor is configured to execute instructions stored in the memory to cause the device to perform a security check method.
The present application provides a computer readable storage medium having instructions stored therein that, when executed on a device, cause the device to perform the above-described security verification method.
The present application provides a computer program product comprising instructions which, when run on a device, cause the device to perform the above-described security verification method.
It should be further noted that the above-described apparatus embodiments are merely illustrative, and that the units described as separate units may or may not be physically separate, and that units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the drawings of the embodiment of the device provided by the application, the connection relation between the modules represents that the modules have communication connection, and can be specifically implemented as one or more communication buses or signal lines.
From the above description of the embodiments, it will be apparent to those skilled in the art that the present application may be implemented by means of software plus necessary general purpose hardware, or of course by means of special purpose hardware including application specific integrated circuits, special purpose CPUs, special purpose memories, special purpose components, etc. Generally, functions performed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same functions can be varied, such as analog circuits, digital circuits, or dedicated circuits. However, a software program implementation is a preferred embodiment for many more of the cases of the present application. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a readable storage medium, such as a floppy disk, a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk or an optical disk of a computer, etc., comprising several instructions for causing a computer device (which may be a personal computer, a training device, a network device, etc.) to perform the method according to the embodiments of the present application.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via a wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a training device, a data center, or the like that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy Disk, a hard Disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.

Claims (6)

1. A method for obtaining a server identification, the method comprising:
when the application is started, a container for deploying the application loads a service container initialization class, wherein the annotation of the service container initialization class comprises a specified class object, the specified class object is used as a parameter to be transmitted to a starting method of the service container initialization class, and the specified class object comprises an application initialization class object;
invoking a starting method of the service container initialization class to obtain an implementation class of the specified class object;
instantiating the implementation class of the specified class object, and adding the instance of the implementation class of the specified class object into a queue;
invoking a starting method of the instance in the queue, and acquiring a server identifier of a server where the container is located from an application context;
the instantiating the implementation class of the specified class object includes:
traversing the application initialization class set when the application initialization class set is not empty;
when the implementation class of the application initialization class object in the application initialization class set is not an interface and abstract class, instantiating the implementation class of the application initialization class object through reflection;
the method for calling the example in the queue to start the example in the queue acquires the server identification of the server where the container is located from the application context, and the method comprises the following steps:
and circularly calling the starting method in the queue, and when the starting method of the instance of the implementation class of the self-defined application initialization class object is called, acquiring the server identification of the server where the container is located from the application context.
2. The method according to claim 1, wherein the method further comprises:
and writing the server identification into a system parameter of the virtual machine so as to refer to the server identification according to the system parameter.
3. The method of claim 1, wherein the implementation class of the application-initialization class object includes a loading order annotation in which a priority of the implementation class of the application-initialization class object is specified, and wherein the priority of the implementation class of the application-initialization class object is higher than a priority of a framework initiator.
4. An apparatus for obtaining a server identification, the apparatus comprising:
the loading module is used for loading a service container initialization class when the application is started, wherein the annotation of the service container initialization class comprises a specified class object which is transmitted to the starting method of the service container initialization class as a parameter, and the specified class object comprises an application initialization class object;
the calling module is used for calling a starting method of the service container initialization class to obtain an implementation class of the specified class object;
an instantiation module, configured to instantiate an implementation class of the specified class object, and add the instance of the implementation class of the specified class object to a queue;
the calling module is further used for calling a starting method of the instance in the queue and acquiring a server identifier of a server where the container is located from an application context;
the instantiation module is specifically configured to:
traversing the application initialization class set when the application initialization class set is not empty;
when the implementation class of the application initialization class object in the application initialization class set is not an interface and abstract class, instantiating the implementation class of the application initialization class object through reflection;
the calling module is specifically configured to:
and circularly calling the starting method in the queue, and when the starting method of the instance of the implementation class of the self-defined application initialization class object is called, acquiring the server identification of the server where the container is located from the application context.
5. An apparatus comprising a processor and a memory;
the processor is configured to execute instructions stored in the memory to cause the apparatus to perform the method of any one of claims 1 to 3.
6. A computer readable storage medium comprising instructions that instruct a device to perform the method of any one of claims 1 to 3.
CN202011637165.1A 2020-12-31 2020-12-31 Method, device, equipment and medium for obtaining server identification Active CN112698930B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011637165.1A CN112698930B (en) 2020-12-31 2020-12-31 Method, device, equipment and medium for obtaining server identification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011637165.1A CN112698930B (en) 2020-12-31 2020-12-31 Method, device, equipment and medium for obtaining server identification

Publications (2)

Publication Number Publication Date
CN112698930A CN112698930A (en) 2021-04-23
CN112698930B true CN112698930B (en) 2023-11-07

Family

ID=75513777

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011637165.1A Active CN112698930B (en) 2020-12-31 2020-12-31 Method, device, equipment and medium for obtaining server identification

Country Status (1)

Country Link
CN (1) CN112698930B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113918235B (en) * 2021-09-17 2023-11-17 贝壳找房(北京)科技有限公司 Application loading method and device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109155749A (en) * 2016-06-21 2019-01-04 甲骨文国际公司 The natural language interaction formula message transfer service session device of internet cloud trustship
CN109491762A (en) * 2018-11-09 2019-03-19 网易(杭州)网络有限公司 Container state control method and device, storage medium, electronic equipment
CN112104715A (en) * 2020-08-31 2020-12-18 银盛支付服务股份有限公司 Link tracking method and system based on microservice log

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
IL148130A0 (en) * 1999-08-16 2002-09-12 Force Corp Z System of reusable software parts and methods of use
WO2007081794A2 (en) * 2006-01-06 2007-07-19 Ld Car, Llc D/B/A Convergence Communications System and method for extending the business data associated with a network-based user collaboration tool to include spatial reference information for collaborative visualization
US10803078B2 (en) * 2015-10-23 2020-10-13 Oracle International Corporation Ability to group multiple container databases as a single container database cluster

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109155749A (en) * 2016-06-21 2019-01-04 甲骨文国际公司 The natural language interaction formula message transfer service session device of internet cloud trustship
CN109491762A (en) * 2018-11-09 2019-03-19 网易(杭州)网络有限公司 Container state control method and device, storage medium, electronic equipment
CN112104715A (en) * 2020-08-31 2020-12-18 银盛支付服务股份有限公司 Link tracking method and system based on microservice log

Also Published As

Publication number Publication date
CN112698930A (en) 2021-04-23

Similar Documents

Publication Publication Date Title
US8103760B2 (en) Dynamic provisioning of service components in a distributed system
CN110752947A (en) K8s cluster deployment method and device, and deployment platform
CN109144478B (en) Component frame system and method of using the same
CN111124589B (en) Service discovery system, method, device and equipment
CN111245634B (en) Virtualization management method and device
CN111857733B (en) Construction method, device and system of service environment and readable storage medium
CN109104368B (en) Connection request method, device, server and computer readable storage medium
CN113691635B (en) Method and device for calling microservice, electronic equipment and readable storage medium
CN113157339A (en) Application service expansion method, system, storage medium and device based on OSB
CN112698838A (en) Multi-cloud container deployment system and container deployment method thereof
CN112698930B (en) Method, device, equipment and medium for obtaining server identification
CN115086166A (en) Computing system, container network configuration method, and storage medium
EP2216962B1 (en) A method for deploying and managing the sip servlet application and the osgi service platform thereof
CN111367685A (en) Interface calling method and device, computer equipment and storage medium
CN116724543A (en) Container cluster management method and device
CN111324395A (en) Calling method, calling device and computer-readable storage medium
CN114726905B (en) Method, device, equipment and storage medium for accessing Tbox network into Android system
CN113064737B (en) Method for enabling components of software communication architecture to run in parallel on multi-core processor
CN116257438A (en) Updating method of interface test case and related equipment
CN115525396A (en) Application management method and device based on cloud protogenesis
CN112738181A (en) Method, device and server for cluster external IP access
CN110413333B (en) Micro-service management method and device of Windows system based on NodeJS and PowerShell
US20210051059A1 (en) Methods and network systems for enabling a network service in a visited network
CN116560756B (en) Service orchestration method, electronic device, computer-readable storage medium
CN112748981B (en) Processing method and device for software mirror image of virtual network function

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