@Test public void testBootDelay() { double delta = 0.1; DescriptiveStatistics stat = new DescriptiveStatistics(); VMex vmex = new VMex("TEST_VM", 2, 3, 4, 5, 6, 7, "vmm", null); vmex.getMetadata().setType("hs1.8xlarge"); vmex.getMetadata().setOS(NIX_OS); assertEquals(DEFAULT_DELAY, bootDelay.getDelay(vmex), delta); stat.clear(); vmex.getMetadata().setType("c1.medium"); for (int i = 0; i < 10_000; i++) { stat.addValue(bootDelay.getDelay(vmex)); } assertEquals(90.0, stat.getMean(), delta); assertEquals(2.0, stat.getStandardDeviation(), delta); stat.clear(); vmex.getMetadata().setType("t1.micro"); for (int i = 0; i < 10_000; i++) { stat.addValue(bootDelay.getDelay(vmex)); } assertEquals(55.0, stat.getMean(), delta); assertEquals(3.0, stat.getStandardDeviation(), delta); stat.clear(); vmex.getMetadata().setOS(WINDOWS); for (int i = 0; i < 10_000; i++) { stat.addValue(bootDelay.getDelay(vmex)); } assertEquals(810.2, stat.getMean(), delta); assertEquals(10.0, stat.getStandardDeviation(), delta); }
@Override public double getDelay(final Vm vm) { double result = defaultValue; if (vm instanceof VMex) { VMex vmex = (VMex) vm; NumberGenerator<Double> gaussianGenerator = null; Pair<String, String> key = BaseCustomerVmBillingPolicy.keyOf(vmex); Pair<String, String> partialKey1 = ImmutablePair.of(vmex.getMetadata().getType(), (String) null); Pair<String, String> partialKey2 = ImmutablePair.of((String) null, vmex.getMetadata().getOS()); if (delayGenerators.containsKey(key)) { gaussianGenerator = delayGenerators.get(key); } else if (delayGenerators.containsKey(partialKey1)) { gaussianGenerator = delayGenerators.get(partialKey1); } else if (delayGenerators.containsKey(partialKey2)) { gaussianGenerator = delayGenerators.get(partialKey2); } if (gaussianGenerator != null) { result = gaussianGenerator.nextValue(); } } return result; }
GaussianByTypeBootDelay implements IVMBootDelayDistribution { @Override public double getDelay(final Vm vm) { double result = defaultValue; if (vm instanceof VMex) { VMex vmex = (VMex) vm; NumberGenerator<Double> gaussianGenerator = null; Pair<String, String> key = BaseCustomerVmBillingPolicy.keyOf(vmex); Pair<String, String> partialKey1 = ImmutablePair.of(vmex.getMetadata().getType(), (String) null); Pair<String, String> partialKey2 = ImmutablePair.of((String) null, vmex.getMetadata().getOS()); if (delayGenerators.containsKey(key)) { gaussianGenerator = delayGenerators.get(key); } else if (delayGenerators.containsKey(partialKey1)) { gaussianGenerator = delayGenerators.get(partialKey1); } else if (delayGenerators.containsKey(partialKey2)) { gaussianGenerator = delayGenerators.get(partialKey2); } if (gaussianGenerator != null) { result = gaussianGenerator.nextValue(); } } return result; } }
GaussianByTypeBootDelay implements IVMBootDelayDistribution { @Override public double getDelay(final Vm vm) { double result = defaultValue; if (vm instanceof VMex) { VMex vmex = (VMex) vm; NumberGenerator<Double> gaussianGenerator = null; Pair<String, String> key = BaseCustomerVmBillingPolicy.keyOf(vmex); Pair<String, String> partialKey1 = ImmutablePair.of(vmex.getMetadata().getType(), (String) null); Pair<String, String> partialKey2 = ImmutablePair.of((String) null, vmex.getMetadata().getOS()); if (delayGenerators.containsKey(key)) { gaussianGenerator = delayGenerators.get(key); } else if (delayGenerators.containsKey(partialKey1)) { gaussianGenerator = delayGenerators.get(partialKey1); } else if (delayGenerators.containsKey(partialKey2)) { gaussianGenerator = delayGenerators.get(partialKey2); } if (gaussianGenerator != null) { result = gaussianGenerator.nextValue(); } } return result; } GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final double defaultVal);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final SeedGenerator seedGen);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed,
            final double defaultVal);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final SeedGenerator seedGen, final double defaultVal); private  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed,
            SeedGenerator seedGen, final double defaultVal); }
GaussianByTypeBootDelay implements IVMBootDelayDistribution { @Override public double getDelay(final Vm vm) { double result = defaultValue; if (vm instanceof VMex) { VMex vmex = (VMex) vm; NumberGenerator<Double> gaussianGenerator = null; Pair<String, String> key = BaseCustomerVmBillingPolicy.keyOf(vmex); Pair<String, String> partialKey1 = ImmutablePair.of(vmex.getMetadata().getType(), (String) null); Pair<String, String> partialKey2 = ImmutablePair.of((String) null, vmex.getMetadata().getOS()); if (delayGenerators.containsKey(key)) { gaussianGenerator = delayGenerators.get(key); } else if (delayGenerators.containsKey(partialKey1)) { gaussianGenerator = delayGenerators.get(partialKey1); } else if (delayGenerators.containsKey(partialKey2)) { gaussianGenerator = delayGenerators.get(partialKey2); } if (gaussianGenerator != null) { result = gaussianGenerator.nextValue(); } } return result; } GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final double defaultVal);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final SeedGenerator seedGen);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed,
            final double defaultVal);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final SeedGenerator seedGen, final double defaultVal); private  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed,
            SeedGenerator seedGen, final double defaultVal); @Override double getDelay(final Vm vm); }
GaussianByTypeBootDelay implements IVMBootDelayDistribution { @Override public double getDelay(final Vm vm) { double result = defaultValue; if (vm instanceof VMex) { VMex vmex = (VMex) vm; NumberGenerator<Double> gaussianGenerator = null; Pair<String, String> key = BaseCustomerVmBillingPolicy.keyOf(vmex); Pair<String, String> partialKey1 = ImmutablePair.of(vmex.getMetadata().getType(), (String) null); Pair<String, String> partialKey2 = ImmutablePair.of((String) null, vmex.getMetadata().getOS()); if (delayGenerators.containsKey(key)) { gaussianGenerator = delayGenerators.get(key); } else if (delayGenerators.containsKey(partialKey1)) { gaussianGenerator = delayGenerators.get(partialKey1); } else if (delayGenerators.containsKey(partialKey2)) { gaussianGenerator = delayGenerators.get(partialKey2); } if (gaussianGenerator != null) { result = gaussianGenerator.nextValue(); } } return result; } GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final double defaultVal);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final SeedGenerator seedGen);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed,
            final double defaultVal);  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs,
            final SeedGenerator seedGen, final double defaultVal); private  GaussianByTypeBootDelay(final Map<Pair<String, String>, Pair<Double, Double>> delayDefs, final byte[] seed,
            SeedGenerator seedGen, final double defaultVal); @Override double getDelay(final Vm vm);  }