Package org.apache.twill.internal

Examples of org.apache.twill.internal.DefaultResourceSpecification


    public final class Done extends Build {
    }

    public abstract class Build {
      public ResourceSpecification build() {
        return new DefaultResourceSpecification(cores, memory, instances, uplink, downlink, hosts, racks);
      }
View Full Code Here


                    "\"downlink\":100," +
                    "\"hosts\":[\"one1\",\"two2\"]," +
                    "\"racks\":[\"three3\"]" +
            "}";
    final ResourceSpecification expected =
            new DefaultResourceSpecification(2, 1024, 2, 100, 100,
                    Arrays.asList("one1", "two2"), Arrays.asList("three3"));
    final String actualString = gson.toJson(expected);
    Assert.assertEquals(expectedString, actualString);

    final JsonElement expectedJson = gson.toJsonTree(expected);
View Full Code Here

            .setUplink(10, ResourceSpecification.SizeUnit.GIGA)
            .setDownlink(5, ResourceSpecification.SizeUnit.GIGA)
            .setHosts("a1", "b2", "c3")
            .setRacks("r2")
            .build();
    final DefaultResourceSpecification expected =
            new DefaultResourceSpecification(5, 4096, 3, 10240, 5120,
                    Arrays.asList("a1", "b2", "c3"), Arrays.asList("r2"));
    ReflectionAssert.assertLenientEquals(expected, actual);
  }
View Full Code Here

            .setUplink(10, ResourceSpecification.SizeUnit.GIGA)
            .setDownlink(5, ResourceSpecification.SizeUnit.GIGA)
            .setHosts(Arrays.asList("a1", "b2", "c3"))
            .setRacks(Arrays.asList("r2"))
            .build();
    final DefaultResourceSpecification expected =
            new DefaultResourceSpecification(5, 4096, 3, 10240, 5120,
                    Arrays.asList("a1", "b2", "c3"), Arrays.asList("r2"));
    ReflectionAssert.assertLenientEquals(expected, actual);
  }
View Full Code Here

                    "\"downlink\":100," +
                    "\"hosts\":[\"one1\",\"two2\"]," +
                    "\"racks\":[\"three3\"]" +
            "}";
    final ResourceSpecification expected =
            new DefaultResourceSpecification(2, 1024, 2, 100, 100,
                    Arrays.asList("one1", "two2"), Arrays.asList("three3"));
    final String actualString = gson.toJson(expected);
    Assert.assertEquals(expectedString, actualString);

    final JsonElement expectedJson = gson.toJsonTree(expected);
View Full Code Here

            .setUplink(10, ResourceSpecification.SizeUnit.GIGA)
            .setDownlink(5, ResourceSpecification.SizeUnit.GIGA)
            .setHosts("a1", "b2", "c3")
            .setRacks("r2")
            .build();
    final DefaultResourceSpecification expected =
            new DefaultResourceSpecification(5, 4096, 3, 10240, 5120,
                    Arrays.asList("a1", "b2", "c3"), Arrays.asList("r2"));
    ReflectionAssert.assertLenientEquals(expected, actual);
  }
View Full Code Here

            .setUplink(10, ResourceSpecification.SizeUnit.GIGA)
            .setDownlink(5, ResourceSpecification.SizeUnit.GIGA)
            .setHosts(Arrays.asList("a1", "b2", "c3"))
            .setRacks(Arrays.asList("r2"))
            .build();
    final DefaultResourceSpecification expected =
            new DefaultResourceSpecification(5, 4096, 3, 10240, 5120,
                    Arrays.asList("a1", "b2", "c3"), Arrays.asList("r2"));
    ReflectionAssert.assertLenientEquals(expected, actual);
  }
View Full Code Here

    public final class Done extends Build {
    }

    public abstract class Build {
      public ResourceSpecification build() {
        return new DefaultResourceSpecification(cores, memory, instances, uplink, downlink, hosts, racks);
      }
View Full Code Here

  public ResourceSpecification deserialize(JsonElement json, Type typeOfT,
                                           JsonDeserializationContext context) throws JsonParseException {
    JsonObject jsonObj = json.getAsJsonObject();
    final List<String> hosts = context.deserialize(jsonObj.getAsJsonArray("hosts"), List.class);
    final List<String> racks = context.deserialize(jsonObj.getAsJsonArray("racks"), List.class);
    return new DefaultResourceSpecification(jsonObj.get("cores").getAsInt(),
                                            jsonObj.get("memorySize").getAsInt(),
                                            jsonObj.get("instances").getAsInt(),
                                            jsonObj.get("uplink").getAsInt(),
                                            jsonObj.get("downlink").getAsInt(),
                                            hosts,
View Full Code Here

  @Override
  public ResourceSpecification deserialize(JsonElement json, Type typeOfT,
                                           JsonDeserializationContext context) throws JsonParseException {
    JsonObject jsonObj = json.getAsJsonObject();
    return new DefaultResourceSpecification(jsonObj.get("cores").getAsInt(),
                                            jsonObj.get("memorySize").getAsInt(),
                                            jsonObj.get("instances").getAsInt(),
                                            jsonObj.get("uplink").getAsInt(),
                                            jsonObj.get("downlink").getAsInt());
  }
View Full Code Here

TOP

Related Classes of org.apache.twill.internal.DefaultResourceSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.