Package org.apache.karaf.cellar.core

Examples of org.apache.karaf.cellar.core.Node


        System.err.println(executeCommand("features:addurl mvn:org.apache.karaf.cellar.samples/dosgi-greeter/2.2.4-SNAPSHOT/xml/features"));

        System.err.println(executeCommand("admin:list"));

        System.err.println(executeCommand("cluster:node-list"));
        Node localNode = clusterManager.getNode();
        Set<Node> nodes = clusterManager.listNodes();
        assertTrue("There should be at least 3 cellar nodes running", 3 <= nodes.size());

        Thread.sleep(DEFAULT_TIMEOUT);

        String node1 = getNodeIdOfChild("node1");
        String node2 = getNodeIdOfChild("node2");

        System.err.println("Node 1: " + node1);
        System.err.println("Node 2: " + node2);

        executeCommand("cluster:group-create client-grp");
        executeCommand("cluster:group-create service-grp");
        System.err.println(executeCommand("cluster:group-list"));
        System.err.println(executeCommand("cluster:group-set client-grp " + localNode.getId()));
        System.err.println(executeCommand("cluster:group-set service-grp " + node1));

        System.err.println(executeCommand("cluster:feature-install client-grp greeter-client"));
        Thread.sleep(10000);
        System.err.println(executeCommand("cluster:feature-install service-grp greeter-service"));
View Full Code Here


        // looking for nodes and check if exist
        Set<Node> recipientList;
        if (nodeIds != null && !nodeIds.isEmpty()) {
            recipientList = new HashSet<Node>();
            for (String nodeId : nodeIds) {
                Node node = clusterManager.findNodeById(nodeId);
                if (node == null) {
                    System.err.println("Cluster node " + nodeId + " doesn't exist");
                } else {
                    recipientList.add(node);
                }
            }
        } else {
            recipientList = clusterManager.listNodes();
        }

        if (recipientList.size() < 1) {
            return null;
        }

        command.setDestination(recipientList);
        command.setHandlerName(handlerName);
        command.setStatus(status);

        Map<Node, ManageHandlersResult> results = executionContext.execute(command);
        if (results == null || results.isEmpty()) {
            System.out.println("No result received within given timeout");
        } else {
            System.out.println(String.format(HEADER_FORMAT, "Node", "Status", "Event Handler"));
            for (Map.Entry<Node,ManageHandlersResult> handlersResultEntry : results.entrySet()) {
                Node node = handlersResultEntry.getKey();
                ManageHandlersResult result = handlersResultEntry.getValue();
                if (result != null && result.getHandlers() != null) {

                    for (Map.Entry<String,String>  handlerEntry: result.getHandlers().entrySet()) {
                        String handler =  handlerEntry.getKey();
                        String s = handlerEntry.getValue();
                        System.out.println(String.format(OUTPUT_FORMAT, node.getId(), s, handler));
                    }
                }
            }
        }
        return null;
View Full Code Here

        registerGroup(DEFAULT_GROUP);
    }

    public void destroy() {
        // update the group
        Node local = this.getNode();
        Set<Group> groups = this.listGroups(local);
        for (Group group : groups) {
            String groupName = group.getName();
            group.getNodes().remove(local);
            listGroups().put(groupName, group);
View Full Code Here

        groupProducers.clear();
    }

    @Override
    public Node getNode() {
        Node node = null;
        Cluster cluster = instance.getCluster();
        if (cluster != null) {
            Member member = cluster.getLocalMember();
            node = new HazelcastNode(member.getInetSocketAddress().getHostName(), member.getInetSocketAddress().getPort());
        }
View Full Code Here

        System.err.println(executeCommand("features:addurl mvn:org.apache.karaf.cellar.samples/camel-hazelcast-app/2.2.4-SNAPSHOT/xml/features"));

        System.err.println(executeCommand("admin:list"));

        System.err.println(executeCommand("cluster:node-list"));
        Node localNode = clusterManager.getNode();
        Set<Node> nodes = clusterManager.listNodes();
        assertTrue("There should be at least 3 Cellar nodes running", nodes.size() >= 3);

        Thread.sleep(DEFAULT_TIMEOUT);

        String node1 = getNodeIdOfChild("node1");
        String node2 = getNodeIdOfChild("node2");

        System.err.println("Node 1: " + node1);
        System.err.println("Node 2: " + node2);

        executeCommand("cluster:group-create producer-grp");
        executeCommand("cluster:group-create consumer-grp");
        System.err.println(executeCommand("cluster:group-set producer-grp " + localNode.getId()));
        System.err.println(executeCommand("cluster:group-set consumer-grp " + node1));
        System.err.println(executeCommand("cluster:group-set consumer-grp " + node2));
        System.err.println(executeCommand("cluster:group-list"));

        System.err.println(executeCommand("cluster:feature-install consumer-grp cellar-sample-camel-consumer"));
View Full Code Here

        Thread.sleep(2000);
        eventadminFeatureStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
        System.err.println(eventadminFeatureStatus);
        assertTrue(eventadminFeatureStatus.startsWith(INSTALLED));

        Node localNode = clusterManager.getNode();
        Set<Node> nodes = clusterManager.listNodes();
        System.err.println(executeCommand("cluster:node-list"));
        assertTrue("There should be at least 2 cellar nodes running", 2 <= nodes.size());
    }
View Full Code Here

        Thread.sleep(DEFAULT_TIMEOUT);
        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
        assertNotNull(clusterManager);

        System.err.println(executeCommand("cluster:node-list"));
        Node localNode = clusterManager.getNode();
        Set<Node> nodes = clusterManager.listNodes();
        assertTrue("There should be at least 2 cellar nodes running", 2 <= nodes.size());

        System.err.println(executeCommand("cluster:group-list"));
        System.err.println(executeCommand("cluster:group-set testgroup " + localNode.getId()));
        System.err.println(executeCommand("cluster:group-list"));

        GroupManager groupManager = getOsgiService(GroupManager.class);
        assertNotNull(groupManager);
View Full Code Here

        ManageGroupResult result = new ManageGroupResult(command.getId());
        ManageGroupAction action = command.getAction();

        String targetGroupName = command.getGroupName();
        Node node = clusterManager.getNode();

        if (ManageGroupAction.JOIN.equals(action)) {
            joinGroup(targetGroupName);
        } else if (ManageGroupAction.QUIT.equals(action)) {
            quitGroup(targetGroupName);
View Full Code Here

     * Adds {@link Node} to the target {@link Group}.
     *
     * @param targetGroupName
     */
    public void joinGroup(String targetGroupName) {
        Node node = clusterManager.getNode();
        Map<String, Group> groups = groupManager.listGroups();
        if (groups != null && !groups.isEmpty()) {
            Group targetGroup = groups.get(targetGroupName);
            if (targetGroup == null) {
                groupManager.registerGroup(targetGroupName);
View Full Code Here

     * Removes {@link Node} from the target {@link Group}.
     *
     * @param targetGroupName
     */
    public void quitGroup(String targetGroupName) {
        Node node = clusterManager.getNode();
        Map<String, Group> groups = groupManager.listGroups();
        if (groups != null && !groups.isEmpty()) {
            Group targetGroup = groups.get(targetGroupName);
            if (targetGroup.getNodes().contains(node)) {
                targetGroup.getNodes().remove(node);
View Full Code Here

TOP

Related Classes of org.apache.karaf.cellar.core.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.