Skip to content

Commit

Permalink
Fix mac aarch compilation (#1303)
Browse files Browse the repository at this point in the history
* Add historic contributors

Add histoic contributors, should thank them for their contribution.

* Fix compatible problem with mac chips.

Fix #1302

* Update nacos-test, nacos, sofa-registry version.

* Fix test case

* Fix test case

* Update version

* Delete comment out code.

* Update pom

---------

Co-authored-by: liujianjun.ljj <[email protected]>
Co-authored-by: 鲁直 <[email protected]>
  • Loading branch information
3 people authored Aug 7, 2023
1 parent 8ca4f28 commit 199be55
Show file tree
Hide file tree
Showing 19 changed files with 475 additions and 443 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ logs/

#protobuf
example/build/*
test/test-integration/build/*
test/test-integration/build/*

registry/registry-polaris/polaris/
6 changes: 3 additions & 3 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@
<netty.version>4.1.44.Final</netty.version>
<hessian.version>3.4.0</hessian.version>
<resteasy.version>3.6.3.Final</resteasy.version>
<bolt.version>1.5.10</bolt.version>
<bolt.version>1.6.6</bolt.version>
<tracer.version>3.0.8</tracer.version>
<lookout.version>1.4.1</lookout.version>
<bytebuddy.version>1.9.8</bytebuddy.version>
<sofa.registry.version>5.2.0</sofa.registry.version>
<sofa.registry.version>6.3.0</sofa.registry.version>
<bolt.swagger.version>1.6.9</bolt.swagger.version>
<asm.version>7.0</asm.version>
<httpclient.version>4.5.13</httpclient.version>
<httpcore.version>4.4.13</httpcore.version>
<grpc.version>1.33.1</grpc.version>
<grpc.version>1.53.0</grpc.version>
<guava.version>27.0-jre</guava.version>
<transmittable.version>2.12.1</transmittable.version>
</properties>
Expand Down
16 changes: 11 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<opentracing.version>0.22.0</opentracing.version>
<dubbo.version>2.6.9</dubbo.version>
<nacos.version>2.0.3</nacos.version>
<sofa.registry.version>5.2.0</sofa.registry.version>
<sofa.registry.version>6.3.0</sofa.registry.version>
<polaris.version>1.2.2</polaris.version>
<swagger.version>1.6.9</swagger.version>
<asm.version>7.0</asm.version>
Expand All @@ -33,12 +33,12 @@
<!-- serialization -->
<hessian.version>3.4.0</hessian.version>
<thrift.version>0.9.2</thrift.version>
<protobuf.version>3.16.3</protobuf.version>
<protobuf.version>3.22.0</protobuf.version>
<jackson.version>2.12.7</jackson.version>
<jackson.databind.version>2.12.7.1</jackson.databind.version>
<msgpack.version>0.6.12</msgpack.version>
<protostuff.version>1.5.9</protostuff.version>
<grpc.version>1.33.1</grpc.version>
<grpc.version>1.53.0</grpc.version>

<!--common-->
<httpcore.version>4.4.13</httpcore.version>
Expand All @@ -51,7 +51,7 @@
<!-- Test libs -->
<junit.version>4.13.1</junit.version>
<!-- alipay libs -->
<bolt.version>1.5.10</bolt.version>
<bolt.version>1.6.6</bolt.version>
<sofa.common.tools.version>1.3.2</sofa.common.tools.version>
<tracer.version>3.0.8</tracer.version>
<lookout.version>1.4.1</lookout.version>
Expand Down Expand Up @@ -514,7 +514,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.25.Final</version>
<version>2.0.59.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
<dependency>
Expand Down Expand Up @@ -557,6 +557,12 @@
<version>${prometheus.client.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>0.16.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
8 changes: 4 additions & 4 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</parent>

<properties>
<protoc.version>3.11.0</protoc.version>
<protoc-gen-grpc-java.version>1.17.0</protoc-gen-grpc-java.version>
<protoc.version>3.22.0</protoc.version>
<protoc-gen-grpc-java.version>1.53.0</protoc-gen-grpc-java.version>
<sofa.rpc.compiler.version>0.0.3</sofa.rpc.compiler.version>
<grpc.version>1.33.1</grpc.version>
<grpc.version>1.53.0</grpc.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
</properties>

Expand Down Expand Up @@ -194,7 +194,7 @@
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<outputDirectory>build/generated/source/proto/main/java</outputDirectory>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
<protoc.version>3.7.1</protoc.version>
<grpc.version>1.27.2</grpc.version>
<protoc.version>3.22.0</protoc.version>
<grpc.version>1.53.0</grpc.version>
<sofa.rpc.compiler.version>0.0.2</sofa.rpc.compiler.version>
</properties>

Expand Down
6 changes: 5 additions & 1 deletion registry/registry-nacos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
<dependency>
<groupId>name.jervyshi</groupId>
<artifactId>nacos-embedded</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void tearDown() {
}

/**
* 测试Zookeeper Provider Observer
* 测试 Nacos Provider Observer
*
* @throws Exception the exception
*/
Expand All @@ -93,21 +93,21 @@ public void testProviderObserver() throws Exception {
TimeUnit.SECONDS.sleep(10);

serverConfig = new ServerConfig()
.setProtocol("bolt")
.setHost("0.0.0.0")
.setPort(12200);
.setProtocol("bolt")
.setHost("0.0.0.0")
.setPort(12200);

ProviderConfig<?> provider = new ProviderConfig();
provider.setInterfaceId("com.alipay.xxx.NacosTestService")
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setUniqueId("nacos-test")
.setProxy("javassist")
.setRegister(true)
.setRegistry(registryConfig)
.setSerialization("hessian2")
.setServer(serverConfig)
.setWeight(222)
.setTimeout(3000);
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setUniqueId("nacos-test")
.setProxy("javassist")
.setRegister(true)
.setRegistry(registryConfig)
.setSerialization("hessian2")
.setServer(serverConfig)
.setWeight(222)
.setTimeout(3000);

// 注册
try {
Expand All @@ -120,13 +120,13 @@ public void testProviderObserver() throws Exception {

ConsumerConfig<?> consumer = new ConsumerConfig();
consumer.setInterfaceId("com.alipay.xxx.NacosTestService")
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setUniqueId("nacos-test")
.setProxy("javassist")
.setSubscribe(true)
.setSerialization("java")
.setInvokeType("sync")
.setTimeout(4444);
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setUniqueId("nacos-test")
.setProxy("javassist")
.setSubscribe(true)
.setSerialization("java")
.setInvokeType("sync")
.setTimeout(4444);

// 订阅
CountDownLatch latch = new CountDownLatch(1);
Expand All @@ -144,12 +144,12 @@ public void testProviderObserver() throws Exception {
// 订阅 错误的uniqueId
ConsumerConfig<?> consumerNoUniqueId = new ConsumerConfig();
consumerNoUniqueId.setInterfaceId("com.alipay.xxx.NacosTestService")
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setProxy("javassist")
.setSubscribe(true)
.setSerialization("java")
.setInvokeType("sync")
.setTimeout(4444);
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setProxy("javassist")
.setSubscribe(true)
.setSerialization("java")
.setInvokeType("sync")
.setTimeout(4444);
latch = new CountDownLatch(1);
MockProviderInfoListener wrongProviderInfoListener = new MockProviderInfoListener();
wrongProviderInfoListener.setCountDownLatch(latch);
Expand All @@ -174,9 +174,9 @@ public void testProviderObserver() throws Exception {
latch = new CountDownLatch(2);
providerInfoListener.setCountDownLatch(latch);
provider.getServer().add(new ServerConfig()
.setProtocol("bolt")
.setHost("0.0.0.0")
.setPort(12201));
.setProtocol("bolt")
.setHost("0.0.0.0")
.setPort(12201));
registry.register(provider);

latch.await(timeoutPerSub * 2, TimeUnit.MILLISECONDS);
Expand All @@ -189,13 +189,13 @@ public void testProviderObserver() throws Exception {
// 重复订阅
ConsumerConfig<?> consumer2 = new ConsumerConfig();
consumer2.setInterfaceId("com.alipay.xxx.NacosTestService")
.setUniqueId("nacos-test")
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setProxy("javassist")
.setSubscribe(true)
.setSerialization("java")
.setInvokeType("sync")
.setTimeout(4444);
.setUniqueId("nacos-test")
.setApplication(new ApplicationConfig().setAppName("test-server"))
.setProxy("javassist")
.setSubscribe(true)
.setSerialization("java")
.setInvokeType("sync")
.setTimeout(4444);
CountDownLatch latch2 = new CountDownLatch(1);
MockProviderInfoListener providerInfoListener2 = new MockProviderInfoListener();
providerInfoListener2.setCountDownLatch(latch2);
Expand All @@ -214,17 +214,17 @@ public void testProviderObserver() throws Exception {
// 批量反注册,判断订阅者2的数据
latch = new CountDownLatch(2);
providerInfoListener2.setCountDownLatch(latch);
List<ProviderConfig> providerConfigList = new ArrayList<ProviderConfig>();
List<ProviderConfig> providerConfigList = new ArrayList<>();
providerConfigList.add(provider);
registry.batchUnRegister(providerConfigList);

latch.await(timeoutPerSub * 2, TimeUnit.MILLISECONDS);
Assert.assertEquals("after unregister: 1", 1, ps2.size());
Assert.assertEquals("after unregister: 0", 0, ps2.size()); // 所有的 Provider 都已经反向注册了,应该是 0

LOGGER.info("after unregister consumer, and consumer2 {}", ps);

// 批量取消订阅
List<ConsumerConfig> consumerConfigList = new ArrayList<ConsumerConfig>();
List<ConsumerConfig> consumerConfigList = new ArrayList<>();
consumerConfigList.add(consumer2);
registry.batchUnSubscribe(consumerConfigList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void adAfterClass() {
@Before
public void setup() {
//see https://nacos.io/zh-cn/docs/2.0.0-compatibility.html
nacosProcess = NacosStarterBuilder.nacosStarter().withServerPort(8848).withNacosVersion("2.0.3").build()
nacosProcess = NacosStarterBuilder.nacosStarter().withServerPort(8848).withNacosVersion("2.2.3").build()
.start();
}

Expand Down
15 changes: 6 additions & 9 deletions registry/registry-sofa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>sofa-rpc-registry-sofa</artifactId>
<properties>
<sofa.registry.version>5.2.0</sofa.registry.version>
<sofa.registry.version>6.3.0</sofa.registry.version>
<argLine>-Dnetwork_interface_denylist=docker0</argLine>
</properties>
<dependencies>
Expand Down Expand Up @@ -66,21 +66,18 @@
<artifactId>log4j-jcl</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-core</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.alipay.sofa.common.profile;

/**
* @author khotyn
* @version StringUtil.java, v 0.1 2023年07月05日 14:40 khotyn
*/
public class StringUtil {
public static boolean equals(String str1, String str2) {
return str1 == null ? str2 == null : str1.equals(str2);
}

public static boolean isNotEmpty(String str) {
return str != null && str.length() > 0;
}

public static boolean isNotBlank(String str) {
int length;
if (str != null && (length = str.length()) != 0) {
for (int i = 0; i < length; ++i) {
if (!Character.isWhitespace(str.charAt(i))) {
return true;
}
}

return false;
} else {
return false;
}
}

public static boolean isBlank(String str) {
int length;
if (str != null && (length = str.length()) != 0) {
for (int i = 0; i < length; ++i) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}

return true;
} else {
return true;
}
}
}
Loading

0 comments on commit 199be55

Please sign in to comment.