List of usage examples for org.apache.thrift.protocol TTupleProtocol TTupleProtocol
public TTupleProtocol(TTransport transport)
From source file:com.facebook.buck.cli.BuildCommand.java
License:Apache License
private int executeDistributedBuild(final CommandRunnerParams params, final WeightedListeningExecutorService executorService) throws IOException, InterruptedException, ActionGraphCreationException { ProjectFilesystem filesystem = params.getCell().getFilesystem(); if (distributedBuildStateFile != null) { Path stateDumpPath = Paths.get(distributedBuildStateFile); TTransport transport;/* ww w .j a v a 2 s. c o m*/ boolean loading = Files.exists(stateDumpPath); if (loading) { transport = new TIOStreamTransport(filesystem.newFileInputStream(stateDumpPath)); } else { transport = new TIOStreamTransport(filesystem.newFileOutputStream(stateDumpPath)); } transport = new TZlibTransport(transport); TProtocol protocol = new TTupleProtocol(transport); try { DistributedBuildTypeCoercerFactory typeCoercerFactory = new DistributedBuildTypeCoercerFactory( params.getObjectMapper()); ParserTargetNodeFactory<TargetNode<?>> parserTargetNodeFactory = DefaultParserTargetNodeFactory .createForDistributedBuild(new ConstructorArgMarshaller(typeCoercerFactory), new TargetNodeFactory(typeCoercerFactory)); DistributedBuildTargetGraphCodec targetGraphCodec = new DistributedBuildTargetGraphCodec( params.getObjectMapper(), parserTargetNodeFactory, new Function<TargetNode<?>, Map<String, Object>>() { @Nullable @Override public Map<String, Object> apply(TargetNode<?> input) { try { return params.getParser().getRawTargetNode(params.getBuckEventBus(), params.getCell().getCell(input.getBuildTarget()), /* enableProfiling */ false, executorService, input); } catch (BuildFileParseException | InterruptedException e) { throw new RuntimeException(e); } } }); if (loading) { DistributedBuildState state = DistributedBuildState.load(protocol, params.getCell()); final TargetGraph targetGraph = state.createTargetGraph(targetGraphCodec); ActionGraphAndResolver actionGraphAndResolver = Preconditions .checkNotNull(params.getActionGraphCache().getActionGraph(params.getBuckEventBus(), /* checkActionGraphs */ false, targetGraph, params.getBuckConfig().getKeySeed())); BuckConfig rootCellBuckConfig = state.getRootCell().getBuckConfig(); DistributedCachingBuildEngineDelegate cachingBuildEngineDelegate = new DistributedCachingBuildEngineDelegate( new SourcePathResolver(actionGraphAndResolver.getResolver()), state); // TODO(ruibm, marcinkosiba): This is incorrect, we probably need rule-level control // over what gets built. ImmutableList<TargetNodeSpec> targetNodeSpecs = parseArgumentsAsTargetNodeSpecs( rootCellBuckConfig, getArguments()); FluentIterable<BuildTarget> targetsToBuild = FluentIterable.from(targetNodeSpecs) .transformAndConcat(new Function<TargetNodeSpec, Iterable<BuildTarget>>() { @Override public Iterable<BuildTarget> apply(TargetNodeSpec input) { return input.filter(targetGraph.getNodes()).keySet(); } }); return executeBuild(params, actionGraphAndResolver, executorService, params.getArtifactCache(), cachingBuildEngineDelegate, rootCellBuckConfig, targetsToBuild); } else { TargetGraphAndBuildTargets targetGraphAndBuildTargets = createTargetGraph(params, executorService); ActionGraphAndResolver actionGraphAndResolver = createActionGraphAndResolver(params, targetGraphAndBuildTargets); DistributedBuildCellIndexer cellIndexer = new DistributedBuildCellIndexer(params.getCell()); DistributedBuildFileHashes distributedBuildFileHashes = new DistributedBuildFileHashes( actionGraphAndResolver.getActionGraph(), new SourcePathResolver(actionGraphAndResolver.getResolver()), params.getFileHashCache(), cellIndexer, executorService, params.getBuckConfig().getKeySeed()); BuildJobState jobState = DistributedBuildState.dump(cellIndexer, distributedBuildFileHashes, targetGraphCodec, targetGraphAndBuildTargets.getTargetGraph()); jobState.write(protocol); transport.flush(); return 0; } } catch (TException e) { throw new RuntimeException(e); } finally { transport.close(); } } DistBuildConfig config = new DistBuildConfig(params.getBuckConfig()); ClientSideSlb slb = config.getFrontendConfig().createHttpClientSideSlb(params.getClock(), params.getBuckEventBus(), new CommandThreadFactory("BuildCommand.HttpLoadBalancer")); OkHttpClient client = config.createOkHttpClient(); try (HttpService httpService = new LoadBalancedService(slb, client, params.getBuckEventBus()); ThriftService<FrontendRequest, FrontendResponse> service = new ThriftOverHttpService<>( ThriftOverHttpServiceConfig.of(httpService))) { DistributedBuild build = new DistributedBuild(new DistBuildService(service, params.getBuckEventBus())); return build.executeAndPrintFailuresToEventBus(); } }
From source file:lizard.comms.thrift.ThriftLib.java
License:Apache License
/** Choose the wire-representation : compact is the normal choice */ public static TProtocol protocol(TTransport transport) { if (true)//from w ww. ja v a 2 s.c o m return new TCompactProtocol(transport); if (false) return new TBinaryProtocol(transport); if (false) return new TTupleProtocol(transport); if (false) return new TJSONProtocol(transport); throw new InternalErrorException("No protocol impl choosen"); }
From source file:org.apache.jena.riot.thrift.TRDF.java
License:Apache License
public static TProtocol protocol(TTransport transport) { if (true)/*from w w w . ja v a 2 s . c o m*/ return new TCompactProtocol(transport); // Keep the warnings down. if (false) return new TTupleProtocol(transport); if (false) return new TJSONProtocol(transport); throw new RiotThriftException("No protocol impl choosen"); }