Package org.apache.karaf.cellar.core

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


        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


     *
     * @param targetGroupName
     */
    public void joinGroup(String targetGroupName) {
        LOGGER.info("CELLAR GROUP: Joining group {}.",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

     *
     * @param targetGroupName
     */
    public void quitGroup(String targetGroupName) {
        LOGGER.info("CELLAR GROUP: Quiting group {}.",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

    /**
     * Removes {@link Node} from ALL {@link Group}s.
     */
    public void purgeGroups() {
        LOGGER.info("CELLAR GROUP: Purging all groups from node.");
        Node node = clusterManager.getNode();
        Set<String> groupNames = groupManager.listGroupNames(node);
        if (groupNames != null && !groupNames.isEmpty()) {
            for (String targetGroupName : groupNames) {
                quitGroup(targetGroupName);
            }
View Full Code Here

*/
public class LocalGroupsCompleter extends GroupCompleterSupport {

    @Override
    protected boolean acceptsGroup(Group group) {
        Node node = groupManager.getNode();
        if (group.getNodes().contains(node))
            return true;
        else return false;
    }
View Full Code Here

*/
public class OtherGroupsCompleter extends GroupCompleterSupport {

    @Override
    protected boolean acceptsGroup(Group group) {
        Node node = groupManager.getNode();
        if (group.getNodes().contains(node))
            return false;
        else return true;
    }
View Full Code Here

    @Argument(index = 2, name = "interval", description = "The time in millis to wait between iterations.", required = false, multiValued = false)
    Long interval = 1000L;

    @Override
    protected Object doExecute() throws Exception {
        Node node = clusterManager.findNodeById(nodeId);
        if (node == null) {
            System.out.println("Node " + nodeId + " doesn't exist");
            return null;
        }
        System.out.println("Pinging node " + node.getId());
        for (int i = 1; i <= iterations; i++) {
            Long start = System.currentTimeMillis();
            Ping ping = new Ping(clusterManager.generateId());
            ping.setDestination(new HashSet(Arrays.asList(node)));
            executionContext.execute(ping);
            Long stop = System.currentTimeMillis();
            Long delay = stop - start;
            System.out.println(String.format("PING %s %s %sms", i, node.getId(), delay));
            Thread.sleep(interval);
        }
        return null;
    }
View Full Code Here

        if (results == null || results.isEmpty()) {
            System.out.println("No result received within given timeout");
        } else {
            System.out.println(String.format(OUTPUT_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

        TabularType tableType = new TabularType("Event Handlers", "Table of Karaf Cellar cluster event handlers",
                compositeType, new String[]{ "node", "handler" });
        TabularDataSupport table = new TabularDataSupport(tableType);

        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 status = handlerEntry.getValue();
                    CompositeDataSupport data = new CompositeDataSupport(compositeType,
                            new String[]{ "node", "handler", "status" },
                            new Object[]{ node.getId(), handler, status });
                    table.put(data);
                }
            }
        }
View Full Code Here

        eventadminFeaturesStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
        System.err.println(eventadminFeaturesStatus);
        assertTrue(eventadminFeaturesStatus.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

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.