Search in sources :

Example 1 with PluginInfo

use of org.killbill.billing.osgi.api.PluginInfo in project killbill by killbill.

the class DefaultKillbillNodesApi method computeLatestNodeInfo.

private String computeLatestNodeInfo(final Iterable<PluginInfo> rawPluginInfo) throws IOException {
    final NodeInfoModelDao nodeInfo = nodeInfoDao.getByNodeName(CreatorName.get());
    NodeInfoModelJson nodeInfoJson = mapper.deserializeNodeInfo(nodeInfo.getNodeInfo());
    final List<PluginInfo> pluginInfos = rawPluginInfo.iterator().hasNext() ? ImmutableList.<PluginInfo>copyOf(rawPluginInfo) : ImmutableList.<PluginInfo>of();
    final NodeInfoModelJson updatedNodeInfoJson = new NodeInfoModelJson(CreatorName.get(), nodeInfoJson.getBootTime(), clock.getUTCNow(), nodeInfoJson.getKillbillVersion(), nodeInfoJson.getApiVersion(), nodeInfoJson.getPluginApiVersion(), nodeInfoJson.getCommonVersion(), nodeInfoJson.getPlatformVersion(), ImmutableList.copyOf(Iterables.transform(pluginInfos, new Function<PluginInfo, PluginInfoModelJson>() {

        @Override
        public PluginInfoModelJson apply(final PluginInfo input) {
            return new PluginInfoModelJson(input);
        }
    })));
    final String nodeInfoValue = mapper.serializeNodeInfo(updatedNodeInfoJson);
    return nodeInfoValue;
}
Also used : NodeInfoModelDao(org.killbill.billing.util.nodes.dao.NodeInfoModelDao) NodeInfoModelJson(org.killbill.billing.util.nodes.json.NodeInfoModelJson) PluginInfoModelJson(org.killbill.billing.util.nodes.json.PluginInfoModelJson) PluginInfo(org.killbill.billing.osgi.api.PluginInfo)

Example 2 with PluginInfo

use of org.killbill.billing.osgi.api.PluginInfo in project killbill by killbill.

the class DefaultKillbillNodesService method createBootNodeInfo.

private void createBootNodeInfo(final boolean skipPlugins) throws JsonProcessingException {
    final DateTime bootTime = clock.getUTCNow();
    final Iterable<PluginInfo> rawPluginInfo = skipPlugins ? ImmutableList.<PluginInfo>of() : pluginInfoApi.getPluginsInfo();
    final List<PluginInfo> pluginInfo = rawPluginInfo.iterator().hasNext() ? ImmutableList.<PluginInfo>copyOf(rawPluginInfo) : ImmutableList.<PluginInfo>of();
    final String kbVersion = org.killbill.billing.util.nodes.KillbillVersions.getKillbillVersion();
    final String kbApiVersion = org.killbill.billing.util.nodes.KillbillVersions.getApiVersion();
    final String kbPluginApiVersion = org.killbill.billing.util.nodes.KillbillVersions.getPluginApiVersion();
    final String kbPlatformVersion = org.killbill.billing.util.nodes.KillbillVersions.getPlatformVersion();
    final String kbCommonVersion = org.killbill.billing.util.nodes.KillbillVersions.getCommonVersion();
    final NodeInfoModelJson nodeInfo = new NodeInfoModelJson(CreatorName.get(), bootTime, bootTime, kbVersion, kbApiVersion, kbPluginApiVersion, kbCommonVersion, kbPlatformVersion, ImmutableList.copyOf(Iterables.transform(pluginInfo, new Function<PluginInfo, PluginInfoModelJson>() {

        @Override
        public PluginInfoModelJson apply(final PluginInfo input) {
            return new PluginInfoModelJson(input);
        }
    })));
    final String nodeInfoValue = mapper.serializeNodeInfo(nodeInfo);
    final NodeInfoModelDao bootNodeInfo = new NodeInfoModelDao(CreatorName.get(), clock.getUTCNow(), nodeInfoValue);
    nodeInfoDao.create(bootNodeInfo);
}
Also used : NodeInfoModelDao(org.killbill.billing.util.nodes.dao.NodeInfoModelDao) NodeInfoModelJson(org.killbill.billing.util.nodes.json.NodeInfoModelJson) PluginInfoModelJson(org.killbill.billing.util.nodes.json.PluginInfoModelJson) PluginInfo(org.killbill.billing.osgi.api.PluginInfo) DateTime(org.joda.time.DateTime)

Example 3 with PluginInfo

use of org.killbill.billing.osgi.api.PluginInfo in project killbill by killbill.

the class TestWithFakeKPMPlugin method testPluginInstallMechanism.

@Test(groups = "slow")
public void testPluginInstallMechanism() throws Exception {
    final NodeCommand nodeCommand = new NodeCommand() {

        @Override
        public boolean isSystemCommandType() {
            return true;
        }

        @Override
        public String getNodeCommandType() {
            return SystemNodeCommandType.INSTALL_PLUGIN.name();
        }

        @Override
        public NodeCommandMetadata getNodeCommandMetadata() {
            return new PluginNodeCommandMetadata(NEW_PLUGIN_NAME, NEW_PLUGIN_NAME, NEW_PLUGIN_VERSION, ImmutableList.<NodeCommandProperty>of());
        }
    };
    busHandler.pushExpectedEvent(NextEvent.BROADCAST_SERVICE);
    nodesApi.triggerNodeCommand(nodeCommand, false);
    assertListenerStatus();
    // Exit condition is based on the new config being updated on disk
    await().atMost(3, SECONDS).until(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            final Iterable<NodeInfo> rawNodeInfos = nodesApi.getNodesInfo();
            final List<NodeInfo> nodeInfos = ImmutableList.<NodeInfo>copyOf(rawNodeInfos);
            Assert.assertEquals(nodeInfos.size(), 1);
            final NodeInfo nodeInfo = nodeInfos.get(0);
            final Iterable<PluginInfo> rawPluginInfos = nodeInfo.getPluginInfo();
            final List<PluginInfo> pluginsInfo = ImmutableList.copyOf(rawPluginInfos);
            if (pluginsInfo.size() == 1) {
                final PluginInfo pluginInfo = pluginsInfo.get(0);
                Assert.assertEquals(pluginInfo.getPluginName(), NEW_PLUGIN_NAME);
                Assert.assertEquals(pluginInfo.getVersion(), NEW_PLUGIN_VERSION);
            }
            return pluginsInfo.size() == 1;
        }
    });
}
Also used : PluginNodeCommandMetadata(org.killbill.billing.util.nodes.PluginNodeCommandMetadata) NodeInfo(org.killbill.billing.util.nodes.NodeInfo) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) LinkedList(java.util.LinkedList) PluginInfo(org.killbill.billing.osgi.api.PluginInfo) NodeCommand(org.killbill.billing.util.nodes.NodeCommand) PluginConfigException(org.killbill.billing.osgi.pluginconf.PluginConfigException) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Aggregations

PluginInfo (org.killbill.billing.osgi.api.PluginInfo)3 NodeInfoModelDao (org.killbill.billing.util.nodes.dao.NodeInfoModelDao)2 NodeInfoModelJson (org.killbill.billing.util.nodes.json.NodeInfoModelJson)2 PluginInfoModelJson (org.killbill.billing.util.nodes.json.PluginInfoModelJson)2 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 DateTime (org.joda.time.DateTime)1 PluginConfigException (org.killbill.billing.osgi.pluginconf.PluginConfigException)1 NodeCommand (org.killbill.billing.util.nodes.NodeCommand)1 NodeInfo (org.killbill.billing.util.nodes.NodeInfo)1 PluginNodeCommandMetadata (org.killbill.billing.util.nodes.PluginNodeCommandMetadata)1 Test (org.testng.annotations.Test)1