Search in sources :

Example 1 with NodeInfoModelJson

use of org.killbill.billing.util.nodes.json.NodeInfoModelJson in project killbill by killbill.

the class TestNodeInfoMapper method testNodeInfoSerialization.

@Test(groups = "fast")
public void testNodeInfoSerialization() throws Exception {
    final PluginServiceInfoModelJson svc = new PluginServiceInfoModelJson("typeName", "registrationName");
    final Set<PluginServiceInfoModelJson> services1 = new HashSet<PluginServiceInfoModelJson>();
    services1.add(svc);
    final List<PluginInfoModelJson> pluginInfos = new ArrayList<PluginInfoModelJson>();
    final PluginInfoModelJson info1 = new PluginInfoModelJson("sym1", "key1", "name1", "vers1", PluginState.STOPPED, true, services1);
    pluginInfos.add(info1);
    final NodeInfoModelJson input = new NodeInfoModelJson("nodeName", clock.getUTCNow(), clock.getUTCNow(), "1.0", "1.0", "1.0", "1.0", "1.0", pluginInfos);
    final String nodeInfoStr = nodeInfoMapper.serializeNodeInfo(input);
    final NodeInfoModelJson res = nodeInfoMapper.deserializeNodeInfo(nodeInfoStr);
    Assert.assertEquals(res, input);
}
Also used : NodeInfoModelJson(org.killbill.billing.util.nodes.json.NodeInfoModelJson) PluginInfoModelJson(org.killbill.billing.util.nodes.json.PluginInfoModelJson) ArrayList(java.util.ArrayList) PluginServiceInfoModelJson(org.killbill.billing.util.nodes.json.PluginServiceInfoModelJson) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 2 with NodeInfoModelJson

use of org.killbill.billing.util.nodes.json.NodeInfoModelJson 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 3 with NodeInfoModelJson

use of org.killbill.billing.util.nodes.json.NodeInfoModelJson 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)

Aggregations

NodeInfoModelJson (org.killbill.billing.util.nodes.json.NodeInfoModelJson)3 PluginInfoModelJson (org.killbill.billing.util.nodes.json.PluginInfoModelJson)3 PluginInfo (org.killbill.billing.osgi.api.PluginInfo)2 NodeInfoModelDao (org.killbill.billing.util.nodes.dao.NodeInfoModelDao)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DateTime (org.joda.time.DateTime)1 PluginServiceInfoModelJson (org.killbill.billing.util.nodes.json.PluginServiceInfoModelJson)1 Test (org.testng.annotations.Test)1