This commit is contained in:
地平线
2015-09-04 09:52:09 +08:00
parent 4419629c71
commit 1869070040

View File

@@ -96,7 +96,7 @@ public final class SncpClient {
protected final BlockingQueue<Runnable> queue = new ArrayBlockingQueue(1024 * 64);
public SncpClient(final String serviceName, final long serviceid0, boolean remote, final Class serviceClass,
boolean onlySncpDyn, final InetSocketAddress clientAddress, final HashSet<String> groups) {
boolean onlySncpDyn, final InetSocketAddress clientAddress, final HashSet<String> groups) {
if (serviceName.length() > 10) throw new RuntimeException(serviceClass + " @Resource name(" + serviceName + ") too long , must less 11");
this.remote = remote;
this.serviceClass = serviceClass;
@@ -152,8 +152,8 @@ public final class SncpClient {
String service = serviceClass.getName();
if (remote) service = service.replace(Sncp.LOCALPREFIX, Sncp.REMOTEPREFIX);
return this.getClass().getSimpleName() + "(service = " + service + ", serviceid = " + serviceid
+ ", name = " + name + ", nameid = " + nameid + ", address = " + (address == null ? "" : (address.getHostString() + ":" + address.getPort()))
+ ", groups = " + groups + ", actions.size = " + actions.length + ")";
+ ", name = " + name + ", nameid = " + nameid + ", address = " + (address == null ? "" : (address.getHostString() + ":" + address.getPort()))
+ ", groups = " + groups + ", actions.size = " + actions.length + ")";
}
public static List<Method> parseMethod(final Class serviceClass, boolean onlySncpDyn) {
@@ -174,7 +174,8 @@ public final class SncpClient {
DLong actionid = Sncp.hash(method);
Method old = actionids.get(actionid);
if (old != null) {
if (old.getDeclaringClass().equals(method.getDeclaringClass())) throw new RuntimeException(serviceClass.getName() + " have one more same action(Method=" + method + ", actionid=" + actionid + ")");
if (old.getDeclaringClass().equals(method.getDeclaringClass()))
throw new RuntimeException(serviceClass.getName() + " have one more same action(Method=" + method + ", actionid=" + actionid + ")");
continue;
}
actionids.put(actionid, method);
@@ -325,10 +326,14 @@ public final class SncpClient {
if (rnameid != nameid) throw new RuntimeException("sncp send nameid = " + nameid + ", but receive next.nameid =" + rnameid);
ractionid1 = buffer.getLong();
ractionid2 = buffer.getLong();
if (!actionid.compare(ractionid1, ractionid2)) throw new RuntimeException("sncp send actionid = " + actionid + ", but receive next.actionid =(" + ractionid1 + "_" + ractionid2 + ")");
if (!actionid.compare(ractionid1, ractionid2))
throw new RuntimeException("sncp send actionid = " + actionid + ", but receive next.actionid =(" + ractionid1 + "_" + ractionid2 + ")");
buffer.getInt();
buffer.getInt();
if (buffer.get() < 1) throw new RuntimeException("sncp send nameid = " + nameid + ", but next.frame.count != " + frameCount);
frameIndex = buffer.get();
if (frameIndex < 0 || frameIndex >= frameCount) throw new RuntimeException("sncp receive nameid = " + nameid + ", but frame.count =" + frameCount + " & next.frame.index =" + frameIndex);
if (frameIndex < 0 || frameIndex >= frameCount)
throw new RuntimeException("sncp receive nameid = " + nameid + ", but frame.count =" + frameCount + " & next.frame.index =" + frameIndex);
int rretcode = buffer.getInt();
if (rretcode != 0) throw new RuntimeException("remote service deal error (receive retcode =" + rretcode + ")");
int rbodylen = buffer.getInt();