format
This commit is contained in:
@@ -54,6 +54,7 @@ public abstract class ClusterAgent {
|
|||||||
|
|
||||||
protected boolean waits;
|
protected boolean waits;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
protected String[] protocols; //必须全大写
|
protected String[] protocols; //必须全大写
|
||||||
|
|
||||||
protected int[] ports;
|
protected int[] ports;
|
||||||
@@ -70,13 +71,9 @@ public abstract class ClusterAgent {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
this.name = config.getValue("name", "");
|
this.name = config.getValue("name", "");
|
||||||
this.waits = config.getBoolValue("waits", false);
|
this.waits = config.getBoolValue("waits", false);
|
||||||
{
|
String ps = config.getValue("protocols", "").toUpperCase();
|
||||||
String ps = config.getValue("protocols", "").toUpperCase();
|
this.protocols = Utility.isEmpty(ps) ? null : ps.split(";");
|
||||||
if (ps == null || ps.isEmpty()) {
|
|
||||||
ps = "SNCP;HTTP";
|
|
||||||
}
|
|
||||||
this.protocols = ps.split(";");
|
|
||||||
}
|
|
||||||
String ts = config.getValue("ports", "");
|
String ts = config.getValue("ports", "");
|
||||||
if (ts != null && !ts.isEmpty()) {
|
if (ts != null && !ts.isEmpty()) {
|
||||||
String[] its = ts.split(";");
|
String[] its = ts.split(";");
|
||||||
@@ -118,7 +115,7 @@ public abstract class ClusterAgent {
|
|||||||
public abstract boolean acceptsConf(AnyValue config);
|
public abstract boolean acceptsConf(AnyValue config);
|
||||||
|
|
||||||
public boolean containsProtocol(String protocol) {
|
public boolean containsProtocol(String protocol) {
|
||||||
if (protocol == null || protocol.isEmpty()) {
|
if (Utility.isEmpty(protocol)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return protocols == null || Utility.contains(protocols, protocol.toUpperCase());
|
return protocols == null || Utility.contains(protocols, protocol.toUpperCase());
|
||||||
@@ -336,6 +333,7 @@ public abstract class ClusterAgent {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String[] getProtocols() {
|
public String[] getProtocols() {
|
||||||
return protocols;
|
return protocols;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class HttpLocalRpcClient extends HttpRpcClient {
|
|||||||
|
|
||||||
public static class HttpMessageLocalResponse extends HttpResponse {
|
public static class HttpMessageLocalResponse extends HttpResponse {
|
||||||
|
|
||||||
private CompletableFuture future;
|
private final CompletableFuture future;
|
||||||
|
|
||||||
public HttpMessageLocalResponse(HttpRequest req, CompletableFuture future) {
|
public HttpMessageLocalResponse(HttpRequest req, CompletableFuture future) {
|
||||||
super(req.getContext(), req, null);
|
super(req.getContext(), req, null);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public final class DeMember<R extends Reader, T, F> {
|
|||||||
this.decoder = decoder;
|
this.decoder = decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <R extends Reader, T, F> DeMember<R, T, F> create(final ConvertFactory factory, final Class<T> clazz, final String fieldName) {
|
public static <R extends Reader, T, F> DeMember<R, T, F> create(ConvertFactory factory, Class<T> clazz, String fieldName) {
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(fieldName);
|
Field field = clazz.getDeclaredField(fieldName);
|
||||||
return new DeMember<>(Attribute.create(field), factory.loadDecoder(field.getGenericType()), field, null);
|
return new DeMember<>(Attribute.create(field), factory.loadDecoder(field.getGenericType()), field, null);
|
||||||
@@ -98,7 +98,7 @@ public final class DeMember<R extends Reader, T, F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <R extends Reader, T, F> DeMember<R, T, F> create(final ConvertFactory factory, final Class<T> clazz, final String fieldName, final Class<F> fieldType) {
|
public static <R extends Reader, T, F> DeMember<R, T, F> create(ConvertFactory factory, Class<T> clazz, String fieldName, Class<F> fieldType) {
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(fieldName);
|
Field field = clazz.getDeclaredField(fieldName);
|
||||||
return new DeMember<>(Attribute.create(clazz, fieldName, fieldType), factory.loadDecoder(fieldType), field, null);
|
return new DeMember<>(Attribute.create(clazz, fieldName, fieldType), factory.loadDecoder(fieldType), field, null);
|
||||||
@@ -107,7 +107,7 @@ public final class DeMember<R extends Reader, T, F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <R extends Reader, T, F> DeMember<R, T, F> create(final Attribute<T, F> attribute, final ConvertFactory factory, final Class<F> fieldType) {
|
public static <R extends Reader, T, F> DeMember<R, T, F> create(Attribute<T, F> attribute, ConvertFactory factory, Class<F> fieldType) {
|
||||||
return new DeMember<>(attribute, factory.loadDecoder(fieldType), null, null);
|
return new DeMember<>(attribute, factory.loadDecoder(fieldType), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,8 @@ public final class DeMember<R extends Reader, T, F> {
|
|||||||
return (this.index == 0 ? Integer.MAX_VALUE : this.index) - (o.index == 0 ? Integer.MAX_VALUE : o.index);
|
return (this.index == 0 ? Integer.MAX_VALUE : this.index) - (o.index == 0 ? Integer.MAX_VALUE : o.index);
|
||||||
}
|
}
|
||||||
if (this.index != 0) {
|
if (this.index != 0) {
|
||||||
throw new ConvertException("fields (" + attribute.field() + ", " + o.attribute.field() + ") have same ConvertColumn.index(" + this.index + ") in " + attribute.declaringClass());
|
throw new ConvertException("fields (" + attribute.field() + ", " + o.attribute.field()
|
||||||
|
+ ") have same ConvertColumn.index(" + this.index + ") in " + attribute.declaringClass());
|
||||||
}
|
}
|
||||||
return fieldSort ? this.attribute.field().compareTo(o.attribute.field()) : 0;
|
return fieldSort ? this.attribute.field().compareTo(o.attribute.field()) : 0;
|
||||||
}
|
}
|
||||||
@@ -190,6 +191,7 @@ public final class DeMember<R extends Reader, T, F> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DeMember{" + "attribute=" + attribute.field() + ", position=" + position + ", tag=" + tag + ", decoder=" + (decoder == null ? null : decoder.getClass().getName()) + '}';
|
return "DeMember{" + "attribute=" + attribute.field() + ", position=" + position +
|
||||||
|
", tag=" + tag + ", decoder=" + (decoder == null ? null : decoder.getClass().getName()) + '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user