Notes 001

1、new String(PropertiesUtil.get("SATRANS.MERCHANT_NAME").getBytes("ISO8859-1"),"UTF-8")

      new String(Base64.decode(encodeStr),"UTF-8")

 

2. We often set the time field in mysql to the bigint type, and when java is stored, it is directly stored in new Date().getTime(), so that the time of the bigint type cannot be viewed when we directly query the sql statement.

      SELECT id,

      FROM_UNIXTIME(time/1000),--2015-09-06 16:51:09.3560

      FROM_UNIXTIME(time/1000, '%Y%m%d'),--20150906

      FROM_UNIXTIME(time/1000, '%Y year%m month%d') --2015-09-06

      FROM aaa_test_table;

 

3. The implementation mechanism of intercepter: struts has its own interceptor mechanism, and spring mvc uses an independent AOP method. In this way, the amount of configuration files of struts is still larger than that of spring mvc, although the configuration of struts can be inherited, so I think that in terms of use, spring mvc is more concise, and the development efficiency of spring mvc is indeed higher than that of struts2.

      Spring mvc is a method-level interception, a method corresponds to a request context, and a method corresponds to a url at the same time, so spring3 mvc can easily implement restful url from the architecture itself.

      Struts2 is a class-level interception, a class corresponds to a request context; it takes effort to implement a restful url, because a method of struts2 action can correspond to a url; and its class attributes are shared by all methods, which cannot use annotations or other methods. Identifies the method to which it belongs.

 

4. Database transaction isolation level

      There are four isolation levels of database transactions, from low to high: Read uncommitted read uncommitted, Read committed read committed, Repeatable read repeated read, Serializable, these four levels can solve dirty read, non-repeatable read, phantom read one by one several types of problems.

      Serializable serialization: Serializable is the highest transaction isolation level, but also has the highest cost, low performance, and is generally rarely used. At this level, transactions are executed sequentially, which can not only avoid dirty reads, non-repeatable reads, but also phantoms read.

 

5. Pessimistic lock, optimistic lock

      Pessimistic Lock, as the name suggests, is very pessimistic. Every time I go to get the data, I think that others will modify it, so every time I get the data, it will be locked, so that others will block until it gets the data. to the lock. Many such lock mechanisms are used in traditional relational databases, such as row locks, table locks, read locks, write locks, etc., all of which are locked before operations are performed.

      Optimistic Lock, as the name suggests, is very optimistic. Every time I go to get data, I think that others will not modify it, so it will not be locked, but when it is updated, it will judge whether others have updated it during this period. Data, you can use mechanisms such as version numbers. Optimistic locks are suitable for multi-read application types, which can improve throughput. For example, if the database provides a mechanism similar to write_condition, it is actually an optimistic lock.

      Both types of locks have their own advantages and disadvantages, and one cannot be considered better than the other. For example, optimistic locks are suitable for the case where there are few writes, that is, when conflicts really rarely occur, which can save the overhead of locks, plus increase the overall throughput of the system. However, if conflicts occur frequently, the upper-layer application will continue to retry, which will reduce performance, so it is more appropriate to use pessimistic locks in this case.

 

6. MQ: safe and stable) (MQ plays a buffering role in the middle) (the main reason is that in a high concurrency environment, because it is too late to process synchronously, requests are often blocked. By using message queues, we can process requests asynchronously. , thereby relieving the pressure on the system.)

 

7. HTTP: HyperText Transfer Protocol (HTTP) is the most widely used network protocol on the Internet.

      TCP (Transmission Control Protocol)

      MIME (Multipurpose Internet Mail Extensions) Multipurpose Internet Mail Extensions

      The HTTP protocol uses a request/response model, where the client sends a request to the server

 

8、HTTP GET、POST

     Http defines different methods for interacting with the server. There are four most basic methods, namely GET, POST, PUT, and DELETE.

     URL (Uniform Resoure Locator: Uniform Resource Locator)

     1. The data of the GET request will be appended to the URL (that is, the data will be placed in the HTTP protocol header), the URL and the transmission data are separated by ?, and the parameters are connected by &, such as: login.action?name=hyddd&password=idontknow&verify= %E4%BD%A0%E5%A5%BD.

       If the data is English letters/numbers, send it as it is, if it is a space, convert it to +, if it is Chinese/other characters, directly encrypt the string with BASE64, and get such as: %E4%BD%A0%E5%A5% BD, where XX in %XX is the ASCII hex representation of the symbol.

           POST places the submitted data in the body of the HTTP packet.

      2. The data submitted by GET method can only be up to 1024 bytes. In theory, there is no limit to POST, and a large amount of data can be transmitted.

      3. The security of POST is higher than that of GET. Submitting data through GET, the user name and password will appear on the URL in plain text, and the information will be leaked.

      4. Get is a request to the server for data, and Post is a request to submit data to the server. In the FORM (form), the Method defaults to "GET". In essence, GET and POST are just different sending mechanisms , not a take a hair!

 

9. Cluster/distributed: Distributed improves efficiency by shortening the execution time of a single task, while cluster improves efficiency by increasing the number of tasks executed per unit time.

      1. Cluster concept:

       Scalability - The performance of the cluster is not limited to a single service entity, and new service entities can be dynamically added to the cluster to enhance the performance of the cluster.

       Clustering saves clients from easily encountering out of service warnings through service entity redundancy. In a cluster, the same service can be provided by multiple service entities. If one service entity fails, another service entity takes over the failed service entity. The ability to recover from one faulty service entity to another service entity provided by the cluster enhances the availability of the application.

      2. Two major abilities:

       Load balancing - Load balancing can distribute tasks evenly to computing and network resources in a cluster environment.

       Error recovery - for some reason a resource performing a task fails, and a resource performing the same task in another service entity then completes the task. This process of transparently continuing to complete tasks due to the inability of resources in one entity to work with resources in another entity is called error recovery.

      3. Two major technologies:

       Cluster address - The cluster consists of multiple service entities, and the cluster client obtains the functions of each service entity in the cluster by accessing the cluster address of the cluster.

       Internal communication - in order to work together, achieve load balancing and error recovery, the entities in the cluster must communicate frequently, such as the load balancer's heartbeat test information for service entities, and the communication of task execution context information between service entities.

    Cluster classification: Linux clusters are mainly divided into three categories (high availability cluster, load balancing cluster, scientific computing cluster)

 

        ServletContext is a global space for storing information. When the server starts, it exists, and when the server closes, it is released. request, a user can have multiple; session, one user; and servletContext, all users share one. Therefore, in order to save space and improve efficiency, in the ServletContext, it is necessary to put necessary and important threads that all users need to share to be safe. ctx.setAttribute("publickey" , Constants.DES_PUBLIC_ENCRYPT_KEY);

 

         CDN (the full name of CDN is Content Delivery Network, that is, Content Delivery Network) 

         hadoop (Hadoop is a distributed system infrastructure developed by the Apache Foundation)

         angluarjs (AngularJS is a JavaScript framework.)

         groovy (Simply put, Groovy is the next-generation java language, and like java, it also runs in the JVM.)

         lua (Lua is a lightweight and compact scripting language, written in standard C language and open in source code form, designed to be embedded in applications to provide flexible extension and customization capabilities for applications.)

         Node.js (In short, Node.js is JavaScript running on the server. Node.js is a platform built on the Chrome JavaScript runtime.)

 

         async: false, (default is true); false is synchronous, when async: true, the ajax request is asynchronous.

 

         Distributed works in parallel, and clusters work in series.

         1: Distributed refers to distributing different services in different places. Clustering refers to grouping several servers together to achieve the same business. 

          Clusters have an organizational structure. When one server fails, other servers can come up.

          Each distributed node completes a different business. If a node fails, the business cannot be accessed.

          2: Simply put, distribution improves efficiency by shortening the execution time of a single task, while clustering improves efficiency by increasing the number of tasks executed per unit time.

 

           @Autowired annotation, it can annotate class member variables, methods and constructors to complete the work of automatic assembly. Eliminate set, get methods through the use of @Autowired.

           The role of @Resource is equivalent to @Autowired, except that @Autowired is automatically injected according to byType, and @Resource is automatically injected according to byName by default.

           There are two important attributes of @Resource, namely name and type. Spring parses the name attribute of the @Resource annotation as the name of the bean, and the type attribute parses it as the type of the bean. So if the name attribute is used, the automatic injection strategy of byName is used, and the automatic injection strategy of byType is used when the type attribute is used. If neither the name nor the type attribute is specified, the strategy will be automatically injected using byName through the reflection mechanism.

 

              @RequestMapping(value = "/index")

      public String index(@RequestParam(value = "action", required = false) String action,                                           @RequestParam(value = "notIncludeTypeId", required = false) int notIncludeTypeId){

                    // .... omit code

              }

              When the optional parameter "notIncludeTypeId" does not exist, Spring assigns it to null by default, but since notIncludeTypeId is already set to be the base type int, the assignment fails! Use wrapper types instead of primitive types, such as "Integer" instead of "int".

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327028901&siteId=291194637
001