Skip to content

Format code #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
286 changes: 5 additions & 281 deletions .settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/main/java/org/msgpack/rpc/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public Client(String host, int port, EventLoop loop)
throws UnknownHostException {
this(new IPAddress(host, port), new TcpClientConfig(), loop);
}
public Client(String host, int port, EventLoop loop,Reflect reflect)

public Client(String host, int port, EventLoop loop, Reflect reflect)
throws UnknownHostException {
this(new IPAddress(host, port), new TcpClientConfig(), loop,reflect);
this(new IPAddress(host, port), new TcpClientConfig(), loop, reflect);
}

public Client(String host, int port, ClientConfig config, EventLoop loop)
Expand All @@ -70,16 +71,18 @@ public Client(InetSocketAddress address, EventLoop loop) {
public Client(InetSocketAddress address, ClientConfig config, EventLoop loop) {
this(new IPAddress(address), config, loop);
}
public Client(InetSocketAddress address, ClientConfig config, EventLoop loop,Reflect reflect) {
this(new IPAddress(address), config, loop,reflect);

public Client(InetSocketAddress address, ClientConfig config, EventLoop loop, Reflect reflect) {
this(new IPAddress(address), config, loop, reflect);
}

Client(Address address, ClientConfig config, EventLoop loop) {
super(address, config, loop);
startTimer();
}

Client(Address address, ClientConfig config, EventLoop loop, Reflect reflect) {
super(address, config, loop,reflect);
super(address, config, loop, reflect);
startTimer();
}

Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/msgpack/rpc/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

import org.msgpack.rpc.builder.DefaultDispatcherBuilder;
import org.msgpack.rpc.builder.DispatcherBuilder;
import org.msgpack.rpc.reflect.Reflect;
import org.msgpack.type.NilValue;
import org.msgpack.type.Value;
import org.msgpack.rpc.address.IPAddress;
import org.msgpack.rpc.dispatcher.Dispatcher;
import org.msgpack.rpc.dispatcher.MethodDispatcher;
import org.msgpack.rpc.config.ClientConfig;
import org.msgpack.rpc.config.ServerConfig;
import org.msgpack.rpc.config.TcpServerConfig;
Expand Down Expand Up @@ -76,7 +73,7 @@ public void serve(Dispatcher dp) {
}

public void serve(Object handler) {
this.dp = dispatcherBuilder.build(handler,this.getEventLoop().getMessagePack());
this.dp = dispatcherBuilder.build(handler, this.getEventLoop().getMessagePack());
}

public void listen(String host, int port) throws UnknownHostException, IOException {
Expand Down Expand Up @@ -112,10 +109,10 @@ public void onRequest(MessageSendable channel, int msgid, String method, Value a
} catch (Exception e) {
logger.error("Unexpected error occured while calling " + method, e);
// FIXME request.sendError("RemoteError", e.getMessage());
if(e.getMessage() == null)
if (e.getMessage() == null)
{
request.sendError("");
}else{
} else {
request.sendError(e.getMessage());
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/msgpack/rpc/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public class Session {
private Map<Integer, FutureImpl> reqtable = new HashMap<Integer, FutureImpl>();

Session(Address address, ClientConfig config, EventLoop loop) {
this(address,config,loop,new Reflect(loop.getMessagePack()));
this(address, config, loop, new Reflect(loop.getMessagePack()));
}

Session(Address address, ClientConfig config, EventLoop loop,Reflect reflect) {
Session(Address address, ClientConfig config, EventLoop loop, Reflect reflect) {
this.address = address;
this.loop = loop;
this.requestTimeout = config.getRequestTimeout();
Expand Down Expand Up @@ -87,16 +87,16 @@ public Value callApply(String method, Object[] args) {
Future<Value> f = sendRequest(method, args);
while (true) {
try {
if(requestTimeout <= 0){
if (requestTimeout <= 0) {
return f.get();
}else{
} else {
return f.get(requestTimeout, TimeUnit.SECONDS);
}
} catch (InterruptedException e) {
// FIXME
} catch (TimeoutException e) {
// FIXME
throw new RuntimeException("Time out to call method:" + method,e);
throw new RuntimeException("Time out to call method:" + method, e);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ public Dispatcher build(Object handler, MessagePack messagePack) {
new Reflect(messagePack), handler);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
*/
public interface DispatcherBuilder {

public Dispatcher build(Object handler,MessagePack messagePack) ;
public Dispatcher build(Object handler, MessagePack messagePack);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public void setVerbose(boolean verbose) {
this.verbose = verbose;
}

public StopWatchDispatcherBuilder withVerboseOutput(boolean verbose){
public StopWatchDispatcherBuilder withVerboseOutput(boolean verbose) {
this.verbose = verbose;
return this;
}

public StopWatchDispatcherBuilder(DispatcherBuilder baseBuilder){
public StopWatchDispatcherBuilder(DispatcherBuilder baseBuilder) {
this.baseBuilder = baseBuilder;
}

Expand All @@ -37,6 +37,6 @@ public Dispatcher decorate(Dispatcher innerDispatcher) {
}

public Dispatcher build(Object handler, MessagePack messagePack) {
return decorate(baseBuilder.build(handler,messagePack));
return decorate(baseBuilder.build(handler, messagePack));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public StopWatchDispatcher(Dispatcher inner) {
}

public void dispatch(Request request) throws Exception {
if(verbose){
logger.info(String.format( "Begin dispatching %s with args %s",request.getMethodName(),request.getArguments().toString()));
if (verbose) {
logger.info(String.format("Begin dispatching %s with args %s", request.getMethodName(), request.getArguments().toString()));
}
long start = System.currentTimeMillis();
try{
try {
innerDispatcher.dispatch(request);
long diff = System.currentTimeMillis() - start;
logger.info(String.format("Dispatch %s in %s msecs",request.getMethodName(),diff));
}catch(Exception e){
logger.info(String.format("Dispatch %s in %s msecs", request.getMethodName(), diff));
} catch (Exception e) {
long diff = System.currentTimeMillis() - start;
logger.info(String.format("%s : %s while dispatching %s,(in %s msecs)",e.getClass().getSimpleName(), e.getMessage(), request.getMethodName(),diff));
logger.info(String.format("%s : %s while dispatching %s,(in %s msecs)", e.getClass().getSimpleName(), e.getMessage(), request.getMethodName(), diff));
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ protected Object decode(ChannelHandlerContext ctx, Channel channel,
ByteArrayInputStream stream = new ByteArrayInputStream(bytes, offset,
length);
int startAvailable = stream.available();
try{
try {
Unpacker unpacker = msgpack.createUnpacker(stream);
Value v = unpacker.readValue();
source.skipBytes(startAvailable - stream.available());
return v;
}catch( EOFException e ){
} catch (EOFException e) {
// not enough buffers.
// So retry reading
source.resetReaderIndex();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/msgpack/rpc/message/NotifyMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.io.IOException;
import org.msgpack.MessagePackable;
import org.msgpack.packer.Packer;
import org.msgpack.type.Value;
import org.msgpack.MessageTypeException;
import org.msgpack.unpacker.Unpacker;

public class NotifyMessage implements MessagePackable {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/msgpack/rpc/message/RequestMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.io.IOException;
import org.msgpack.MessagePackable;
import org.msgpack.packer.Packer;
import org.msgpack.type.Value;
import org.msgpack.MessageTypeException;
import org.msgpack.unpacker.Unpacker;

public class RequestMessage implements MessagePackable {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/msgpack/rpc/message/ResponseMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import java.io.IOException;
import org.msgpack.*;
import org.msgpack.packer.Packer;
import org.msgpack.template.Template;
import org.msgpack.type.Value;
import org.msgpack.type.ValueFactory;
import org.msgpack.unpacker.Unpacker;

public class ResponseMessage implements MessagePackable {
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/msgpack/rpc/reflect/InvokerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.msgpack.*;
import org.msgpack.template.*;
import org.msgpack.rpc.Callback;
import org.msgpack.rpc.Request;

public abstract class InvokerBuilder {
public static class ArgumentEntry {
Expand Down Expand Up @@ -181,14 +180,11 @@ static ArgumentEntry[] readArgumentEntries(Method targetMethod,
/*
* index:
*
* @Index(0) int field_a; // 0
* int field_b; // 1
* @Index(0) int field_a; // 0 int field_b; // 1
*
* @Index(3) int field_c; // 3
* int field_d; // 4
* @Index(3) int field_c; // 3 int field_d; // 4
*
* @Index(2) int field_e; // 2
* int field_f; // 5
* @Index(2) int field_e; // 2 int field_f; // 5
*/
List<ArgumentEntry> indexed = new ArrayList<ArgumentEntry>();
int maxIndex = -1;
Expand Down
Loading