use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class CuratorFactoryBean method getObject.
// FactoryBean interface
// -------------------------------------------------------------------------
public CuratorFramework getObject() throws Exception {
LOG.debug("Connecting to ZooKeeper on " + connectString);
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(connectString).retryPolicy(new ExponentialBackoffRetry(5, 10)).connectionTimeoutMs(getTimeout());
if (password != null && !password.isEmpty()) {
builder.aclProvider(new CuratorACLManager());
builder.authorization("digest", ("fabric:" + password).getBytes("UTF-8"));
}
this.curator = builder.build();
LOG.debug("Starting curator " + curator);
curator.start();
return curator;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class ManagerTest method testManager.
@Test
public void testManager() throws Exception {
ZKServerFactoryBean zkServerFactoryBean = null;
try {
int zooKeeperPort = getFreePort();
int serverPort = getFreePort();
zkServerFactoryBean = new ZKServerFactoryBean();
zkServerFactoryBean.setPurge(true);
zkServerFactoryBean.setClientPortAddress(new InetSocketAddress("localhost", zooKeeperPort));
zkServerFactoryBean.afterPropertiesSet();
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString("localhost:" + zooKeeperPort).retryPolicy(new RetryOneTime(1000)).connectionTimeoutMs(60000);
CuratorFramework curator = builder.build();
curator.start();
curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
BundleContext bundleContext = createMock(BundleContext.class);
ServiceRegistration registration = createMock(ServiceRegistration.class);
Manager manager = new Manager(bundleContext, curator, "tcp://localhost:" + serverPort, "localhost", TimeUnit.MINUTES.toMillis(5));
bundleContext.addServiceListener(manager, "(service.exported.interfaces=*)");
expect(bundleContext.getProperty("org.osgi.framework.uuid")).andReturn("the-framework-uuid");
expect(bundleContext.registerService(EasyMock.<String[]>anyObject(), same(manager), EasyMock.<Dictionary>same(null))).andReturn(registration);
expect(bundleContext.getServiceReferences((String) null, "(service.exported.interfaces=*)")).andReturn(null);
replay(bundleContext, registration);
manager.init();
verify(bundleContext, registration);
reset(bundleContext, registration);
BundleContext expBundleContext = createMock(BundleContext.class);
Bundle expBundle = createMock(Bundle.class);
ServiceReference reference = createMock(ServiceReference.class);
final Properties props = new Properties();
props.put(Constants.OBJECTCLASS, new String[] { ConfigurationAdmin.class.getName() });
expect(reference.getProperty(EasyMock.<String>anyObject())).andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
return props.get(EasyMock.getCurrentArguments()[0]);
}
}).anyTimes();
expect(reference.getPropertyKeys()).andReturn(props.keySet().toArray(new String[0]));
expect(reference.getBundle()).andReturn(expBundle).anyTimes();
expect(expBundle.getBundleContext()).andReturn(expBundleContext).anyTimes();
expect(expBundle.getState()).andReturn(Bundle.ACTIVE).anyTimes();
replay(bundleContext, registration, reference, expBundleContext, expBundle);
manager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, reference));
Thread.sleep(1000);
verify(bundleContext, registration, reference, expBundleContext, expBundle);
} finally {
try {
zkServerFactoryBean.destroy();
} catch (Throwable t) {
}
}
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class ContainerBuilder method prepareAsync.
public Future<Set<Container>> prepareAsync(B builder) {
BundleContext syscontext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(syscontext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
CompletionService<Set<Container>> completionService = new ExecutorCompletionService<Set<Container>>(executorService);
return completionService.submit(new CreateContainerTask(fabricService, builder));
} finally {
fabricProxy.close();
}
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class ContainerBuilder method buildInternal.
private Set<ContainerProxy> buildInternal(Collection<B> buildersList) {
Set<ContainerProxy> containers = new HashSet<ContainerProxy>();
BundleContext bundleContext = getBundleContext();
ServiceLocator.awaitService(getBundleContext(), FabricComplete.class);
synchronizeGitRepositories();
FabricService fabricService = fabricServiceServiceProxy.getService();
CompletionService<Set<ContainerProxy>> completionService = new ExecutorCompletionService<Set<ContainerProxy>>(executorService);
int tasks = 0;
for (B builder : buildersList) {
builder.profiles(profileNames);
if (!builder.isEnsembleServer()) {
builder.zookeeperUrl(fabricService.getZookeeperUrl());
CreateContainerBasicOptions options = builder.build();
ServiceLocator.awaitService(bundleContext, ContainerProvider.class, "(fabric.container.protocol=" + options.getProviderType() + ")", CREATE_TIMEOUT, TimeUnit.MILLISECONDS);
completionService.submit(new CreateContainerTask(fabricServiceServiceProxy, options));
tasks++;
}
}
try {
for (int i = 0; i < tasks; i++) {
Future<Set<ContainerProxy>> futureContainerSet = completionService.poll(CREATE_TIMEOUT, TimeUnit.MILLISECONDS);
Set<ContainerProxy> containerSet = futureContainerSet.get();
containers.addAll(containerSet);
}
try {
if (waitForProvisioning) {
Provision.containerStatus(containers, provisionTimeOut);
}
if (assertProvisioningResult) {
Provision.provisioningSuccess(containers, provisionTimeOut, ContainerCallback.DISPLAY_ALL);
}
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
return Collections.unmodifiableSet(containers);
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class ManagedContainerTest method testContainerLifecycle.
@Test
public void testContainerLifecycle() throws Exception {
ContainerConfigurationBuilder builder = ContainerConfigurationBuilder.create();
ContainerConfiguration configuration = builder.setTargetDirectory("target/managed-container").getConfiguration();
ManagedContainer<?> container = ManagedContainer.Factory.create(configuration);
Assert.assertNotNull("ManagedContainer not null", container);
try {
Assert.assertNotNull("Container home not null", container.getContainerHome());
container.start();
} finally {
container.destroy();
}
}
Aggregations