fixed broken multi-node cloning due to missing synchronized keyword on NodeCreator. changed name of masterscache to mastersloadingcache. changed jetty port to a non common one. checked null on finally block

This commit is contained in:
David Ribeiro Alves 2012-03-15 02:20:31 +00:00
parent 1036c7a0f1
commit 78d85fc960
7 changed files with 11 additions and 14 deletions

View File

@ -78,7 +78,7 @@ public class VirtualBoxPropertiesBuilder extends PropertiesBuilder {
properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor); properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor);
properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:8080/src/test/resources/preseed.cfg"); properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/src/test/resources/preseed.cfg");
return properties; return properties;
} }

View File

@ -70,7 +70,7 @@ import org.jclouds.virtualbox.functions.IMachineToHardware;
import org.jclouds.virtualbox.functions.IMachineToImage; import org.jclouds.virtualbox.functions.IMachineToImage;
import org.jclouds.virtualbox.functions.IMachineToNodeMetadata; import org.jclouds.virtualbox.functions.IMachineToNodeMetadata;
import org.jclouds.virtualbox.functions.IMachineToSshClient; import org.jclouds.virtualbox.functions.IMachineToSshClient;
import org.jclouds.virtualbox.functions.MastersCache; import org.jclouds.virtualbox.functions.MastersLoadingCache;
import org.jclouds.virtualbox.functions.NodeCreator; import org.jclouds.virtualbox.functions.NodeCreator;
import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig; import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
import org.jclouds.virtualbox.functions.admin.FileDownloadFromURI; import org.jclouds.virtualbox.functions.admin.FileDownloadFromURI;
@ -141,7 +141,7 @@ public class VirtualBoxComputeServiceContextModule extends
}).to((Class) YamlImagesFromFileConfig.class); }).to((Class) YamlImagesFromFileConfig.class);
// the master machines cache // the master machines cache
bind(new TypeLiteral<LoadingCache<Image, Master>>() { bind(new TypeLiteral<LoadingCache<Image, Master>>() {
}).to((Class) MastersCache.class); }).to((Class) MastersLoadingCache.class);
// the master creating function // the master creating function
bind(new TypeLiteral<Function<MasterSpec, IMachine>>() { bind(new TypeLiteral<Function<MasterSpec, IMachine>>() {
}).to((Class) CreateAndInstallVm.class); }).to((Class) CreateAndInstallVm.class);

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.virtualbox.functions; package org.jclouds.virtualbox.functions;
import static org.jclouds.scriptbuilder.domain.Statements.call;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Iterables.transform;
@ -29,9 +28,6 @@ import javax.annotation.Resource;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
@ -51,8 +47,6 @@ import com.google.common.base.Predicate;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject; import com.google.inject.Inject;
@Singleton @Singleton
@ -113,6 +107,7 @@ public class CreateAndInstallVm implements Function<MasterSpec, IMachine> {
configureOsInstallationWithKeyboardSequence(vmName, configureOsInstallationWithKeyboardSequence(vmName,
installationKeySequence); installationKeySequence);
SshClient client = sshClientForIMachine.apply(vm); SshClient client = sshClientForIMachine.apply(vm);
logger.debug(">> awaiting installation to finish node(%s)", vmName); logger.debug(">> awaiting installation to finish node(%s)", vmName);

View File

@ -74,7 +74,7 @@ import com.google.common.collect.Maps;
* *
*/ */
@Singleton @Singleton
public class MastersCache extends AbstractLoadingCache<Image, Master> { public class MastersLoadingCache extends AbstractLoadingCache<Image, Master> {
// TODO parameterize // TODO parameterize
public static final int MASTER_PORT = 2222; public static final int MASTER_PORT = 2222;
@ -94,7 +94,7 @@ public class MastersCache extends AbstractLoadingCache<Image, Master> {
private String version; private String version;
@Inject @Inject
public MastersCache(@Named(Constants.PROPERTY_BUILD_VERSION) String version, public MastersLoadingCache(@Named(Constants.PROPERTY_BUILD_VERSION) String version,
@Named(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE) String installationKeySequence, @Named(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE) String installationKeySequence,
@Named(VIRTUALBOX_WORKINGDIR) String workingDir, Function<MasterSpec, IMachine> masterLoader, @Named(VIRTUALBOX_WORKINGDIR) String workingDir, Function<MasterSpec, IMachine> masterLoader,
Supplier<Map<Image, YamlImage>> yamlMapper, Supplier<VirtualBoxManager> manager, Supplier<Map<Image, YamlImage>> yamlMapper, Supplier<VirtualBoxManager> manager,

View File

@ -95,7 +95,7 @@ public class NodeCreator implements Function<NodeSpec, NodeAndInitialCredentials
} }
@Override @Override
public NodeAndInitialCredentials<IMachine> apply(NodeSpec nodeSpec) { public synchronized NodeAndInitialCredentials<IMachine> apply(NodeSpec nodeSpec) {
checkNotNull(nodeSpec, "NodeSpec"); checkNotNull(nodeSpec, "NodeSpec");

View File

@ -71,9 +71,11 @@ public class TakeSnapshotIfNotAlreadyAttached implements Function<IMachine, ISna
Throwables.propagate(e); Throwables.propagate(e);
assert false; assert false;
} finally { } finally {
if (session != null) {
session.unlockMachine(); session.unlockMachine();
} }
} }
}
return machine.getCurrentSnapshot(); return machine.getCurrentSnapshot();
} }

View File

@ -66,7 +66,7 @@ public class VirtualBoxExperimentLiveTest {
@Test @Test
public void testLaunchCluster() throws RunNodesException { public void testLaunchCluster() throws RunNodesException {
int numNodes = 1; int numNodes = 4;
final String clusterName = "test-launch-cluster"; final String clusterName = "test-launch-cluster";
Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(clusterName, numNodes, Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(clusterName, numNodes,
TemplateOptions.Builder.runScript(AdminAccess.standard())); TemplateOptions.Builder.runScript(AdminAccess.standard()));