use of org.apache.tez.dag.records.TezTaskAttemptID in project hive by apache.
the class TestConverters method testFragmentSpecToTaskSpec.
@Test(timeout = 10000)
public void testFragmentSpecToTaskSpec() {
ByteBuffer procBb = ByteBuffer.allocate(4);
procBb.putInt(0, 200);
ByteBuffer input1Bb = ByteBuffer.allocate(4);
input1Bb.putInt(0, 300);
ByteBuffer output1Bb = ByteBuffer.allocate(4);
output1Bb.putInt(0, 400);
ApplicationId appId = ApplicationId.newInstance(1000, 100);
TezDAGID tezDagId = TezDAGID.getInstance(appId, 300);
TezVertexID tezVertexId = TezVertexID.getInstance(tezDagId, 400);
TezTaskID tezTaskId = TezTaskID.getInstance(tezVertexId, 500);
TezTaskAttemptID tezTaskAttemptId = TezTaskAttemptID.getInstance(tezTaskId, 600);
QueryIdentifierProto queryIdentifierProto = QueryIdentifierProto.newBuilder().setApplicationIdString(appId.toString()).setAppAttemptNumber(333).setDagIndex(tezDagId.getId()).build();
SignableVertexSpec.Builder builder = SignableVertexSpec.newBuilder();
builder.setQueryIdentifier(queryIdentifierProto);
builder.setHiveQueryId("hiveQueryId");
builder.setVertexIndex(tezVertexId.getId());
builder.setDagName("dagName");
builder.setVertexName("vertexName");
builder.setProcessorDescriptor(EntityDescriptorProto.newBuilder().setClassName("fakeProcessorName").setUserPayload(UserPayloadProto.newBuilder().setUserPayload(ByteString.copyFrom(procBb))));
builder.addInputSpecs(IOSpecProto.newBuilder().setConnectedVertexName("sourceVertexName1").setPhysicalEdgeCount(33).setIoDescriptor(EntityDescriptorProto.newBuilder().setClassName("input1ClassName").setUserPayload(UserPayloadProto.newBuilder().setUserPayload(ByteString.copyFrom(input1Bb)))));
builder.addInputSpecs(IOSpecProto.newBuilder().setConnectedVertexName("sourceVertexName2").setPhysicalEdgeCount(44).setIoDescriptor(EntityDescriptorProto.newBuilder().setClassName("input1ClassName").setUserPayload(UserPayloadProto.newBuilder().setUserPayload(ByteString.copyFrom(input1Bb)))));
builder.addOutputSpecs(IOSpecProto.newBuilder().setConnectedVertexName("destVertexName1").setPhysicalEdgeCount(55).setIoDescriptor(EntityDescriptorProto.newBuilder().setClassName("outputClassName").setUserPayload(UserPayloadProto.newBuilder().setUserPayload(ByteString.copyFrom(output1Bb)))));
builder.addOutputSpecs(IOSpecProto.newBuilder().setConnectedVertexName("destVertexName2").setPhysicalEdgeCount(66).setIoDescriptor(EntityDescriptorProto.newBuilder().setClassName("outputClassName").setUserPayload(UserPayloadProto.newBuilder().setUserPayload(ByteString.copyFrom(output1Bb)))));
SignableVertexSpec vertexProto = builder.build();
TaskSpec taskSpec = Converters.getTaskSpecfromProto(vertexProto, 0, 0, tezTaskAttemptId);
assertEquals("dagName", taskSpec.getDAGName());
assertEquals("vertexName", taskSpec.getVertexName());
assertEquals(tezTaskAttemptId, taskSpec.getTaskAttemptID());
assertEquals("fakeProcessorName", taskSpec.getProcessorDescriptor().getClassName());
byte[] serialized = new byte[taskSpec.getProcessorDescriptor().getUserPayload().getPayload().remaining()];
taskSpec.getProcessorDescriptor().getUserPayload().getPayload().get(serialized);
assertArrayEquals(procBb.array(), serialized);
assertEquals(2, taskSpec.getInputs().size());
assertEquals(2, taskSpec.getOutputs().size());
verifyInputSpecAndProto(taskSpec.getInputs().get(0), vertexProto.getInputSpecs(0));
verifyInputSpecAndProto(taskSpec.getInputs().get(1), vertexProto.getInputSpecs(1));
verifyOutputSpecAndProto(taskSpec.getOutputs().get(0), vertexProto.getOutputSpecs(0));
verifyOutputSpecAndProto(taskSpec.getOutputs().get(1), vertexProto.getOutputSpecs(1));
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project hive by apache.
the class Converters method constructSignableVertexSpec.
public static SignableVertexSpec.Builder constructSignableVertexSpec(TaskSpec taskSpec, QueryIdentifierProto queryIdentifierProto, String tokenIdentifier, String user, String hiveQueryIdString) {
TezTaskAttemptID tId = taskSpec.getTaskAttemptID();
SignableVertexSpec.Builder builder = SignableVertexSpec.newBuilder();
builder.setQueryIdentifier(queryIdentifierProto);
builder.setHiveQueryId(hiveQueryIdString);
builder.setVertexIndex(tId.getTaskID().getVertexID().getId());
builder.setDagName(taskSpec.getDAGName());
builder.setVertexName(taskSpec.getVertexName());
builder.setVertexParallelism(taskSpec.getVertexParallelism());
builder.setTokenIdentifier(tokenIdentifier);
builder.setUser(user);
if (taskSpec.getProcessorDescriptor() != null) {
builder.setProcessorDescriptor(convertToProto(taskSpec.getProcessorDescriptor()));
}
if (taskSpec.getInputs() != null && !taskSpec.getInputs().isEmpty()) {
for (InputSpec inputSpec : taskSpec.getInputs()) {
builder.addInputSpecs(convertInputSpecToProto(inputSpec));
}
}
if (taskSpec.getOutputs() != null && !taskSpec.getOutputs().isEmpty()) {
for (OutputSpec outputSpec : taskSpec.getOutputs()) {
builder.addOutputSpecs(convertOutputSpecToProto(outputSpec));
}
}
if (taskSpec.getGroupInputs() != null && !taskSpec.getGroupInputs().isEmpty()) {
for (GroupInputSpec groupInputSpec : taskSpec.getGroupInputs()) {
builder.addGroupedInputSpecs(convertGroupInputSpecToProto(groupInputSpec));
}
}
return builder;
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project hive by apache.
the class Converters method getTaskSpecfromProto.
public static TaskSpec getTaskSpecfromProto(SignableVertexSpec vectorProto, int fragmentNum, int attemptNum, TezTaskAttemptID attemptId) {
TezTaskAttemptID taskAttemptID = attemptId != null ? attemptId : createTaskAttemptId(vectorProto.getQueryIdentifier(), vectorProto.getVertexIndex(), fragmentNum, attemptNum);
ProcessorDescriptor processorDescriptor = null;
if (vectorProto.hasProcessorDescriptor()) {
processorDescriptor = convertProcessorDescriptorFromProto(vectorProto.getProcessorDescriptor());
}
List<InputSpec> inputSpecList = new ArrayList<InputSpec>(vectorProto.getInputSpecsCount());
if (vectorProto.getInputSpecsCount() > 0) {
for (IOSpecProto inputSpecProto : vectorProto.getInputSpecsList()) {
inputSpecList.add(getInputSpecFromProto(inputSpecProto));
}
}
List<OutputSpec> outputSpecList = new ArrayList<OutputSpec>(vectorProto.getOutputSpecsCount());
if (vectorProto.getOutputSpecsCount() > 0) {
for (IOSpecProto outputSpecProto : vectorProto.getOutputSpecsList()) {
outputSpecList.add(getOutputSpecFromProto(outputSpecProto));
}
}
List<GroupInputSpec> groupInputSpecs = new ArrayList<GroupInputSpec>(vectorProto.getGroupedInputSpecsCount());
if (vectorProto.getGroupedInputSpecsCount() > 0) {
for (GroupInputSpecProto groupInputSpecProto : vectorProto.getGroupedInputSpecsList()) {
groupInputSpecs.add(getGroupInputSpecFromProto(groupInputSpecProto));
}
}
TaskSpec taskSpec = new TaskSpec(taskAttemptID, vectorProto.getDagName(), vectorProto.getVertexName(), vectorProto.getVertexParallelism(), processorDescriptor, inputSpecList, outputSpecList, groupInputSpecs);
return taskSpec;
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project hive by apache.
the class TestLlapTaskCommunicator method constructTaskAttemptId.
private TezTaskAttemptID constructTaskAttemptId(int id) {
TezTaskAttemptID taskAttemptId = mock(TezTaskAttemptID.class);
doReturn(id).when(taskAttemptId).getId();
return taskAttemptId;
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project hive by apache.
the class LlapTaskCommunicator method nodePinged.
void nodePinged(String hostname, String uniqueId, int port, TezAttemptArray tasks) {
// TODO: do we ever need the port? we could just do away with nodeId altogether.
LlapNodeId nodeId = LlapNodeId.getInstance(hostname, port);
registerPingingNode(nodeId);
BiMap<ContainerId, TezTaskAttemptID> biMap = entityTracker.getContainerAttemptMapForNode(nodeId);
if (biMap != null) {
HashSet<TezTaskAttemptID> attempts = new HashSet<>();
for (Writable w : tasks.get()) {
attempts.add((TezTaskAttemptID) w);
}
String error = "";
synchronized (biMap) {
for (Map.Entry<ContainerId, TezTaskAttemptID> entry : biMap.entrySet()) {
// TODO: this is a stopgap fix. We really need to change all mappings by unique node ID,
// or at least (in this case) track the latest unique ID for LlapNode and retry all
// older-node tasks proactively. For now let the heartbeats fail them.
TezTaskAttemptID attemptId = entry.getValue();
String taskNodeId = entityTracker.getUniqueNodeId(attemptId);
// Also, we prefer a missed heartbeat over a stuck query in case of discrepancy in ET.
if (taskNodeId != null && taskNodeId.equals(uniqueId)) {
if (attempts.contains(attemptId)) {
getContext().taskAlive(entry.getValue());
} else {
error += (attemptId + ", ");
}
getContext().containerAlive(entry.getKey());
}
}
}
if (!error.isEmpty()) {
LOG.info("The tasks we expected to be on the node are not there: " + error);
}
} else {
long currentTs = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
if (currentTs > nodeNotFoundLogTime.get() + 5000l) {
LOG.warn("Received ping from node without any registered tasks or containers: " + hostname + ":" + port + ". Could be caused by pre-emption by the AM," + " or a mismatched hostname. Enable debug logging for mismatched host names");
nodeNotFoundLogTime.set(currentTs);
}
}
}
Aggregations