use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.
the class Fabric8Container method start.
@Override
public void start() throws LifecycleException {
// lets kill any containers that are running before we start
FabricAssertions.killJavaAndDockerProcesses();
fabricControllerManager = createFabricControllerManager();
Fabric8ContainerConfiguration config = configuration.get();
config.configure(fabricControllerManager);
try {
FabricController fabricController = FabricAssertions.assertFabricCreate(fabricControllerManager);
controller.set(fabricController);
} catch (Exception e) {
throw new LifecycleException("Failed to create fabric: " + e, e);
}
System.out.println("Created a controller " + controller.get());
}
use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.
the class ProxyServlet method init.
/**
* Initialize the <code>ProxyServlet</code>
*
* @param config The Servlet configuration passed in by the servlet container
*/
@Override
public void init(ServletConfig config) throws ServletException {
HttpProxyRuleBase ruleBase = new HttpProxyRuleBase();
loadRuleBase(config, ruleBase);
resolver.setMappingRules(ruleBase);
Protocol.registerProtocol("http", new Protocol("http", new NonBindingSocketFactory(), 80));
Protocol.registerProtocol("https", new Protocol("https", new NonBindingSocketFactory(), 443));
}
use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.
the class Log4jLogQuery method loadCoords.
protected String loadCoords(String coords, String filePath, String classifier) throws IOException {
String[] split = coords.split("/");
if (split != null && split.length > 2) {
String groupId = split[0];
String artifactId = split[1];
String version = split[2];
if (resolver == null) {
Properties defaultProperties = getDefaultProperties();
Properties systemProperties = System.getProperties();
if (config == null) {
Properties combined = new Properties();
combined.putAll(defaultProperties);
combined.putAll(systemProperties);
if (properties != null) {
combined.putAll(properties);
}
config = new MavenConfigurationImpl(new PropertiesPropertyResolver(combined), ServiceConstants.PID);
}
resolver = new AetherBasedResolver(config);
}
File file = resolver.resolveFile(groupId, artifactId, classifier, "jar", version);
if (file.exists() && file.isFile()) {
if (isRoot(filePath)) {
return jarIndex(file);
}
String fileUri = file.toURI().toString();
URL url = new URL("jar:" + fileUri + "!" + filePath);
return loadString(url);
}
}
return null;
}
use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.
the class ServiceFactoryTest method testDiscoveryOnRestartCurator.
@Test
public void testDiscoveryOnRestartCurator() throws Exception {
underTest = new ActiveMQServiceFactory();
underTest.curator = curator;
Properties props = new Properties();
props.put("config", "amq.xml");
props.put("broker-name", "amq");
props.put("group", "amq");
props.put("connectors", "openwire");
props.put("openwire-port", "0");
props.put("container.ip", "localhost");
underTest.updated("b", props);
final AtomicReference<CuratorFramework> curatorFrameworkAtomicReference = new AtomicReference<>(curator);
OsgiFabricDiscoveryAgent osgiFabricDiscoveryAgent = new OsgiFabricDiscoveryAgent(new BundleContext() {
@Override
public String getProperty(String s) {
return null;
}
@Override
public Bundle getBundle() {
return null;
}
@Override
public Bundle installBundle(String s, InputStream inputStream) throws BundleException {
return null;
}
@Override
public Bundle installBundle(String s) throws BundleException {
return null;
}
@Override
public Bundle getBundle(long l) {
return null;
}
@Override
public Bundle[] getBundles() {
return new Bundle[0];
}
@Override
public void addServiceListener(ServiceListener serviceListener, String s) throws InvalidSyntaxException {
}
@Override
public void addServiceListener(ServiceListener serviceListener) {
}
@Override
public void removeServiceListener(ServiceListener serviceListener) {
}
@Override
public void addBundleListener(BundleListener bundleListener) {
}
@Override
public void removeBundleListener(BundleListener bundleListener) {
}
@Override
public void addFrameworkListener(FrameworkListener frameworkListener) {
}
@Override
public void removeFrameworkListener(FrameworkListener frameworkListener) {
}
@Override
public ServiceRegistration<?> registerService(String[] strings, Object o, Dictionary<String, ?> dictionary) {
return null;
}
@Override
public ServiceRegistration<?> registerService(String s, Object o, Dictionary<String, ?> dictionary) {
return null;
}
@Override
public <S> ServiceRegistration<S> registerService(Class<S> aClass, S s, Dictionary<String, ?> dictionary) {
return null;
}
@Override
public ServiceReference<?>[] getServiceReferences(String s, String s1) throws InvalidSyntaxException {
return new ServiceReference<?>[0];
}
@Override
public ServiceReference<?>[] getAllServiceReferences(String s, String s1) throws InvalidSyntaxException {
return new ServiceReference<?>[0];
}
@Override
public ServiceReference<?> getServiceReference(String s) {
return null;
}
@Override
public <S> ServiceReference<S> getServiceReference(Class<S> aClass) {
return null;
}
@Override
public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> aClass, String s) throws InvalidSyntaxException {
return null;
}
@Override
public <S> S getService(ServiceReference<S> serviceReference) {
return (S) curatorFrameworkAtomicReference.get();
}
@Override
public boolean ungetService(ServiceReference<?> serviceReference) {
return false;
}
@Override
public File getDataFile(String s) {
return null;
}
@Override
public Filter createFilter(String s) throws InvalidSyntaxException {
return null;
}
@Override
public Bundle getBundle(String s) {
return null;
}
});
final LinkedBlockingQueue<DiscoveryEvent> discoveryEvents = new LinkedBlockingQueue<DiscoveryEvent>(10);
osgiFabricDiscoveryAgent.setDiscoveryListener(new DiscoveryListener() {
@Override
public void onServiceAdd(DiscoveryEvent discoveryEvent) {
discoveryEvents.offer(discoveryEvent);
}
@Override
public void onServiceRemove(DiscoveryEvent discoveryEvent) {
}
});
// will call into dummy bundle and get curator
osgiFabricDiscoveryAgent.addingService(null);
osgiFabricDiscoveryAgent.setGroupName("amq");
osgiFabricDiscoveryAgent.start();
DiscoveryEvent event = discoveryEvents.poll(5, TimeUnit.SECONDS);
LOG.info("event: " + event);
assertNotNull("got added service", event);
underTest.deleted("b");
// swap curator ref
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString("localhost:" + zkPort).sessionTimeoutMs(15000).retryPolicy(new RetryNTimes(5000, 1000));
curator = builder.build();
LOG.debug("Starting new curator " + curator);
curator.start();
curatorFrameworkAtomicReference.get().close();
curatorFrameworkAtomicReference.set(curator);
// will call into dummy bundle and get new curator ref
osgiFabricDiscoveryAgent.addingService(null);
// start broker again
underTest.curator = curator;
underTest.updated("b", props);
event = discoveryEvents.poll(5, TimeUnit.SECONDS);
LOG.info("new event: " + event);
assertNotNull("got newly added service", event);
underTest.deleted("b");
}
use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.
the class DeploymentAgentTest method testFeatureRepoResolution.
@Test
@SuppressWarnings("unchecked")
public void testFeatureRepoResolution() throws Exception {
CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning");
// We are just want to use a feature repository that is not part of the distribution.
CommandSupport.executeCommand("fabric:profile-create --parent feature-camel test-profile");
CommandSupport.executeCommand("fabric:version-create --parent 1.0 1.1");
CommandSupport.executeCommand("fabric:profile-edit --repository mvn:io.fabric8.examples.fabric-camel-dosgi/features/" + System.getProperty("fabric.version") + "/xml/features test-profile 1.1");
CommandSupport.executeCommand("fabric:profile-edit --feature fabric-dosgi test-profile 1.1");
// We remove all repositories from agent config but the maven central to rely on the fabric-maven-proxy.
// Also remove local repository
CommandSupport.executeCommand("fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repo1.maven.org/maven2@id=m2central default 1.1");
CommandSupport.executeCommand("fabric:profile-edit --pid test-profile 1.1");
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
Set<Container> containers = ContainerBuilder.create().withName("smoke_cnt_a").withProfiles("test-profile").assertProvisioningResult().build(fabricService);
try {
// We want to remove all repositories from fabric-agent.
for (Container container : containers) {
CommandSupport.executeCommand("fabric:container-upgrade 1.1 " + container.getId());
System.out.flush();
}
ProvisionSupport.provisioningSuccess(containers, ProvisionSupport.PROVISION_TIMEOUT);
CommandSupport.executeCommand("fabric:container-list");
for (Container container : containers) {
CommandSupport.executeCommand("fabric:container-connect -u admin -p admin " + container.getId() + " osgi:list");
CommandSupport.executeCommand("fabric:container-connect -u admin -p admin " + container.getId() + " config:proplist --pid org.ops4j.pax.url.mvn");
System.out.flush();
}
} finally {
ContainerBuilder.stop(fabricService, containers);
}
} finally {
fabricProxy.close();
}
}
Aggregations