").click(function(){
18 | var html = $(this).parent().html();
19 | html = cleanSource(html);
20 | $("#source-modal pre").text(html);
21 | $("#source-modal").modal();
22 | });
23 |
24 | $('.bs-component [data-toggle="popover"]').popover();
25 | $('.bs-component [data-toggle="tooltip"]').tooltip();
26 |
27 | $(".bs-component").hover(function(){
28 | $(this).append($button);
29 | $button.show();
30 | }, function(){
31 | $button.hide();
32 | });
33 |
34 | function cleanSource(html) {
35 | var lines = html.split(/\n/);
36 |
37 | lines.shift();
38 | lines.splice(-1, 1);
39 |
40 | var indentSize = lines[0].length - lines[0].trim().length,
41 | re = new RegExp(" {" + indentSize + "}");
42 |
43 | lines = lines.map(function(line){
44 | if (line.match(re)) {
45 | line = line.substring(indentSize);
46 | }
47 |
48 | return line;
49 | });
50 |
51 | lines = lines.join("\n");
52 |
53 | return lines;
54 | }
55 |
56 | })();
57 |
--------------------------------------------------------------------------------
/reloud-admin/src/main/java/net/dubboclub/reloud/manager/entity/RedisNode.java:
--------------------------------------------------------------------------------
1 | package net.dubboclub.reloud.manager.entity;
2 |
3 | /**
4 | * Created by bieber on 16/3/31.
5 | */
6 | public class RedisNode {
7 |
8 | //节点地址
9 | private String nodeHost;
10 |
11 | //节点的端口
12 | private String nodePort;
13 |
14 | //节点分组,为了方便管理
15 | private String nodeGroup;
16 |
17 | //节点的状态
18 | private NodeStatus status;
19 |
20 | //检查节点的ping间隔周期
21 | private long pingInterval;
22 |
23 | //上次ping的时间戳
24 | private long lastPingTime;
25 |
26 | public long getLastPingTime() {
27 | return lastPingTime;
28 | }
29 |
30 | public void setLastPingTime(long lastPingTime) {
31 | this.lastPingTime = lastPingTime;
32 | }
33 |
34 | public long getPingInterval() {
35 | return pingInterval;
36 | }
37 |
38 | public void setPingInterval(long pingInterval) {
39 | this.pingInterval = pingInterval;
40 | }
41 |
42 | public NodeStatus getStatus() {
43 | return status;
44 | }
45 |
46 | public void setStatus(NodeStatus status) {
47 | this.status = status;
48 | }
49 |
50 | public String getNodeHost() {
51 | return nodeHost;
52 | }
53 |
54 | public void setNodeHost(String nodeHost) {
55 | this.nodeHost = nodeHost;
56 | }
57 |
58 | public String getNodePort() {
59 | return nodePort;
60 | }
61 |
62 | public void setNodePort(String nodePort) {
63 | this.nodePort = nodePort;
64 | }
65 |
66 | public String getNodeGroup() {
67 | return nodeGroup;
68 | }
69 |
70 | public void setNodeGroup(String nodeGroup) {
71 | this.nodeGroup = nodeGroup;
72 | }
73 |
74 | static enum NodeStatus{
75 | ENABLE,DISABLE,NET_ERROR;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/reloud-admin/src/main/resources/META-INF/spring/mybatis.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/reloud-admin/src/main/webapp/css/reloud.css:
--------------------------------------------------------------------------------
1 | .td-30-width{
2 | width:30%;
3 | word-break: break-all;
4 | word-wrap: break-word;
5 | }
6 | .td-10-width{
7 | width:10%;
8 | word-break: break-all;
9 | word-wrap: break-word;
10 | }
11 | .td-15-width{
12 | width:15%;
13 | word-break: break-all;
14 | word-wrap: break-word;
15 | }
16 | .td-25-width{
17 | width:25%;
18 | word-break: break-all;
19 | word-wrap: break-word;
20 | }
21 | .td-35-width{
22 | width: 35%;
23 | word-break: break-all;
24 | word-wrap: break-word;
25 | }
26 | .td-90-width{
27 | width: 90%;
28 | word-break: break-all;
29 | word-wrap: break-word;
30 | }
31 | .td-5-width{
32 | width: 5%;
33 | word-break: break-all;
34 | word-wrap: break-word;
35 | }
36 | .td-23-width{
37 | width: 23%;
38 | word-break: break-all;
39 | word-wrap: break-word;
40 | }
41 | .td-12-width{
42 | width: 12%;
43 | word-break: break-all;
44 | word-wrap: break-word;
45 | }
46 | .td-20-width{
47 | width: 20%;
48 | word-break: break-all;
49 | word-wrap: break-word;
50 | }
51 | td{
52 | word-break: break-all;
53 | word-wrap: break-word;
54 | }
55 | body{
56 | padding-top: 70px;
57 | font-size: 13px;
58 | }
59 | *{
60 | font-family: "Microsoft YaHei","宋体", Arial, Helvetica, sans-serif;
61 | }
62 | .inner-form-element{
63 | color: #555;
64 | background-color: #fff;
65 | background-image: none;
66 | border: 1px solid #ccc;
67 | border-radius: 4px;
68 | padding: 1px 2px;
69 | font-size: 12px;
70 | }
71 | .app-container{
72 | font-size: 12px;
73 | }
74 | .app-container td{
75 | font-size: 12px;
76 | }
77 | .app-container th{
78 | font-size: 12px;
79 | }
80 | .app-container a{
81 | font-size: 12px;
82 | }
83 |
84 | .can-click{
85 | cursor: pointer;
86 | }
87 |
88 | .white-color{
89 | color:#ffffff;
90 | }
91 | .full-screen{
92 | width: 100%!important;
93 | height: 100%!important;
94 | }
--------------------------------------------------------------------------------
/reloud-admin/src/main/webapp/css/themes/assets/css/bootswatch.min.css:
--------------------------------------------------------------------------------
1 | body{padding-top:50px}body>.navbar{-webkit-transition:background-color 300ms ease-in;transition:background-color 300ms ease-in}@media (min-width:768px){body>.navbar-transparent{background-color:transparent}body>.navbar-transparent .navbar-nav>.open>a{background-color:transparent!important}}#home{padding-top:0}#home .navbar-brand{padding:13.5px 15px 12.5px}#home .navbar-brand>img{display:inline;margin:0 10px;height:100%}#banner{min-height:300px;border-bottom:none}.page-header h1{font-size:4em}.bs-docs-section{margin-top:8em}.bs-component{position:relative}.bs-component .modal{position:relative;top:auto;right:auto;left:auto;bottom:auto;z-index:1;display:block}.bs-component .modal-dialog{width:90%}.bs-component .popover{position:relative;display:inline-block;width:220px;margin:20px}#source-button{position:absolute;top:0;right:0;z-index:100;font-weight:700}.nav-tabs{margin-bottom:15px}.progress{margin-bottom:10px}footer{margin:5em 0}footer li{float:left;margin-right:1.5em;margin-bottom:1.5em}footer p{clear:left;margin-bottom:0}.splash{padding:9em 0 2em;background-color:#141d27;background-image:url(../img/bg.jpg);background-size:cover;background-attachment:fixed;color:#fff;text-align:center}.splash .logo{width:160px}.splash h1{font-size:3em}.splash #social{margin:2em 0}.splash .alert{margin:2em 0}.section-tout{padding:4em 0 3em;border-bottom:1px solid rgba(0,0,0,.05);background-color:#eaf1f1}.section-tout .fa{margin-right:.5em}.section-tout p{margin-bottom:3em}.section-preview{padding:4em 0 4em}.section-preview .preview{margin-bottom:4em;background-color:#eaf1f1}.section-preview .preview .image{position:relative}.section-preview .preview .image:before{box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);position:absolute;top:0;left:0;width:100%;height:100%;content:"";pointer-events:none}.section-preview .preview .options{padding:1em 2em 2em;border:1px solid rgba(0,0,0,.05);border-top:none;text-align:center}.section-preview .preview .options p{margin-bottom:2em}.section-preview .dropdown-menu{text-align:left}.section-preview .lead{margin-bottom:2em}@media (max-width:767px){.section-preview .image img{width:100%}}.sponsor{text-align:center}.sponsor a:hover{text-decoration:none}@media (max-width:767px){.splash{padding-top:4em}.splash .logo{width:100px}.splash h1{font-size:2em}#banner{margin-bottom:2em;text-align:center}}
--------------------------------------------------------------------------------
/reloud-admin/src/main/webapp/js/angularjs/angular-cookies.min.js.map:
--------------------------------------------------------------------------------
1 | {
2 | "version":3,
3 | "file":"angular-cookies.min.js",
4 | "lineCount":7,
5 | "mappings":"A;;;;;aAKC,SAAQ,CAACA,CAAD,CAASC,CAAT,CAAkBC,CAAlB,CAA6B,CAmBtCD,CAAAE,OAAA,CAAe,WAAf,CAA4B,CAAC,IAAD,CAA5B,CAAAC,QAAA,CA0BW,UA1BX,CA0BuB,CAAC,YAAD,CAAe,UAAf,CAA2B,QAAQ,CAACC,CAAD,CAAaC,CAAb,CAAuB,CAAA,IACvEC,EAAU,EAD6D,CAEvEC,EAAc,EAFyD,CAGvEC,CAHuE,CAIvEC,EAAU,CAAA,CAJ6D,CAKvEC,EAAOV,CAAAU,KALgE,CAMvEC,EAAcX,CAAAW,YAGlBN,EAAAO,UAAA,CAAmB,QAAQ,EAAG,CAC5B,IAAIC,EAAiBR,CAAAC,QAAA,EACjBE,EAAJ,EAA0BK,CAA1B,GACEL,CAGA,CAHqBK,CAGrB,CAFAH,CAAA,CAAKG,CAAL,CAAqBN,CAArB,CAEA,CADAG,CAAA,CAAKG,CAAL,CAAqBP,CAArB,CACA,CAAIG,CAAJ,EAAaL,CAAAU,OAAA,EAJf,CAF4B,CAA9B,CAAA,EAUAL,EAAA,CAAU,CAAA,CAKVL,EAAAW,OAAA,CASAC,QAAa,EAAG,CAAA,IACVC,CADU,CAEVC,CAFU,CAIVC,CAGJ,KAAKF,CAAL,GAAaV,EAAb,CACMI,CAAA,CAAYL,CAAA,CAAQW,CAAR,CAAZ,CAAJ,GACEZ,CAAAC,QAAA,CAAiBW,CAAjB,CAAuBhB,CAAvB,CACA,CAAA,OAAOM,CAAA,CAAYU,CAAZ,CAFT,CAOF,KAAKA,CAAL,GAAaX,EAAb,CACEY,CAKA,CALQZ,CAAA,CAAQW,CAAR,CAKR,CAJKjB,CAAAoB,SAAA,CAAiBF,CAAjB,CAIL,GAHEA,CACA,CADQ,EACR,CADaA,CACb,CAAAZ,CAAA,CAAQW,CAAR,CAAA,CAAgBC,CAElB,EAAIA,CAAJ,GAAcX,CAAA,CAAYU,CAAZ,CAAd,GACEZ,CAAAC,QAAA,CAAiBW,CAAjB,CAAuBC,CAAvB,CAEA,CADAX,CAAA,CAAYU,CAAZ,CACA,CADoBC,CACpB,CAAAC,CAAA,CAAU,CAAA,CAHZ,CAQF,IAAIA,CAAJ,CAGE,IAAKF,CAAL,GAFAI,EAEaf,CAFID,CAAAC,QAAA,EAEJA,CAAAA,CAAb,CACMA,CAAA,CAAQW,CAAR,CAAJ,GAAsBI,CAAA,CAAeJ,CAAf,CAAtB,GAEMN,CAAA,CAAYU,CAAA,CAAeJ,CAAf,CAAZ,CAAJ,EACE,OAAOX,CAAA,CAAQW,CAAR,CACP,CAAA,OAAOV,CAAA,CAAYU,CAAZ,CAFT,EAIEX,CAAA,CAAQW,CAAR,CAJF;AAIkBV,CAAA,CAAYU,CAAZ,CAJlB,CAIsCI,CAAA,CAAeJ,CAAf,CANxC,CAjCU,CAThB,CAEA,OAAOX,EA1BoE,CAA1D,CA1BvB,CAAAH,QAAA,CAqIW,cArIX,CAqI2B,CAAC,UAAD,CAAa,QAAQ,CAACmB,CAAD,CAAW,CAErD,MAAO,CAWLC,IAAKA,QAAQ,CAACC,CAAD,CAAM,CAEjB,MAAO,CADHN,CACG,CADKI,CAAA,CAASE,CAAT,CACL,EAAQxB,CAAAyB,SAAA,CAAiBP,CAAjB,CAAR,CAAkCA,CAFxB,CAXd,CA0BLQ,IAAKA,QAAQ,CAACF,CAAD,CAAMN,CAAN,CAAa,CACxBI,CAAA,CAASE,CAAT,CAAA,CAAgBxB,CAAA2B,OAAA,CAAeT,CAAf,CADQ,CA1BrB,CAuCLU,OAAQA,QAAQ,CAACJ,CAAD,CAAM,CACpB,OAAOF,CAAA,CAASE,CAAT,CADa,CAvCjB,CAF8C,CAAhC,CArI3B,CAnBsC,CAArC,CAAD,CAyMGzB,MAzMH,CAyMWA,MAAAC,QAzMX;",
6 | "sources":["angular-cookies.js"],
7 | "names":["window","angular","undefined","module","factory","$rootScope","$browser","cookies","lastCookies","lastBrowserCookies","runEval","copy","isUndefined","addPollFn","currentCookies","$apply","$watch","push","name","value","updated","isString","browserCookies","$cookies","get","key","fromJson","put","toJson","remove"]
8 | }
9 |
--------------------------------------------------------------------------------
/reloud-admin/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | org.springframework.web.context.ContextLoaderListener
8 |
9 |
10 |
11 | contextConfigLocation
12 | classpath*:/META-INF/spring/*.xml
13 |
14 |
15 |
16 | dispatcherServlet
17 | org.springframework.web.servlet.DispatcherServlet
18 |
19 | contextConfigLocation
20 | classpath:webApplication.xml
21 |
22 | 1
23 |
24 |
25 | dispatcherServlet
26 | /
27 |
28 |
29 | default
30 | *.js
31 |
32 |
33 | default
34 | *.css
35 |
36 |
37 | default
38 | *.jpg
39 |
40 |
41 | default
42 | *.ttf
43 |
44 |
45 | default
46 | *.map
47 |
48 |
49 | default
50 | *.md
51 |
52 |
53 | default
54 | *.woff
55 |
56 |
57 | default
58 | *.woff2
59 |
60 |
61 | default
62 | *.html
63 |
64 |
65 | index.jsp
66 |
67 |
68 |
--------------------------------------------------------------------------------
/reloud-admin/src/main/resources/webApplication.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | json=application/json
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/reloud-admin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | reloud
7 | net.dubboclub
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 | war
12 | reloud-admin
13 |
14 |
15 | 8.1.0.RC5
16 | 2.2.0.v201303151357
17 | 2.2.0.v201303151357
18 | 1.2.1
19 | 2.2.2.v201112011158
20 | 1.2.0.v201112081803
21 | 1.1.2
22 |
23 |
24 |
25 |
26 | mysql
27 | mysql-connector-java
28 |
29 |
30 | org.mybatis
31 | mybatis
32 |
33 |
34 | org.mybatis
35 | mybatis-spring
36 |
37 |
38 | commons-dbcp
39 | commons-dbcp
40 |
41 |
42 |
43 | org.eclipse.jetty.aggregate
44 | jetty-all
45 | ${jetty.version}
46 | test
47 |
48 |
49 | org.eclipse.jetty.orbit
50 | javax.el
51 | ${javax.el.version}
52 | test
53 |
54 |
55 | org.eclipse.jetty.orbit
56 | com.sun.el
57 | ${sun.el.version}
58 | test
59 |
60 |
61 | javax.servlet.jsp.jstl
62 | javax.servlet.jsp.jstl-api
63 | ${jsp.jstl.api.version}
64 | test
65 |
66 |
67 | org.eclipse.jetty.orbit
68 | org.apache.jasper.glassfish
69 | ${jasper.version}
70 | test
71 |
72 |
73 | org.eclipse.jetty.orbit
74 | org.apache.taglibs.standard.glassfish
75 | ${taglibs.version}
76 | test
77 |
78 |
79 | javax.servlet
80 | javax.servlet-api
81 | 3.0.1
82 | test
83 |
84 |
85 |
--------------------------------------------------------------------------------
/reloud-common/reloud-common.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/reloud-client/reloud-client.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/reloud-common/src/main/java/net/dubboclub/reloud/util/ByteUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright [2009-2010] [dennis zhuang(killme2008@gmail.com)]
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
10 | * either express or implied. See the License for the specific language governing permissions and limitations under the License
11 | */
12 | package net.dubboclub.reloud.util;
13 |
14 | import java.io.UnsupportedEncodingException;
15 |
16 | /**
17 | * Utilities for byte process
18 | *
19 | * @author dennis
20 | */
21 | public class ByteUtils {
22 |
23 | public static final byte[] getBytes(String k) {
24 | if (k == null || k.length() == 0) {
25 | throw new IllegalArgumentException("Key must not be blank");
26 | }
27 | try {
28 | return k.getBytes("utf-8");
29 | } catch (UnsupportedEncodingException e) {
30 | throw new RuntimeException(e);
31 | }
32 | }
33 |
34 | public static byte[] int2bytes(int v) {
35 | byte[] ret = {0, 0, 0, 0};
36 | int2bytes(v, ret);
37 | return ret;
38 | }
39 |
40 | public static void int2bytes(int v, byte[] b) {
41 | int2bytes(v, b, 0);
42 | }
43 |
44 | public static void int2bytes(int v, byte[] b, int off) {
45 | b[off + 3] = (byte) v;
46 | b[off + 2] = (byte) (v >>> 8);
47 | b[off + 1] = (byte) (v >>> 16);
48 | b[off + 0] = (byte) (v >>> 24);
49 | }
50 |
51 | public static byte[] long2bytes(long v) {
52 | byte[] ret = {0, 0, 0, 0, 0, 0, 0, 0};
53 | long2bytes(v, ret);
54 | return ret;
55 | }
56 |
57 | public static void long2bytes(long v, byte[] b) {
58 | long2bytes(v, b, 0);
59 | }
60 |
61 | public static void long2bytes(long v, byte[] b, int off) {
62 | b[off + 7] = (byte) v;
63 | b[off + 6] = (byte) (v >>> 8);
64 | b[off + 5] = (byte) (v >>> 16);
65 | b[off + 4] = (byte) (v >>> 24);
66 | b[off + 3] = (byte) (v >>> 32);
67 | b[off + 2] = (byte) (v >>> 40);
68 | b[off + 1] = (byte) (v >>> 48);
69 | b[off + 0] = (byte) (v >>> 56);
70 | }
71 |
72 |
73 | public static byte[] float2bytes(float v) {
74 | byte[] ret = {0, 0, 0, 0};
75 | float2bytes(v, ret);
76 | return ret;
77 | }
78 |
79 | public static void float2bytes(float v, byte[] b) {
80 | float2bytes(v, b, 0);
81 | }
82 |
83 | public static void float2bytes(float v, byte[] b, int off) {
84 | int i = Float.floatToIntBits(v);
85 | int2bytes(i, b, off);
86 | }
87 |
88 |
89 | public static byte[] double2bytes(double v) {
90 | byte[] ret = {0, 0, 0, 0, 0, 0, 0, 0};
91 | double2bytes(v, ret);
92 | return ret;
93 | }
94 |
95 | public static void double2bytes(double v, byte[] b) {
96 | double2bytes(v, b, 0);
97 | }
98 |
99 | public static void double2bytes(double v, byte[] b, int off) {
100 | long l = Double.doubleToLongBits(v);
101 | long2bytes(l, b, off);
102 | }
103 |
104 | public static int bytes2int(byte[] b){
105 | return bytes2int(b,0);
106 | }
107 |
108 | public static int bytes2int(byte[] b, int off) {
109 | return ((b[off + 3] & 0xFF) << 0) + ((b[off + 2] & 0xFF) << 8) + ((b[off + 1] & 0xFF) << 16) + (b[off + 0] << 24);
110 | }
111 |
112 | public static long byte2long(byte[] b){
113 | return bytes2long(b,0);
114 | }
115 |
116 | public static long bytes2long(byte[] b, int off) {
117 | return ((b[off + 7] & 0xFFL) << 0) + ((b[off + 6] & 0xFFL) << 8) + ((b[off + 5] & 0xFFl) << 16) + ((b[off + 4] & 0xFFl) << 24) + ((b[off + 3] & 0xFFl) << 32) + ((b[off + 2] & 0xFFl) << 40) + ((b[off + 1] & 0xFFl) << 48) + (b[off + 5] << 56);
118 | }
119 |
120 | public static float bytes2float(byte[] b){
121 | return bytes2float(b,0);
122 | }
123 |
124 | public static float bytes2float(byte[] b,int off){
125 | int i = bytes2int(b,off);
126 | return Float.intBitsToFloat(i);
127 | }
128 |
129 |
130 | public static double bytes2double(byte[] b){
131 | return bytes2double(b,0);
132 | }
133 |
134 | public static double bytes2double(byte[] b,int off){
135 | long l = bytes2long(b,off);
136 | return Double.longBitsToDouble(l);
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/reloud-common/src/main/java/net/dubboclub/reloud/util/HashAlgorithm.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * 平安付
4 | * Copyright (c) 2013-2014 PingAnFu,Inc.All Rights Reserved.
5 | */
6 | package net.dubboclub.reloud.util;
7 |
8 | import java.io.UnsupportedEncodingException;
9 | import java.security.MessageDigest;
10 | import java.security.NoSuchAlgorithmException;
11 | import java.util.zip.CRC32;
12 |
13 | /**
14 | * Known hashing algorithms for locating a server for a key. Note that all hash
15 | * algorithms return 64-bits of hash, but only the lower 32-bits are
16 | * significant. This allows a positive 32-bit number to be returned for all
17 | * cases.
18 | */
19 | public enum HashAlgorithm {
20 |
21 | /**
22 | * Native hash (String.hashCode()).
23 | */
24 | NATIVE_HASH,
25 | /**
26 | * CRC32_HASH as used by the perl API. This will be more consistent both
27 | * across multiple API users as well as java versions, but is mostly likely
28 | * significantly slower.
29 | */
30 | CRC32_HASH,
31 | /**
32 | * FNV hashes are designed to be fast while maintaining a low collision
33 | * rate. The FNV speed allows one to quickly hash lots of data while
34 | * maintaining a reasonable collision rate.
35 | *
36 | * @see http://www.isthe.com/chongo/tech/comp/fnv/
37 | * @see http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
38 | */
39 | FNV1_64_HASH,
40 | /**
41 | * Variation of FNV.
42 | */
43 | FNV1A_64_HASH,
44 | /**
45 | * 32-bit FNV1.
46 | */
47 | FNV1_32_HASH,
48 | /**
49 | * 32-bit FNV1a.
50 | */
51 | FNV1A_32_HASH,
52 | /**
53 | * MD5-based hash algorithm used by ketama.
54 | */
55 | KETAMA_HASH,
56 |
57 | /**
58 | * From mysql source
59 | */
60 | MYSQL_HASH,
61 |
62 | ELF_HASH,
63 |
64 | RS_HASH,
65 |
66 | /**
67 | * From lua source,it is used for long key
68 | */
69 | LUA_HASH,
70 |
71 | ELECTION_HASH,
72 | /**
73 | * The Jenkins One-at-a-time hash ,please see
74 | * http://www.burtleburtle.net/bob/hash/doobs.html
75 | */
76 | ONE_AT_A_TIME;
77 |
78 | private static final long FNV_64_INIT = 0xcbf29ce484222325L;
79 | private static final long FNV_64_PRIME = 0x100000001b3L;
80 |
81 | private static final long FNV_32_INIT = 2166136261L;
82 | private static final long FNV_32_PRIME = 16777619;
83 |
84 | public long hash(byte[] bytes){
85 | long rv = 0;
86 | switch (this){
87 | case KETAMA_HASH:
88 | byte[] bKey = computeMd5(bytes);
89 | rv = (long) (bKey[3] & 0xFF) << 24 | (long) (bKey[2] & 0xFF) << 16
90 | | (long) (bKey[1] & 0xFF) << 8 | bKey[0] & 0xFF;
91 | break;
92 | }
93 | return rv;
94 | }
95 | /**
96 | * Compute the hash for the given key.
97 | *
98 | * @return a positive integer hash
99 | */
100 | public long hash(final String k) {
101 | long rv = 0;
102 | switch (this) {
103 | case NATIVE_HASH:
104 | rv = k.hashCode();
105 | break;
106 | case CRC32_HASH:
107 | // return (crc32(shift) >> 16) & 0x7fff;
108 | CRC32 crc32 = new CRC32();
109 | crc32.update(ByteUtils.getBytes(k));
110 | rv = crc32.getValue() >> 16 & 0x7fff;
111 | break;
112 | case FNV1_64_HASH: {
113 | // Thanks to pierre@demartines.com for the pointer
114 | rv = FNV_64_INIT;
115 | int len = k.length();
116 | for (int i = 0; i < len; i++) {
117 | rv *= FNV_64_PRIME;
118 | rv ^= k.charAt(i);
119 | }
120 | }
121 | break;
122 | case FNV1A_64_HASH: {
123 | rv = FNV_64_INIT;
124 | int len = k.length();
125 | for (int i = 0; i < len; i++) {
126 | rv ^= k.charAt(i);
127 | rv *= FNV_64_PRIME;
128 | }
129 | }
130 | break;
131 | case FNV1_32_HASH: {
132 | rv = FNV_32_INIT;
133 | int len = k.length();
134 | for (int i = 0; i < len; i++) {
135 | rv *= FNV_32_PRIME;
136 | rv ^= k.charAt(i);
137 | }
138 | }
139 | break;
140 | case FNV1A_32_HASH: {
141 | rv = FNV_32_INIT;
142 | int len = k.length();
143 | for (int i = 0; i < len; i++) {
144 | rv ^= k.charAt(i);
145 | rv *= FNV_32_PRIME;
146 | }
147 | }
148 | break;
149 | case ELECTION_HASH:
150 | case KETAMA_HASH:
151 | byte[] bKey = computeMd5(k);
152 | rv = (long) (bKey[3] & 0xFF) << 24 | (long) (bKey[2] & 0xFF) << 16
153 | | (long) (bKey[1] & 0xFF) << 8 | bKey[0] & 0xFF;
154 | break;
155 |
156 | case MYSQL_HASH:
157 | int nr2 = 4;
158 | for (int i = 0; i < k.length(); i++) {
159 | rv ^= ((rv & 63) + nr2) * k.charAt(i) + (rv << 8);
160 | nr2 += 3;
161 | }
162 | break;
163 | case ELF_HASH:
164 | long x = 0;
165 | for (int i = 0; i < k.length(); i++) {
166 | rv = (rv << 4) + k.charAt(i);
167 | if ((x = rv & 0xF0000000L) != 0) {
168 | rv ^= x >> 24;
169 | rv &= ~x;
170 | }
171 | }
172 | rv = rv & 0x7FFFFFFF;
173 | break;
174 | case RS_HASH:
175 | long b = 378551;
176 | long a = 63689;
177 | for (int i = 0; i < k.length(); i++) {
178 | rv = rv * a + k.charAt(i);
179 | a *= b;
180 | }
181 | rv = rv & 0x7FFFFFFF;
182 | break;
183 | case LUA_HASH:
184 | int step = (k.length() >> 5) + 1;
185 | rv = k.length();
186 | for (int len = k.length(); len >= step; len -= step) {
187 | rv = rv ^ (rv << 5) + (rv >> 2) + k.charAt(len - 1);
188 | }
189 | case ONE_AT_A_TIME:
190 | try {
191 | int hash = 0;
192 | for (byte bt : k.getBytes("utf-8")) {
193 | hash += (bt & 0xFF);
194 | hash += (hash << 10);
195 | hash ^= (hash >>> 6);
196 | }
197 | hash += (hash << 3);
198 | hash ^= (hash >>> 11);
199 | hash += (hash << 15);
200 | return hash;
201 | } catch (UnsupportedEncodingException e) {
202 | throw new IllegalStateException("Hash function error", e);
203 | }
204 | default:
205 | assert false;
206 | }
207 |
208 | return rv & 0xffffffffL; /* Truncate to 32-bits */
209 | }
210 |
211 | private static ThreadLocal md5Local = new ThreadLocal();
212 |
213 | /**
214 | * Get the md5 of the given key.
215 | */
216 | public static byte[] computeMd5(String k) {
217 | MessageDigest md5 = md5Local.get();
218 | if (md5 == null) {
219 | try {
220 | md5 = MessageDigest.getInstance("MD5");
221 | md5Local.set(md5);
222 | } catch (NoSuchAlgorithmException e) {
223 | throw new RuntimeException("MD5 not supported", e);
224 | }
225 | }
226 | md5.reset();
227 | md5.update(ByteUtils.getBytes(k));
228 | return md5.digest();
229 | }
230 | /**
231 | * Get the md5 of the given key.
232 | */
233 | public static byte[] computeMd5(byte[] bytes) {
234 | MessageDigest md5 = md5Local.get();
235 | if (md5 == null) {
236 | try {
237 | md5 = MessageDigest.getInstance("MD5");
238 | md5Local.set(md5);
239 | } catch (NoSuchAlgorithmException e) {
240 | throw new RuntimeException("MD5 not supported", e);
241 | }
242 | }
243 | md5.reset();
244 | md5.update(bytes);
245 | return md5.digest();
246 | }
247 |
248 | // public static void main(String[] args) {
249 | // HashAlgorithm alg=HashAlgorithm.CRC32_HASH;
250 | // long h=0;
251 | // long start=System.currentTimeMillis();
252 | // for(int i=0;i<100000;i++)
253 | // h=alg.hash("MYSQL_HASH");
254 | // System.out.println(System.currentTimeMillis()-start);
255 | // }
256 | }
257 |
--------------------------------------------------------------------------------
/reloud-admin/src/main/webapp/css/bootstrap-table.css:
--------------------------------------------------------------------------------
1 | /**
2 | * @author zhixin wen
3 | * version: 1.8.1
4 | * https://github.com/wenzhixin/bootstrap-table/
5 | */
6 |
7 | .bootstrap-table .table {
8 | margin-bottom: 0 !important;
9 | border-bottom: 1px solid #dddddd;
10 | border-collapse: collapse !important;
11 | border-radius: 1px;
12 | }
13 |
14 | .bootstrap-table .table,
15 | .bootstrap-table .table > tbody > tr > th,
16 | .bootstrap-table .table > tfoot > tr > th,
17 | .bootstrap-table .table > thead > tr > td,
18 | .bootstrap-table .table > tbody > tr > td,
19 | .bootstrap-table .table > tfoot > tr > td {
20 | padding: 8px !important;
21 | }
22 |
23 | .bootstrap-table .table.table-no-bordered > thead > tr > th,
24 | .bootstrap-table .table.table-no-bordered > tbody > tr > td {
25 | border-right: 2px solid transparent;
26 | }
27 |
28 | .fixed-table-container {
29 | position: relative;
30 | clear: both;
31 | border: 1px solid #dddddd;
32 | border-radius: 4px;
33 | -webkit-border-radius: 4px;
34 | -moz-border-radius: 4px;
35 | }
36 |
37 | .fixed-table-container.table-no-bordered {
38 | border: 1px solid transparent;
39 | }
40 |
41 | .fixed-table-footer,
42 | .fixed-table-header {
43 | height: 37px; /*cellHeight*/
44 | overflow: hidden;
45 | border-radius: 4px 4px 0 0;
46 | -webkit-border-radius: 4px 4px 0 0;
47 | -moz-border-radius: 4px 4px 0 0;
48 | }
49 |
50 | .fixed-table-header {
51 | border-bottom: 1px solid #dddddd;
52 | }
53 |
54 | .fixed-table-footer {
55 | border-top: 1px solid #dddddd;
56 | }
57 |
58 | .fixed-table-body {
59 | overflow-x: auto;
60 | overflow-y: auto;
61 | height: 100%;
62 | }
63 |
64 | .fixed-table-container table {
65 | width: 100%;
66 | }
67 |
68 | .fixed-table-container thead th {
69 | height: 0;
70 | padding: 0;
71 | margin: 0;
72 | border-left: 1px solid #dddddd;
73 | }
74 |
75 | .fixed-table-container thead th:first-child {
76 | border-left: none;
77 | border-top-left-radius: 4px;
78 | -webkit-border-top-left-radius: 4px;
79 | -moz-border-radius-topleft: 4px;
80 | }
81 |
82 | .fixed-table-container thead th .th-inner {
83 | padding: 8px;
84 | line-height: 24px;
85 | vertical-align: top;
86 | overflow: hidden;
87 | text-overflow: ellipsis;
88 | white-space: nowrap;
89 | }
90 |
91 | .fixed-table-container thead th .sortable {
92 | cursor: pointer;
93 | background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC');
94 | background-position: right;
95 | background-repeat: no-repeat;
96 | padding-right: 30px;
97 | }
98 |
99 | .fixed-table-container th.detail {
100 | width: 30px;
101 | }
102 |
103 | .fixed-table-container tbody td {
104 | border-left: 1px solid #dddddd;
105 | }
106 |
107 | .fixed-table-container tbody tr:first-child td {
108 | border-top: none;
109 | }
110 |
111 | .fixed-table-container tbody td:first-child {
112 | border-left: none;
113 | }
114 |
115 | /* the same color with .active */
116 | .fixed-table-container tbody .selected td {
117 | background-color: #f5f5f5;
118 | }
119 |
120 | .fixed-table-container .bs-checkbox {
121 | text-align: center;
122 | }
123 |
124 | .fixed-table-container .bs-checkbox .th-inner {
125 | padding: 8px 0;
126 | }
127 |
128 | .fixed-table-container input[type="radio"],
129 | .fixed-table-container input[type="checkbox"] {
130 | margin: 0 auto !important;
131 | }
132 |
133 | .fixed-table-container .no-records-found {
134 | text-align: center;
135 | }
136 |
137 | .fixed-table-pagination div.pagination,
138 | .fixed-table-pagination .pagination-detail {
139 | margin-top: 10px;
140 | margin-bottom: 10px;
141 | }
142 |
143 | .fixed-table-pagination div.pagination .pagination {
144 | margin: 0;
145 | }
146 |
147 | .fixed-table-pagination .pagination a {
148 | padding: 6px 12px;
149 | line-height: 1.428571429;
150 | }
151 |
152 | .fixed-table-pagination .pagination-info {
153 | line-height: 34px;
154 | margin-right: 5px;
155 | }
156 |
157 | .fixed-table-pagination .btn-group {
158 | position: relative;
159 | display: inline-block;
160 | vertical-align: middle;
161 | }
162 |
163 | .fixed-table-pagination .dropup .dropdown-menu {
164 | margin-bottom: 0;
165 | }
166 |
167 | .fixed-table-pagination .page-list {
168 | display: inline-block;
169 | }
170 |
171 | .fixed-table-toolbar .columns-left {
172 | margin-right: 5px;
173 | }
174 |
175 | .fixed-table-toolbar .columns-right {
176 | margin-left: 5px;
177 | }
178 |
179 | .fixed-table-toolbar .columns label {
180 | display: block;
181 | padding: 3px 20px;
182 | clear: both;
183 | font-weight: normal;
184 | line-height: 1.428571429;
185 | }
186 |
187 | .fixed-table-toolbar .bars,
188 | .fixed-table-toolbar .search,
189 | .fixed-table-toolbar .columns {
190 | position: relative;
191 | margin-top: 10px;
192 | margin-bottom: 10px;
193 | line-height: 34px;
194 | }
195 |
196 | .fixed-table-pagination li.disabled a {
197 | pointer-events: none;
198 | cursor: default;
199 | }
200 |
201 | .fixed-table-loading {
202 | display: none;
203 | position: absolute;
204 | top: 42px;
205 | right: 0;
206 | bottom: 0;
207 | left: 0;
208 | z-index: 99;
209 | background-color: #fff;
210 | text-align: center;
211 | }
212 |
213 | .fixed-table-body .card-view .title {
214 | font-weight: bold;
215 | display: inline-block;
216 | min-width: 30%;
217 | text-align: left !important;
218 | }
219 |
220 | /* support bootstrap 2 */
221 | .fixed-table-body thead th .th-inner {
222 | box-sizing: border-box;
223 | }
224 |
225 | .table th, .table td {
226 | vertical-align: middle;
227 | box-sizing: border-box;
228 | }
229 |
230 | .fixed-table-toolbar .dropdown-menu {
231 | text-align: left;
232 | max-height: 300px;
233 | overflow: auto;
234 | }
235 |
236 | .fixed-table-toolbar .btn-group > .btn-group {
237 | display: inline-block;
238 | margin-left: -1px !important;
239 | }
240 |
241 | .fixed-table-toolbar .btn-group > .btn-group > .btn {
242 | border-radius: 0;
243 | }
244 |
245 | .fixed-table-toolbar .btn-group > .btn-group:first-child > .btn {
246 | border-top-left-radius: 4px;
247 | border-bottom-left-radius: 4px;
248 | }
249 |
250 | .fixed-table-toolbar .btn-group > .btn-group:last-child > .btn {
251 | border-top-right-radius: 4px;
252 | border-bottom-right-radius: 4px;
253 | }
254 |
255 | .bootstrap-table .table > thead > tr > th {
256 | vertical-align: bottom;
257 | border-bottom: 2px solid #ddd;
258 | }
259 |
260 | /* support bootstrap 3 */
261 | .bootstrap-table .table thead > tr > th {
262 | padding: 0;
263 | margin: 0;
264 | }
265 |
266 | .pull-right .dropdown-menu {
267 | right: 0;
268 | left: auto;
269 | }
270 |
271 | /* calculate scrollbar width */
272 | p.fixed-table-scroll-inner {
273 | width: 100%;
274 | height: 200px;
275 | }
276 |
277 | div.fixed-table-scroll-outer {
278 | top: 0;
279 | left: 0;
280 | visibility: hidden;
281 | width: 200px;
282 | height: 150px;
283 | overflow: hidden;
284 | }
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | net.dubboclub
8 | reloud
9 | pom
10 | 1.0-SNAPSHOT
11 |
12 | reloud-client
13 | reloud-common
14 | reloud-admin
15 |
16 |
17 | 2.7.2
18 | 2.5.3
19 | 5.3.20
20 | 2.5
21 | 5.3.0
22 | findbugs-exclude.xml
23 | UTF-8
24 | 2.7
25 | 0.0.6
26 | 2.12.6.1
27 | 2.6
28 | 1.2.83
29 | 0.1
30 | 3.4.14
31 | 1.2.9
32 | 3.5.6
33 | 1.1.0
34 | 1.4
35 | 8.0.28
36 |
37 |
38 |
39 |
40 |
41 | mysql
42 | mysql-connector-java
43 | ${mysql.driver.version}
44 |
45 |
46 | org.mybatis
47 | mybatis
48 | ${mybatis.version}
49 |
50 |
51 | org.mybatis
52 | mybatis-spring
53 | ${mybatis.spring.version}
54 |
55 |
56 | commons-dbcp
57 | commons-dbcp
58 | ${commons-dbcp.version}
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | redis.clients
68 | jedis
69 | ${jedis.version}
70 |
71 |
72 |
73 |
74 |
75 | ch.qos.logback
76 | logback-classic
77 | ${logback.version}
78 |
79 |
80 | ch.qos.logback
81 | logback-core
82 | ${logback.version}
83 |
84 |
85 |
86 |
87 | commons-io
88 | commons-io
89 | ${common.io.version}
90 |
91 |
92 | commons-lang
93 | commons-lang
94 | ${commons.lang.version}
95 |
96 |
97 |
98 |
99 | com.fasterxml.jackson.core
100 | jackson-databind
101 | ${jackson.version}
102 |
103 |
104 | com.fasterxml.jackson.core
105 | jackson-core
106 | ${jackson.version}
107 |
108 |
109 | com.fasterxml.jackson.core
110 | jackson-annotations
111 | ${jackson.version}
112 |
113 |
114 | com.alibaba
115 | fastjson
116 | ${fastjson.version}
117 |
118 |
119 |
120 |
121 | com.github.sgroschupf
122 | zkclient
123 | ${zk.version}
124 |
125 |
126 | org.apache.zookeeper
127 | zookeeper
128 | ${zookeeper.version}
129 |
130 |
131 |
132 |
133 |
134 | org.springframework
135 | spring-context
136 | ${spring_version}
137 |
138 |
139 | org.springframework
140 | spring-web
141 | ${spring_version}
142 |
143 |
144 | org.springframework
145 | spring-tx
146 | ${spring_version}
147 |
148 |
149 | org.springframework
150 | spring-core
151 | ${spring_version}
152 |
153 |
154 | org.springframework
155 | spring-webmvc
156 | ${spring_version}
157 |
158 |
159 | org.springframework
160 | spring-tx
161 | ${spring_version}
162 |
163 |
164 | org.springframework
165 | spring-context-support
166 | ${spring_version}
167 |
168 |
169 |
170 |
171 | org.springframework
172 | spring-test
173 | ${spring_version}
174 | test
175 |
176 |
177 | javax.servlet
178 | servlet-api
179 | 2.5
180 | provided
181 |
182 |
183 | javax.servlet
184 | servlet-api
185 | 2.5
186 | provided
187 |
188 |
189 | taglibs
190 | standard
191 | 1.1.2
192 |
193 |
194 | junit
195 | junit
196 | 4.13.1
197 | test
198 |
199 |
200 |
201 |
202 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/cluster/synchronizer/UsingHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.cluster.synchronizer;
206 |
207 | /**
208 | * @date: 2016/1/22.
209 | * @author:bieber.
210 | * @project:reloud.
211 | * @package:net.dubboclub.reloud.cluster.
212 | * @version:1.0.0
213 | * @fix:
214 | * @description: 描述功能
215 | */
216 | public interface UsingHandler {
217 |
218 | T using();
219 |
220 | }
221 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/cluster/synchronizer/RefreshingHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.cluster.synchronizer;
206 |
207 | /**
208 | * @date: 2016/1/22.
209 | * @author:bieber.
210 | * @project:reloud.
211 | * @package:net.dubboclub.reloud.cluster.
212 | * @version:1.0.0
213 | * @fix:
214 | * @description: 将注册中心的信息刷新到本地内存中
215 | */
216 | public interface RefreshingHandler {
217 |
218 | void refreshing();
219 | }
220 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/client/OperateHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.client;
206 |
207 | import redis.clients.jedis.Jedis;
208 |
209 | /**
210 | * @date: 2016/2/15.
211 | * @author:bieber.
212 | * @project:reloud.
213 | * @package:net.dubboclub.reloud.client.
214 | * @version:1.0.0
215 | * @fix:
216 | * @description: 描述功能
217 | */
218 | public interface OperateHandler {
219 |
220 | public T operate(Jedis jedis);
221 | }
222 |
--------------------------------------------------------------------------------
/reloud-common/src/main/java/net/dubboclub/reloud/notify/ReloudNotify.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.notify;
206 |
207 | import java.util.Collection;
208 | import java.util.List;
209 |
210 | /**
211 | * @date: 2016/1/20.
212 | * @author:bieber.
213 | * @project:reloud.
214 | * @package:net.dubboclub.reloud.notify.
215 | * @version:1.0.0
216 | * @fix:
217 | * @description: 接受zk端变更的通知接口
218 | */
219 | public interface ReloudNotify {
220 |
221 | void notify(List children);
222 |
223 | }
224 |
--------------------------------------------------------------------------------
/reloud-common/src/main/java/net/dubboclub/reloud/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud;
206 |
207 | /**
208 | * @date: 2016/1/20.
209 | * @author:bieber.
210 | * @project:reloud.
211 | * @package:net.dubboclub.reloud.
212 | * @version:1.0.0
213 | * @fix:
214 | * @description: 描述功能
215 | */
216 | public class Constants {
217 |
218 | public static final String ZK_ROOT="reloud";
219 |
220 |
221 | public static final String PORT_SPLIT=":";
222 |
223 |
224 | public static final String NONE="NONE";
225 |
226 |
227 | public static final String SPLIT_FLAG="-";
228 |
229 | }
230 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/strategy/ShardStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.strategy;
206 |
207 | import net.dubboclub.reloud.cluster.ReloudShard;
208 |
209 | import java.util.Collection;
210 |
211 | /**
212 | * @date: 2016/1/22.
213 | * @author:bieber.
214 | * @project:reloud.
215 | * @package:net.dubboclub.reloud.strategy.
216 | * @version:1.0.0
217 | * @fix:
218 | * @description: 分片策略
219 | */
220 | public interface ShardStrategy {
221 |
222 | public int shard(String key, Collection sharedList);
223 |
224 | public int shard(byte[] bytes, Collection sharedList);
225 | }
226 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/strategy/RoundRobinShard.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.strategy;
206 |
207 | import net.dubboclub.reloud.cluster.ReloudShard;
208 | import net.dubboclub.reloud.util.HashAlgorithm;
209 |
210 | import java.util.Collection;
211 |
212 | /**
213 | * @date: 2016/1/22.
214 | * @author:bieber.
215 | * @project:reloud.
216 | * @package:net.dubboclub.reloud.strategy.
217 | * @version:1.0.0
218 | * @fix:
219 | * @description: 通过hash取模的方式确定某个key在哪个分片
220 | */
221 | public class RoundRobinShard implements ShardStrategy {
222 |
223 | public int shard(String key, Collection sharedList) {
224 | return (int) (HashAlgorithm.KETAMA_HASH.hash(key)%sharedList.size());
225 | }
226 |
227 | public int shard(byte[] bytes, Collection sharedList) {
228 | return (int) (HashAlgorithm.KETAMA_HASH.hash(bytes)%sharedList.size());
229 | }
230 | }
231 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/Reloud.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud;
206 |
207 | import net.dubboclub.reloud.cluster.ReloudCluster;
208 | import net.dubboclub.reloud.cluster.ReloudShard;
209 | import net.dubboclub.reloud.util.HashAlgorithm;
210 | import org.springframework.beans.factory.InitializingBean;
211 |
212 | import java.util.List;
213 |
214 | /**
215 | * @date: 2016/1/20.
216 | * @author:bieber.
217 | * @project:reloud.
218 | * @package:net.dubboclub.reloud.
219 | * @version:1.0.0
220 | * @fix:
221 | * @description: redis客户端入口
222 | */
223 | public class Reloud implements InitializingBean{
224 |
225 | private String zookeeperConnects;
226 |
227 | private int zkConnectionTimeout;
228 |
229 | private int zkSessionTimeout;
230 |
231 | //所有的redis集群
232 | private ReloudCluster reloudCluster;
233 |
234 | public void afterPropertiesSet() throws Exception {
235 |
236 | }
237 |
238 | /**
239 | * 通过该key获取所有
240 | * @param key
241 | * @return
242 | */
243 | public ReloudShard getShard(String key){
244 | return reloudCluster.getShared(key);
245 | }
246 |
247 | public ReloudShard getShard(byte[] key){
248 | return reloudCluster.getShared(key);
249 | }
250 |
251 | public void setZkConnectionTimeout(int zkConnectionTimeout) {
252 | this.zkConnectionTimeout = zkConnectionTimeout;
253 | }
254 |
255 | public void setZkSessionTimeout(int zkSessionTimeout) {
256 | this.zkSessionTimeout = zkSessionTimeout;
257 | }
258 |
259 | public void setZookeeperConnects(String zookeeperConnects) {
260 | this.zookeeperConnects = zookeeperConnects;
261 | }
262 | }
263 |
--------------------------------------------------------------------------------
/reloud-client/src/main/java/net/dubboclub/reloud/cluster/synchronizer/Synchronizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Apache License
3 | * Version 2.0, January 2004
4 | * http://www.apache.org/licenses/
5 | *
6 | * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 | *
8 | * 1. Definitions.
9 | *
10 | * "License" shall mean the terms and conditions for use, reproduction,
11 | * and distribution as defined by Sections 1 through 9 of this document.
12 | *
13 | * "Licensor" shall mean the copyright owner or entity authorized by
14 | * the copyright owner that is granting the License.
15 | *
16 | * "Legal Entity" shall mean the union of the acting entity and all
17 | * other entities that control, are controlled by, or are under common
18 | * control with that entity. For the purposes of this definition,
19 | * "control" means (i) the power, direct or indirect, to cause the
20 | * direction or management of such entity, whether by contract or
21 | * otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | * outstanding shares, or (iii) beneficial ownership of such entity.
23 | *
24 | * "You" (or "Your") shall mean an individual or Legal Entity
25 | * exercising permissions granted by this License.
26 | *
27 | * "Source" form shall mean the preferred form for making modifications,
28 | * including but not limited to software source code, documentation
29 | * source, and configuration files.
30 | *
31 | * "Object" form shall mean any form resulting from mechanical
32 | * transformation or translation of a Source form, including but
33 | * not limited to compiled object code, generated documentation,
34 | * and conversions to other media types.
35 | *
36 | * "Work" shall mean the work of authorship, whether in Source or
37 | * Object form, made available under the License, as indicated by a
38 | * copyright notice that is included in or attached to the work
39 | * (an example is provided in the Appendix below).
40 | *
41 | * "Derivative Works" shall mean any work, whether in Source or Object
42 | * form, that is based on (or derived from) the Work and for which the
43 | * editorial revisions, annotations, elaborations, or other modifications
44 | * represent, as a whole, an original work of authorship. For the purposes
45 | * of this License, Derivative Works shall not include works that remain
46 | * separable from, or merely link (or bind by name) to the interfaces of,
47 | * the Work and Derivative Works thereof.
48 | *
49 | * "Contribution" shall mean any work of authorship, including
50 | * the original version of the Work and any modifications or additions
51 | * to that Work or Derivative Works thereof, that is intentionally
52 | * submitted to Licensor for inclusion in the Work by the copyright owner
53 | * or by an individual or Legal Entity authorized to submit on behalf of
54 | * the copyright owner. For the purposes of this definition, "submitted"
55 | * means any form of electronic, verbal, or written communication sent
56 | * to the Licensor or its representatives, including but not limited to
57 | * communication on electronic mailing lists, source code control systems,
58 | * and issue tracking systems that are managed by, or on behalf of, the
59 | * Licensor for the purpose of discussing and improving the Work, but
60 | * excluding communication that is conspicuously marked or otherwise
61 | * designated in writing by the copyright owner as "Not a Contribution."
62 | *
63 | * "Contributor" shall mean Licensor and any individual or Legal Entity
64 | * on behalf of whom a Contribution has been received by Licensor and
65 | * subsequently incorporated within the Work.
66 | *
67 | * 2. Grant of Copyright License. Subject to the terms and conditions of
68 | * this License, each Contributor hereby grants to You a perpetual,
69 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | * copyright license to reproduce, prepare Derivative Works of,
71 | * publicly display, publicly perform, sublicense, and distribute the
72 | * Work and such Derivative Works in Source or Object form.
73 | *
74 | * 3. Grant of Patent License. Subject to the terms and conditions of
75 | * this License, each Contributor hereby grants to You a perpetual,
76 | * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | * (except as stated in this section) patent license to make, have made,
78 | * use, offer to sell, sell, import, and otherwise transfer the Work,
79 | * where such license applies only to those patent claims licensable
80 | * by such Contributor that are necessarily infringed by their
81 | * Contribution(s) alone or by combination of their Contribution(s)
82 | * with the Work to which such Contribution(s) was submitted. If You
83 | * institute patent litigation against any entity (including a
84 | * cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | * or a Contribution incorporated within the Work constitutes direct
86 | * or contributory patent infringement, then any patent licenses
87 | * granted to You under this License for that Work shall terminate
88 | * as of the date such litigation is filed.
89 | *
90 | * 4. Redistribution. You may reproduce and distribute copies of the
91 | * Work or Derivative Works thereof in any medium, with or without
92 | * modifications, and in Source or Object form, provided that You
93 | * meet the following conditions:
94 | *
95 | * (a) You must give any other recipients of the Work or
96 | * Derivative Works a copy of this License; and
97 | *
98 | * (b) You must cause any modified files to carry prominent notices
99 | * stating that You changed the files; and
100 | *
101 | * (c) You must retain, in the Source form of any Derivative Works
102 | * that You distribute, all copyright, patent, trademark, and
103 | * attribution notices from the Source form of the Work,
104 | * excluding those notices that do not pertain to any part of
105 | * the Derivative Works; and
106 | *
107 | * (d) If the Work includes a "NOTICE" text file as part of its
108 | * distribution, then any Derivative Works that You distribute must
109 | * include a readable copy of the attribution notices contained
110 | * within such NOTICE file, excluding those notices that do not
111 | * pertain to any part of the Derivative Works, in at least one
112 | * of the following places: within a NOTICE text file distributed
113 | * as part of the Derivative Works; within the Source form or
114 | * documentation, if provided along with the Derivative Works; or,
115 | * within a display generated by the Derivative Works, if and
116 | * wherever such third-party notices normally appear. The contents
117 | * of the NOTICE file are for informational purposes only and
118 | * do not modify the License. You may add Your own attribution
119 | * notices within Derivative Works that You distribute, alongside
120 | * or as an addendum to the NOTICE text from the Work, provided
121 | * that such additional attribution notices cannot be construed
122 | * as modifying the License.
123 | *
124 | * You may add Your own copyright statement to Your modifications and
125 | * may provide additional or different license terms and conditions
126 | * for use, reproduction, or distribution of Your modifications, or
127 | * for any such Derivative Works as a whole, provided Your use,
128 | * reproduction, and distribution of the Work otherwise complies with
129 | * the conditions stated in this License.
130 | *
131 | * 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | * any Contribution intentionally submitted for inclusion in the Work
133 | * by You to the Licensor shall be under the terms and conditions of
134 | * this License, without any additional terms or conditions.
135 | * Notwithstanding the above, nothing herein shall supersede or modify
136 | * the terms of any separate license agreement you may have executed
137 | * with Licensor regarding such Contributions.
138 | *
139 | * 6. Trademarks. This License does not grant permission to use the trade
140 | * names, trademarks, service marks, or product names of the Licensor,
141 | * except as required for reasonable and customary use in describing the
142 | * origin of the Work and reproducing the content of the NOTICE file.
143 | *
144 | * 7. Disclaimer of Warranty. Unless required by applicable law or
145 | * agreed to in writing, Licensor provides the Work (and each
146 | * Contributor provides its Contributions) on an "AS IS" BASIS,
147 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | * implied, including, without limitation, any warranties or conditions
149 | * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | * PARTICULAR PURPOSE. You are solely responsible for determining the
151 | * appropriateness of using or redistributing the Work and assume any
152 | * risks associated with Your exercise of permissions under this License.
153 | *
154 | * 8. Limitation of Liability. In no event and under no legal theory,
155 | * whether in tort (including negligence), contract, or otherwise,
156 | * unless required by applicable law (such as deliberate and grossly
157 | * negligent acts) or agreed to in writing, shall any Contributor be
158 | * liable to You for damages, including any direct, indirect, special,
159 | * incidental, or consequential damages of any character arising as a
160 | * result of this License or out of the use or inability to use the
161 | * Work (including but not limited to damages for loss of goodwill,
162 | * work stoppage, computer failure or malfunction, or any and all
163 | * other commercial damages or losses), even if such Contributor
164 | * has been advised of the possibility of such damages.
165 | *
166 | * 9. Accepting Warranty or Additional Liability. While redistributing
167 | * the Work or Derivative Works thereof, You may choose to offer,
168 | * and charge a fee for, acceptance of support, warranty, indemnity,
169 | * or other liability obligations and/or rights consistent with this
170 | * License. However, in accepting such obligations, You may act only
171 | * on Your own behalf and on Your sole responsibility, not on behalf
172 | * of any other Contributor, and only if You agree to indemnify,
173 | * defend, and hold each Contributor harmless for any liability
174 | * incurred by, or claims asserted against, such Contributor by reason
175 | * of your accepting any such warranty or additional liability.
176 | *
177 | * END OF TERMS AND CONDITIONS
178 | *
179 | * APPENDIX: How to apply the Apache License to your work.
180 | *
181 | * To apply the Apache License to your work, attach the following
182 | * boilerplate notice, with the fields enclosed by brackets "{}"
183 | * replaced with your own identifying information. (Don't include
184 | * the brackets!) The text should be enclosed in the appropriate
185 | * comment syntax for the file format. We also recommend that a
186 | * file or class name and description of purpose be included on the
187 | * same "printed page" as the copyright notice for easier
188 | * identification within third-party archives.
189 | *
190 | * Copyright {yyyy} {name of copyright owner}
191 | *
192 | * Licensed under the Apache License, Version 2.0 (the "License");
193 | * you may not use this file except in compliance with the License.
194 | * You may obtain a copy of the License at
195 | *
196 | * http://www.apache.org/licenses/LICENSE-2.0
197 | *
198 | * Unless required by applicable law or agreed to in writing, software
199 | * distributed under the License is distributed on an "AS IS" BASIS,
200 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | * See the License for the specific language governing permissions and
202 | * limitations under the License.
203 | */
204 |
205 | package net.dubboclub.reloud.cluster.synchronizer;
206 |
207 | /**
208 | * @date: 2016/1/22.
209 | * @author:bieber.
210 | * @project:reloud.
211 | * @package:net.dubboclub.reloud.cluster.
212 | * @version:1.0.0
213 | * @fix:
214 | * @description: 和注册中心同步器
215 | */
216 | public abstract class Synchronizer {
217 |
218 | //没有在刷新当前分片的节点
219 | protected volatile boolean notRefreshing=false;
220 | //没有有正在使用的
221 | protected volatile boolean notUsing=true;
222 |
223 | protected final void checkUsing(){
224 | while(!notUsing){
225 | try {
226 | this.wait(100);
227 | } catch (InterruptedException e) {
228 | //do nothing
229 | }
230 | }
231 | }
232 |
233 | protected final void checkRefreshing(){
234 | while(!notRefreshing){
235 | try {
236 | this.wait(100);
237 | } catch (InterruptedException e) {
238 | //do nothing
239 | }
240 | }
241 | }
242 |
243 | protected final T using(UsingHandler handler){
244 | checkRefreshing();
245 | notUsing=false;
246 | try{
247 | return handler.using();
248 | }finally {
249 | notUsing=true;
250 | }
251 | }
252 |
253 | protected final void refreshing(RefreshingHandler handler){
254 | notRefreshing=false;
255 | checkUsing();
256 | try{
257 | handler.refreshing();
258 | }finally {
259 | notRefreshing=true;
260 | }
261 | }
262 |
263 | }
264 |
--------------------------------------------------------------------------------