org.apache.avro.Protocol.getName()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.apache.avro.Protocol.getName()方法的一些代码示例,展示了Protocol.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.getName()方法的具体详情如下:
包路径:org.apache.avro.Protocol
类名称:Protocol
方法名:getName

Protocol.getName介绍

[英]The name of this protocol.
[中]此协议的名称。

代码示例

代码示例来源:origin: apache/avro

/**
 * Provides a a unique gRPC service name for Avro RPC interface or its subclass Callback
 * Interface.
 *
 * @param iface Avro RPC interface.
 * @return unique service name for gRPC.
 */
public static String getServiceName(Class iface) {
 Protocol protocol = getProtocol(iface);
 return protocol.getNamespace() + "." + protocol.getName();
}

代码示例来源:origin: apache/avro

/**
 * Constructs a similar Protocol instance with the same {@code name}, {@code doc}, and {@code namespace} as {code p}
 * has. It also copies all the {@code props}.
 */
public Protocol(Protocol p) {
 this(p.getName(), p.getDoc(), p.getNamespace());
 putAll(p);
}

代码示例来源:origin: apache/avro

OutputFile compileInterface(Protocol protocol) {
 protocol = addStringType(protocol);           // annotate protocol as needed
 VelocityContext context = new VelocityContext();
 context.put("protocol", protocol);
 context.put("this", this);
 String out = renderTemplate(templateDir+"protocol.vm", context);
 OutputFile outputFile = new OutputFile();
 String mangledName = mangle(protocol.getName());
 outputFile.path = makePath(mangledName, protocol.getNamespace());
 outputFile.contents = out;
 outputFile.outputCharacterEncoding = outputCharacterEncoding;
 return outputFile;
}

代码示例来源:origin: apache/avro

private Protocol addStringType(Protocol p) {
 if (stringType != StringType.String)
  return p;
 Protocol newP = new Protocol(p.getName(), p.getDoc(), p.getNamespace());
 Map<Schema,Schema> types = new LinkedHashMap<>();
 for (Map.Entry<String, Object> a : p.getObjectProps().entrySet()) {
  newP.addProp(a.getKey(), a.getValue());
 }
 // annotate types
 Collection<Schema> namedTypes = new LinkedHashSet<>();
 for (Schema s : p.getTypes())
  namedTypes.add(addStringType(s, types));
 newP.setTypes(namedTypes);
 // annotate messages
 Map<String,Message> newM = newP.getMessages();
 for (Message m : p.getMessages().values())
  newM.put(m.getName(), m.isOneWay()
       ? newP.createMessage(m,
                 addStringType(m.getRequest(), types))
       : newP.createMessage(m,
                 addStringType(m.getRequest(), types),
                 addStringType(m.getResponse(), types),
                 addStringType(m.getErrors(), types)));
 return newP;
}

代码示例来源:origin: apache/avro

Protocol result = new Protocol(protocol.getName(), protocol.getDoc(), protocol.getNamespace());
final Collection<Schema> types = protocol.getTypes();

代码示例来源:origin: org.apache.hadoop/avro

private OutputFile compileInterface(Protocol protocol) {
 OutputFile outputFile = new OutputFile();
 String mangledName = mangle(protocol.getName());
 outputFile.path = makePath(mangledName, protocol.getNamespace());
 StringBuilder out = new StringBuilder();
 header(out, protocol.getNamespace());
 doc(out, 1, protocol.getDoc());
 line(out, 0, "public interface " + mangledName + " {");
 line(out, 1, "public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse(\""
     +esc(protocol)+"\");");
 for (Map.Entry<String,Message> e : protocol.getMessages().entrySet()) {
  String name = e.getKey();
  Message message = e.getValue();
  Schema request = message.getRequest();
  Schema response = message.getResponse();
  doc(out, 1, e.getValue().getDoc());
  line(out, 1, unbox(response)+" "+ mangle(name)+"("+params(request)+")");
  line(out, 2,"throws org.apache.avro.ipc.AvroRemoteException"+errors(message.getErrors())+";");
 }
 line(out, 0, "}");
 outputFile.contents = out.toString();
 return outputFile;
}

代码示例来源:origin: org.apache.cassandra.deps/avro

private OutputFile compileInterface(Protocol protocol) {
 OutputFile outputFile = new OutputFile();
 String mangledName = mangle(protocol.getName());
 outputFile.path = makePath(mangledName, protocol.getNamespace());
 StringBuilder out = new StringBuilder();
 header(out, protocol.getNamespace());
 doc(out, 1, protocol.getDoc());
 line(out, 0, "public interface " + mangledName + " {");
 line(out, 1, "public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse(\""
     +esc(protocol)+"\");");
 for (Map.Entry<String,Message> e : protocol.getMessages().entrySet()) {
  String name = e.getKey();
  Message message = e.getValue();
  Schema request = message.getRequest();
  String response = message.isOneWay() ? "void"
   : unbox(message.getResponse());
  doc(out, 1, e.getValue().getDoc());
  line(out, 1, response+" "+ mangle(name)+"("+params(request)+")"
     + (message.isOneWay() ? ""
      : (" throws org.apache.avro.ipc.AvroRemoteException"
        +errors(message.getErrors())))
     +";");
 }
 line(out, 0, "}");
 outputFile.contents = out.toString();
 return outputFile;
}

相关文章