Package com.trendmicro.codi

Examples of com.trendmicro.codi.ZNode


    public void createProcessor(@PathParam("name") String name, @Context SecurityContext sc) throws CODIException, JAXBException {
        if(graphEditor.isSecurityEnabled() && !(sc.isUserInRole("admin") || sc.isUserInRole("super"))){
            throw new WebApplicationException(new Exception("You are not in the role 'admin'!"), Status.FORBIDDEN.getStatusCode());
        }

        ZNode node = new ZNode("/global/graph/processor/" + name);
        ProcessorModel processor = new ProcessorModel(name);
        processor.addInput(name + ".in");
        processor.addOutput(name + ".out");
        node.create(false, new Gson().toJson(processor));
    }
View Full Code Here


    }
   
    @Path("/{name}")
    @DELETE
    public void removeProcessor(@PathParam("name") String name) throws CODIException, JAXBException {
        ZNode node = new ZNode("/global/graph/processor/" + name);
        node.delete();
    }
View Full Code Here

        ZNode node = new ZNode("/global/graph/processor/" + name);
        node.delete();
    }
   
    private void setProcessor(ProcessorModel processor) throws CODIException, JAXBException {
        ZNode node = new ZNode("/global/graph/processor/" + processor.getName());
        node.setContent(new Gson().toJson(processor));
    }
View Full Code Here

        brkBuilder.addAccount(ZooKeeperInfo.Broker.Account.newBuilder().setUser("admin").setPassword("admin").build());
        brkBuilder.setBrokerType("openmq");
        brkBuilder.setVersion("4.4");
        brkBuilder.setReserved(false);

        ZNode brkNode = new ZNode("/tme2/broker/127.0.0.1");
        brkNode.create(false, brkBuilder.build().toString());

        ZNode loadingNode = new ZNode("/tme2/broker/127.0.0.1/loading");
        loadingNode.create(false, ZooKeeperInfo.Loading.newBuilder().setLoading(0).setLastUpdate(0).setFreeMemory(0).setMaxMemory(0).build().toString());
    }
View Full Code Here

    public void setDrop(@PathParam("name") String name, String policy) throws Exception {
        Exchange ex = new Exchange(name);
        String path = "/global/drop_exchange/" + ex.getName();
        ZooKeeperInfo.DropConfig dropConfig = ZooKeeperInfo.DropConfig.newBuilder().setPolicy(policy.equals("newest") ? DropConfig.Policy.NEWEST: DropConfig.Policy.OLDEST).build();
       
        ZNode node = new ZNode(path);
        if(node.exists()) {
            node.setContent(dropConfig.toString().getBytes());
        }
        else {
            node.create(false, dropConfig.toString().getBytes());
        }
       
        String broker = exchangeFarm.getCurrentExchangeHost(ex);
        if(broker != null) {
            BrokerAdmin brokerAdmin = new BrokerAdmin(broker);
View Full Code Here

    @DELETE
    public void setBlock(@PathParam("name") String name) throws Exception {
        Exchange ex = new Exchange(name);
        String path = "/global/drop_exchange/" + ex.getName();
       
        new ZNode(path).delete();
        String broker = exchangeFarm.getCurrentExchangeHost(ex);
        if(broker != null) {
            BrokerAdmin brokerAdmin = new BrokerAdmin(broker);
            brokerAdmin.jmxConnectServer();
            try {
View Full Code Here

    public void setSizeLimit(@PathParam("name") String name, String sizeLimit) throws Exception {
        Exchange ex = new Exchange(name);
        String path = "/global/limit_exchange/" + ex.getName();
       
        ZooKeeperInfo.TotalLimit limit = exchangeFarm.getTotalLimit(ex);
        ZNode node = new ZNode(path);
        if(node.exists()) {
            node.setContent(limit.toBuilder().setSizeBytes(Long.valueOf(sizeLimit)).build().toString().getBytes());
        }
        else {
            node.create(false, limit.toBuilder().setSizeBytes(Long.valueOf(sizeLimit)).build().toString().getBytes());
        }
       
        String broker = exchangeFarm.getCurrentExchangeHost(ex);
        if(broker != null) {
            BrokerAdmin brokerAdmin = new BrokerAdmin(broker);
View Full Code Here

    public void setCountLimit(@PathParam("name") String name, String countLimit) throws Exception {
        Exchange ex = new Exchange(name);
        String path = "/global/limit_exchange/" + ex.getName();
       
        ZooKeeperInfo.TotalLimit limit = exchangeFarm.getTotalLimit(ex);
        ZNode node = new ZNode(path);
        if(node.exists()) {
            node.setContent(limit.toBuilder().setCount(Long.valueOf(countLimit)).build().toString().getBytes());
        }
        else {
            node.create(false, limit.toBuilder().setCount(Long.valueOf(countLimit)).build().toString().getBytes());
        }
       
        String broker = exchangeFarm.getCurrentExchangeHost(ex);
        if(broker != null) {
            BrokerAdmin brokerAdmin = new BrokerAdmin(broker);
View Full Code Here

                Table tab = new Table(3);
                tab.addCell("Exchange");
                tab.addCell("Config. Type");
                tab.addCell("Remark");
               
                List<String> fixed_ex = new ZNode(ZNODE_FIXED).getChildren();
                for(String name: fixed_ex) {
                    ZooKeeperInfo.Exchange.Builder builder = ZooKeeperInfo.Exchange.newBuilder();
                    TextFormat.merge(new String(new ZNode(ZNODE_FIXED + "/" + name).getContent()), builder);
                    tab.addCell("{queue,topic}:" + name);
                    tab.addCell("Fixed", new CellStyle(HorizontalAlign.center));
                    tab.addCell(builder.build().getHost());
                }
               
                List<String> drop_ex = new ZNode(ZNODE_DROP).getChildren();
                for(String name : drop_ex) {
                    ZooKeeperInfo.DropConfig.Builder drop_builder = ZooKeeperInfo.DropConfig.newBuilder();
                    TextFormat.merge(new String(new ZNode(ZNODE_DROP + "/" + name).getContent()), drop_builder);
                    tab.addCell(name);
                    tab.addCell("Drop Polocy", new CellStyle(HorizontalAlign.center));
                    tab.addCell(drop_builder.build().getPolicy() == DropConfig.Policy.NEWEST ? "newest": "oldest");
                }
               
                List<String> limit_ex = new ZNode(ZNODE_LIMIT).getChildren();
                for(String name : limit_ex) {
                    ZooKeeperInfo.TotalLimit.Builder limit_builder = ZooKeeperInfo.TotalLimit.newBuilder();
                    TextFormat.merge(new String(new ZNode(ZNODE_LIMIT + "/" + name).getContent()), limit_builder);
                    tab.addCell(name);
                    tab.addCell("Maximum limit", new CellStyle(HorizontalAlign.center));
                    ZooKeeperInfo.TotalLimit limit = limit_builder.build();
                    tab.addCell(String.format("%d bytes / %d messages", limit.getSizeBytes(), limit.getCount()));
                }

                List<String> alert_limit_ex = new ZNode(ZNODE_ALERT_LIMIT).getChildren();
                for(String name : alert_limit_ex) {
                    ZooKeeperInfo.AlertConfig.Builder alert_limit_builder = ZooKeeperInfo.AlertConfig.newBuilder();
                    TextFormat.merge(new ZNode(ZNODE_ALERT_LIMIT + "/" + name).getContentString(), alert_limit_builder);
                    ZooKeeperInfo.AlertConfig alertConfig = alert_limit_builder.build();
                    tab.addCell(name);
                    tab.addCell("Alert limit", new CellStyle(HorizontalAlign.center));
                    tab.addCell(String.format("%d messages to %s", alertConfig.getCount(), alertConfig.getReceiver()));
                }
View Full Code Here

    public ZKIdentityService(String authNodePath, ZKSessionManager zksm) throws InterruptedException, CODIException {
        if(authNodePath == null)
            throw new IllegalArgumentException("The authorization node path should not be null");
        if(zksm == null)
            throw new IllegalStateException("The ZKSessionManager should be initialized");
        authNode = new ZNode(authNodePath, zksm);
        authNode.getContent();
    }
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.