优化变量名
This commit is contained in:
@@ -52,7 +52,7 @@ public final class SncpClient {
|
||||
|
||||
protected final DLong serviceid;
|
||||
|
||||
protected final int serviceversion;
|
||||
protected final int serviceVersion;
|
||||
|
||||
protected final SncpAction[] actions;
|
||||
|
||||
@@ -83,7 +83,7 @@ public final class SncpClient {
|
||||
Class<?> tn = serviceTypeOrImplClass;
|
||||
Version ver = tn.getAnnotation(Version.class);
|
||||
this.serviceClass = serviceClass;
|
||||
this.serviceversion = ver == null ? 0 : ver.value();
|
||||
this.serviceVersion = ver == null ? 0 : ver.value();
|
||||
this.clientSncpAddress = clientSncpAddress;
|
||||
this.name = serviceName;
|
||||
tn = ResourceFactory.getResourceType(tn);
|
||||
@@ -120,8 +120,8 @@ public final class SncpClient {
|
||||
return serviceid;
|
||||
}
|
||||
|
||||
public int getServiceversion() {
|
||||
return serviceversion;
|
||||
public int getServiceVersion() {
|
||||
return serviceVersion;
|
||||
}
|
||||
|
||||
public int getActionCount() {
|
||||
@@ -148,7 +148,7 @@ public final class SncpClient {
|
||||
public String toString() {
|
||||
String service = serviceClass.getName();
|
||||
if (remote) service = service.replace("DynLocalService", "DynRemoteService");
|
||||
return this.getClass().getSimpleName() + "(service = " + service + ", serviceid = " + serviceid + ", serviceversion = " + serviceversion + ", name = '" + name
|
||||
return this.getClass().getSimpleName() + "(service = " + service + ", serviceid = " + serviceid + ", serviceVersion = " + serviceVersion + ", name = '" + name
|
||||
+ "', address = " + (clientSncpAddress == null ? "" : (clientSncpAddress.getHostString() + ":" + clientSncpAddress.getPort()))
|
||||
+ ", actions.size = " + actions.length + ")";
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public final class SncpClient {
|
||||
}
|
||||
String service = serviceClass.getAnnotation(SncpDyn.class) ==null? serviceClass.getName() : serviceClass.getSuperclass().getSimpleName();
|
||||
if (remote) service = service.replace("DynLocalService", "DynRemoteService");
|
||||
return service + "(name = '" + name + "', serviceid = " + serviceid + ", serviceversion = " + serviceversion
|
||||
return service + "(name = '" + name + "', serviceid = " + serviceid + ", serviceVersion = " + serviceVersion
|
||||
+ ", clientaddr = " + (clientSncpAddress == null ? "" : (clientSncpAddress.getHostString() + ":" + clientSncpAddress.getPort()))
|
||||
+ ((remoteGroups == null || remoteGroups.isEmpty()) ? "" : ", remoteGroups = " + remoteGroups)
|
||||
+ (remoteGroupTransport == null ? "" : ", remoteGroupTransport = " + Arrays.toString(remoteGroupTransport.getRemoteAddresses()))
|
||||
@@ -460,7 +460,7 @@ public final class SncpClient {
|
||||
DLong rserviceid = DLong.read(buffer);
|
||||
if (!rserviceid.equals(this.serviceid)) throw new RuntimeException("sncp(" + action.method + ") response.serviceid = " + serviceid + ", but request.serviceid =" + rserviceid);
|
||||
int version = buffer.getInt();
|
||||
if (version != this.serviceversion) throw new RuntimeException("sncp(" + action.method + ") response.serviceversion = " + serviceversion + ", but request.serviceversion =" + version);
|
||||
if (version != this.serviceVersion) throw new RuntimeException("sncp(" + action.method + ") response.serviceVersion = " + serviceVersion + ", but request.serviceVersion =" + version);
|
||||
DLong raction = DLong.read(buffer);
|
||||
DLong actid = action.actionid;
|
||||
if (!actid.equals(raction)) throw new RuntimeException("sncp(" + action.method + ") response.actionid = " + action.actionid + ", but request.actionid =(" + raction + ")");
|
||||
@@ -477,7 +477,7 @@ public final class SncpClient {
|
||||
offset += 2;
|
||||
DLong.write(buffer, offset, this.serviceid);
|
||||
offset += 16;
|
||||
buffer.putInt(offset, this.serviceversion);
|
||||
buffer.putInt(offset, this.serviceVersion);
|
||||
offset += 4;
|
||||
DLong.write(buffer, offset, actionid);
|
||||
offset += 16;
|
||||
@@ -498,7 +498,7 @@ public final class SncpClient {
|
||||
// buffer.putLong(seqid); //序列号
|
||||
// buffer.putChar((char) HEADER_SIZE); //header长度
|
||||
// DLong.write(buffer, this.serviceid);
|
||||
// buffer.putInt(this.serviceversion);
|
||||
// buffer.putInt(this.serviceVersion);
|
||||
// DLong.write(buffer, actionid);
|
||||
// buffer.put(addrBytes);
|
||||
// buffer.putChar((char) this.addrPort);
|
||||
|
||||
@@ -40,21 +40,21 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
|
||||
protected int readState = READ_STATE_ROUTE;
|
||||
|
||||
private int serviceversion;
|
||||
private int serviceVersion;
|
||||
|
||||
private DLong serviceid;
|
||||
|
||||
private DLong actionid;
|
||||
|
||||
private int bodylength;
|
||||
private int bodyLength;
|
||||
|
||||
private int bodyoffset;
|
||||
private int bodyOffset;
|
||||
|
||||
private boolean ping;
|
||||
|
||||
private byte[] body;
|
||||
|
||||
private byte[] addrbytes = new byte[6];
|
||||
private final byte[] addrBytes = new byte[6];
|
||||
|
||||
protected SncpRequest(SncpContext context) {
|
||||
super(context);
|
||||
@@ -78,38 +78,30 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
return -1;
|
||||
}
|
||||
this.serviceid = DLong.read(buffer); //16
|
||||
this.serviceversion = buffer.getInt(); //4
|
||||
this.serviceVersion = buffer.getInt(); //4
|
||||
this.actionid = DLong.read(buffer); //16
|
||||
buffer.get(addrbytes); //ipaddr //6
|
||||
this.bodylength = buffer.getInt(); //4
|
||||
buffer.get(addrBytes); //ipaddr //6
|
||||
this.bodyLength = buffer.getInt(); //4
|
||||
|
||||
if (buffer.getInt() != 0) { //4
|
||||
if (context.getLogger().isLoggable(Level.FINEST)) context.getLogger().finest("sncp buffer header.retcode not 0");
|
||||
return -1;
|
||||
}
|
||||
this.body = new byte[this.bodylength];
|
||||
this.body = new byte[this.bodyLength];
|
||||
this.readState = READ_STATE_BODY;
|
||||
}
|
||||
//---------------------body----------------------------------
|
||||
if (this.readState == READ_STATE_BODY) {
|
||||
int len = Math.min(this.bodylength, buffer.remaining());
|
||||
int len = Math.min(this.bodyLength, buffer.remaining());
|
||||
buffer.get(body, 0, len);
|
||||
this.bodyoffset = len;
|
||||
int rs = bodylength - len;
|
||||
this.bodyOffset = len;
|
||||
int rs = bodyLength - len;
|
||||
if (rs == 0) this.readState = READ_STATE_END;
|
||||
return rs;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected int readBody(ByteBuffer buffer, int length) {
|
||||
// final int framelen = buffer.remaining();
|
||||
// int len = Math.min(framelen, length);
|
||||
// buffer.get(this.body, this.bodyoffset, len);
|
||||
// this.bodyoffset += len;
|
||||
// return len;
|
||||
// }
|
||||
@Override
|
||||
protected void prepare() {
|
||||
this.keepAlive = true;
|
||||
@@ -122,9 +114,9 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
@Override
|
||||
public String toString() {
|
||||
return SncpRequest.class.getSimpleName() + "{seqid=" + this.seqid
|
||||
+ ",serviceversion=" + this.serviceversion + ",serviceid=" + this.serviceid
|
||||
+ ",actionid=" + this.actionid + ",bodylength=" + this.bodylength
|
||||
+ ",bodyoffset=" + this.bodyoffset + ",remoteAddress=" + getRemoteAddress() + "}";
|
||||
+ ",serviceVersion=" + this.serviceVersion + ",serviceid=" + this.serviceid
|
||||
+ ",actionid=" + this.actionid + ",bodyLength=" + this.bodyLength
|
||||
+ ",bodyOffset=" + this.bodyOffset + ",remoteAddress=" + getRemoteAddress() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,13 +124,13 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
this.seqid = 0;
|
||||
this.readState = READ_STATE_ROUTE;
|
||||
this.serviceid = null;
|
||||
this.serviceversion = 0;
|
||||
this.serviceVersion = 0;
|
||||
this.actionid = null;
|
||||
this.bodylength = 0;
|
||||
this.bodyoffset = 0;
|
||||
this.bodyLength = 0;
|
||||
this.bodyOffset = 0;
|
||||
this.body = null;
|
||||
this.ping = false;
|
||||
this.addrbytes[0] = 0;
|
||||
this.addrBytes[0] = 0;
|
||||
super.recycle();
|
||||
}
|
||||
|
||||
@@ -154,8 +146,8 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
return seqid;
|
||||
}
|
||||
|
||||
public int getServiceversion() {
|
||||
return serviceversion;
|
||||
public int getServiceVersion() {
|
||||
return serviceVersion;
|
||||
}
|
||||
|
||||
public DLong getServiceid() {
|
||||
@@ -167,9 +159,9 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
}
|
||||
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
if (addrbytes[0] == 0) return null;
|
||||
return new InetSocketAddress((0xff & addrbytes[0]) + "." + (0xff & addrbytes[1]) + "." + (0xff & addrbytes[2]) + "." + (0xff & addrbytes[3]),
|
||||
((0xff00 & (addrbytes[4] << 8)) | (0xff & addrbytes[5])));
|
||||
if (addrBytes[0] == 0) return null;
|
||||
return new InetSocketAddress((0xff & addrBytes[0]) + "." + (0xff & addrBytes[1]) + "." + (0xff & addrBytes[2]) + "." + (0xff & addrBytes[3]),
|
||||
((0xff00 & (addrBytes[4] << 8)) | (0xff & addrBytes[5])));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
|
||||
|
||||
public static final int RETCODE_ILLSERVICEID = (1 << 1); //无效serviceid
|
||||
|
||||
public static final int RETCODE_ILLSERVICEVER = (1 << 2); //无效serviceversion
|
||||
public static final int RETCODE_ILLSERVICEVER = (1 << 2); //无效serviceVersion
|
||||
|
||||
public static final int RETCODE_ILLACTIONID = (1 << 3); //无效actionid
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
|
||||
|
||||
public static String getRetCodeInfo(int retcode) {
|
||||
if (retcode == RETCODE_ILLSERVICEID) return "The serviceid is invalid";
|
||||
if (retcode == RETCODE_ILLSERVICEVER) return "The serviceversion is invalid";
|
||||
if (retcode == RETCODE_ILLSERVICEVER) return "The serviceVersion is invalid";
|
||||
if (retcode == RETCODE_ILLACTIONID) return "The actionid is invalid";
|
||||
if (retcode == RETCODE_THROWEXCEPTION) return "Inner exception";
|
||||
return null;
|
||||
@@ -84,7 +84,7 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
|
||||
offset += 2;
|
||||
DLong.write(buffer, offset, request.getServiceid());
|
||||
offset += 16;
|
||||
buffer.putInt(offset, request.getServiceversion());
|
||||
buffer.putInt(offset, request.getServiceVersion());
|
||||
offset += 4;
|
||||
DLong.write(buffer, offset, request.getActionid());
|
||||
offset += 16;
|
||||
@@ -105,7 +105,7 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
|
||||
// buffer.putLong(request.getSeqid());
|
||||
// buffer.putChar((char) SncpRequest.HEADER_SIZE);
|
||||
// DLong.write(buffer, request.getServiceid());
|
||||
// buffer.putInt(request.getServiceversion());
|
||||
// buffer.putInt(request.getServiceVersion());
|
||||
// DLong.write(buffer, request.getActionid());
|
||||
// buffer.put(addrBytes);
|
||||
// buffer.putChar((char) this.addrPort);
|
||||
|
||||
Reference in New Issue
Block a user