System works fine using Pax-runner , but don't work with Karaf. Datastax exception. Pool is busy

80 views Asked by At

I'm working on a feature, here at the company, which aims to substitute the OSGi deploy (which uses Pax-runner now with equinox as framework, using pax:provision), for a full Karaf container. Here are the steps that I'm doing:

1 - Run a pax:directory instead of "pax:provision", to generate a file called config.ini, where has the start order of the bundles.

2- I copy all the bundles that have been aggregated in a folder by pax:directory, to the karaf root directory.

3- I created a Java project (KarafProvisioner), an osgi bundle, that read the bundles from the config.ini, and start the jar bundles. The mains logic is showed below.

@Activate
protected void activate(BundleContext pBundleContext) throws IOException, InvalidSyntaxException, BundleException
{
    LOG.info(LogConstants.ACTIVATING_SERVICE, this);
    while (getActiveBundles(pBundleContext) < pBundleContext.getBundles().length - 2)
    {
        startAllBundles(pBundleContext);
    }
    File bundleList = new File(BUNDLE_LIST);
    String bundleListString = FileUtils.readFileToString(bundleList, "UTF-8");
    Matcher regexBundleNameMatcher = regexBundleName.matcher(bundleListString);
    while (regexBundleNameMatcher.find() == true)
    {
        String jarBundle = regexBundleNameMatcher.group(0);
        Matcher regexBundleSymbolicNameMatcher = regexBundleSymbolicName.matcher(jarBundle);
        String bundle = "";
        if (regexBundleSymbolicNameMatcher.find())
        {
            bundle = regexBundleSymbolicNameMatcher.group(0);
        }
        if (true
                && !bundle.contains(FELIX_SCR)
                && !bundle.contains(FELIX_WEBCONSOLE)
                && !bundle.contains(EQUINOX_CM)
                && !bundle.contains(COMMONS_IO)
                && !bundle.contains(JAVAX_MAIL)
                && !bundle.contains(OPS4J_PAX_LOGGING_API)
                && !bundle.contains(JETTY_GROUP_ID))
        {
            startBundle(pBundleContext, jarBundle, bundle);
            long bundleID = findBundle(pBundleContext, bundle);
            BUNDLE_STATUS status = getBundleStatusByID(pBundleContext, bundleID);
            while (status == BUNDLE_STATUS.STARTING)
            {
                status = getBundleStatusByID(pBundleContext, bundleID);
            }
        }
    }
    //Start Devenv Configurator
    //        startBundle(pBundleContext, bundleNameDevenvConfigurator, DEVENV_CONFIGURATOR);
    //Continue verifying until all the possible bundles have been active
    while (getActiveBundles(pBundleContext) < pBundleContext.getBundles().length - 5)
    {
        startAllBundles(pBundleContext);
    }
    LOG.info(LogConstants.ACTIVATED_SERVICE, this);
}

With this KarafProvisioner bundle I'm able to start all the bundles, and I put a loop to keep trying to start everything. Everything looks like to work, because all the 350 bundles, that the system has, are ACTIVE.

Obs.

  • I have already tried to generate a features.xml to auto deploy the application, but it didn't work.

  • I boot Karaf with the webconsole feature, so Karaf starts by default with something around 50 bundles, such as logf4j, jetty, and so on. I start my KarafProvisioner as default together with this feature.

  • Using pax-runner all the bundles start normally. And the system works fine.

This approach works partially, because all the bundles is in the ACTIVE mode, but the PROBLEM is:

The application uses a Cassandra database, with an internal java project that encapsulate all the operations, and creates a common interface to manipulate the storage. Using pax-runner everything works fine, but using Karaf this erros is showed:

%PARSER_ERROR[Exception]ConfidentialInternalInterfaceExcpetion: Server overloaded. The query could not be executed at the specified priority level
at ConfidentialInternalInterfaceProject(ExceptionHandler.java:65)
at ConfidentialInternalInterfaceProject(PersistenceHandler.java:840)
at ConfidentialInternalInterfaceProject(PersistenceHandler.java:852)
at ConfidentialInternalInterfaceProject(PersistenceHandler.java:1041)
at ConfidentialInternalInterfaceProject(PersistenceHandler.java:1061)
at ConfidentialInternalInterfaceProject(PersistenceHandler.java:517)
at ConfidentialInternalInterfaceProject(StorageConfigurationBootstrap.java:105)
at ConfidentialInternalInterfaceProject(CilInitializer.java:182)
at ConfidentialInternalInterfaceProject(DevenvConfigurator.java:743)
at ConfidentialInternalInterfaceProject(DevenvConfigurator.java:53)
at ConfidentialInternalInterfaceProject(DevenvConfigurator.java:916)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:64169 (com.datastax.driver.core.exceptions.BusyPoolException: [/127.0.0.1] Pool is busy (no available connection and timed out after 5000 MILLISECONDS)))
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:37)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:68)
at ConfidentialInternalInterfaceProject(PersistenceHandler.java:836)
... 11 common frames omitted

My questions are:

1- Does the fact that I'm using an auxiliary bundle to load all the remaining bundles, impacts the flow of the system? Considering that everything gets ACTIVE using pax-runner.

2- Does the problem with Cassandra, the interface and datastax, have any relation with the OSGi stuff?(Obs. 1- The interface uses a property from the OSGi environment to know the host and the port of the Cassandra database, and this property is OK. 2- The database is started, and and ckecked this with Dbeaver and cqlsh.)

3- There is any way to resolve this problem without modifying the interface? Maybe using some configuration?

Again, using pax-runner(with equinox simple bundles) everything works fine. The problem is happening when I try do deploy the application in the Karaf container.

0

There are 0 answers