diff --git a/novel-front/src/main/java/com/java2nb/novel/core/filter/NovelFilter.java b/novel-front/src/main/java/com/java2nb/novel/core/filter/NovelFilter.java index 63f5f04..99566a4 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/filter/NovelFilter.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/filter/NovelFilter.java @@ -55,7 +55,7 @@ public class NovelFilter implements Filter { userMark = UUIDUtil.getUUID32(); CookieUtil.setCookie(resp,Constants.USER_CLIENT_MARK_KEY,userMark); } - ThreadLocalUtil.setCientId(userMark); + ThreadLocalUtil.setClientId(userMark); //根据浏览器类型选择前端模板 String to = req.getParameter("to"); CacheService cacheService = SpringUtil.getBean(CacheService.class); diff --git a/novel-front/src/main/java/com/java2nb/novel/core/utils/ThreadLocalUtil.java b/novel-front/src/main/java/com/java2nb/novel/core/utils/ThreadLocalUtil.java index 2c63f4c..48d7fd3 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/utils/ThreadLocalUtil.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/utils/ThreadLocalUtil.java @@ -41,7 +41,7 @@ public class ThreadLocalUtil { /** * 设置当前访问线程的客户端ID * */ - public static void setCientId(String id){ + public static void setClientId(String id){ clientId.set(id); } diff --git a/novel-front/src/main/java/com/java2nb/novel/page/PageController.java b/novel-front/src/main/java/com/java2nb/novel/page/PageController.java index 90dee93..0c88e76 100644 --- a/novel-front/src/main/java/com/java2nb/novel/page/PageController.java +++ b/novel-front/src/main/java/com/java2nb/novel/page/PageController.java @@ -77,7 +77,8 @@ public class PageController extends BaseController { * 首页 */ @RequestMapping(path = {"/", "/index", "/index.html"}) - public String index() { + public String index(Model model) { + model.addAttribute("bookMap",bookService.listBookSettingVO()); return ThreadLocalUtil.getTemplateDir() + "index"; } diff --git a/novel-front/src/main/resources/static/javascript/pay.js b/novel-front/src/main/resources/static/javascript/pay.js index faaf28d..162808c 100644 --- a/novel-front/src/main/resources/static/javascript/pay.js +++ b/novel-front/src/main/resources/static/javascript/pay.js @@ -3,16 +3,6 @@ var UserPay = { czPayPalData: [[20, "10000屋币"], [50, "25000屋币"], [100, "50000屋币"], [80, "全站包年阅读"]], sendPay: function () { $("#payform").submit(); - }, - GetPayState: function (payId) { - $.post("/api/book.aspx", { act: "getpaystatus", pid: payId }, function (data, textStatus) { - if (data == "1") { - location.href = '/pay/wx_return.aspx?out_trade_no=sc'+payId; - } - else { - setTimeout("UserPay.GetPayState("+payId+")",3000); - } - }, "html"); } } @@ -46,20 +36,6 @@ $(function () { $("#ulZFWXXJ").show(); } - var postUrl = ""; - switch (type) - { - case "1": - postUrl = "sendalipay.aspx"; - break; - case "2": - postUrl = "sendwxpaynowqr.aspx"; - break; - case "3": - postUrl = "sendpaypal.aspx"; - break; - } - $("#payform").attr("action", postUrl); }) $("#ulZFWX li").click(function () { diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.001.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.001.png deleted file mode 100644 index f1aa8a5..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.001.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.002.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.002.png deleted file mode 100644 index f7ade17..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.002.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.003.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.003.png deleted file mode 100644 index 3cf0cb5..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.003.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.004.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.004.png deleted file mode 100644 index 6b9d22a..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.004.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.005.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.005.png deleted file mode 100644 index eab4c71..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.005.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.006.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.006.png deleted file mode 100644 index 47ca516..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.006.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.007.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.007.png deleted file mode 100644 index e7c4cfe..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.007.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.008.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.008.png deleted file mode 100644 index 5564cf1..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.008.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.009.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.009.png deleted file mode 100644 index c452adf..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.009.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.010.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.010.png deleted file mode 100644 index a4b26c9..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.010.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.011.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.011.png deleted file mode 100644 index 71c445f..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.011.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.012.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.012.png deleted file mode 100644 index 381c5fe..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.012.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.013.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.013.png deleted file mode 100644 index 91b237c..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.013.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.014.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.014.png deleted file mode 100644 index 646bb42..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.014.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.015.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.015.png deleted file mode 100644 index bca9ffc..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.015.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.016.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.016.png deleted file mode 100644 index eee0a1e..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.016.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.017.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.017.png deleted file mode 100644 index 25856dd..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.017.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.018.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.018.png deleted file mode 100644 index 7771bfb..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.018.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.019.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.019.png deleted file mode 100644 index c6947cc..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.019.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.020.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.020.png deleted file mode 100644 index 58bcb5c..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.020.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.021.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.021.png deleted file mode 100644 index 05bd1d2..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.021.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.022.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.022.png deleted file mode 100644 index dacaf46..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.022.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.023.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.023.png deleted file mode 100644 index badaaa1..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.023.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.024.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.024.png deleted file mode 100644 index 9e10a80..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.024.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.025.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.025.png deleted file mode 100644 index 2de1e28..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.025.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.026.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.026.png deleted file mode 100644 index e140735..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.026.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.027.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.027.png deleted file mode 100644 index 7133a5d..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.027.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.028.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.028.png deleted file mode 100644 index 799e145..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.028.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.030.png b/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.030.png deleted file mode 100644 index 6d9e86f..0000000 Binary files a/novel-front/src/main/resources/static/mobile/html/9a4a540e-1759-4268-90fa-7fb652c3604a.030.png and /dev/null differ diff --git a/novel-front/src/main/resources/static/mobile/html/note_1.html b/novel-front/src/main/resources/static/mobile/html/note_1.html deleted file mode 100644 index 1f729f5..0000000 --- a/novel-front/src/main/resources/static/mobile/html/note_1.html +++ /dev/null @@ -1,270 +0,0 @@ - -
- - - -============================原理=================== -
- -//RestTemplate restTemplate = new RestTemplate(); -
-// 当返回的response-header的content-type属性有charset值时, -
-// restTemplate的 StringHttpMessageConverter会读取该charset值,并使用该值进行 -
- - - -通过源码可以发现restTemplate底层默认使用了HttpURLConnection,可以支持其他多种http客户端,如httpclient、okhttp等,通过工厂方法模式创建请求:
- - - - - - - - - - - - - - - -执行请求,调用ResponseExtractor responseExtractor.extractData()对相应结果进行数据提取 -
- -调用HttpMessageConverterExtractor this.delegate.extractData()执行抽取数据的操作 -
- -获取response-header的content-type, -
- - - -判断消息转换器对应的支持媒体类型supportMediaType是否包含该content-type -
- -调用第一个包含该content-type的GenericHttpMessageConverter转换数据读取数据 -
- - - -读取数据的时候会再一次获取response-header的content-type的字符集
-如果该字符集存在,则使用该字符集进行 IO流 =》字符串 转换 -
- - - - - - - - - - - - - -响应头中并没有content-type的header,照理说浏览器应该不知道服务端返回的输入流编码,如果和浏览器默认的编码不匹配应该会出现乱码,但是现在浏览器有编码自动识别功能,所以上面的代码没有加content-type的Header也没有问题 -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -跨域处理 -
- -跨域是什么?浏览器从一个域名的网页去请求另一个域名的资源时,域名、端口、 协议任一不同,都是跨域 。我们是采用前后端分离开发的,也是前后端分离部署的,必然会存在跨域问题。 怎么解决跨域?很简单,只需要在controller类上添加注解 @CrossOrigin 即可!这个注解其实是CORS的实现。 -
-CORS(Cross-Origin Resource Sharing, 跨源资源共享)是W3C出的一个标准,其思 想是使用自定义的HTTP头部让浏览器与服务器进行沟通,从而决定请求或响应是应该成 功,还是应该失败。因此,要想实现CORS进行跨域,需要服务器进行一些设置,同时前端也需要做一些配置和分析。本文简单的对服务端的配置和前端的一些设置进行分析。 -
- -1️⃣在controller类上添加注解 @CrossOrigin,表示Controller上的所以方法允许跨域,在方法上添加注解 @CrossOrigin,表示该方法允许跨域 -
- -@Target({ ElementType.METHOD, ElementType.TYPE }) -
-@Retention(RetentionPolicy.RUNTIME)
- -public @interface CrossOrigin {
- -String[] DEFAULT_ORIGINS = { "*" };
- -String[] DEFAULT_ALLOWED_HEADERS = { "*" }; -
- -boolean DEFAULT_ALLOW_CREDENTIALS = true; -
- - - - - - - - - - - -* 所有支持域的集合,例如"http://domain1.com"。
-* <p>这些值都显示在请求头中的Access-Control-Allow-Origin -
- - - - - -String[] origins() default {};
- - - - -String[] allowedHeaders() default {};
- - - - -String[] exposedHeaders() default {};
- - -* 请求支持的方法,例如"{RequestMethod.GET, RequestMethod.POST}"}。 -
- - -RequestMethod[] methods() default {};
- - - - -String allowCredentials() default "";
- - - - - - - - - - - - -public class GlobalCorsConfig {
- - -public CorsFilter corsFilter() {
- -CorsConfiguration config = new CorsConfiguration();
-//1) 允许的域,不要写*,否则cookie就无法使用了 -
-config.addAllowedOrigin("http://manage.shop.com");
-config.addAllowedOrigin("http://www.shop.com");
- -config.setAllowCredentials(true);
- -config.addAllowedMethod("OPTIONS");
-config.addAllowedMethod("HEAD");
-config.addAllowedMethod("GET");
-config.addAllowedMethod("PUT");
-config.addAllowedMethod("POST");
-config.addAllowedMethod("DELETE");
-config.addAllowedMethod("PATCH");
- - - - - - -UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource(); -
-configSource.registerCorsConfiguration("/**", config);
- - - - -在分布式系统中,为了保证数据的高可用,通常会将数据保留多个副本(replica),这些副本会放置在不同的物理的机器上。 -
- -在数据有多份副本的情况下,如果网络、服务器或者软件出现故障,会导致部分副本写入成功,部分副本写入失败。这就造成各个副本之间的数据不一致,数据内容冲突。 -
- - -CAP理论认为在分布式的环境下设计和部署系统时,有3个核心的需求: -
-Consistency,Availability和Partition Tolerance,即CAP。 -
- -Consistency:一致性,这个和数据库ACID的一致性类似,但这里关注的所有数据节点上的数据一致性和正确性,而数据库的ACID关注的是在在一个事务内,对数据的一些约束。系统在执行过某项操作后仍然处于一致的状态。在分布式系统中,更新操作执行成功后所有的用户都应该读取到最新值。 -
-Availability:可用性,每一个操作总是能够在一定时间内返回结果。需要注意“一定时间”和“返回结果”。“一定时间”是指,系统结果必须在给定时间内返回。“返回结果”是指系统返回操作成功或失败的结果。 -
-Partition Tolerance:分区容忍性,是否可以对数据进行分区。这是考虑到性能和可伸缩性。 -
- -一些分布式系统通过复制数据来提高系统的可靠性和容错性,并且将数据的不同的副本存放在不同的机器。 -
- -当更新操作完成之后,任何多个后续进程或者线程的访问都会返回最新的更新过的值。这种是对用户最友好的,就是用户上一次写什么,下一次就保证能读到什么。根据 CAP 理论,这种实现需要牺牲可用性。 -
- -系统并不保证续进程或者线程的访问都会返回最新的更新过的值。用户读到某一操作对系统特定数据的更新需要一段时间,我们称这段时间为“不一致性窗口”。系统在数据写入成功之后,不承诺立即可以读到最新写入的值,也不会具体的承诺多久之后可以读到。 -
- -是弱一致性的一种特例。系统保证在没有后续更新的前提下,系统最终返回上一次更新操作的值。在没有故障发生的前提下,不一致窗口的时间主要受通信延迟,系统负载和复制副本的个数影响。DNS 是一个典型的最终一致性系统。 -
- - -跨行转账问题是一个典型的分布式事务,用户A向B的一个转账1000,要进行A的余额-1000,B的余额+1000,显然必须保证这两个操作的事务性。 -
-类似的还有,电商系统中,当有用户下单后,除了在订单表插入记,还要在商品表更新库存等,特别是随着微服务架构的流行,分布式事务的场景更变得更普遍。 -
- - -两阶段提交协议是协调所有分布式原子事务参与者,并决定提交或取消(回滚)的分布式算法。 -
- -在两阶段提交协议中,系统一般包含两类机器(或节点):一类为协调者(coordinator),通常一个系统中只有一个;另一类为事务参与者(participants,cohorts或workers),一般包含多个,在数据存储系统中可以理解为数据副本的个数。协议中假设每个节点都会记录写前日志(write-ahead log)并持久性存储,即使节点发生故障日志也不会丢失。协议中同时假设节点不会发生永久性故障而且任意两个节点都可以互相通信。 -
- - -1.请求阶段(commit-request phase,或称表决阶段,voting phase) -
-在请求阶段,协调者将通知事务参与者准备提交或取消事务,然后进入表决过程。 -
-在表决过程中,参与者将告知协调者自己的决策:同意(事务参与者本地作业执行成功)或取消(本地作业执行故障)。 -
- -在该阶段,协调者将基于第一个阶段的投票结果进行决策:提交或取消。 -
-当且仅当所有的参与者同意提交事务协调者才通知所有的参与者提交事务,否则协调者将通知所有的参与者取消事务。 -
- - -1.同步阻塞问题。执行过程中,所有参与节点都是事务阻塞型的。 -
-当参与者占有公共资源时,其他第三方节点访问公共资源不得不处于阻塞状态。 -
- -参与者会一直阻塞下去。尤其在第二阶段,协调者发生故障,那么所有的参与者还都处于锁定事务资源的状态中,而无法继续完成事务操作。(如果是协调者挂掉,可以重新选举一个协调者,但是无法解决因为协调者宕机导致的参与者处于阻塞状态的问题) -
-3.数据不一致。在二阶段提交的阶段二中,当协调者向参与者发送commit请求之后,发生了局部网络异常或者在发送commit请求过程中协调者发生了故障,这回导致只有一部分参与者接受到了commit请求。 -
-而在这部分参与者接到commit请求之后就会执行commit操作。但是其他部分未接到commit请求的机器则无法执行事务提交。于是整个分布式系统便出现了数据部一致性的现象。 -
-(4)两阶段提交无法解决的问题 -
-当协调者出错,同时参与者也出错时,两阶段无法保证事务执行的完整性。 -
-考虑协调者再发出commit消息之后宕机,而唯一接收到这条消息的参与者同时也宕机了。 -
-那么即使协调者通过选举协议产生了新的协调者,这条事务的状态也是不确定的,没人知道事务是否被已经提交。 -
- - -三阶段提交协议在协调者和参与者中都引入超时机制,并且把两阶段提交协议的第一个阶段拆分成了两步:询问,然后再锁资源,最后真正提交。 -
- - - -3PC的CanCommit阶段其实和2PC的准备阶段很像。 -
-协调者向参与者发送commit请求,参与者如果可以提交就返回Yes响应,否则返回No响应。 -
- -Coordinator根据Cohort的反应情况来决定是否可以继续事务的PreCommit操作。 -
- -A.假如Coordinator从所有的Cohort获得的反馈都是Yes响应,那么就会进行事务的预执行: -
-发送预提交请求。Coordinator向Cohort发送PreCommit请求,并进入Prepared阶段。 -
-事务预提交。Cohort接收到PreCommit请求后,会执行事务操作,并将undo和redo信息记录到事务日志中。 -
-响应反馈。如果Cohort成功的执行了事务操作,则返回ACK响应,同时开始等待最终指令。 -
-B.假如有任何一个Cohort向Coordinator发送了No响应,或者等待超时之后,Coordinator都没有接到Cohort的响应,那么就中断事务: -
-发送中断请求。Coordinator向所有Cohort发送abort请求。 -
-中断事务。Cohort收到来自Coordinator的abort请求之后(或超时之后,仍未收到Cohort的请求),执行事务的中断。 -
- - - -A.发送提交请求。Coordinator接收到Cohort发送的ACK响应,那么他将从预提交状态进入到提交状态。并向所有Cohort发送doCommit请求。 -
-B.事务提交。Cohort接收到doCommit请求之后,执行正式的事务提交。并在完成事务提交之后释放所有事务资源。 -
-C.响应反馈。事务提交完之后,向Coordinator发送ACK响应。 -
-D.完成事务。Coordinator接收到所有Cohort的ACK响应之后,完成事务。 -
- -Coordinator没有接收到Cohort发送的ACK响应(可能是接受者发送的不是ACK响应,也可能响应超时),那么就会执行中断事务。 -
- -对于协调者(Coordinator)和参与者(Cohort)都设置了超时机制(在2PC中,只有协调者拥有超时机制,即如果在一定时间内没有收到cohort的消息则默认失败)。 -
-在2PC的准备阶段和提交阶段之间,插入预提交阶段,使3PC拥有CanCommit、PreCommit、DoCommit三个阶段。 -
-PreCommit是一个缓冲,保证了在最后提交阶段之前各参与节点的状态是一致的。 -
- -如果进入PreCommit后,Coordinator发出的是abort请求,假设只有一个Cohort收到并进行了abort操作, -
-@PostMapping("/jobPosition/listJobPositionByPage") -
-List<MiniJobPositionVO> listJobPositionByPage(@RequestParam(value = "posName") String posName,@RequestParam(value = "jobTypeId") String jobTypeId, @RequestBody PageBean pageBean); -
-当调用该接口时,posName或jobTypeId传递为null时报错400 bad request,提示需要string parameter -
- - -2.集成zipkin时配置正确,zipkin-server却收不到调用信息
-通过HTTP使用基于Zipkin的Sleuth时,如果框架集成了rabbitmq,默认会按rabbitmq的异步方式发送调用链信息,默认的以http同步方式发送调用链信息就不会生效,注释rabbitmq配置后,发送成功。 -
- - - - - - - - - -java -jar D:\software\zipkin-server-2.10.1-exec.jar --zipkin.collector.rabbitmq.addresses=192.168.99.100:5673 --zipkin.collector.rabbitmq.username=guest --zipkin.collector.rabbitmq.password=test --zipkin.collector.rabbitmq.useSsl=false --zipkin.collector.rabbitmq.virtual-host=/ --zipkin.collector.rabbitmq.queue=zipkin -
- - - - -docker run -d -p 9411:9411 --env RABBIT_ADDRESSES=192.168.99.100:5673 --env RABBIT_USER=guest --env RABBIT_P -
-ASSWORD=test --env RABBIT_USE_SSL=false --env RABBIT_VIRTUAL_HOST=/ --env RABBIT_QUEUE=zipkin openzipkin/zipkin -
- - -
- zipkin: |
-
-
|
-
-
|
-
- self-tracing: |
-
-
|
-
- # Set to true to enable self-tracing. - |
-
-
|
-
- enabled: ${SELF_TRACING_ENABLED:false} - |
-
-
|
-
- # percentage to self-traces to retain - |
-
-
|
-
- sample-rate: ${SELF_TRACING_SAMPLE_RATE:1.0} - |
-
-
|
-
- # Timeout in seconds to flush self-tracing data to storage. - |
-
-
|
-
- message-timeout: ${SELF_TRACING_FLUSH_INTERVAL:1} - |
-
-
|
-
- collector: |
-
-
|
-
- # percentage to traces to retain - |
-
-
|
-
- sample-rate: ${COLLECTOR_SAMPLE_RATE:1.0} - |
-
-
|
-
- http: |
-
-
|
-
- # Set to false to disable creation of spans via HTTP collector API - |
-
-
|
-
- enabled: ${HTTP_COLLECTOR_ENABLED:true} - |
-
-
|
-
- kafka: |
-
-
|
-
- # Kafka bootstrap broker list, comma-separated host:port values. Setting this activates the - |
-
-
|
-
- # Kafka 0.10+ collector. - |
-
-
|
-
- bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:} - |
-
-
|
-
- # Name of topic to poll for spans - |
-
-
|
-
- topic: ${KAFKA_TOPIC:zipkin} - |
-
-
|
-
- # Consumer group this process is consuming on behalf of. - |
-
-
|
-
- group-id: ${KAFKA_GROUP_ID:zipkin} - |
-
-
|
-
- # Count of consumer threads consuming the topic - |
-
-
|
-
- streams: ${KAFKA_STREAMS:1} - |
-
-
|
-
- rabbitmq: |
-
-
|
-
- # RabbitMQ server address list (comma-separated list of host:port) - |
-
-
|
-
- addresses: ${RABBIT_ADDRESSES:} - |
-
-
|
-
- concurrency: ${RABBIT_CONCURRENCY:1} - |
-
-
|
-
- # TCP connection timeout in milliseconds - |
-
-
|
-
- connection-timeout: ${RABBIT_CONNECTION_TIMEOUT:60000} - |
-
-
|
-
- password: ${RABBIT_PASSWORD:guest} - |
-
-
|
-
- queue: ${RABBIT_QUEUE:zipkin} - |
-
-
|
-
- username: ${RABBIT_USER:guest} - |
-
-
|
-
- virtual-host: ${RABBIT_VIRTUAL_HOST:/} - |
-
-
|
-
- useSsl: ${RABBIT_USE_SSL:false} - |
-
-
|
-
- uri: ${RABBIT_URI:} - |
-
-
|
-
- query: |
-
-
|
-
- enabled: ${QUERY_ENABLED:true} - |
-
-
|
-
- # 1 day in millis - |
-
-
|
-
- lookback: ${QUERY_LOOKBACK:86400000} - |
-
-
|
-
- # The Cache-Control max-age (seconds) for /api/v2/services and /api/v2/spans - |
-
-
|
-
- names-max-age: 300 |
-
-
|
-
- # CORS allowed-origins. - |
-
-
|
-
- allowed-origins: "*" |
-
-
|
-
-
|
-
-
|
-
- storage: |
-
-
|
-
- strict-trace-id: ${STRICT_TRACE_ID:true} - |
-
-
|
-
- search-enabled: ${SEARCH_ENABLED:true} - |
-
-
|
-
- type: ${STORAGE_TYPE:mem} - |
-
-
|
-
- mem: |
-
-
|
-
- # Maximum number of spans to keep in memory. When exceeded, oldest traces (and their spans) will be purged. - |
-
-
|
-
- # A safe estimate is 1K of memory per span (each span with 2 annotations + 1 binary annotation), plus - |
-
-
|
-
- # 100 MB for a safety buffer. You'll need to verify in your own environment. - |
-
-
|
-
- # Experimentally, it works with: max-spans of 500000 with JRE argument -Xmx600m. - |
-
-
|
-
- max-spans: 500000 |
-
-
|
-
- cassandra: |
-
-
|
-
- # Comma separated list of host addresses part of Cassandra cluster. Ports default to 9042 but you can also specify a custom port with 'host:port'. - |
-
-
|
-
- contact-points: ${CASSANDRA_CONTACT_POINTS:localhost} - |
-
-
|
-
- # Name of the datacenter that will be considered "local" for latency load balancing. When unset, load-balancing is round-robin. - |
-
-
|
-
- local-dc: ${CASSANDRA_LOCAL_DC:} - |
-
-
|
-
- # Will throw an exception on startup if authentication fails. - |
-
-
|
-
- username: ${CASSANDRA_USERNAME:} - |
-
-
|
-
- password: ${CASSANDRA_PASSWORD:} - |
-
-
|
-
- keyspace: ${CASSANDRA_KEYSPACE:zipkin} - |
-
-
|
-
- # Max pooled connections per datacenter-local host. - |
-
-
|
-
- max-connections: ${CASSANDRA_MAX_CONNECTIONS:8} - |
-
-
|
-
- # Ensuring that schema exists, if enabled tries to execute script /zipkin-cassandra-core/resources/cassandra-schema-cql3.txt. - |
-
-
|
-
- ensure-schema: ${CASSANDRA_ENSURE_SCHEMA:true} - |
-
-
|
-
- # 7 days in seconds - |
-
-
|
-
- span-ttl: ${CASSANDRA_SPAN_TTL:604800} - |
-
-
|
-
- # 3 days in seconds - |
-
-
|
-
- index-ttl: ${CASSANDRA_INDEX_TTL:259200} - |
-
-
|
-
- # the maximum trace index metadata entries to cache - |
-
-
|
-
- index-cache-max: ${CASSANDRA_INDEX_CACHE_MAX:100000} - |
-
-
|
-
- # how long to cache index metadata about a trace. 1 minute in seconds - |
-
-
|
-
- index-cache-ttl: ${CASSANDRA_INDEX_CACHE_TTL:60} - |
-
-
|
-
- # how many more index rows to fetch than the user-supplied query limit - |
-
-
|
-
- index-fetch-multiplier: ${CASSANDRA_INDEX_FETCH_MULTIPLIER:3} - |
-
-
|
-
- # Using ssl for connection, rely on Keystore - |
-
-
|
-
- use-ssl: ${CASSANDRA_USE_SSL:false} - |
-
-
|
-
- cassandra3: |
-
-
|
-
- # Comma separated list of host addresses part of Cassandra cluster. Ports default to 9042 but you can also specify a custom port with 'host:port'. - |
-
-
|
-
- contact-points: ${CASSANDRA_CONTACT_POINTS:localhost} - |
-
-
|
-
- # Name of the datacenter that will be considered "local" for latency load balancing. When unset, load-balancing is round-robin. - |
-
-
|
-
- local-dc: ${CASSANDRA_LOCAL_DC:} - |
-
-
|
-
- # Will throw an exception on startup if authentication fails. - |
-
-
|
-
- username: ${CASSANDRA_USERNAME:} - |
-
-
|
-
- password: ${CASSANDRA_PASSWORD:} - |
-
-
|
-
- keyspace: ${CASSANDRA_KEYSPACE:zipkin2} - |
-
-
|
-
- # Max pooled connections per datacenter-local host. - |
-
-
|
-
- max-connections: ${CASSANDRA_MAX_CONNECTIONS:8} - |
-
-
|
-
- # Ensuring that schema exists, if enabled tries to execute script /zipkin2-schema.cql - |
-
-
|
-
- ensure-schema: ${CASSANDRA_ENSURE_SCHEMA:true} - |
-
-
|
-
- # how many more index rows to fetch than the user-supplied query limit - |
-
-
|
-
- index-fetch-multiplier: ${CASSANDRA_INDEX_FETCH_MULTIPLIER:3} - |
-
-
|
-
- # Using ssl for connection, rely on Keystore - |
-
-
|
-
- use-ssl: ${CASSANDRA_USE_SSL:false} - |
-
-
|
-
- elasticsearch: |
-
-
|
-
- # host is left unset intentionally, to defer the decision - |
-
-
|
-
- hosts: ${ES_HOSTS:} - |
-
-
|
-
- pipeline: ${ES_PIPELINE:} - |
-
-
|
-
- max-requests: ${ES_MAX_REQUESTS:64} - |
-
-
|
-
- timeout: ${ES_TIMEOUT:10000} - |
-
-
|
-
- index: ${ES_INDEX:zipkin} - |
-
-
|
-
- date-separator: ${ES_DATE_SEPARATOR:-} - |
-
-
|
-
- index-shards: ${ES_INDEX_SHARDS:5} - |
-
-
|
-
- index-replicas: ${ES_INDEX_REPLICAS:1} - |
-
-
|
-
- username: ${ES_USERNAME:} - |
-
-
|
-
- password: ${ES_PASSWORD:} - |
-
-
|
-
- http-logging: ${ES_HTTP_LOGGING:} - |
-
-
|
-
- legacy-reads-enabled: ${ES_LEGACY_READS_ENABLED:true} - |
-
-
|
-
- mysql: |
-
-
|
-
- host: ${MYSQL_HOST:localhost} - |
-
-
|
-
- port: ${MYSQL_TCP_PORT:3306} - |
-
-
|
-
- username: ${MYSQL_USER:} - |
-
-
|
-
- password: ${MYSQL_PASS:} - |
-
-
|
-
- db: ${MYSQL_DB:zipkin} - |
-
-
|
-
- max-active: ${MYSQL_MAX_CONNECTIONS:10} - |
-
-
|
-
- use-ssl: ${MYSQL_USE_SSL:false} - |
-
-
|
-
- ui: |
-
-
|
-
- enabled: ${QUERY_ENABLED:true} - |
-
-
|
-
- ## Values below here are mapped to ZipkinUiProperties, served as /config.json - |
-
-
|
-
- # Default limit for Find Traces - |
-
-
|
-
- query-limit: 10 |
-
-
|
-
- # The value here becomes a label in the top-right corner - |
-
-
|
-
- environment: |
-
-
|
-
- # Default duration to look back when finding traces. - |
-
-
|
-
- # Affects the "Start time" element in the UI. 1 hour in millis - |
-
-
|
-
- default-lookback: 3600000 |
-
-
|
-
- # When false, disables the "find a trace" screen - |
-
-
|
-
- search-enabled: ${SEARCH_ENABLED:true} - |
-
-
|
-
- # Which sites this Zipkin UI covers. Regex syntax. (e.g. http:\/\/example.com\/.*) - |
-
-
|
-
- # Multiple sites can be specified, e.g. - |
-
-
|
-
- # - .*example1.com - |
-
-
|
-
- # - .*example2.com - |
-
-
|
-
- # Default is "match all websites" - |
-
-
|
-
- instrumented: .* |
-
-
|
-
- # URL placed into the <base> tag in the HTML - |
-
-
|
-
- base-path: /zipkin |
-
-
|
-
-
|
-
-
|
-
- server: |
-
-
|
-
- port: ${QUERY_PORT:9411} - |
-
-
|
-
- use-forward-headers: true |
-
-
|
-
- compression: |
-
-
|
-
- enabled: true |
-
-
|
-
- # compresses any response over min-response-size (default is 2KiB) - |
-
-
|
-
- # Includes dynamic json content and large static assets from zipkin-ui - |
-
-
|
-
- mime-types: application/json,application/javascript,text/css,image/svg - |
-
-
|
-
-
|
-
-
|
-
- spring: |
-
-
|
-
- jmx: |
-
-
|
-
- # reduce startup time by excluding unexposed JMX service - |
-
-
|
-
- enabled: false |
-
-
|
-
- mvc: |
-
-
|
-
- favicon: |
-
-
|
-
- # zipkin has its own favicon - |
-
-
|
-
- enabled: false |
-
-
|
-
- autoconfigure: |
-
-
|
-
- exclude: |
-
-
|
-
- # otherwise we might initialize even when not needed (ex when storage type is cassandra) - |
-
-
|
-
- - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration - |
-
-
|
-
- info: |
-
-
|
-
- zipkin: |
-
-
|
-
- version: "@project.version@" - |
-
-
|
-
-
|
-
-
|
-
- logging: |
-
-
|
-
- pattern: |
-
-
|
-
- level: "%clr(%5p) %clr([%X{traceId}/%X{spanId}]){yellow}" - |
-
-
|
-
- level: |
-
-
|
-
- # Silence Invalid method name: '__can__finagle__trace__v3__' - |
-
-
|
-
- com.facebook.swift.service.ThriftServiceProcessor: 'OFF' |
-
-
|
-
- # # investigate /api/v2/dependencies - |
-
-
|
-
- # zipkin2.internal.DependencyLinker: 'DEBUG' - |
-
-
|
-
- # # log cassandra queries (DEBUG is without values) - |
-
-
|
-
- # com.datastax.driver.core.QueryLogger: 'TRACE' - |
-
-
|
-
- # # log cassandra trace propagation - |
-
-
|
-
- # com.datastax.driver.core.Message: 'TRACE' - |
-
-
|
-
- # # log reason behind http collector dropped messages - |
-
-
|
-
- # zipkin2.server.ZipkinHttpCollector: 'DEBUG' - |
-
-
|
-
- # zipkin2.collector.kafka.KafkaCollector: 'DEBUG' - |
-
-
|
-
- # zipkin2.collector.kafka08.KafkaCollector: 'DEBUG' - |
-
-
|
-
- # zipkin2.collector.rabbitmq.RabbitMQCollector: 'DEBUG' - |
-
-
|
-
- # zipkin2.collector.scribe.ScribeCollector: 'DEBUG' - |
-
-
|
-
-
|
-
-
|
-
- management: |
-
-
|
-
- endpoints: |
-
-
|
-
- web: |
-
-
|
-
- exposure: |
-
-
|
-
- include: '*' |
-
-
|
-
- endpoint: |
-
-
|
-
- health: |
-
-
|
-
- show-details: always |
-
-
|
-
- # Disabling auto time http requests since it is added in Undertow HttpHandler in Zipkin autoconfigure - |
-
-
|
-
- # Prometheus module. In Zipkin we use different naming for the http requests duration - |
-
-
|
-
- metrics: |
-
-
|
-
- web: |
-
-
|
-
- server: |
-
-
|
-
- auto-time-requests: false |
-