public static MethodMetadata toMethodMetadata(ThriftCodecManager codecManager, ThriftMethodMetadata metadata) { List<ParameterMetadata> parameters = metadata.getParameters().stream() .map(parameter -> new ParameterMetadata( parameter.getId(), parameter.getName(), getCodec(codecManager, parameter.getThriftType()))) .collect(Collectors.toList()); ThriftCodec<Object> resultCodec = getCodec(codecManager, metadata.getReturnType()); Map<Short, ThriftCodec<Object>> exceptionCodecs = ImmutableMap.copyOf( transformEntries(metadata.getExceptions(), (key, value) -> getCodec(codecManager, value))); return new MethodMetadata( metadata.getName(), parameters, resultCodec, exceptionCodecs, metadata.getOneway(), metadata.isIdempotent()); }
(ThriftCodec<Object>) codecManager.getCodec(optionalType)); MethodMetadata methodMetadata = new MethodMetadata( "Log", ImmutableList.of(parameter),
private static int logApacheThriftInvocationHandler(HostAndPort address, List<DriftLogEntry> entries) { ApacheThriftClientConfig config = new ApacheThriftClientConfig(); ApacheThriftConnectionFactoryConfig factoryConfig = new ApacheThriftConnectionFactoryConfig(); try (ApacheThriftMethodInvokerFactory<Void> methodInvokerFactory = new ApacheThriftMethodInvokerFactory<>(factoryConfig, clientIdentity -> config)) { MethodInvoker methodInvoker = methodInvokerFactory.createMethodInvoker(null); ParameterMetadata parameter = new ParameterMetadata( (short) 1, "messages", (ThriftCodec<Object>) codecManager.getCodec(list(codecManager.getCodec(DriftLogEntry.class).getType()))); MethodMetadata methodMetadata = new MethodMetadata( "Log", ImmutableList.of(parameter), (ThriftCodec<Object>) (Object) codecManager.getCodec(DriftResultCode.class), ImmutableMap.of(), false, true); ListenableFuture<Object> future = methodInvoker.invoke(new InvokeRequest(methodMetadata, () -> address, ImmutableMap.of(), ImmutableList.of(entries))); assertEquals(future.get(), DRIFT_OK); return 1; } catch (Exception e) { throw new RuntimeException(e); } }
(ThriftCodec<Object>) CODEC_MANAGER.getCodec(optionalType)); MethodMetadata methodMetadata = new MethodMetadata( "Log", ImmutableList.of(parameter),
new MethodMetadata( "test", ImmutableList.of(),
new MethodMetadata( "test", ImmutableList.of(),
(ThriftCodec<Object>) CODEC_MANAGER.getCodec(optionalType)); MethodMetadata methodMetadata = new MethodMetadata( "Log", ImmutableList.of(parameter),