コード例 #1
0
  private static Instance getInstance(byte[] ipAddress, int dataPort, String hostname, int slots)
      throws Exception {
    HardwareDescription hardwareDescription =
        new HardwareDescription(4, 2L * 1024 * 1024 * 1024, 1024 * 1024 * 1024, 512 * 1024 * 1024);

    InstanceConnectionInfo connection = mock(InstanceConnectionInfo.class);
    when(connection.address()).thenReturn(InetAddress.getByAddress(ipAddress));
    when(connection.dataPort()).thenReturn(dataPort);
    when(connection.getInetAdress()).thenReturn(InetAddress.getByAddress(ipAddress).toString());
    when(connection.getHostname()).thenReturn(hostname);
    when(connection.getFQDNHostname()).thenReturn(hostname);

    return new Instance(taskManager, connection, new InstanceID(), hardwareDescription, slots);
  }
コード例 #2
0
  @Override
  public String handleRequest(ExecutionJobVertex jobVertex, Map<String, String> params)
      throws Exception {
    StringWriter writer = new StringWriter();
    JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);

    gen.writeStartObject();
    gen.writeStringField("id", jobVertex.getJobVertexId().toString());
    gen.writeNumberField("parallelism", jobVertex.getParallelism());

    gen.writeArrayFieldStart("subtasks");

    int num = 0;
    for (ExecutionVertex vertex : jobVertex.getTaskVertices()) {

      InstanceConnectionInfo location = vertex.getCurrentAssignedResourceLocation();
      String locationString = location == null ? "(unassigned)" : location.getHostname();

      gen.writeStartObject();

      gen.writeNumberField("subtask", num++);
      gen.writeNumberField("attempt", vertex.getCurrentExecutionAttempt().getAttemptNumber());
      gen.writeStringField("host", locationString);

      StringifiedAccumulatorResult[] accs =
          vertex.getCurrentExecutionAttempt().getUserAccumulatorsStringified();
      gen.writeArrayFieldStart("user-accumulators");
      for (StringifiedAccumulatorResult acc : accs) {
        gen.writeStartObject();
        gen.writeStringField("name", acc.getName());
        gen.writeStringField("type", acc.getType());
        gen.writeStringField("value", acc.getValue());
        gen.writeEndObject();
      }
      gen.writeEndArray();

      gen.writeEndObject();
    }
    gen.writeEndArray();

    gen.writeEndObject();
    gen.close();
    return writer.toString();
  }