Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions client/all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
</scm>

<properties>
<!-- Build args -->
<module.install.skip>true</module.install.skip>
<module.deploy.skip>true</module.deploy.skip>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -119,6 +116,16 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
21 changes: 17 additions & 4 deletions client/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<artifactId>registry-client-api</artifactId>

<properties>
<!-- Build args -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.user.dir>../../</main.user.dir>
</properties>

Expand All @@ -34,6 +30,16 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
Expand All @@ -48,6 +54,13 @@
<skip>${module.deploy.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<configuration>
<skipNexusStagingDeployMojo>${nexus.staging.deploy.mojo.skip}</skipNexusStagingDeployMojo>
</configuration>
</plugin>
</plugins>
</build>
</project>
17 changes: 17 additions & 0 deletions client/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
Expand All @@ -97,6 +107,13 @@
<skip>${module.deploy.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<configuration>
<skipNexusStagingDeployMojo>${nexus.staging.deploy.mojo.skip}</skipNexusStagingDeployMojo>
</configuration>
</plugin>
</plugins>
</build>
</project>
17 changes: 17 additions & 0 deletions client/log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
Expand All @@ -49,6 +59,13 @@
<skip>${module.deploy.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<configuration>
<skipNexusStagingDeployMojo>${nexus.staging.deploy.mojo.skip}</skipNexusStagingDeployMojo>
</configuration>
</plugin>
</plugins>
</build>
</project>
23 changes: 22 additions & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- Build args -->
<module.install.skip>true</module.install.skip>
<module.deploy.skip>true</module.deploy.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<nexus.staging.deploy.mojo.skip>true</nexus.staging.deploy.mojo.skip>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -88,6 +88,27 @@
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>${module.install.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>${module.deploy.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<configuration>
<skipNexusStagingDeployMojo>${nexus.staging.deploy.mojo.skip}</skipNexusStagingDeployMojo>
</configuration>
</plugin>
</plugins>
</build>
</project>
14 changes: 0 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,6 @@
<maven.javadoc.quiet>true</maven.javadoc.quiet>
</properties>
</profile>
<profile>
<id>ci-install</id>
<properties>
<skipTests>true</skipTests>
<maven.javadoc.skip>false</maven.javadoc.skip>
</properties>
</profile>
<profile>
<id>ci-test</id>
<properties>
<dependency.test.skip>false</dependency.test.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
</profile>
<profile>
<id>release</id>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timeout;
import io.netty.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
Expand All @@ -36,36 +34,11 @@
* @version $Id: AsyncHashedWheelTimer.java, v 0.1 2019-01-11 10:54 AM kezhu.wukz Exp $
*/
public class AsyncHashedWheelTimer extends HashedWheelTimer {

private static final Logger LOGGER = LoggerFactory
.getLogger(AsyncHashedWheelTimer.class);

/** */
public static final TaskFailedCallback DEFAULT_TASK_FAILED_CALLBACK = new TaskFailedCallback() {
@Override
public void executionRejected(Throwable e) {
LOGGER
.error(
"executionRejected: "
+ e.getMessage(),
e);
}

@Override
public void executionFailed(Throwable e) {
LOGGER
.error(
"executionFailed: "
+ e.getMessage(),
e);
}
};

/** */
private final Executor executor;
private final Executor executor;

/** */
private final TaskFailedCallback taskFailedCallback;
private final TaskFailedCallback taskFailedCallback;

/**
*
Expand All @@ -85,56 +58,6 @@ public AsyncHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, Tim
this.taskFailedCallback = taskFailedCallback;
}

/**
*
* @param threadFactory
* @param tickDuration
* @param unit
* @param ticksPerWheel
* @param asyncExecutor
*/
public AsyncHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit,
int ticksPerWheel, Executor asyncExecutor,
TaskFailedCallback taskFailedCallback) {
super(threadFactory, tickDuration, unit, ticksPerWheel);

this.executor = asyncExecutor;
this.taskFailedCallback = taskFailedCallback;
}

/**
*
* @param threadFactory
* @param tickDuration
* @param unit
* @param ticksPerWheel
* @param asyncThreadFactory
*/
public AsyncHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit,
int ticksPerWheel, ThreadFactory asyncThreadFactory) {
super(threadFactory, tickDuration, unit, ticksPerWheel);

this.executor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
new SynchronousQueue<>(), asyncThreadFactory);
this.taskFailedCallback = DEFAULT_TASK_FAILED_CALLBACK;
}

/**
*
* @param threadFactory
* @param tickDuration
* @param unit
* @param ticksPerWheel
* @param asyncExecutor
*/
public AsyncHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit,
int ticksPerWheel, Executor asyncExecutor) {
super(threadFactory, tickDuration, unit, ticksPerWheel);

this.executor = asyncExecutor;
this.taskFailedCallback = DEFAULT_TASK_FAILED_CALLBACK;
}

/**
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class ScopeEnumConverterTest {
@Test
public void doTest() {
Assert.assertEquals(ScopeEnum.zone, ScopeEnumConverter.convertToScope("zone"));
Assert.assertEquals(ScopeEnum.zone, new ScopeEnumConverter().convertToScope("zone"));
Assert.assertEquals(ScopeEnum.dataCenter, ScopeEnumConverter.convertToScope("dataCenter"));
Assert.assertEquals(ScopeEnum.global, ScopeEnumConverter.convertToScope("global"));
Assert.assertEquals(ScopeEnum.zone, ScopeEnumConverter.convertToScope("other value"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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.registry.timer;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.util.Timer;
import org.junit.Assert;
import org.junit.Test;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
* @author xuanbei
* @since 2019/3/27
*/
public class AsyncHashedWheelTimerTest {
private long currentTime;
private long executeTime;
private Throwable executionRejectedThrowable;
private Throwable executionFailedThrowable;

@Test
public void doTest() throws InterruptedException {
CountDownLatch countDownLatch = new CountDownLatch(2);
ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder();
threadFactoryBuilder.setDaemon(true);
final Timer timer = new AsyncHashedWheelTimer(threadFactoryBuilder.setNameFormat(
"AsyncHashedWheelTimerTest").build(), 50, TimeUnit.MILLISECONDS, 10,
threadFactoryBuilder.setNameFormat("Registry-DataNodeServiceImpl-WheelExecutor-%d")
.build(), new AsyncHashedWheelTimer.TaskFailedCallback() {
@Override
public void executionRejected(Throwable t) {
executionRejectedThrowable = t;
}

@Override
public void executionFailed(Throwable t) {
executionFailedThrowable = t;
countDownLatch.countDown();
}
});

currentTime = System.currentTimeMillis();
executeTime = currentTime;
timer.newTimeout((timeout)-> {
executeTime = System.currentTimeMillis();
countDownLatch.countDown();
throw new Exception("execution failed.");
},1000, TimeUnit.MILLISECONDS);

countDownLatch.await(3000, TimeUnit.MILLISECONDS);
Assert.assertTrue(executeTime >= currentTime + 1000);
Assert.assertNull(executionRejectedThrowable);
Assert.assertNotNull(executionFailedThrowable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public void testGetRandom() {
boolean allValueSame = true;
String firstValue = null;
for (int i = 0; i < 10; i++) {
String radomeValue = CollectionUtils.getRandom(stringCollection).get();
String radomeValue = i % 2 == 0 ? CollectionUtils.getRandom(stringCollection).get()
: new CollectionUtils().getRandom(stringCollection).get();
Assert.assertTrue(stringCollection.contains(radomeValue));
if (firstValue == null) {
firstValue = radomeValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void doTest() throws Exception {
FileUtils.forceDelete(dir);

String data = "FileUtilsTest";
FileUtils.writeByteArrayToFile(file, data.getBytes(), true);
new FileUtils().writeByteArrayToFile(file, data.getBytes(), true);
byte[] readByte = FileUtils.readFileToByteArray(file);
assertEquals(data, new String(readByte));

Expand Down
Loading