Giter Club home page Giter Club logo

fabric8poc's People

Contributors

chirino avatar iocanel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

fabric8poc's Issues

Revisit ContainerIdentity in CreateOptions

Currently the user needs to define the ContainerIdentity. This does not work when a batch of containers need to be create at once. The API should use an identity prefix

With a prefix like

foo#

the system would append a unique identifier. Without trailing hash, the given prefix becomes the identity.

Use Felix SCR annotations

I think I prefer felix scr annotations mostly because they provide great metatype support, they allow annotating fields and are less ugly when it comes to annotate properties and set default values.

Since they are just used for compile time, I'd pick the ones that feel better when coding.

Use consistent package naming

Currently we have

io.fabric8.container.karaf   
io.fabric8.container.tomcat  
io.fabric8.container.wildfly     
io.fabric8.container.wildfly.connector   
io.fabric8.karaf.attributes  
io.fabric8.tomcat.attributes     
io.fabric8.wildfly.attributes

The attributes packages should move to their respective container packages (preferred). Alternatively 'container' could be dropped, which may grow confusing when more containers are added

Smoke Tests fail on Windows

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running io.fabric8.core.utils.ConfigInjectionUtilsTest
log4j:ERROR Could not read configuration file from URL [file://C:/Users/chirino/sandbox/fabric8poc/itests/smoke/embedded/src/test/resources/logging.properties].
java.net.UnknownHostException: C
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:943)
        at sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:903)
        at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:998)
        at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:984)
        at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:294)
        at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:393)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:524)
        at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
        at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
        at io.fabric8.core.utils.ConfigInjectionUtils.<clinit>(ConfigInjectionUtils.java:25)
        at io.fabric8.core.utils.ConfigInjectionUtilsTest.testNormalizePropertiesWithPrefixes(ConfigInjectionUtilsTest.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
log4j:ERROR Ignoring configuration file [file://C:/Users/chirino/sandbox/fabric8poc/itests/smoke/embedded/src/test/resources/logging.properties].
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.004 sec - in io.fabric8.core.utils.ConfigInjectionUtilsTest
Running io.fabric8.test.smoke.embedded.BasicContainerLifecycleTest
log4j:WARN No appenders could be found for logger (org.jboss.gravia.runtime).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 26.145 sec <<< FAILURE! - in io.fabric8.test.smoke.embedded.BasicContainerLifecycleTest
io.fabric8.test.smoke.embedded.BasicContainerLifecycleTest  Time elapsed: 26.145 sec  <<< ERROR!
java.lang.RuntimeException: Cannot obtain service: io.fabric8.spi.BootstrapComplete
        at org.jboss.gravia.runtime.ServiceLocator.awaitService(ServiceLocator.java:107)
        at org.jboss.gravia.runtime.ServiceLocator.awaitService(ServiceLocator.java:79)
        at io.fabric8.test.embedded.support.EmbeddedTestSupport.beforeClass(EmbeddedTestSupport.java:52)
        at io.fabric8.test.smoke.embedded.BasicContainerLifecycleTest.beforeClass(BasicContainerLifecycleTest.java:61)

Running io.fabric8.test.smoke.embedded.BasicProfilesTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 29.421 sec <<< FAILURE! - in io.fabric8.test.smoke.embedded.BasicProfilesTest
io.fabric8.test.smoke.embedded.BasicProfilesTest  Time elapsed: 29.421 sec  <<< ERROR!
java.lang.RuntimeException: Cannot obtain service: io.fabric8.spi.BootstrapComplete
        at org.jboss.gravia.runtime.ServiceLocator.awaitService(ServiceLocator.java:107)
        at org.jboss.gravia.runtime.ServiceLocator.awaitService(ServiceLocator.java:79)
        at io.fabric8.test.embedded.support.EmbeddedTestSupport.beforeClass(EmbeddedTestSupport.java:52)
        at io.fabric8.test.smoke.embedded.BasicProfilesTest.beforeClass(BasicProfilesTest.java:38)

Running io.fabric8.test.smoke.embedded.ComplexContainerTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 31.683 sec <<< FAILURE! - in io.fabric8.test.smoke.embedded.ComplexContainerTest
io.fabric8.test.smoke.embedded.ComplexContainerTest  Time elapsed: 31.683 sec  <<< ERROR!
java.lang.RuntimeException: Cannot obtain service: io.fabric8.spi.BootstrapComplete
        at org.jboss.gravia.runtime.ServiceLocator.awaitService(ServiceLocator.java:107)
        at org.jboss.gravia.runtime.ServiceLocator.awaitService(ServiceLocator.java:79)
        at io.fabric8.test.embedded.support.EmbeddedTestSupport.beforeClass(EmbeddedTestSupport.java:52)
        at io.fabric8.test.smoke.embedded.ComplexContainerTest.beforeClass(ComplexContainerTest.java:65)

Define an entry level api for clients and internal use

Currently we have things like the ProfileManager the ContainerManager etc, but I think that we should have an entry level api for clients and internal use.

The entry point can directly make use of ProfileManager and ContainerManager etc.

Obtaining the entry point

Internally can be done by service lookup.

Excternallyl it could look like:

FabricConnection fabric = new FabricConnection(url, username, password);

Playing with containers

List

fabric.container().list();

Create:

fabric.container().newContainer(ChildContainerProvider.class)
                           .id("mycontainer")
                           .parent("root")
                           .version("1.1")
                           .profile("myprofile")
                           .create();

Stop / Destroy a container

fabric.container().find("mycontainer").stop();
fabric.container().find("mycontainer").destroy();

Operate on multiple containers using Predicates (as used in guava and java8) :

fabric.container().find(new Predicate<Container>(){ 
    Boolean apply(Container cnt) {
        return cnt.getIdentity().startsWith("broker");
    }
}).stop();

Playing with Versions

List

fabric.version().list();

Create

fabric.version().newVersion().id("1.1.0").create()

Delete

fabric.version().find("1.1.0").delete()

List Profiles

fabric.version().find("1.1.0").profiles().list()

Playing with Profiles

Create

fabric.version().find("1.1.0").newProfile().id("myprofile")
        .addParent("profileA")
        .addConfigItem("my.pid", map)
        .create()

Make ProfileBuilder more friendly.

The profile builder needs to be improved and become more friendly / DSL-y

Currently the builder works like this:

ProfileBuilder.Factory pb = ProfileBuilder.Factory.create(id);
ConfigurationProfileItem item1 = pb.getProfileItemBuilder("id1", ConfigurationProfileItemBuilder.class).setConfiguration(map1);
ConfigurationProfileItem item2 = pb.getProfileItemBuilder("id2", ConfigurationProfileItemBuilder.class).setConfiguration(map2);

Profile p = pb
    .addAttributes(attributes)
    .addProfileItem(item1)
    .addProfileItem(item2)
    .build();

With the above approach there are two issues:
i) A lot of boilerplate.
ii) I need to hold a reference of the ProfileBuilder in order to create a ConfigProfileItem and this spoils the DSL-y style of the builder.

Since the builder knows what profile items and profile item builders it supports. It should be like:

Profile p = ProfileBuilder.Factory.create(id)
    .addAttributes(attributes)
    .addConfiguration("id1", map1)
    .addConfiguration("id2", map2)
    .build();

or

Profile p = ProfileBuilder.Factory.create(id)
    .addAttributes(attributes)
    .addProfileItem(ConfigurationProfileItemBuilder.Factory.create("id1", map1)
    .addProfileItem(ConfigurationProfileItemBuilder.Factory.create("id2", map2)
    .build();

I think I prefer the first alternative, or a combination of the two.

Builder Improvements

Currently the poc project is extensively using Builders. I found the way the builders work in some case confusing and I think that some things could be improved.

i) Some builders do use a mutable version of the target object. This 'kind of' defeats the purpose of the builder itself and also adds more classes into the mix.
ii) Some builders contain a makeImmutable() method to prevent further modification on the builder. The need for something like this is not obvious. Since a builder is something that is not supposed to be shared and is by definition mutable, I am not sure I understand the need for something like this.
iii) I'd expect a Builder to have a build() method rather than a getProfile() or getContainer() etc.
iv) Some Builders interfaces provide a Factory that is coupled with ServiceLocator and gravia. A builder or a builder factory should be simpler classes that do not rely on any service framework e.g. osgi, gravia, scr etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.