@Override public boolean apply(Hardware input) { return getSpace(input) >= TemplateBuilderImpl.this.minDisk; }
@Override public boolean apply(Hardware input) { return getSpace(input) >= TemplateBuilderImpl.this.minDisk; }
@Override public String apply(Hardware hardware) { if (hardware.getRam() >= 8 * 1024 || getCores(hardware) >= 6 || getSpace(hardware) >= 450) return "8GB"; if (hardware.getRam() >= 4 * 1024 || getCores(hardware) >= 3 || getSpace(hardware) >= 230) return "4GB"; if (hardware.getRam() >= 2 * 1024 || getSpace(hardware) >= 110) return "2GB"; if (hardware.getRam() >= 1024 || getSpace(hardware) >= 55) return "1GB"; return "512MB"; /* smallest */ } };
/** * {@inheritDoc} */ @Override public int compareTo(ResourceMetadata<ComputeType> that) { if (that instanceof Hardware) { Hardware thatHardware = Hardware.class.cast(that); return ComparisonChain.start().compare(getCores(this), getCores(thatHardware)).compare(this.getRam(), thatHardware.getRam()) .compare(getSpace(this), getSpace(thatHardware)).result(); } else { return super.compareTo(that); } }
/** * {@inheritDoc} */ @Override public int compareTo(ResourceMetadata<ComputeType> that) { if (that instanceof Hardware) { Hardware thatHardware = Hardware.class.cast(that); return ComparisonChain.start().compare(getCores(this), getCores(thatHardware)).compare(this.getRam(), thatHardware.getRam()) .compare(getSpace(this), getSpace(thatHardware)).result(); } else { return super.compareTo(that); } }
/** * {@inheritDoc} */ @Override public int compareTo(ResourceMetadata<ComputeType> that) { if (that instanceof Hardware) { Hardware thatHardware = Hardware.class.cast(that); return ComparisonChain.start().compare(getCores(this), getCores(thatHardware)).compare(this.getRam(), thatHardware.getRam()) .compare(getSpace(this), getSpace(thatHardware)).result(); } else { return super.compareTo(that); } }
@Override public boolean apply(Hardware input) { return input.getRam() == machineInDatacenter.get().getMemorySizeMb() && getSpace(input) == machineInDatacenter.get().getDiskSizeGb() && input.getLocation().getId().equals(machineInDatacenter.getDatacenter()); } }).orNull();
@Override public boolean apply(Hardware input) { return input.getRam() == machineInDatacenter.get().getMemorySizeMb() && getSpace(input) == machineInDatacenter.get().getDiskSizeGb() && input.getLocation().getId().equals(machineInDatacenter.getDatacenter()); } }).orNull();
@Override public boolean apply(Hardware input) { return input.getRam() == machineInDatacenter.get().getMemorySizeMb() && getSpace(input) == machineInDatacenter.get().getDiskSizeGb() && input.getLocation().getId().equals(machineInDatacenter.getDatacenter()); } }).orNull();
/** * {@inheritDoc} */ @Override public TemplateBuilder fromHardware(Hardware hardware) { if (currentLocationWiderThan(hardware.getLocation())) this.location = hardware.getLocation(); this.minCores = getCores(hardware); this.minRam = hardware.getRam(); this.minDisk = getSpace(hardware); this.hypervisor = hardware.getHypervisor(); return this; }
/** * {@inheritDoc} */ @Override public TemplateBuilder fromHardware(Hardware hardware) { if (currentLocationWiderThan(hardware.getLocation())) this.location = hardware.getLocation(); this.minCores = getCores(hardware); this.minRam = hardware.getRam(); this.minDisk = getSpace(hardware); this.hypervisor = hardware.getHypervisor(); return this; }
@Test public void testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testBiggestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 16); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1 * 1024); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testBiggestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), MAX_RAM); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); assertEquals(defaultTemplate.getHardware().getRam(), 1); assertEquals(getSpace(defaultTemplate.getHardware()), 25.0d); assertEquals(defaultTemplate.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); // test that we bound the correct templateoptions in guice assertEquals(defaultTemplate.getOptions().getClass(), SoftLayerTemplateOptions.class); }