@Test public void shouldRetrieveANodeEvenWithAnEmptyPool() throws NodeNotCreatedException { int N = 5; IdlePool pool = IdlePoolFactory.getCleanInstance(CloudConfiguration.getCloudConfigurationInstance(), N, POOL_THRESHOLD); CloudNode node = pool.retriveNode(); assertNotNull(node); assertNotNull(node.getId()); assertFalse(node.getId().isEmpty()); }
public CloudNode retriveNode() throws NodeNotCreatedException { if (idleNodes.isEmpty()) { VMCreator vmCreator = new VMCreator(); vmCreator.run(); if (!vmCreator.ok) { throw new NodeNotCreatedException(""); } } synchronized (this) { CloudNode node = idleNodes.iterator().next(); idleNodes.remove(node); adaptPoolSize(); return node; } }
IdlePool { public CloudNode retriveNode() throws NodeNotCreatedException { if (idleNodes.isEmpty()) { VMCreator vmCreator = new VMCreator(); vmCreator.run(); if (!vmCreator.ok) { throw new NodeNotCreatedException(""); } } synchronized (this) { CloudNode node = idleNodes.iterator().next(); idleNodes.remove(node); adaptPoolSize(); return node; } } }
IdlePool { public CloudNode retriveNode() throws NodeNotCreatedException { if (idleNodes.isEmpty()) { VMCreator vmCreator = new VMCreator(); vmCreator.run(); if (!vmCreator.ok) { throw new NodeNotCreatedException(""); } } synchronized (this) { CloudNode node = idleNodes.iterator().next(); idleNodes.remove(node); adaptPoolSize(); return node; } } IdlePool(CloudConfiguration cloudConfiguration, int poolSize, int threshold); }
IdlePool { public CloudNode retriveNode() throws NodeNotCreatedException { if (idleNodes.isEmpty()) { VMCreator vmCreator = new VMCreator(); vmCreator.run(); if (!vmCreator.ok) { throw new NodeNotCreatedException(""); } } synchronized (this) { CloudNode node = idleNodes.iterator().next(); idleNodes.remove(node); adaptPoolSize(); return node; } } IdlePool(CloudConfiguration cloudConfiguration, int poolSize, int threshold); int getSize(); int getThreshold(); CloudNode retriveNode(); void createExtraVMs(int howManyVMs); boolean isFull(); void fillPool(); void emptyPool(); }
IdlePool { public CloudNode retriveNode() throws NodeNotCreatedException { if (idleNodes.isEmpty()) { VMCreator vmCreator = new VMCreator(); vmCreator.run(); if (!vmCreator.ok) { throw new NodeNotCreatedException(""); } } synchronized (this) { CloudNode node = idleNodes.iterator().next(); idleNodes.remove(node); adaptPoolSize(); return node; } } IdlePool(CloudConfiguration cloudConfiguration, int poolSize, int threshold); int getSize(); int getThreshold(); CloudNode retriveNode(); void createExtraVMs(int howManyVMs); boolean isFull(); void fillPool(); void emptyPool();  }