Aggarwal-Raghav commented on code in PR #483: URL: https://github.com/apache/tez/pull/483#discussion_r3107203547
########## tez-runtime-internals/src/main/java/org/apache/tez/runtime/internals/protocolPB/TezTaskUmbilicalProtocolPBClientImpl.java: ########## @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tez.runtime.internals.protocolPB; + +import static org.apache.tez.runtime.internals.protocolPB.TezTaskUmbilicalProtocolUtils.service; + +import java.io.Closeable; +import java.io.IOException; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.ipc.ProtocolSignature; +import org.apache.hadoop.ipc.RPC; +import org.apache.tez.common.ContainerContext; +import org.apache.tez.common.ContainerTask; +import org.apache.tez.common.TezPBConverters; +import org.apache.tez.common.TezTaskUmbilicalProtocol; +import org.apache.tez.dag.api.TezException; +import org.apache.tez.dag.records.TezTaskAttemptID; +import org.apache.tez.runtime.api.impl.TezHeartbeatRequest; +import org.apache.tez.runtime.api.impl.TezHeartbeatResponse; +import org.apache.tez.runtime.internals.protocolPB.TezTaskUmbilicalProtocolProtos.CanCommitRequestProto; +import org.apache.tez.runtime.internals.protocolPB.TezTaskUmbilicalProtocolProtos.ContainerContextProto; +import org.apache.tez.runtime.internals.protocolPB.TezTaskUmbilicalProtocolProtos.GetTaskRequestProto; +import org.apache.tez.runtime.internals.protocolPB.TezTaskUmbilicalProtocolProtos.GetTaskResponseProto; +import org.apache.tez.runtime.internals.protocolPB.TezTaskUmbilicalProtocolProtos.HeartbeatRequestProto; + +/** + * Protobuf-based client implementation for the TezTaskUmbilicalProtocol. This class handles the + * translation between Java API calls and remote RPC calls. + */ +@Private +public class TezTaskUmbilicalProtocolPBClientImpl implements TezTaskUmbilicalProtocol, Closeable { + + private final TezTaskUmbilicalProtocolBlockingPB proxy; + + public TezTaskUmbilicalProtocolPBClientImpl(TezTaskUmbilicalProtocolBlockingPB proxy) { + this.proxy = proxy; + } + + @Override + public void close() throws IOException { + if (proxy != null) { + RPC.stopProxy(proxy); + } + } + + @Override + public long getProtocolVersion(String protocol, long clientVersion) throws IOException { + return service(() -> RPC.getProtocolVersion(TezTaskUmbilicalProtocolBlockingPB.class)); + } + + @Override + public ProtocolSignature getProtocolSignature( + String protocol, long clientVersion, int clientMethodsHash) throws IOException { + return ProtocolSignature.getProtocolSignature(this, protocol, clientVersion, clientMethodsHash); + } + + /** Called by the Task process to retrieve the work from the AM. */ + @Override + public ContainerTask getTask(ContainerContext containerContext) throws IOException { + return service( Review Comment: Used the same the service and translate FunctionalInterfaces for Exception wrapping as in MR -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
