Package com.trendmicro.codi

Examples of com.trendmicro.codi.ZNode


        brkNode.deleteRecursively();
    }
   
    private ZooKeeperInfo.Broker.Status getNewStatus() {
        try {
            byte[] data = new ZNode(tmeRoot + "/broker/" + host).getContent();
            ZooKeeperInfo.Broker.Builder builder = ZooKeeperInfo.Broker.newBuilder();
            TextFormat.merge(new String(data), builder);
            return builder.build().getStatus();
        }
        catch(Exception e) {
View Full Code Here


    }

    private boolean isValidBrokerIP(String broker_ip) {
        String path = String.format("/broker/%s", broker_ip);
        try {
            if(new ZNode(path).exists())
                return true;
        }
        catch(CODIException e) {
            e.printStackTrace();
        }
View Full Code Here

        }
        return isOnline;
    }
   
    public void reportLoadingForever() throws InterruptedException {
        ZNode loadingNode = new ZNode(tmeRoot + "/broker/" + host + "/loading");
        while(true) {
            if(checkOnlineStatus()) {
                long free = Runtime.getRuntime().freeMemory();
                long total = Runtime.getRuntime().totalMemory();
                long max = Runtime.getRuntime().maxMemory();
               
                ZooKeeperInfo.Loading.Builder load_builder = ZooKeeperInfo.Loading.newBuilder();
                load_builder.setLoading(Math.round(((float) (max - free) / max) * 100));
                load_builder.setLastUpdate(new Date().getTime());
                load_builder.setFreeMemory(free);
                load_builder.setMaxMemory(max);
                try {
                    loadingNode.setContent(load_builder.build().toString());
                    logger.info(String.format("Reporting loading: free memory: %d, total memory: %d max memory: %d", free, total, max));
                }
                catch(CODIException e) {
                    logger.error("Cannot report loading", e);
                }
View Full Code Here

        }
        return false;
    }

    private boolean createAndSetNode(String path, byte[] data) {
        ZNode node = new ZNode(path);
        try {
            if(!node.exists()) {
                node.create(false, data);
                return true;
            }
            else {
                node.setContent(data);
                return true;
            }

        }
        catch(Exception e) {
View Full Code Here

            return false;
        }
    }

    private boolean deleteNode(String path) {
        ZNode node = new ZNode(path);
        try {
            if(!node.exists())
                return false;
            node.delete();
        }
        catch(CODIException e) {
            e.printStackTrace();
        }
        return true;
View Full Code Here

    private static boolean authenticateLock() throws Exception {
        ZKSessionManager.initialize(Daemon.propMIST.getProperty("mistd.zookeeper") + Daemon.propMIST.getProperty("mistd.zookeeper.tmeroot"), Integer.valueOf(Daemon.propMIST.getProperty("mistd.zookeeper.timeout")));
        ZKSessionManager zksm = ZKSessionManager.instance();
        zksm.waitConnected();

        ZNode authNode = new ZNode(ACL_NODE);
        if(authNode.exists()) {
            LoginContext lc = new LoginContext("ldaploginmodule", new CallbackHandler() {

                @Override
                public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                    for(Callback cb : callbacks) {
                        if(cb instanceof NameCallback) {
                            System.out.print("Enter username: ");
                            ((NameCallback) cb).setName(System.console().readLine());
                        }
                        else if(cb instanceof PasswordCallback) {
                            System.out.print("Enter password: ");
                            ((PasswordCallback) cb).setPassword(System.console().readPassword());
                        }
                    }
                }
            });
            lc.login();

            boolean authorized = false;
            for(String admin : authNode.getContentString().split(",")) {
                for(Principal p : lc.getSubject().getPrincipals()) {
                    if(p instanceof UserPrincipal) {
                        if(p.getName().equals(admin.trim())) {
                            authorized = true;
                        }
View Full Code Here

       
        if(now - m_last_update > INTERVAL) {
            m_last_update = now;
           
            try {
                gocUrl = new URL(new ZNode("/global/goc_server").getContentString());
            }
            catch(Exception e) {
                logger.error(e.getMessage(), e);
                gocUrl = null;
            }
View Full Code Here

            }
        }
    }

    private CommandHandler() {
        commandNode = new ZNode(NODE_PATH);
        try {
            commandNode.deleteRecursively();
        }
        catch(CODIException e) {
        }
View Full Code Here

            catch(Exception e) {
                logger.error("unable to process command " + new String(ent.getValue()));
            }
            finally {
                try {
                    new ZNode(parentPath + "/" + ent.getKey()).delete();
                }
                catch(CODIException e) {
                    logger.error("cannot delete command node " + parentPath + ent.getKey());
                }
            }
View Full Code Here

    }

    private boolean hasReference(Exchange exchange) {
        try {
            String path = "/exchange/" + exchange.toString();
            ZNode node = new ZNode(path);
            boolean no_ref = ((!node.exists()) || (node.getChildren().size() == 0));
            return !no_ref;
        }
        catch(Exception e) {
            logger.error(e.getMessage(), e);
            return true;
View Full Code Here

TOP

Related Classes of com.trendmicro.codi.ZNode

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.