parent
7a0c805487
commit
bbcb26cae2
|
|
@ -120,7 +120,7 @@ public class NetUtils {
|
|||
|
||||
/**
|
||||
* Check the port whether is in use in os
|
||||
*
|
||||
*
|
||||
* @param port the port to check if in use
|
||||
* @return is the given port in use or not
|
||||
*/
|
||||
|
|
@ -346,7 +346,7 @@ public class NetUtils {
|
|||
for(String ignoredInterface: ignoredInterfaces.split(",")){
|
||||
String trimIgnoredInterface = ignoredInterface.trim();
|
||||
boolean matched = false;
|
||||
try {
|
||||
try {
|
||||
matched = networkInterfaceDisplayName.matches(trimIgnoredInterface);
|
||||
} catch (PatternSyntaxException e) {
|
||||
// if trimIgnoredInterface is a invalid regular expression, a PatternSyntaxException will be thrown out
|
||||
|
|
@ -592,7 +592,7 @@ public class NetUtils {
|
|||
splitCharacter = SPLIT_IPV6_CHARACTER;
|
||||
}
|
||||
String[] mask = pattern.split(splitCharacter);
|
||||
//check format of pattern
|
||||
// check format of pattern
|
||||
checkHostPattern(pattern, mask, isIpv4);
|
||||
|
||||
host = inetAddress.getHostAddress();
|
||||
|
|
|
|||
|
|
@ -707,12 +707,12 @@ public class PojoUtilsTest {
|
|||
String dateTimeStr = "2018-09-12 10:12:33";
|
||||
String[] dateFormat = new String[]{"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "HH:mm:ss"};
|
||||
|
||||
//java.util.Date
|
||||
// java.util.Date
|
||||
Object date = PojoUtils.realize(dateTimeStr, Date.class, (Type) Date.class);
|
||||
assertEquals(Date.class, date.getClass());
|
||||
assertEquals(dateTimeStr, new SimpleDateFormat(dateFormat[0]).format(date));
|
||||
|
||||
//java.sql.Time
|
||||
// java.sql.Time
|
||||
Object time = PojoUtils.realize(dateTimeStr, java.sql.Time.class, (Type) java.sql.Time.class);
|
||||
assertEquals(java.sql.Time.class, time.getClass());
|
||||
assertEquals(timeStr, new SimpleDateFormat(dateFormat[2]).format(time));
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ public class RpcContext {
|
|||
try {
|
||||
setAttachment(Constants.ASYNC_KEY, Boolean.TRUE.toString());
|
||||
final T o = callable.call();
|
||||
//local invoke will return directly
|
||||
// local invoke will return directly
|
||||
if (o != null) {
|
||||
FutureTask<T> f = new FutureTask<T>(new Callable<T>() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class DefaultCommandExecutor implements CommandExecutor {
|
|||
String extName = StringUtils.camelToSplitName(commandContext.getCommandName(), PROPERTIES_CHAR_SEPARATOR);
|
||||
command = ExtensionLoader.getExtensionLoader(BaseCommand.class).getExtension(extName);
|
||||
} catch (Throwable throwable) {
|
||||
//can't find command
|
||||
// can't find command
|
||||
}
|
||||
if (command == null) {
|
||||
throw new NoSuchCommandException(commandContext.getCommandName());
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ public abstract class DynamicDirectory<T> extends AbstractDirectory<T> implement
|
|||
// unsubscribe.
|
||||
try {
|
||||
if (getSubscribeConsumerurl() != null && registry != null && registry.isAvailable()) {
|
||||
//overwrite by child, so need call function
|
||||
// overwrite by child, so need call function
|
||||
unSubscribe(getSubscribeConsumerurl());
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class RegistryProtocolTest {
|
|||
newRegistryUrl, new ExchangeClient[] {new MockedClient("10.20.20.20", 2222, true)});
|
||||
Exporter<DemoService> exporter = registryProtocol.export(invoker);
|
||||
Exporter<DemoService> exporter2 = registryProtocol.export(invoker);
|
||||
//The same invoker, exporter that multiple exported are different
|
||||
// The same invoker, exporter that multiple exported are different
|
||||
Assertions.assertNotSame(exporter, exporter2);
|
||||
exporter.unexport();
|
||||
exporter2.unexport();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
private Object decode(byte[] request) throws IOException {
|
||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(request);
|
||||
AbstractMockChannel channel = getServerSideChannel(url);
|
||||
//decode
|
||||
// decode
|
||||
Object obj = codec.decode(channel, buffer);
|
||||
return obj;
|
||||
}
|
||||
|
|
@ -146,17 +146,17 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(join(request, baddata));
|
||||
Response obj = (Response) codec.decode(channel, buffer);
|
||||
Assertions.assertEquals(person, obj.getResult());
|
||||
//only decode necessary bytes
|
||||
// only decode necessary bytes
|
||||
Assertions.assertEquals(request.length, buffer.readerIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Decode_Error_Response_Object() throws IOException {
|
||||
//00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
|
||||
// 00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, 0x02, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
//bad object
|
||||
// bad object
|
||||
byte[] badbytes = new byte[]{-1, -2, -3, -4, -3, -4, -3, -4, -3, -4, -3, -4};
|
||||
System.arraycopy(badbytes, 0, request, 21, badbytes.length);
|
||||
|
||||
|
|
@ -220,13 +220,13 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(header);
|
||||
Object obj = codec.decode(channel, buffer);
|
||||
Assertions.assertEquals(TelnetCodec.DecodeResult.NEED_MORE_INPUT, obj);
|
||||
//If the telnet data and request data are in the same data packet, we should guarantee that the receipt of request data won't be affected by the factor that telnet does not have an end characters.
|
||||
// If the telnet data and request data are in the same data packet, we should guarantee that the receipt of request data won't be affected by the factor that telnet does not have an end characters.
|
||||
Assertions.assertEquals(2, buffer.readerIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Decode_Return_Response_Person() throws IOException {
|
||||
//00000010-response/oneway/hearbeat=false/hessian |20-stats=ok|id=0|length=0
|
||||
// 00000010-response/oneway/hearbeat=false/hessian |20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, 2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
|
|
@ -249,7 +249,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Decode_Return_Request_Event_Object() throws IOException {
|
||||
//|10011111|20-stats=ok|id=0|length=0
|
||||
// |10011111|20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, (byte) 0xe2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
|
|
@ -266,7 +266,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Decode_Return_Request_Event_String() throws IOException {
|
||||
//|10011111|20-stats=ok|id=0|length=0
|
||||
// |10011111|20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, (byte) 0xe2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
String event = READONLY_EVENT;
|
||||
byte[] request = getRequestBytes(event, header);
|
||||
|
|
@ -281,7 +281,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Decode_Return_Request_Heartbeat_Object() throws IOException {
|
||||
//|10011111|20-stats=ok|id=0|length=0
|
||||
// |10011111|20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, (byte) 0xe2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
byte[] request = getRequestBytes(null, header);
|
||||
Request obj = (Request) decode(request);
|
||||
|
|
@ -294,7 +294,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Decode_Return_Request_Object() throws IOException {
|
||||
//|10011111|20-stats=ok|id=0|length=0
|
||||
// |10011111|20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, (byte) 0xc2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
|
|
@ -309,11 +309,11 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Decode_Error_Request_Object() throws IOException {
|
||||
//00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
|
||||
// 00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, (byte) 0xe2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
//bad object
|
||||
// bad object
|
||||
byte[] badbytes = new byte[]{-1, -2, -3, -4, -3, -4, -3, -4, -3, -4, -3, -4};
|
||||
System.arraycopy(badbytes, 0, request, 21, badbytes.length);
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Header_Response_NoSerializationFlag() throws IOException {
|
||||
//00000010-response/oneway/hearbeat=false/noset |20-stats=ok|id=0|length=0
|
||||
// 00000010-response/oneway/hearbeat=false/noset |20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, (byte) 0x02, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
|
|
@ -337,7 +337,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void test_Header_Response_Heartbeat() throws IOException {
|
||||
//00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
|
||||
// 00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, 0x02, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Person person = new Person();
|
||||
byte[] request = getRequestBytes(person, header);
|
||||
|
|
@ -358,7 +358,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
|
||||
codec.encode(channel, encodeBuffer, request);
|
||||
|
||||
//encode resault check need decode
|
||||
// encode resault check need decode
|
||||
byte[] data = new byte[encodeBuffer.writerIndex()];
|
||||
encodeBuffer.readBytes(data);
|
||||
ChannelBuffer decodeBuffer = ChannelBuffers.wrappedBuffer(data);
|
||||
|
|
@ -385,7 +385,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
byte[] data = new byte[encodeBuffer.writerIndex()];
|
||||
encodeBuffer.readBytes(data);
|
||||
|
||||
//encode resault check need decode
|
||||
// encode resault check need decode
|
||||
ChannelBuffer decodeBuffer = ChannelBuffers.wrappedBuffer(data);
|
||||
Response obj = (Response) codec.decode(channel, decodeBuffer);
|
||||
|
||||
|
|
@ -416,7 +416,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
byte[] data = new byte[encodeBuffer.writerIndex()];
|
||||
encodeBuffer.readBytes(data);
|
||||
|
||||
//encode resault check need decode
|
||||
// encode result check need decode
|
||||
ChannelBuffer decodeBuffer = ChannelBuffers.wrappedBuffer(data);
|
||||
Response obj = (Response) codec.decode(channel, decodeBuffer);
|
||||
Assertions.assertEquals(response.getId(), obj.getId());
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class TelnetCodecTest {
|
|||
bytes = (byte[]) obj;
|
||||
} else {
|
||||
try {
|
||||
//object to bytearray
|
||||
// object to bytearray
|
||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oo = new ObjectOutputStream(bo);
|
||||
oo.writeObject(obj);
|
||||
|
|
@ -109,19 +109,19 @@ public class TelnetCodecTest {
|
|||
}
|
||||
|
||||
protected void testDecode_assertEquals(byte[] request, Object ret, boolean isServerside) throws IOException {
|
||||
//init channel
|
||||
// init channel
|
||||
Channel channel = isServerside ? getServerSideChannel(url) : getCliendSideChannel(url);
|
||||
//init request string
|
||||
// init request string
|
||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(request);
|
||||
|
||||
//decode
|
||||
// decode
|
||||
Object obj = codec.decode(channel, buffer);
|
||||
Assertions.assertEquals(ret, obj);
|
||||
}
|
||||
|
||||
|
||||
protected void testEecode_assertEquals(Object request, byte[] ret, boolean isServerside) throws IOException {
|
||||
//init channel
|
||||
// init channel
|
||||
Channel channel = isServerside ? getServerSideChannel(url) : getCliendSideChannel(url);
|
||||
|
||||
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
|
||||
|
|
@ -147,7 +147,7 @@ public class TelnetCodecTest {
|
|||
}
|
||||
|
||||
private void testDecode_assertEquals(AbstractMockChannel channel, Object request, Object expectret, Object channelReceive) throws IOException {
|
||||
//init channel
|
||||
// init channel
|
||||
if (channel == null) {
|
||||
channel = getServerSideChannel(url);
|
||||
}
|
||||
|
|
@ -155,21 +155,21 @@ public class TelnetCodecTest {
|
|||
byte[] buf = objectToByte(request);
|
||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(buf);
|
||||
|
||||
//decode
|
||||
// decode
|
||||
Object obj = codec.decode(channel, buffer);
|
||||
Assertions.assertEquals(expectret, obj);
|
||||
Assertions.assertEquals(channelReceive, channel.getReceivedMessage());
|
||||
}
|
||||
|
||||
private void testDecode_PersonWithEnterByte(byte[] enterbytes, boolean isNeedmore) throws IOException {
|
||||
//init channel
|
||||
// init channel
|
||||
Channel channel = getServerSideChannel(url);
|
||||
//init request string
|
||||
// init request string
|
||||
Person request = new Person();
|
||||
byte[] newbuf = join(objectToByte(request), enterbytes);
|
||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(newbuf);
|
||||
|
||||
//decode
|
||||
// decode
|
||||
Object obj = codec.decode(channel, buffer);
|
||||
if (isNeedmore) {
|
||||
Assertions.assertEquals(Codec2.DecodeResult.NEED_MORE_INPUT, obj);
|
||||
|
|
@ -179,11 +179,11 @@ public class TelnetCodecTest {
|
|||
}
|
||||
|
||||
private void testDecode_WithExitByte(byte[] exitbytes, boolean isChannelClose) throws IOException {
|
||||
//init channel
|
||||
// init channel
|
||||
Channel channel = getServerSideChannel(url);
|
||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(exitbytes);
|
||||
|
||||
//decode
|
||||
// decode
|
||||
codec.decode(channel, buffer);
|
||||
Assertions.assertEquals(isChannelClose, channel.isClosed());
|
||||
}
|
||||
|
|
@ -304,26 +304,26 @@ public class TelnetCodecTest {
|
|||
public void testEncode_String_ClientSide() throws IOException {
|
||||
testEecode_assertEquals("aaa", "aaa\r\n".getBytes(), false);
|
||||
}
|
||||
|
||||
|
||||
/*@Test()
|
||||
public void testDecode_History_UP_DOWN_MULTI() throws IOException{
|
||||
AbstractMockChannel channel = getServerSideChannel(url);
|
||||
|
||||
String request1 = "aaa\n";
|
||||
|
||||
String request1 = "aaa\n";
|
||||
Object expected1 = request1.replace("\n", "");
|
||||
//init history
|
||||
//init history
|
||||
testDecode_assertEquals(channel, request1, expected1, null);
|
||||
|
||||
String request2 = "bbb\n";
|
||||
|
||||
String request2 = "bbb\n";
|
||||
Object expected2 = request2.replace("\n", "");
|
||||
//init history
|
||||
//init history
|
||||
testDecode_assertEquals(channel, request2, expected2, null);
|
||||
|
||||
String request3 = "ccc\n";
|
||||
|
||||
String request3 = "ccc\n";
|
||||
Object expected3= request3.replace("\n", "");
|
||||
//init history
|
||||
//init history
|
||||
testDecode_assertEquals(channel, request3, expected3, null);
|
||||
|
||||
|
||||
byte[] UP = new byte[] {27, 91, 65};
|
||||
byte[] DOWN = new byte[] {27, 91, 66};
|
||||
//history[aaa,bbb,ccc]
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ public class RpcContext {
|
|||
try {
|
||||
setAttachment(ASYNC_KEY, Boolean.TRUE.toString());
|
||||
final T o = callable.call();
|
||||
//local invoke will return directly
|
||||
// local invoke will return directly
|
||||
if (o != null) {
|
||||
if (o instanceof CompletableFuture) {
|
||||
return (CompletableFuture<T>) o;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class CallbackServiceCodec {
|
|||
}
|
||||
}
|
||||
tmpMap.putAll(params);
|
||||
|
||||
|
||||
tmpMap.remove(VERSION_KEY);// doesn't need to distinguish version for callback
|
||||
tmpMap.remove(Constants.BIND_PORT_KEY); //callback doesn't needs bind.port
|
||||
tmpMap.put(INTERFACE_KEY, clazz.getName());
|
||||
|
|
@ -173,8 +173,8 @@ class CallbackServiceCodec {
|
|||
channel.setAttribute(invokerCacheKey, invoker);
|
||||
increaseInstanceCount(channel, countkey);
|
||||
|
||||
//convert error fail fast .
|
||||
//ignore concurrent problem.
|
||||
// convert error fail fast .
|
||||
// ignore concurrent problem.
|
||||
Set<Invoker<?>> callbackInvokers = (Set<Invoker<?>>) channel.getAttribute(CHANNEL_CALLBACK_KEY);
|
||||
if (callbackInvokers == null) {
|
||||
callbackInvokers = new ConcurrentHashSet<>(1);
|
||||
|
|
@ -229,7 +229,7 @@ class CallbackServiceCodec {
|
|||
Integer count = (Integer) channel.getAttribute(isServer ? getServerSideCountKey(channel, interfaceClass) : getClientSideCountKey(interfaceClass));
|
||||
int limit = url.getParameter(CALLBACK_INSTANCES_LIMIT_KEY, DEFAULT_CALLBACK_INSTANCES);
|
||||
if (count != null && count >= limit) {
|
||||
//client side error
|
||||
// client side error
|
||||
throw new IllegalStateException("interface " + interfaceClass + " `s callback instances num exceed providers limit :" + limit
|
||||
+ " ,current num: " + (count + 1) + ". The new callback service will not work !!! you can cancle the callback service which exported before. channel :" + channel);
|
||||
} else {
|
||||
|
|
@ -239,7 +239,7 @@ class CallbackServiceCodec {
|
|||
|
||||
private static void increaseInstanceCount(Channel channel, String countkey) {
|
||||
try {
|
||||
//ignore concurrent problem?
|
||||
// ignore concurrent problem?
|
||||
Integer count = (Integer) channel.getAttribute(countkey);
|
||||
if (count == null) {
|
||||
count = 1;
|
||||
|
|
|
|||
|
|
@ -208,9 +208,9 @@ final class ReferenceCountExchangeClient implements ExchangeClient {
|
|||
if (!(client instanceof LazyConnectExchangeClient)) {
|
||||
// this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
|
||||
URL lazyUrl = url.addParameter(LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.TRUE)
|
||||
//.addParameter(RECONNECT_KEY, Boolean.FALSE)
|
||||
// .addParameter(RECONNECT_KEY, Boolean.FALSE)
|
||||
.addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
|
||||
//.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
|
||||
// .addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
|
||||
client = new LazyConnectExchangeClient(lazyUrl, client.getExchangeHandler());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue