ITeye博客

2017 年文章归档

共 119 篇文章

Java类加载器类型

原创转载请注明出处: http://agilestyle.iteye.com/blog/2369539 JVM自带的加载器 根类加载器(Bootstrap)(C++编写) 扩展类加载器(Extension)(Java编写) 系统类加载器System)(也被称为应用类加载器,Java编写) 用户自定义的类加载器 java.lang.ClassLoader的子类 用户可以定制类的加载方式 Java的可执行文件不同于C/C++,Java编译器只产生中间字节码文件(.class文件),由Java虚拟机(java.exe)解释执行。Java发布的程序(JAR包)也多半是一堆class文件,运行时由Cl…

2017-04-16 23:17 · JVM

JVM heap and stack

原创转载请注明出处: http://agilestyle.iteye.com/blog/2369538 heap 和stack 有什么区别 栈是运行时的单位,地址是由高到低减少的。 堆是存储的单位,地址是由低到高增长的。 栈中存的是基本数据类型和堆中对象的引用;堆中存的是对象。

2017-04-16 23:05 · JVM

Spring MVC processing flow

原创转载请注明出处: http://agilestyle.iteye.com/blog/2369016 DispatcherServlet receives the request. DispatcherServlet dispatches the task of selecting an appropriate controller to HandlerMapping. HandlerMapping selects the controller which is mapped to the incoming request URL and returns the (selected Han…

2017-04-13 19:36 · Spring

高可用高并发设计原则

原创转载请注明出处: http://agilestyle.iteye.com/blog/2368282 高并发原则 无状态 拆分 服务化 消息队列 数据异构 缓存银弹 并发化 高可用原则 网站高可用的主要手段是冗余 ,应用部署在多台服务器上同时提供访问,数据存储在多台服务器上互相备份,任何一台服务器宕机不影响应用的整体可用,也不会导致数据丢失。 对于应用服务器而言,多台应用服务器通过负载均衡设备组成一个集群共同对外提供服务,任何一台服务器宕机,只需要把请求切换到其他服务器就可实现应用的高可用,但是一个前提条件是应用服务器上不能保存请求的会话信息。否则服务器宕机,会话丢失,即使将用户请求转发到…

2017-04-09 22:34 · MicroService

网站架构演化历程

原创转载请注明出处: http://agilestyle.iteye.com/blog/2367277 初始阶段的网站架构 应用服务和数据服务分离 使用缓存改善网站性能 使用应用服务器集群改善网站的并发处理能力 数据库读写分离 使用反向代理和CDN加速网站响应 使用分布式文件系统和分布式数据库系统 使用NoSQL和搜索引擎 业务拆分 分布式服务 Reference 大型网站技术架构 核心原理与案例分析 李智慧 著

2017-04-04 14:36 · MicroService

Cookie和Session

原创转载请注明出处: http://agilestyle.iteye.com/blog/2367166 Cookie Cookie可以让服务端程序跟踪每个客户端的访问,但是每次客户端的访问都必须传回这些Cookie,如果Cookie很多,则无形地增加了客户端与服务端的数据传输量,而Session的出现正是为了解决这个问题。 Session 同一个客户每次和服务端交互时,不需要每次都传回所有的Cookie值,而是只要传回一个ID,这个ID是客户端第一次访问服务器时生成的,而且每个客户端是唯一的。这样每个客户端就有了一个唯一的ID,客户端只要传回这个ID就行了,这个ID通常是NAME为JSESS…

2017-04-02 23:37 · JavaWeb

Oracle优化常见术语

原创转载请注明出处: http://agilestyle.iteye.com/blog/2367164 Explain Plan http://www.orafaq.com/wiki/Explain_Plan DBMS STATS http://www.orafaq.com/wiki/DBMS_STATS Hint http://www.orafaq.com/wiki/Hint RBO http://www.orafaq.com/wiki/Rule_Based_Optimizer CBO http://www.orafaq.com/wiki/Cost_Based_Optimizer Refe…

2017-04-02 23:03 · RDBMS

Oracle分区

原创转载请注明出处: http://agilestyle.iteye.com/blog/2367159 Introduction http://www.orafaq.com/wiki/Partitioning Range partitioning http://www.orafaq.com/wiki/Range_partitioning List partitioning http://www.orafaq.com/wiki/List_partitioning Hash partitioning http://www.orafaq.com/wiki/Hash_partitioning Com…

2017-04-02 22:03 · RDBMS

JSON hijacking

原创转载请注明出处: http://agilestyle.iteye.com/blog/2367009 Issue JSON劫持利用一些浏览器的功能,允许脚本覆盖核心语言的对象setter的例程,它允许恶意JavaScript插入逻辑,使其监控服务器返回的JSON消息。 在一个JSON劫持攻击中,攻击者将覆盖的JavaScript数组传递给它的构造函数来窃取信息。攻击者然后嵌入域被劫持的JSON端点在HTML脚本标记。浏览器将把跨域资源作为一个JavaScript文件和试图呈现,导致调用数组构造函数的攻击者的版本,导致跨领域的信息暴露。 Solution 为了防止JSON劫持: 使用appl…

2017-04-01 11:42 · JSON

Node Fetch

原创转载请注明出处: http://agilestyle.iteye.com/blog/2364959 Client-Side Fetch https://github.com/github/fetch Server-Side Fetch https://github.com/bitinn/node-fetch

2017-03-23 10:23 · Node.js

Find the 'closest' value in a BST with a given value M

原创转载请注明出处: http://agilestyle.iteye.com/blog/2361956 Question: Find the 'closest' value in a BST with a given value M Analysis: 1. Traditional Binary Search Tree searching M: O(logN) time to return found M or not 2. "closest" value in BST to M: A particular value in the BST tree so that Math.abs(val…

2017-03-13 15:27 · Algorithm

Print all possible combinations of coins per change amount

原创转载请注明出处: http://agilestyle.iteye.com/blog/2361927 Question: Given a change amount, print all possible combinations using different sets of coins Solution: 核心思想:递归 1. Sort coins from large to small based on amount 2. Determine how many large coins used 3. Calculate how much the amount left using a…

2017-03-13 14:24 · Algorithm

Print all pairs of values a sorted array that sum up to a given value M

原创转载请注明出处: http://agilestyle.iteye.com/blog/2361909 Question Print all pairs of values a sorted array that sum up to a given value M Example Solution 1. Scan from both ends, calculate the sum 2. if(sum is equal to M), print and shrink the focus window 3. if(sum is less than M), shift left focus ind…

2017-03-13 12:16 · Algorithm

Merge Two Sorted Arrays without additional memory

原创转载请注明出处: http://agilestyle.iteye.com/blog/2361133 Question Merge Two Sorted Arrays into the larger array, given the large array has extra storage. Merge without additional memory Requirements Long sorted array {1,3,5,0,0,0} (0 means blank spaces), so used length is 3 The short sorted array {2,4} …

2017-03-09 13:58 · Algorithm

Use stack (LIFO) to simulate queue (FIFO)

原创转载请注明出处: http://agilestyle.iteye.com/blog/2360962 Solution 1. Using 2 stacks 1.1. One stack to accept incoming values in FILO manner 1.2. The other stack to reverse the values in first stack, so LIFO+LIFO becomes FIFO for value retrieval 2. An example 2.1. Incoming order: (1,2,3) 2.2. Stack 1 sto…

2017-03-08 16:28 · Algorithm

Print all elements at a given level in the binary tree

原创转载请注明出处: http://agilestyle.iteye.com/blog/2360924 method 1 —— 使用两个队列 use a queue to store elements and levels keep dequeing elements until the associated levels equals to the desired level print out elements and stop when queue is empty method 2 —— 递归 recursion keep track of current level versus …

2017-03-08 15:09 · Algorithm

Verify if a tree is a binary search tree(BST)

原创转载请注明出处: http://agilestyle.iteye.com/blog/2360893 Binary Search Tree any node in left sub-tree < its parent any node in rigth sub-tree > its parent 核心思想:递归 recursively to check values within range recursion, update range for both left and right sub-trees and continue verifying initial range for t…

2017-03-08 12:11 · Algorithm

Print all valid combinations of groups of parenthesis

原创转载请注明出处: http://agilestyle.iteye.com/blog/2360764 Given Three pairs of "((()))" Print "()()(), (())(), ()(()), ((()))" 核心思想: 递归 package org.fool.java.test; public class ParenthesisPrintTest { public static void main(String[] args) { printParenthesis(3, 3, ""); } // left and right remains are keep…

2017-03-07 16:42 · Algorithm

Reverse a linked list

原创转载请注明出处: http://agilestyle.iteye.com/blog/2360694 Recursive Idea Reverse(Head -> Remaining List) => Reverse(Remaining List) -> Head Example: Reverse(1->2->3->4->5) => Reverse(2->3->4->5) -> 1 Demo package org.fool.java.collections; public class ReverseLinkedListTest { public static void main(Stri…

2017-03-07 13:08 · Algorithm

Get all subset of a set

原创转载请注明出处: http://agilestyle.iteye.com/blog/2360659 找出一个Set集合中的所有子集 比如全集为 {1, 2, 3} 子集则有{},{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3} 此算法的核心思想: 递归 package org.fool.java.collections; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class GetAllSubSetTest { public static voi…

2017-03-07 10:14 · Algorithm