Package at.salzburgresearch.nodekeeper.model

Examples of at.salzburgresearch.nodekeeper.model.Node


            if(path.matches(pattern)) {
                for(NodeListener listener : listeners.get(pattern)) {
                    if(handlers.containsKey(listener.getType())) {
                        switch (version) {
                            case NodeCreated:
                                listener.onNodeCreated(new Node(path,handlers.get(listener.getType()).parse(zk.getData(path,this,stat))));
                                setStatus(path,stat.getVersion());
                                break;
                            case NodeDataChanged:
                                listener.onNodeUpdated(new Node(path,handlers.get(listener.getType()).parse(zk.getData(path,this,stat))));
                                setStatus(path,stat.getVersion());
                                break;
                            case NodeDeleted:
                                listener.onNodeDeleted(new Node(path));
                                removeStatus(path);
                                break;
                        }
                    } else throw new NodeKeeperException(String.format("cannot handle type %s",listener.getType()));
                }
View Full Code Here


        try {
            Stat stat;
            if((stat=zk.exists(path,false))!=null) {
                if(handlers.containsKey(clazz)) {
                    byte[] data = zk.getData(path,false,stat);
                    return new Node(path,handlers.get(clazz).parse(data),stat.getVersion());
                }
            }
        } catch (KeeperException e) {
            throw new NodeKeeperException("cannot read node");
        }
View Full Code Here

    private void deleteRemoved() throws KeeperException, InterruptedException, NodeKeeperException {
        for (String path : properties.stringPropertyNames()) {
            for(String pathPattern : listeners.keySet()) {
                if (!path.matches(pathPattern)) continue;
                if (zk.exists(path, false) == null) {
                    Node node = new Node(path);
                    for(NodeListener listener : listeners.get(pathPattern)) {
                        listener.onNodeDeleted(node);
                    }
                    removeStatus(path);
                }
View Full Code Here

public class NodeData extends Function {
    @Override
    public Object execute(NodeKeeper nodeKeeper, Node current) {
        try {
            Class clazz = params.length == 2 ? Class.forName((String)((Function)params[0]).execute(nodeKeeper,current)) : String.class;
            Node node = nodeKeeper.readNode((String)((Function)params[0]).execute(nodeKeeper,current),clazz);
            return node == null ? null : node.getData();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

            if(path.matches(pattern)) {
                for(NodeListener listener : listeners.get(pattern)) {
                    if(handlers.containsKey(listener.getType())) {
                        switch (version) {
                            case NodeCreated:
                                listener.onNodeCreated(new Node(path,handlers.get(listener.getType()).parse(zk.getData(path,this,stat))));
                                break;
                            case NodeDataChanged:
                                listener.onNodeUpdated(new Node(path,handlers.get(listener.getType()).parse(zk.getData(path,this,stat))));
                                break;
                            case NodeDeleted:
                                listener.onNodeDeleted(new Node(path));
                                break;
                        }
                    } else throw new NodeKeeperException(String.format("cannot handle type %s",listener.getType()));
                }
            }
View Full Code Here

        try {
            Stat stat;
            if((stat=zk.exists(path,false))!=null) {
                if(handlers.containsKey(clazz)) {
                    byte[] data = zk.getData(path,false,stat);
                    return new Node(path,handlers.get(clazz).parse(data),stat.getVersion());
                }
            }
        } catch (KeeperException e) {
            throw new NodeKeeperException("cannot read node");
        }
View Full Code Here

    private void deleteRemoved() throws KeeperException, InterruptedException, NodeKeeperException {
        for (String path : properties.stringPropertyNames()) {
            for(String pathPattern : listeners.keySet()) {
                if (!path.matches(pathPattern)) continue;
                if (zk.exists(path, false) == null) {
                    Node node = new Node(path);
                    for(NodeListener listener : listeners.get(pathPattern)) {
                        listener.onNodeDeleted(node);
                    }
                    removeStatus(path);
                }
View Full Code Here

        load(new FileInputStream(file),clean);
    }

    public void load(InputStream is, boolean clean) throws IOException, NodeKeeperException, InterruptedException {

        if(clean) cleanNode(new Node("/"));

        Properties properties = new Properties();
        properties.load(is);

        for(Object key : properties.keySet()) {
View Full Code Here

        load(new FileInputStream(file),clean);
    }

    public void load(InputStream is, boolean clean) throws IOException, NodeKeeperException, InterruptedException {

        if(clean) nodeKeeper.deleteNode(new Node("/"), true);

        Properties properties = new Properties();
        properties.load(is);

        for(Object key : properties.keySet()) {
View Full Code Here

            if(path.matches(pattern)) {
                for(NodeListener listener : listeners.get(pattern)) {
                    if(handlers.containsKey(listener.getType())) {
                        switch (version) {
                            case NodeCreated:
                                listener.onNodeCreated(new Node(path,handlers.get(listener.getType()).parse(zk.getData(path,this,stat))));
                                break;
                            case NodeDataChanged:
                                listener.onNodeUpdated(new Node(path,handlers.get(listener.getType()).parse(zk.getData(path,this,stat))));
                                break;
                            case NodeDeleted:
                                listener.onNodeDeleted(new Node(path));
                                break;
                        }
                    } else throw new NodeKeeperException(String.format("cannot handle type %s",listener.getType()));
                }
            }
View Full Code Here

TOP

Related Classes of at.salzburgresearch.nodekeeper.model.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.