From 425f4c019aa53c9e519b98e6b31799f30b2bc3d6 Mon Sep 17 00:00:00 2001
From: Eric Hettiaratchi <35978114+Braavos96@users.noreply.github.com>
Date: Tue, 23 Jul 2019 11:51:13 +0100
Subject: [PATCH 01/22] Add unit tests for common.GroupKey and utils.MD5
Fully-qualified classname
com.alibaba.nacos.client.config.common.GroupKey
com.alibaba.nacos.client.config.utils.MD5
These tests were written using Diffblue Cover.
---
.../client/config/common/GroupKeyTest.java | 67 +++++++++++++++++
.../nacos/client/config/utils/MD5Test.java | 71 +++++++++++++++++++
2 files changed, 138 insertions(+)
create mode 100644 client/src/test/java/com/alibaba/nacos/client/config/common/GroupKeyTest.java
create mode 100644 client/src/test/java/com/alibaba/nacos/client/config/utils/MD5Test.java
diff --git a/client/src/test/java/com/alibaba/nacos/client/config/common/GroupKeyTest.java b/client/src/test/java/com/alibaba/nacos/client/config/common/GroupKeyTest.java
new file mode 100644
index 000000000..98d3009cf
--- /dev/null
+++ b/client/src/test/java/com/alibaba/nacos/client/config/common/GroupKeyTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999-2019 Alibaba Group Holding Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.nacos.client.config.common;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class GroupKeyTest {
+
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testGetKey() {
+ Assert.assertEquals("1+foo", GroupKey.getKey("1", "foo"));
+ Assert.assertEquals("1+foo+bar", GroupKey.getKey("1", "foo", "bar"));
+ Assert.assertEquals("1+f%2Boo+b%25ar",
+ GroupKey.getKey("1", "f+oo", "b%ar"));
+ }
+
+ @Test
+ public void testGetKeyTenant() {
+ Assert.assertEquals("1+foo+bar",
+ GroupKey.getKeyTenant("1", "foo", "bar"));
+ }
+
+ @Test
+ public void testParseKey() {
+ Assert.assertArrayEquals(new String[]{null, "f+oo", null},
+ GroupKey.parseKey("f%2Boo"));
+ Assert.assertArrayEquals(new String[]{null, "f%oo", null},
+ GroupKey.parseKey("f%25oo"));
+ }
+
+ @Test
+ public void testParseKeyIllegalArgumentException1() {
+ thrown.expect(IllegalArgumentException.class);
+ GroupKey.parseKey("");
+ }
+
+ @Test
+ public void testParseKeyIllegalArgumentException2() {
+ thrown.expect(IllegalArgumentException.class);
+ GroupKey.parseKey("f%oo");
+ }
+
+ @Test
+ public void testParseKeyIllegalArgumentException3() {
+ thrown.expect(IllegalArgumentException.class);
+ GroupKey.parseKey("f+o+o+bar");
+ }
+}
diff --git a/client/src/test/java/com/alibaba/nacos/client/config/utils/MD5Test.java b/client/src/test/java/com/alibaba/nacos/client/config/utils/MD5Test.java
new file mode 100644
index 000000000..21ca3b98e
--- /dev/null
+++ b/client/src/test/java/com/alibaba/nacos/client/config/utils/MD5Test.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 1999-2019 Alibaba Group Holding Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.nacos.client.config.utils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MD5Test {
+
+ @Test
+ public void testGetMD5String() {
+ Assert.assertEquals("d41d8cd98f00b204e9800998ecf8427e",
+ MD5.getInstance().getMD5String(""));
+ Assert.assertEquals("acbd18db4cc2f85cedef654fccc4a4d8",
+ MD5.getInstance().getMD5String("foo"));
+
+ Assert.assertEquals("d41d8cd98f00b204e9800998ecf8427e",
+ MD5.getInstance().getMD5String(new byte[0]));
+ Assert.assertEquals("5289df737df57326fcdd22597afb1fac",
+ MD5.getInstance().getMD5String(new byte[]{1, 2, 3}));
+ }
+
+ @Test
+ public void testGetMD5Bytes() {
+ byte[] bytes1 = new byte[]{-44, 29, -116, -39, -113, 0, -78,
+ 4, -23, -128, 9, -104, -20, -8, 66, 126};
+ byte[] bytes2 = new byte[]{82, -119, -33, 115, 125, -11, 115,
+ 38, -4, -35, 34, 89, 122, -5, 31, -84};
+
+ Assert.assertArrayEquals(bytes1,
+ MD5.getInstance().getMD5Bytes(new byte[0]));
+ Assert.assertArrayEquals(bytes2,
+ MD5.getInstance().getMD5Bytes(new byte[]{1, 2, 3}));
+ }
+
+ @Test
+ public void testHash() {
+ byte[] bytes1 = new byte[]{-44, 29, -116, -39, -113, 0, -78,
+ 4, -23, -128, 9, -104, -20, -8, 66, 126};
+ byte[] bytes2 = new byte[]{-84, -67, 24, -37, 76, -62, -8, 92,
+ -19, -17, 101, 79, -52, -60, -92, -40};
+ byte[] bytes3 = new byte[]{82, -119, -33, 115, 125, -11, 115,
+ 38, -4, -35, 34, 89, 122, -5, 31, -84};
+
+ Assert.assertArrayEquals(bytes1, MD5.getInstance().hash(""));
+ Assert.assertArrayEquals(bytes2, MD5.getInstance().hash("foo"));
+ Assert.assertArrayEquals(bytes1, MD5.getInstance().hash(new byte[0]));
+ Assert.assertArrayEquals(bytes3,
+ MD5.getInstance().hash(new byte[]{1, 2, 3}));
+ }
+
+ @Test
+ public void testBytes2string() {
+ Assert.assertEquals("", MD5.getInstance().bytes2string(new byte[0]));
+ Assert.assertEquals("010203",
+ MD5.getInstance().bytes2string(new byte[]{1, 2, 3}));
+ }
+}
From 74694ede6e1a66ca41b53212da99e696e5ebc78f Mon Sep 17 00:00:00 2001
From: keran <213539@qq.com>
Date: Tue, 30 Jul 2019 13:56:12 +0800
Subject: [PATCH 02/22] =?UTF-8?q?=E4=BF=AE=E5=A4=8D#1583?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../static/console-fe/src/locales/en-US.js | 2 +
.../static/console-fe/src/locales/zh-CN.js | 2 +
.../ConfigurationManagement.js | 41 +++++++++----------
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/console/src/main/resources/static/console-fe/src/locales/en-US.js b/console/src/main/resources/static/console-fe/src/locales/en-US.js
index acc8e2982..a4094c9ed 100644
--- a/console/src/main/resources/static/console-fe/src/locales/en-US.js
+++ b/console/src/main/resources/static/console-fe/src/locales/en-US.js
@@ -291,6 +291,8 @@ const I18N_CONF = {
target: 'Target:',
selectNamespace: 'Select Namespace',
selectedEntry: '| Selected Entry',
+ cloneSelectedAlertTitle: 'Clone config',
+ cloneSelectedAlertContent: 'please select the configuration to clone',
},
NewConfig: {
newListingMain: 'Create Configuration',
diff --git a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
index df9bf0e09..f82313fab 100644
--- a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
+++ b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
@@ -289,6 +289,8 @@ const I18N_CONF = {
target: '目标空间:',
selectNamespace: '请选择命名空间',
selectedEntry: '| 选中的条目',
+ cloneSelectedAlertTitle: '配置克隆',
+ cloneSelectedAlertContent: '请选择要克隆的配置',
},
NewConfig: {
newListingMain: '新建配置',
diff --git a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js
index fb3f245cc..8eefaf87b 100644
--- a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js
+++ b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js
@@ -100,6 +100,10 @@ class ConfigurationManagement extends React.Component {
contentList: [],
isAdvancedQuery: false,
isCheckAll: false,
+ rowSelection: {
+ onChange: this.configDataTableOnChange.bind(this),
+ selectedRowKeys: [],
+ },
};
const obj = {
dataId: this.dataId || '',
@@ -250,6 +254,10 @@ class ConfigurationManagement extends React.Component {
});
}
this.getData();
+ configsTableSelected.clear();
+ const { rowSelection } = this.state;
+ rowSelection.selectedRowKeys = [];
+ this.setState({ rowSelection });
}
getData(pageNo = 1, clearSelect = true) {
@@ -704,8 +712,8 @@ class ConfigurationManagement extends React.Component {
self.field.setValue('cloneTargetSpace', undefined);
if (configsTableSelected.size === 0) {
Dialog.alert({
- title: locale.exportSelectedAlertTitle,
- content: locale.exportSelectedAlertContent,
+ title: locale.cloneSelectedAlertTitle,
+ content: locale.cloneSelectedAlertContent,
});
return;
}
@@ -1024,22 +1032,14 @@ class ConfigurationManagement extends React.Component {
});
}
- configsTableOnSelect(selected, record, records) {
- if (selected) {
- configsTableSelected.set(record.id, record);
- } else {
- configsTableSelected.delete(record.id);
- }
- }
-
- configsTableOnSelectAll(selected, records) {
- if (selected) {
- records.forEach((record, i) => {
- configsTableSelected.set(record.id, record);
- });
- } else {
- configsTableSelected.clear();
- }
+ configDataTableOnChange(ids, records) {
+ const { rowSelection } = this.state;
+ rowSelection.selectedRowKeys = ids;
+ this.setState({ rowSelection });
+ configsTableSelected.clear();
+ ids.forEach((id, i) => {
+ configsTableSelected.set(id, id);
+ });
}
render() {
@@ -1239,10 +1239,7 @@ class ConfigurationManagement extends React.Component {
fixedHeader
maxBodyHeight={400}
ref={'dataTable'}
- rowSelection={{
- onSelect: this.configsTableOnSelect,
- onSelectAll: this.configsTableOnSelectAll,
- }}
+ rowSelection={this.state.rowSelection}
>
From 934c4238c13ef413e815214a1a91c3d267d4e504 Mon Sep 17 00:00:00 2001
From: Thomas Perkins
Date: Tue, 6 Aug 2019 17:15:01 +0100
Subject: [PATCH 03/22] Add unit tests for
com.alibaba.nacos.config.server.utils.GroupKey
These tests were written using Diffblue Cover
---
.../config/server/utils/GroupKeyTest.java | 122 ++++++++++++++++++
1 file changed, 122 insertions(+)
diff --git a/config/src/test/java/com/alibaba/nacos/config/server/utils/GroupKeyTest.java b/config/src/test/java/com/alibaba/nacos/config/server/utils/GroupKeyTest.java
index 56077cc2e..2b8e3b65d 100644
--- a/config/src/test/java/com/alibaba/nacos/config/server/utils/GroupKeyTest.java
+++ b/config/src/test/java/com/alibaba/nacos/config/server/utils/GroupKeyTest.java
@@ -16,7 +16,9 @@
package com.alibaba.nacos.config.server.utils;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@@ -25,6 +27,8 @@ import org.springframework.test.context.web.WebAppConfiguration;
@WebAppConfiguration
public class GroupKeyTest {
+ @Rule public final ExpectedException thrown = ExpectedException.none();
+
@Test
public void test_parseGroupKey_非法的() {
String key = "11111+222+333333+444";
@@ -64,4 +68,122 @@ public class GroupKeyTest {
Assert.assertEquals("11111%", pair[0]);
Assert.assertEquals("222", pair[1]);
}
+
+ @Test
+ public void getKey_ThreeParams() {
+
+ // Act
+ final String actual = GroupKey.getKey(",", ",", "3");
+
+ // Assert result
+ Assert.assertEquals(",+,+3", actual);
+ }
+
+ @Test
+ public void getKey_TwoParams() {
+
+ // Act
+ final String actual = GroupKey.getKey("3", "\'");
+
+ // Assert result
+ Assert.assertEquals("3+\'", actual);
+ }
+
+ @Test
+ public void getKeyTenant_Plus_ThreeParams() {
+
+ // Act
+ final String actual = GroupKey.getKeyTenant("3", "1", ",");
+
+ // Assert result
+ Assert.assertEquals("3+1+,", actual);
+ }
+
+ @Test
+ public void getKeyTenant_Percent_ThreeParams() {
+
+ // Act
+ final String actual = GroupKey.getKeyTenant("\u0000\u0000", "%+", null);
+
+ // Assert result
+ Assert.assertEquals("\u0000\u0000+%25%2B", actual);
+ }
+
+ @Test
+ public void parseKey_SingleCharacter() {
+
+ // Act
+ final String[] actual = GroupKey.parseKey("/");
+
+ // Assert result
+ Assert.assertArrayEquals(new String[] {null, "/", null}, actual);
+ }
+
+ @Test
+ public void parseKey_Plus_IllegalArgumentException() {
+
+ // Act
+ thrown.expect(IllegalArgumentException.class);
+ GroupKey.parseKey("+");
+
+ // Method is not expected to return due to exception thrown
+ }
+
+ @Test
+ public void parseKey_Percent_IllegalArgumentException() {
+
+ // Act
+ thrown.expect(IllegalArgumentException.class);
+ GroupKey.parseKey("%%%5\u0000??????????????");
+
+ // Method is not expected to return due to exception thrown
+ }
+
+ @Test
+ public void parseKey_Invalid_StringIndexOutOfBoundsException() {
+
+ // Act
+ thrown.expect(StringIndexOutOfBoundsException.class);
+ GroupKey.parseKey("++%");
+
+ // Method is not expected to return due to exception thrown
+ }
+
+ @Test
+ public void urlEncode_Plus() {
+
+ // Arrange
+ final StringBuilder sb = new StringBuilder("????");
+
+ // Act
+ GroupKey.urlEncode("+", sb);
+
+ // Assert side effects
+ Assert.assertNotNull(sb);
+ Assert.assertEquals("????%2B", sb.toString());
+ }
+
+ @Test
+ public void urlEncode_Percent() {
+
+ // Arrange
+ final StringBuilder sb = new StringBuilder("??????");
+
+ // Act
+ GroupKey.urlEncode("%", sb);
+
+ // Assert side effects
+ Assert.assertNotNull(sb);
+ Assert.assertEquals("??????%25", sb.toString());
+ }
+
+ @Test
+ public void urlEncode_NullStringBuilder() {
+
+ // Act
+ thrown.expect(NullPointerException.class);
+ GroupKey.urlEncode("+", null);
+
+ // Method is not expected to return due to exception thrown
+ }
}
From 7f0bcaa5cb4992a6c60809a67de3354e615bfeb8 Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Mon, 9 Sep 2019 10:48:11 +0800
Subject: [PATCH 04/22] feature(triggerFlag): add triggerFlag for service
---
.../com/alibaba/nacos/api/naming/pojo/Service.java | 14 ++++++++++++++
.../naming/controllers/CatalogController.java | 14 ++------------
.../com/alibaba/nacos/naming/core/Service.java | 9 +++++++--
.../com/alibaba/nacos/naming/pojo/ServiceView.java | 9 +++++++++
4 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
index 7e8fe2d34..cb7a9afb5 100644
--- a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
+++ b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
@@ -34,6 +34,11 @@ public class Service {
*/
private String name;
+ /**
+ * service protect threshold trigger flag
+ */
+ private boolean triggerFlag = false;
+
/**
* protect threshold
*/
@@ -102,10 +107,19 @@ public class Service {
this.metadata.put(key, value);
}
+ public boolean isTriggerFlag() {
+ return triggerFlag;
+ }
+
+ public void setTriggerFlag(boolean triggerFlag) {
+ this.triggerFlag = triggerFlag;
+ }
+
@Override
public String toString() {
return "Service{" +
"name='" + name + '\'' +
+ "triggerFlag='" + triggerFlag + '\'' +
", protectThreshold=" + protectThreshold +
", appName='" + appName + '\'' +
", groupName='" + groupName + '\'' +
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
index 6d47e67e5..6b24b2a15 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
@@ -284,18 +284,8 @@ public class CatalogController {
serviceView.setGroupName(NamingUtils.getGroupName(service.getName()));
serviceView.setClusterCount(service.getClusterMap().size());
serviceView.setIpCount(service.allIPs().size());
-
- // FIXME should be optimized:
- int validCount = 0;
- for (Instance instance : service.allIPs()) {
- if (instance.isHealthy()) {
- validCount++;
- }
-
- }
-
- serviceView.setHealthyInstanceCount(validCount);
-
+ serviceView.setHealthyInstanceCount(service.healthyInstanceCount());
+ serviceView.setTriggerFlag(service.isTriggerFlag());
serviceJsonArray.add(serviceView);
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
index cedbaa555..76eea304d 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
@@ -172,6 +172,8 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
updateIPs(value.getInstanceList(), KeyBuilder.matchEphemeralInstanceListKey(key));
+ updateTriggerFlag();
+
recalculateChecksum();
}
@@ -191,8 +193,9 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
return healthyCount;
}
- public boolean meetProtectThreshold() {
- return (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
+ public void updateTriggerFlag() {
+ boolean triggerFlag = (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
+ setTriggerFlag(triggerFlag);
}
public void updateIPs(Collection instances, boolean ephemeral) {
@@ -422,6 +425,8 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
setMetadata(vDom.getMetadata());
+ updateTriggerFlag();
+
updateOrAddCluster(vDom.getClusterMap().values());
remvDeadClusters(this, vDom);
recalculateChecksum();
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
index 056397dc9..e35e0250b 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
@@ -27,6 +27,7 @@ public class ServiceView {
private int clusterCount;
private int ipCount;
private int healthyInstanceCount;
+ private boolean triggerFlag;
public String getName() {
return name;
@@ -68,6 +69,14 @@ public class ServiceView {
this.healthyInstanceCount = healthyInstanceCount;
}
+ public boolean isTriggerFlag() {
+ return triggerFlag;
+ }
+
+ public void setTriggerFlag(boolean triggerFlag) {
+ this.triggerFlag = triggerFlag;
+ }
+
@Override
public String toString() {
return JSON.toJSONString(this);
From 5681ca3f78862903c1915b190d90c777d8527ebf Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Mon, 9 Sep 2019 15:13:24 +0800
Subject: [PATCH 05/22] feture(triggerFlag): add frontend show triggerFlag
---
.../src/main/resources/static/console-fe/src/locales/en-US.js | 1 +
.../src/main/resources/static/console-fe/src/locales/zh-CN.js | 1 +
.../src/pages/ServiceManagement/ServiceList/ServiceList.js | 1 +
3 files changed, 3 insertions(+)
diff --git a/console/src/main/resources/static/console-fe/src/locales/en-US.js b/console/src/main/resources/static/console-fe/src/locales/en-US.js
index f1315f082..7ab529a80 100644
--- a/console/src/main/resources/static/console-fe/src/locales/en-US.js
+++ b/console/src/main/resources/static/console-fe/src/locales/en-US.js
@@ -101,6 +101,7 @@ const I18N_CONF = {
columnClusterCount: 'Cluster Count',
columnIpCount: 'Instance Count',
columnHealthyInstanceCount: 'Healthy Instance Count',
+ columnTriggerFlag: 'Trigger Flag',
operation: 'Operation',
detail: 'Details',
sampleCode: 'Code Example',
diff --git a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
index 9218da10a..c2fd5cec3 100644
--- a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
+++ b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
@@ -101,6 +101,7 @@ const I18N_CONF = {
columnClusterCount: '集群数目',
columnIpCount: '实例数',
columnHealthyInstanceCount: '健康实例数',
+ columnTriggerFlag: '触发阈值',
operation: '操作',
detail: '详情',
sampleCode: '示例代码',
diff --git a/console/src/main/resources/static/console-fe/src/pages/ServiceManagement/ServiceList/ServiceList.js b/console/src/main/resources/static/console-fe/src/pages/ServiceManagement/ServiceList/ServiceList.js
index 642130fda..73a943446 100644
--- a/console/src/main/resources/static/console-fe/src/pages/ServiceManagement/ServiceList/ServiceList.js
+++ b/console/src/main/resources/static/console-fe/src/pages/ServiceManagement/ServiceList/ServiceList.js
@@ -281,6 +281,7 @@ class ServiceList extends React.Component {
title={locale.columnHealthyInstanceCount}
dataIndex="healthyInstanceCount"
/>
+
Date: Mon, 9 Sep 2019 20:24:59 +0800
Subject: [PATCH 06/22] improve(triggerFlag): add pre check for triggerFlag
---
.../nacos/naming/controllers/CatalogController.java | 2 +-
.../main/java/com/alibaba/nacos/naming/core/Service.java | 9 +++++++++
.../java/com/alibaba/nacos/naming/pojo/ServiceView.java | 6 +++---
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
index 6b24b2a15..d051939ca 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
@@ -285,7 +285,7 @@ public class CatalogController {
serviceView.setClusterCount(service.getClusterMap().size());
serviceView.setIpCount(service.allIPs().size());
serviceView.setHealthyInstanceCount(service.healthyInstanceCount());
- serviceView.setTriggerFlag(service.isTriggerFlag());
+ serviceView.setTriggerFlag(service.isTriggerFlag()?"True":"False");
serviceJsonArray.add(serviceView);
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
index 76eea304d..f19772533 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
@@ -194,6 +194,15 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
}
public void updateTriggerFlag() {
+ if(0 == healthyInstanceCount()) {
+ setTriggerFlag(true);
+ return;
+ }
+ Float compareValue = 0.0F;
+ if(Float.floatToIntBits(compareValue) == getProtectThreshold()) {
+ setTriggerFlag(false);
+ return;
+ }
boolean triggerFlag = (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
setTriggerFlag(triggerFlag);
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
index e35e0250b..014725bff 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
@@ -27,7 +27,7 @@ public class ServiceView {
private int clusterCount;
private int ipCount;
private int healthyInstanceCount;
- private boolean triggerFlag;
+ private String triggerFlag;
public String getName() {
return name;
@@ -69,11 +69,11 @@ public class ServiceView {
this.healthyInstanceCount = healthyInstanceCount;
}
- public boolean isTriggerFlag() {
+ public String isTriggerFlag() {
return triggerFlag;
}
- public void setTriggerFlag(boolean triggerFlag) {
+ public void setTriggerFlag(String triggerFlag) {
this.triggerFlag = triggerFlag;
}
From f95215f218576f219194e6f6ba3107eb36b8c3c6 Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Mon, 9 Sep 2019 21:25:38 +0800
Subject: [PATCH 07/22] chore(triggerFlag): adjust some details
---
.../main/java/com/alibaba/nacos/naming/pojo/ServiceView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
index 014725bff..afe2e21ea 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceView.java
@@ -69,7 +69,7 @@ public class ServiceView {
this.healthyInstanceCount = healthyInstanceCount;
}
- public String isTriggerFlag() {
+ public String getTriggerFlag() {
return triggerFlag;
}
From 54ae846cb71c13799f29985119542b9721844143 Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Tue, 10 Sep 2019 15:53:26 +0800
Subject: [PATCH 08/22] improve(instanceHealth): add update logic
---
.../alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java
index 00b6bacb3..4dc4a5672 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java
@@ -88,5 +88,6 @@ public class ClientBeatProcessor implements Runnable {
}
}
}
+ service.updateTriggerFlag();
}
}
From 0f3c9f3c87d43fbb9048e3e59b66c6fefaf28fa7 Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Tue, 17 Sep 2019 19:52:12 +0800
Subject: [PATCH 09/22] improve(triggerFlag): adjust triggerFlag calculation
chance
---
.../com/alibaba/nacos/api/naming/pojo/Service.java | 14 --------------
.../naming/controllers/CatalogController.java | 2 +-
.../com/alibaba/nacos/naming/core/Service.java | 12 ++++--------
.../naming/healthcheck/ClientBeatProcessor.java | 1 -
4 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
index cb7a9afb5..7e8fe2d34 100644
--- a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
+++ b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
@@ -34,11 +34,6 @@ public class Service {
*/
private String name;
- /**
- * service protect threshold trigger flag
- */
- private boolean triggerFlag = false;
-
/**
* protect threshold
*/
@@ -107,19 +102,10 @@ public class Service {
this.metadata.put(key, value);
}
- public boolean isTriggerFlag() {
- return triggerFlag;
- }
-
- public void setTriggerFlag(boolean triggerFlag) {
- this.triggerFlag = triggerFlag;
- }
-
@Override
public String toString() {
return "Service{" +
"name='" + name + '\'' +
- "triggerFlag='" + triggerFlag + '\'' +
", protectThreshold=" + protectThreshold +
", appName='" + appName + '\'' +
", groupName='" + groupName + '\'' +
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
index d051939ca..2b552b2eb 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
@@ -285,7 +285,7 @@ public class CatalogController {
serviceView.setClusterCount(service.getClusterMap().size());
serviceView.setIpCount(service.allIPs().size());
serviceView.setHealthyInstanceCount(service.healthyInstanceCount());
- serviceView.setTriggerFlag(service.isTriggerFlag()?"True":"False");
+ serviceView.setTriggerFlag(service.triggerFlag()?"true":"false");
serviceJsonArray.add(serviceView);
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
index f19772533..2423bf7c9 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
@@ -172,8 +172,6 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
updateIPs(value.getInstanceList(), KeyBuilder.matchEphemeralInstanceListKey(key));
- updateTriggerFlag();
-
recalculateChecksum();
}
@@ -193,18 +191,16 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
return healthyCount;
}
- public void updateTriggerFlag() {
+ public boolean triggerFlag() {
if(0 == healthyInstanceCount()) {
- setTriggerFlag(true);
- return;
+ return true;
}
Float compareValue = 0.0F;
if(Float.floatToIntBits(compareValue) == getProtectThreshold()) {
- setTriggerFlag(false);
- return;
+ return false;
}
boolean triggerFlag = (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
- setTriggerFlag(triggerFlag);
+ return triggerFlag;
}
public void updateIPs(Collection instances, boolean ephemeral) {
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java
index 4dc4a5672..00b6bacb3 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java
@@ -88,6 +88,5 @@ public class ClientBeatProcessor implements Runnable {
}
}
}
- service.updateTriggerFlag();
}
}
From c0a6adc0833f8f5086b3b2013db5097d726ff640 Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Wed, 18 Sep 2019 12:04:48 +0800
Subject: [PATCH 10/22] chore(reiggerFlag): delete unused function
---
naming/src/main/java/com/alibaba/nacos/naming/core/Service.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
index 2423bf7c9..b4956b32e 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
@@ -430,8 +430,6 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
setMetadata(vDom.getMetadata());
- updateTriggerFlag();
-
updateOrAddCluster(vDom.getClusterMap().values());
remvDeadClusters(this, vDom);
recalculateChecksum();
From 5413402869f748619feffd90f88fa09eef631d00 Mon Sep 17 00:00:00 2001
From: universefeeler
Date: Thu, 19 Sep 2019 20:03:09 +0800
Subject: [PATCH 11/22] improve(triggerFlag): improve instance health flag
---
.../resources/static/console-fe/src/locales/en-US.js | 2 +-
.../resources/static/console-fe/src/locales/zh-CN.js | 2 +-
.../java/com/alibaba/nacos/naming/core/Service.java | 10 +---------
3 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/console/src/main/resources/static/console-fe/src/locales/en-US.js b/console/src/main/resources/static/console-fe/src/locales/en-US.js
index 7ab529a80..662113da5 100644
--- a/console/src/main/resources/static/console-fe/src/locales/en-US.js
+++ b/console/src/main/resources/static/console-fe/src/locales/en-US.js
@@ -101,7 +101,7 @@ const I18N_CONF = {
columnClusterCount: 'Cluster Count',
columnIpCount: 'Instance Count',
columnHealthyInstanceCount: 'Healthy Instance Count',
- columnTriggerFlag: 'Trigger Flag',
+ columnTriggerFlag: 'Trigger Protection Threshold',
operation: 'Operation',
detail: 'Details',
sampleCode: 'Code Example',
diff --git a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
index c2fd5cec3..27a061b90 100644
--- a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
+++ b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js
@@ -101,7 +101,7 @@ const I18N_CONF = {
columnClusterCount: '集群数目',
columnIpCount: '实例数',
columnHealthyInstanceCount: '健康实例数',
- columnTriggerFlag: '触发阈值',
+ columnTriggerFlag: '触发保护阈值',
operation: '操作',
detail: '详情',
sampleCode: '示例代码',
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
index b4956b32e..779a9e1f5 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
@@ -192,15 +192,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
}
public boolean triggerFlag() {
- if(0 == healthyInstanceCount()) {
- return true;
- }
- Float compareValue = 0.0F;
- if(Float.floatToIntBits(compareValue) == getProtectThreshold()) {
- return false;
- }
- boolean triggerFlag = (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
- return triggerFlag;
+ return (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
}
public void updateIPs(Collection instances, boolean ephemeral) {
From 9cf3f5747e958149495ab7fc737036725a616d76 Mon Sep 17 00:00:00 2001
From: nkorange
Date: Sat, 21 Sep 2019 15:09:19 +0800
Subject: [PATCH 12/22] Add synchronized when add/remove instance
---
.../alibaba/nacos/naming/core/ServiceManager.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java
index e0e854b80..a379a8e2b 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java
@@ -523,17 +523,22 @@ public class ServiceManager implements RecordListener {
Service service = getService(namespaceId, serviceName);
- List instanceList = addIpAddresses(service, ephemeral, ips);
+ synchronized (service) {
+ List instanceList = addIpAddresses(service, ephemeral, ips);
- Instances instances = new Instances();
- instances.setInstanceList(instanceList);
+ Instances instances = new Instances();
+ instances.setInstanceList(instanceList);
- consistencyService.put(key, instances);
+ consistencyService.put(key, instances);
+ }
}
public void removeInstance(String namespaceId, String serviceName, boolean ephemeral, Instance... ips) throws NacosException {
Service service = getService(namespaceId, serviceName);
- removeInstance(namespaceId, serviceName, ephemeral, service, ips);
+
+ synchronized (service) {
+ removeInstance(namespaceId, serviceName, ephemeral, service, ips);
+ }
}
public void removeInstance(String namespaceId, String serviceName, boolean ephemeral, Service service, Instance... ips) throws NacosException {
From 0b66b0c6fd7b04de80d41e282bf8ddbeb5ab5152 Mon Sep 17 00:00:00 2001
From: nkorange
Date: Tue, 24 Sep 2019 10:57:02 +0800
Subject: [PATCH 13/22] Update jackson version, see
https://nvd.nist.gov/vuln/detail/CVE-2019-16335
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index bc8c1c00f..a9611dd96 100644
--- a/pom.xml
+++ b/pom.xml
@@ -668,13 +668,13 @@
com.fasterxml.jackson.core
jackson-core
- 2.9.9
+ 2.9.10
com.fasterxml.jackson.core
jackson-databind
- 2.9.9
+ 2.9.10
org.codehaus.jackson
From 6b7b894a0decd53195ba125ef752bd3c167b5230 Mon Sep 17 00:00:00 2001
From: nkorange
Date: Wed, 25 Sep 2019 15:46:34 +0800
Subject: [PATCH 14/22] Fix #1874
---
.../nacos/api/exception/NacosException.java | 4 +
config/pom.xml | 4 +
.../server/controller/ConfigController.java | 2 +-
.../exception/GlobalExceptionHandler.java | 1 +
.../server/exception/NacosException.java | 93 ------------------
.../config/server/service/PersistService.java | 2 +-
.../nacos/config/server/utils/ParamUtils.java | 2 +-
.../controller/NamespaceController.java | 2 +-
.../naming/controllers/CatalogController.java | 2 +-
.../naming/controllers/ClusterController.java | 2 +-
.../naming/controllers/DistroController.java | 2 +-
.../controllers/InstanceController.java | 2 +-
.../naming/controllers/RaftController.java | 2 +-
.../naming/controllers/ServiceController.java | 2 +-
.../alibaba/nacos/naming/core/Instance.java | 2 +-
.../naming/exception/NacosException.java | 95 -------------------
.../exception/ResponseExceptionHandler.java | 5 +-
.../nacos/naming/misc/UtilsAndCommons.java | 2 +-
.../nacos/naming/selector/LabelSelector.java | 2 +-
.../controllers/ClusterControllerTest.java | 2 +-
.../naming/selector/LabelSelectorTest.java | 3 +-
21 files changed, 27 insertions(+), 206 deletions(-)
delete mode 100644 config/src/main/java/com/alibaba/nacos/config/server/exception/NacosException.java
delete mode 100644 naming/src/main/java/com/alibaba/nacos/naming/exception/NacosException.java
diff --git a/api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java b/api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java
index f9fa85814..e2eca489a 100644
--- a/api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java
+++ b/api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java
@@ -123,6 +123,10 @@ public class NacosException extends Exception {
* no right(鉴权失败)
*/
public static final int NO_RIGHT = 403;
+ /**
+ * not found
+ */
+ public static final int NOT_FOUND = 404;
/**
* conflict(写并发冲突)
*/
diff --git a/config/pom.xml b/config/pom.xml
index 68141b6b9..fe7aa30a2 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -42,6 +42,10 @@
org.springframework.boot
spring-boot-starter-web
+
+ ${project.groupId}
+ nacos-api
+
${project.groupId}
nacos-core
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java
index 668097b61..bc48d72e5 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java
@@ -16,7 +16,7 @@
package com.alibaba.nacos.config.server.controller;
import com.alibaba.nacos.config.server.constant.Constants;
-import com.alibaba.nacos.config.server.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.config.server.model.*;
import com.alibaba.nacos.config.server.result.ResultBuilder;
import com.alibaba.nacos.config.server.result.code.ResultCodeEnum;
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandler.java b/config/src/main/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandler.java
index 5982213a1..7a52a8c2d 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandler.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandler.java
@@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.config.server.exception;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.config.server.monitor.MetricsMonitor;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.CannotGetJdbcConnectionException;
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/exception/NacosException.java b/config/src/main/java/com/alibaba/nacos/config/server/exception/NacosException.java
deleted file mode 100644
index d24d95867..000000000
--- a/config/src/main/java/com/alibaba/nacos/config/server/exception/NacosException.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.alibaba.nacos.config.server.exception;
-
-/**
- * Nacos exception
- *
- * @author Nacos
- */
-public class NacosException extends Exception {
-
- /**
- * serialVersionUID
- */
- private static final long serialVersionUID = -3913902031489277776L;
-
- private int errCode;
-
- private String errMsg;
-
- public NacosException() {
- }
-
- public NacosException(int errCode, String errMsg) {
- super(errMsg);
- this.errCode = errCode;
- this.errMsg = errMsg;
- }
-
- public int getErrCode() {
- return errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrCode(int errCode) {
- this.errCode = errCode;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- @Override
- public String toString() {
- return "ErrCode:" + errCode + ",ErrMsg:" + errMsg;
- }
-
- /**
- * server error code, use http code 400 403 throw exception to user 500 502
- * 503 change ip and retry
- */
- /**
- * invalid param(参数错误)
- */
- public static final int INVALID_PARAM = 400;
- /**
- * no right(鉴权失败)
- */
- public static final int NO_RIGHT = 403;
- /**
- * conflict(写并发冲突)
- */
- public static final int CONFLICT = 409;
- /**
- * server error(server异常,如超时)
- */
- public static final int SERVER_ERROR = 500;
- /**
- * bad gateway(路由异常,如nginx后面的Server挂掉)
- */
- public static final int BAD_GATEWAY = 502;
- /**
- * over threshold(超过server端的限流阈值)
- */
- public static final int OVER_THRESHOLD = 503;
-
-}
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java
index 5fb623921..2cda8c7a1 100755
--- a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java
@@ -16,7 +16,7 @@
package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.config.server.enums.FileTypeEnum;
-import com.alibaba.nacos.config.server.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.config.server.model.*;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.MD5;
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java b/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java
index 793810ed7..6292b5854 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java
@@ -17,7 +17,7 @@ package com.alibaba.nacos.config.server.utils;
import java.util.Map;
-import com.alibaba.nacos.config.server.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import org.apache.commons.lang3.StringUtils;
diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java b/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java
index f74b38d2a..a6250e576 100644
--- a/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java
+++ b/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java
@@ -15,7 +15,7 @@
*/
package com.alibaba.nacos.console.controller;
-import com.alibaba.nacos.config.server.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.config.server.model.RestResult;
import com.alibaba.nacos.config.server.model.TenantInfo;
import com.alibaba.nacos.config.server.service.PersistService;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
index 2b552b2eb..a9533845e 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java
@@ -25,7 +25,7 @@ import com.alibaba.nacos.core.utils.WebUtils;
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.core.ServiceManager;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.healthcheck.HealthCheckTask;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.alibaba.nacos.naming.pojo.ClusterInfo;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java
index 8e2e0948c..32649ec2d 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java
@@ -24,7 +24,7 @@ import com.alibaba.nacos.core.utils.WebUtils;
import com.alibaba.nacos.naming.core.Cluster;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.core.ServiceManager;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.healthcheck.HealthCheckType;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java
index 3bf647277..a71e7eb85 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java
@@ -25,7 +25,7 @@ import com.alibaba.nacos.naming.consistency.ephemeral.distro.DataStore;
import com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl;
import com.alibaba.nacos.naming.core.Instances;
import com.alibaba.nacos.naming.core.ServiceManager;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.SwitchDomain;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java
index 4c846c33b..36881d41a 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java
@@ -26,7 +26,7 @@ import com.alibaba.nacos.naming.core.DistroMapper;
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.core.ServiceManager;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.healthcheck.RsInfo;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.SwitchDomain;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java
index c2f1443b6..be16831a5 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java
@@ -30,7 +30,7 @@ import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeer;
import com.alibaba.nacos.naming.core.Instances;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.core.ServiceManager;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.misc.NetUtils;
import com.alibaba.nacos.naming.misc.SwitchDomain;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java
index 56067b19a..d89ff2e2b 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java
@@ -25,7 +25,7 @@ import com.alibaba.nacos.api.selector.SelectorType;
import com.alibaba.nacos.core.utils.WebUtils;
import com.alibaba.nacos.naming.cluster.ServerListManager;
import com.alibaba.nacos.naming.core.*;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.alibaba.nacos.naming.pojo.Subscriber;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Instance.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Instance.java
index 1e6419e11..7b7dcb588 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Instance.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Instance.java
@@ -17,7 +17,7 @@ package com.alibaba.nacos.naming.core;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.healthcheck.HealthCheckStatus;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/exception/NacosException.java b/naming/src/main/java/com/alibaba/nacos/naming/exception/NacosException.java
deleted file mode 100644
index edc43187d..000000000
--- a/naming/src/main/java/com/alibaba/nacos/naming/exception/NacosException.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.alibaba.nacos.naming.exception;
-
-/**
- * @author nkorange
- */
-public class NacosException extends Exception {
-
- private static final long serialVersionUID = 266495151581594848L;
-
- private int errorCode;
-
- private String errorMsg;
-
- public NacosException() {
- super();
- }
-
- public NacosException(int errorCode) {
- super();
- this.errorCode = errorCode;
- }
-
- public NacosException(int errorCode, String errorMsg) {
- super(errorMsg);
- this.errorCode = errorCode;
- this.errorMsg = errorMsg;
- }
-
- public NacosException(int errorCode, String msg, Throwable cause) {
- super(msg, cause);
- this.errorCode = errorCode;
- }
-
- public NacosException(int errorCode, Throwable cause) {
- super(cause);
- this.errorCode = errorCode;
- }
-
- public int getErrorCode() {
- return errorCode;
- }
-
- public String getErrorMsg() {
- return errorMsg;
- }
-
- /**
- * server error code, use http code 400 403 throw exception to user 500 502
- * 503 change ip and retry
- */
- /**
- * invalid param
- */
- public static final int INVALID_PARAM = 400;
- /**
- * no right
- */
- public static final int NO_RIGHT = 403;
- /**
- * not found
- */
- public static final int NOT_FOUND = 404;
-
- /**
- * conflict
- */
- public static final int CONFLICT = 409;
- /**
- * server error
- */
- public static final int SERVER_ERROR = 500;
- /**
- * bad gateway
- */
- public static final int BAD_GATEWAY = 502;
- /**
- * over threshold
- */
- public static final int OVER_THRESHOLD = 503;
-}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/exception/ResponseExceptionHandler.java b/naming/src/main/java/com/alibaba/nacos/naming/exception/ResponseExceptionHandler.java
index bd9ca3501..54bc43158 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/exception/ResponseExceptionHandler.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/exception/ResponseExceptionHandler.java
@@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.naming.exception;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.misc.Loggers;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -30,8 +31,8 @@ public class ResponseExceptionHandler {
@ExceptionHandler(NacosException.class)
private ResponseEntity handleNacosException(NacosException e) {
- Loggers.SRV_LOG.error("got exception. {}", e.getErrorMsg(), e);
- return ResponseEntity.status(e.getErrorCode()).body(e.getMessage());
+ Loggers.SRV_LOG.error("got exception. {}", e.getErrMsg(), e);
+ return ResponseEntity.status(e.getErrCode()).body(e.getMessage());
}
@ExceptionHandler(IllegalArgumentException.class)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java
index 9d0ed3b5e..f381a120f 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java
@@ -22,7 +22,7 @@ import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
import com.alibaba.nacos.common.util.VersionUtils;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.healthcheck.JsonAdapter;
import com.alibaba.nacos.naming.selector.Selector;
import com.alibaba.nacos.naming.selector.SelectorJsonAdapter;
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/selector/LabelSelector.java b/naming/src/main/java/com/alibaba/nacos/naming/selector/LabelSelector.java
index 88facd35f..5a089de02 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/selector/LabelSelector.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/selector/LabelSelector.java
@@ -22,7 +22,7 @@ import com.alibaba.nacos.api.selector.SelectorType;
import com.alibaba.nacos.cmdb.service.CmdbReader;
import com.alibaba.nacos.naming.boot.SpringContext;
import com.alibaba.nacos.naming.core.Instance;
-import com.alibaba.nacos.naming.exception.NacosException;
+import com.alibaba.nacos.api.exception.NacosException;
import org.apache.commons.lang3.StringUtils;
diff --git a/naming/src/test/java/com/alibaba/nacos/naming/controllers/ClusterControllerTest.java b/naming/src/test/java/com/alibaba/nacos/naming/controllers/ClusterControllerTest.java
index bcdfac6a2..df25b3d25 100644
--- a/naming/src/test/java/com/alibaba/nacos/naming/controllers/ClusterControllerTest.java
+++ b/naming/src/test/java/com/alibaba/nacos/naming/controllers/ClusterControllerTest.java
@@ -16,10 +16,10 @@
package com.alibaba.nacos.naming.controllers;
import com.alibaba.nacos.api.common.Constants;
+import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.naming.BaseTest;
import com.alibaba.nacos.naming.core.Cluster;
import com.alibaba.nacos.naming.core.Service;
-import com.alibaba.nacos.naming.exception.NacosException;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import org.junit.Assert;
import org.junit.Before;
diff --git a/naming/src/test/java/com/alibaba/nacos/naming/selector/LabelSelectorTest.java b/naming/src/test/java/com/alibaba/nacos/naming/selector/LabelSelectorTest.java
index eb829d288..2f6437010 100644
--- a/naming/src/test/java/com/alibaba/nacos/naming/selector/LabelSelectorTest.java
+++ b/naming/src/test/java/com/alibaba/nacos/naming/selector/LabelSelectorTest.java
@@ -1,7 +1,6 @@
package com.alibaba.nacos.naming.selector;
-import com.alibaba.nacos.naming.exception.NacosException;
-
+import com.alibaba.nacos.api.exception.NacosException;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
From f0c19859cec47f8d15680ac13b9086c1696b39dc Mon Sep 17 00:00:00 2001
From: nkorange
Date: Wed, 25 Sep 2019 16:15:31 +0800
Subject: [PATCH 15/22] #1873, set default server expire timeout to 10 seconds
and configurable.
---
.../com/alibaba/nacos/naming/cluster/ServerListManager.java | 2 +-
.../java/com/alibaba/nacos/naming/misc/SwitchDomain.java | 4 ++--
.../main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java | 3 ++-
.../java/com/alibaba/nacos/naming/misc/SwitchManager.java | 5 +++++
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java b/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java
index b6624a528..7caef5ff1 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java
@@ -73,7 +73,7 @@ public class ServerListManager {
@PostConstruct
public void init() {
GlobalExecutor.registerServerListUpdater(new ServerListUpdater());
- GlobalExecutor.registerServerStatusReporter(new ServerStatusReporter(), 5000);
+ GlobalExecutor.registerServerStatusReporter(new ServerStatusReporter(), 2000);
}
private List refreshServerList() {
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java
index 162c938bd..17024eab5 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java
@@ -58,7 +58,7 @@ public class SwitchDomain implements Record, Cloneable {
private List incrementalList = new ArrayList<>();
- private long serverStatusSynchronizationPeriodMillis = TimeUnit.SECONDS.toMillis(15);
+ private long serverStatusSynchronizationPeriodMillis = TimeUnit.SECONDS.toMillis(2);
private long serviceStatusSynchronizationPeriodMillis = TimeUnit.SECONDS.toMillis(5);
@@ -71,7 +71,7 @@ public class SwitchDomain implements Record, Cloneable {
/**
* The server is regarded as expired if its two reporting interval is lagger than this variable.
*/
- private long distroServerExpiredMillis = TimeUnit.SECONDS.toMillis(30);
+ private long distroServerExpiredMillis = TimeUnit.SECONDS.toMillis(10);
/**
* since which version, push can be enabled
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java
index f48a44f8a..55299e1c5 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java
@@ -46,7 +46,7 @@ public class SwitchEntry {
public static final int MIN_PUSH_CACHE_TIME_MIILIS = 10000;
public static final int MIN_CACHE_TIME_MIILIS = 1000;
public static final int MIN_SERVICE_SYNC_TIME_MIILIS = 5000;
- public static final int MIN_SERVER_SYNC_TIME_MIILIS = 15000;
+ public static final int MIN_SERVER_SYNC_TIME_MIILIS = 1000;
public static final String ACTION_ADD = "add";
public static final String ACTION_REPLACE = "replace";
@@ -60,4 +60,5 @@ public class SwitchEntry {
public static final String OVERRIDDEN_SERVER_STATUS = "overriddenServerStatus";
public static final String DEFAULT_INSTANCE_EPHEMERAL = "defaultInstanceEphemeral";
+ public static final String DISTRO_SERVER_EXPIRED_MILLIS = "distroServerExpiredMillis";
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java
index e34192c56..65823b51b 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java
@@ -267,6 +267,11 @@ public class SwitchManager implements RecordListener {
switchDomain.setDefaultInstanceEphemeral(Boolean.parseBoolean(defaultEphemeral));
}
+ if (entry.equals(SwitchEntry.DISTRO_SERVER_EXPIRED_MILLIS)) {
+ String distroServerExpiredMillis = value;
+ switchDomain.setDistroServerExpiredMillis(Long.parseLong(distroServerExpiredMillis));
+ }
+
if (debug) {
update(switchDomain);
} else {
From 71ce4dad4d2907f68651fe7a50b0254b79b29826 Mon Sep 17 00:00:00 2001
From: freekry
Date: Fri, 30 Aug 2019 14:50:06 +0800
Subject: [PATCH 16/22] fix bug #1775
fix bug #1775
---
.../src/pages/ConfigurationManagement/NewConfig/NewConfig.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/NewConfig/NewConfig.js b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/NewConfig/NewConfig.js
index 12836ad87..1a1cf0f5b 100644
--- a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/NewConfig/NewConfig.js
+++ b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/NewConfig/NewConfig.js
@@ -414,7 +414,7 @@ class NewConfig extends React.Component {
label: 'YAML',
},
{
- value: 'text/html',
+ value: 'html',
label: 'HTML',
},
{
From 4f85dc0df3e08663519879cbb9875b9adb1819a1 Mon Sep 17 00:00:00 2001
From: LoadChange
Date: Wed, 25 Sep 2019 20:23:09 +0800
Subject: [PATCH 17/22] build fe
---
console/src/main/resources/static/js/main.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/console/src/main/resources/static/js/main.js b/console/src/main/resources/static/js/main.js
index b38e4016c..0d24bec1f 100644
--- a/console/src/main/resources/static/js/main.js
+++ b/console/src/main/resources/static/js/main.js
@@ -47,12 +47,12 @@
*
* Date: 2019-04-08
*/
-function(n){function d(e,t,n){var a="0x"+t-65536;return a!=a||n?t:a<0?String.fromCharCode(65536+a):String.fromCharCode(a>>10|55296,1023&a|56320)}function o(){w()}var e,f,b,r,i,h,p,m,M,l,u,w,k,s,S,g,c,y,_,T="sizzle"+1*new Date,v=n.document,C=0,a=0,x=le(),E=le(),L=le(),D=le(),N=function(e,t){return e===t&&(u=!0),0},O={}.hasOwnProperty,t=[],Y=t.pop,P=t.push,j=t.push,I=t.slice,A=function(e,t){for(var n=0,a=e.length;n+~]|"+H+")"+H+"*"),q=new RegExp(H+"|>"),G=new RegExp(W),J=new RegExp("^"+F+"$"),$={ID:new RegExp("^#("+F+")"),CLASS:new RegExp("^\\.("+F+")"),TAG:new RegExp("^("+F+"|[*])"),ATTR:new RegExp("^"+z),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+H+"*(even|odd|(([+-]|)(\\d*)n|)"+H+"*(?:([+-]|)"+H+"*(\\d+)|))"+H+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+H+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+H+"*((?:-\\d)?\\d*)"+H+"*\\)|)(?=[^-]|$)","i")},Q=/HTML$/i,X=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,ee=/^[^{]+\{\s*\[native \w/,te=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ne=/[+~]/,ae=new RegExp("\\\\([\\da-f]{1,6}"+H+"?|("+H+")|.)","ig"),oe=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,re=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},ie=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{j.apply(t=I.call(v.childNodes),v.childNodes),t[v.childNodes.length].nodeType}catch(e){j={apply:t.length?function(e,t){P.apply(e,I.call(t))}:function(e,t){for(var n=e.length,a=0;e[n++]=t[a++];);e.length=n-1}}}function se(t,e,n,a){var o,r,i,s,l,u,c,d=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!a&&((e?e.ownerDocument||e:v)!==k&&w(e),e=e||k,S)){if(11!==p&&(l=te.exec(t)))if(o=l[1]){if(9===p){if(!(i=e.getElementById(o)))return n;if(i.id===o)return n.push(i),n}else if(d&&(i=d.getElementById(o))&&_(e,i)&&i.id===o)return n.push(i),n}else{if(l[2])return j.apply(n,e.getElementsByTagName(t)),n;if((o=l[3])&&f.getElementsByClassName&&e.getElementsByClassName)return j.apply(n,e.getElementsByClassName(o)),n}if(f.qsa&&!D[t+" "]&&(!g||!g.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,d=e,1===p&&q.test(t)){for((s=e.getAttribute("id"))?s=s.replace(oe,re):e.setAttribute("id",s=T),r=(u=h(t)).length;r--;)u[r]="#"+s+" "+ve(u[r]);c=u.join(","),d=ne.test(t)&&ye(e.parentNode)||e}try{return j.apply(n,d.querySelectorAll(c)),n}catch(e){D(t,!0)}finally{s===T&&e.removeAttribute("id")}}}return m(t.replace(V,"$1"),e,n,a)}function le(){var a=[];return function e(t,n){return a.push(t+" ")>b.cacheLength&&delete e[a.shift()],e[t+" "]=n}}function ue(e){return e[T]=!0,e}function ce(e){var t=k.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function de(e,t){for(var n=e.split("|"),a=n.length;a--;)b.attrHandle[n[a]]=t}function pe(e,t){var n=t&&e,a=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(a)return a;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function fe(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function me(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ie(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ge(i){return ue(function(r){return r=+r,ue(function(e,t){for(var n,a=i([],e.length,r),o=a.length;o--;)e[n=a[o]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&void 0!==e.getElementsByTagName&&e}for(e in f=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Q.test(t||n&&n.nodeName||"HTML")},w=se.setDocument=function(e){var t,n,a=e?e.ownerDocument||e:v;return a!==k&&9===a.nodeType&&a.documentElement&&(s=(k=a).documentElement,S=!i(k),v!==k&&(n=k.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",o,!1):n.attachEvent&&n.attachEvent("onunload",o)),f.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),f.getElementsByTagName=ce(function(e){return e.appendChild(k.createComment("")),!e.getElementsByTagName("*").length}),f.getElementsByClassName=ee.test(k.getElementsByClassName),f.getById=ce(function(e){return s.appendChild(e).id=T,!k.getElementsByName||!k.getElementsByName(T).length}),f.getById?(b.filter.ID=function(e){var t=e.replace(ae,d);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if(void 0!==t.getElementById&&S){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(ae,d);return function(e){var t=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if(void 0!==t.getElementById&&S){var n,a,o,r=t.getElementById(e);if(r){if((n=r.getAttributeNode("id"))&&n.value===e)return[r];for(o=t.getElementsByName(e),a=0;r=o[a++];)if((n=r.getAttributeNode("id"))&&n.value===e)return[r]}return[]}}),b.find.TAG=f.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):f.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,a=[],o=0,r=t.getElementsByTagName(e);if("*"!==e)return r;for(;n=r[o++];)1===n.nodeType&&a.push(n);return a},b.find.CLASS=f.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&S)return t.getElementsByClassName(e)},c=[],g=[],(f.qsa=ee.test(k.querySelectorAll))&&(ce(function(e){s.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&g.push("[*^$]="+H+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||g.push("\\["+H+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+T+"-]").length||g.push("~="),e.querySelectorAll(":checked").length||g.push(":checked"),e.querySelectorAll("a#"+T+"+*").length||g.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=k.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&g.push("name"+H+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&g.push(":enabled",":disabled"),s.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(f.matchesSelector=ee.test(y=s.matches||s.webkitMatchesSelector||s.mozMatchesSelector||s.oMatchesSelector||s.msMatchesSelector))&&ce(function(e){f.disconnectedMatch=y.call(e,"*"),y.call(e,"[s!='']:x"),c.push("!=",W)}),g=g.length&&new RegExp(g.join("|")),c=c.length&&new RegExp(c.join("|")),t=ee.test(s.compareDocumentPosition),_=t||ee.test(s.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,a=t&&t.parentNode;return e===a||!(!a||1!==a.nodeType||!(n.contains?n.contains(a):e.compareDocumentPosition&&16&e.compareDocumentPosition(a)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},N=t?function(e,t){if(e===t)return u=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!f.sortDetached&&t.compareDocumentPosition(e)===n?e===k||e.ownerDocument===v&&_(v,e)?-1:t===k||t.ownerDocument===v&&_(v,t)?1:l?A(l,e)-A(l,t):0:4&n?-1:1)}:function(e,t){if(e===t)return u=!0,0;var n,a=0,o=e.parentNode,r=t.parentNode,i=[e],s=[t];if(!o||!r)return e===k?-1:t===k?1:o?-1:r?1:l?A(l,e)-A(l,t):0;if(o===r)return pe(e,t);for(n=e;n=n.parentNode;)i.unshift(n);for(n=t;n=n.parentNode;)s.unshift(n);for(;i[a]===s[a];)a++;return a?pe(i[a],s[a]):i[a]===v?-1:s[a]===v?1:0}),k},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==k&&w(e),f.matchesSelector&&S&&!D[t+" "]&&(!c||!c.test(t))&&(!g||!g.test(t)))try{var n=y.call(e,t);if(n||f.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){D(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(ae,d),e[3]=(e[3]||e[4]||e[5]||"").replace(ae,d),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return $.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&G.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(ae,d).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=x[e+" "];return t||(t=new RegExp("(^|"+H+")"+e+"("+H+"|$)"))&&x(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,a,o){return function(e){var t=se.attr(e,n);return null==t?"!="===a:!a||(t+="","="===a?t===o:"!="===a?t!==o:"^="===a?o&&0===t.indexOf(o):"*="===a?o&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function L(e,n,a){return v(n)?T.grep(e,function(e,t){return!!n.call(e,t,e)!==a}):n.nodeType?T.grep(e,function(e){return e===n!==a}):"string"!=typeof n?T.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(T.fn.init=function(e,t,n){var a,o;if(!e)return this;if(n=n||D,"string"!=typeof e)return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(T):T.makeArray(e,this);if(!(a="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:N.exec(e))||!a[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(a[1]){if(t=t instanceof T?t[0]:t,T.merge(this,T.parseHTML(a[1],t&&t.nodeType?t.ownerDocument||t:S,!0)),E.test(a[1])&&T.isPlainObject(t))for(a in t)v(this[a])?this[a](t[a]):this.attr(a,t[a]);return this}return(o=S.getElementById(a[2]))&&(this[0]=o,this.length=1),this}).prototype=T.fn,D=T(S);var O=/^(?:parents|prev(?:Until|All))/,Y={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}T.fn.extend({has:function(e){var t=T(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,fe=/^$|^module$|\/(?:java|ecma)script/i,he={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};function me(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&x(e,t)?T.merge([e],n):n}function ge(e,t){for(var n=0,a=e.length;nx",_.noCloneChecked=!!ye.cloneNode(!0).lastChild.defaultValue;var Me=/^key/,we=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ke=/^([^.]*)(?:\.(.+)|)/;function Se(){return!0}function Te(){return!1}function Ce(e,t){return e===function(){try{return S.activeElement}catch(e){}}()==("focus"===t)}function xe(e,t,n,a,o,r){var i,s;if("object"==typeof t){for(s in"string"!=typeof n&&(a=a||n,n=void 0),t)xe(e,s,n,a,t[s],r);return e}if(null==a&&null==o?(o=n,a=n=void 0):null==o&&("string"==typeof n?(o=a,a=void 0):(o=a,a=n,n=void 0)),!1===o)o=Te;else if(!o)return e;return 1===r&&(i=o,(o=function(e){return T().off(e),i.apply(this,arguments)}).guid=i.guid||(i.guid=T.guid++)),e.each(function(){T.event.add(this,t,o,a,n)})}function Ee(e,o,r){r?(J.set(e,o,!1),T.event.add(e,o,{namespace:!1,handler:function(e){var t,n,a=J.get(this,o);if(1&e.isTrigger&&this[o]){if(a.length)(T.event.special[o]||{}).delegateType&&e.stopPropagation();else if(a=s.call(arguments),J.set(this,o,a),t=r(this,o),this[o](),a!==(n=J.get(this,o))||t?J.set(this,o,!1):n={},a!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else a.length&&(J.set(this,o,{value:T.event.trigger(T.extend(a[0],T.Event.prototype),a.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===J.get(e,o)&&T.event.add(e,o,Se)}T.event={global:{},add:function(t,e,n,a,o){var r,i,s,l,u,c,d,p,f,h,m,g=J.get(t);if(g)for(n.handler&&(n=(r=n).handler,o=r.selector),o&&T.find.matchesSelector(ae,o),n.guid||(n.guid=T.guid++),(l=g.events)||(l=g.events={}),(i=g.handle)||(i=g.handle=function(e){return void 0!==T&&T.event.triggered!==e.type?T.event.dispatch.apply(t,arguments):void 0}),u=(e=(e||"").match(j)||[""]).length;u--;)f=m=(s=ke.exec(e[u])||[])[1],h=(s[2]||"").split(".").sort(),f&&(d=T.event.special[f]||{},f=(o?d.delegateType:d.bindType)||f,d=T.event.special[f]||{},c=T.extend({type:f,origType:m,data:a,handler:n,guid:n.guid,selector:o,needsContext:o&&T.expr.match.needsContext.test(o),namespace:h.join(".")},r),(p=l[f])||((p=l[f]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(t,a,h,i)||t.addEventListener&&t.addEventListener(f,i)),d.add&&(d.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),o?p.splice(p.delegateCount++,0,c):p.push(c),T.event.global[f]=!0)},remove:function(e,t,n,a,o){var r,i,s,l,u,c,d,p,f,h,m,g=J.hasData(e)&&J.get(e);if(g&&(l=g.events)){for(u=(t=(t||"").match(j)||[""]).length;u--;)if(f=m=(s=ke.exec(t[u])||[])[1],h=(s[2]||"").split(".").sort(),f){for(d=T.event.special[f]||{},p=l[f=(a?d.delegateType:d.bindType)||f]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=r=p.length;r--;)c=p[r],!o&&m!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||a&&a!==c.selector&&("**"!==a||!c.selector)||(p.splice(r,1),c.selector&&p.delegateCount--,d.remove&&d.remove.call(e,c));i&&!p.length&&(d.teardown&&!1!==d.teardown.call(e,h,g.handle)||T.removeEvent(e,f,g.handle),delete l[f])}else for(f in l)T.event.remove(e,f+t[u],n,a,!0);T.isEmptyObject(l)&&J.remove(e,"handle events")}},dispatch:function(e){var t,n,a,o,r,i,s=T.event.fix(e),l=new Array(arguments.length),u=(J.get(this,"events")||{})[s.type]||[],c=T.event.special[s.type]||{};for(l[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,De=/