Package com.trendmicro.mist.util

Examples of com.trendmicro.mist.util.Exchange


        private void fix(String [] argv) {
            if(argv.length == 1) {
                myConsole.logResponse("exchange: `%s', missing broker_ip%n", argv[0]);
                return;
            }
            Exchange ex = new Exchange(argv[0]);
            String broker_ip = argv[1];
            if(!isValidBrokerIP(broker_ip)) {
                myConsole.logResponse("broker_ip `%s' not available%n", broker_ip);
                return;
            }

            ZooKeeperInfo.Exchange.Builder builder = ZooKeeperInfo.Exchange.newBuilder();
            builder.setHost(broker_ip);
            ZooKeeperInfo.Exchange ex_data = builder.build();

            String path = String.format("/global/fixed_exchange/%s", ex.getName());
            createAndSetNode(path, ex_data.toString().getBytes());
            myConsole.logResponse("exchange `%s' fixed on broker `%s'%n", ex.getName(), broker_ip);
        }
View Full Code Here


            createAndSetNode(path, ex_data.toString().getBytes());
            myConsole.logResponse("exchange `%s' fixed on broker `%s'%n", ex.getName(), broker_ip);
        }

        private void unfix(String exchange) {
            Exchange ex = new Exchange(exchange);
            String path = String.format("/global/fixed_exchange/%s", ex.getName());
            if(deleteNode(path))
                myConsole.logResponse("fixed exchange `%s' removed%n", ex.getName());
            else
                myConsole.logResponse("fixed exchange `%s' not found%n", ex.getName());
        }
View Full Code Here

            else
                myConsole.logResponse("fixed exchange `%s' not found%n", ex.getName());
        }

        public void migrate(String exchange) {
            MigrateThread th = new MigrateThread(new Exchange(exchange));
            th.start();
            while(th.isAlive()) {
                if(th.getPendingCnt() > 0)
                    myConsole.logResponseNL("[" + exchange + "] " + th.getPendingCnt() + " messages left");
                Utils.justSleep(2000);
View Full Code Here

            }
            if(strArray[1].compareTo("newest") != 0 && strArray[1].compareTo("oldest") != 0) {
                System.out.println("Drop policy should be either [newest] or [oldest]!");
                return;
            }
            Exchange ex = new Exchange(strArray[0]);
            String path = ZNODE_DROP + "/" + ex.getName();
            ZooKeeperInfo.DropConfig dropConfig = ZooKeeperInfo.DropConfig.newBuilder().setPolicy(strArray[1].compareTo("newest") == 0 ? DropConfig.Policy.NEWEST: DropConfig.Policy.OLDEST).build();
            createAndSetNode(path, dropConfig.toString().getBytes());
           
            try {
                if(dropConfig.getPolicy().equals(ZooKeeperInfo.DropConfig.Policy.NEWEST))
View Full Code Here

            catch(Exception e) {
            }
        }

        private void block(String exchange) {
            Exchange ex = new Exchange(exchange);
            String path = ZNODE_DROP + "/" + ex.getName();
            if(deleteNode(path))
                System.out.printf(String.format("drop policy on `%s' removed%n", ex.getName()));
            else
                System.out.printf(String.format("`%s' not found%n", ex.getName()));
            try {
                BrokerSpy.setExchangeFlowControl(ex, ExchangeFarm.FlowControlBehavior.BLOCK);
            }
            catch(Exception e) {
            }
View Full Code Here

            if(!limitStr.matches(".*:\\d+:\\d+")) {
                help();
                return;
            }
            String strArray[] = limitStr.split(":");
            Exchange ex = new Exchange(strArray[0]);
            long size = Long.valueOf(strArray[1]);
            long count = Long.valueOf(strArray[2]);

            ZooKeeperInfo.TotalLimit limitConfig = ZooKeeperInfo.TotalLimit.newBuilder().setSizeBytes(size).setCount(count).build();
            String path = ZNODE_LIMIT + "/" + ex.getName();
            createAndSetNode(path, limitConfig.toString().getBytes());

            try {
                BrokerSpy.setExchangeTotalLimit(ex, size, count);
            }
View Full Code Here

            catch(Exception e) {
            }
        }

        private void defLimit(String exchange) {
            Exchange ex = new Exchange(exchange);
            String path = ZNODE_LIMIT + "/" + ex.getName();
            if(deleteNode(path))
                System.out.printf(String.format("limit on `%s' changed to default%n", ex.getName()));
            else
                System.out.printf(String.format("`%s' not found%n", ex.getName()));

            try {
                BrokerSpy.setExchangeTotalLimit(ex, 10485760L, 100000);
            }
            catch(Exception e) {
View Full Code Here

            if(!limitStr.matches(".*:\\d+:.*")) {
                help();
                return;
            }
            String strArray[] = limitStr.split(":");
            Exchange ex = new Exchange(strArray[0]);
            long count = Long.valueOf(strArray[1]);
            String receiver = strArray.length == 3 ? strArray[2]: "";

            String path = ZNODE_ALERT_LIMIT + "/" + ex.getName();
            if(count <= 0) {
                deleteNode(path);
            }
            else {
                ZooKeeperInfo.AlertConfig.Builder alertConfigBuilder = ZooKeeperInfo.AlertConfig.newBuilder();
View Full Code Here

        /**
         * The route cache should be empty at the beginning
         */
        assertTrue(routeCacheMap.isEmpty());

        Exchange fooOutEx = new Exchange("queue:foo.out");
        sess.addClient(clientConfig);
        Vector<Exchange> destList = new Vector<Exchange>();
        destList.add(new Exchange("bar.in"));
        RouteFarm.getInstance().getRouteTable().put(fooOutEx.getName(), destList);
        updateRoute.invoke(sess, new Object[] {});
        assertEquals("queue:bar.in", routeCacheMap.get(fooOutEx).get(0).toString());

        /**
         * Update the routing table and invoke updateRoute before the cache
         * expires, and the cache should remain the same
         */
        destList.add(new Exchange("log.in"));
        updateRoute.invoke(sess, new Object[] {});
        assertEquals("queue:bar.in", routeCacheMap.get(fooOutEx).get(0).toString());
        assertEquals(1, routeCacheMap.get(fooOutEx).size());

        /**
 
View Full Code Here

        /**
         * Test Local Forwarding: foo.out->bar.in, ,log.in
         */
        Vector<Exchange> destList = new Vector<Exchange>();
        destList.add(new Exchange("bar.in"));
        destList.add(new Exchange(""));
        destList.add(new Exchange("log.in"));
        RouteFarm.getInstance().getRouteTable().put("foo.out", destList);
        // Wait until local routing cache expires
        Utils.justSleep(2000);
        msg = MistMessage.MessageBlock.newBuilder().setId("queue:foo.out").setMessage(ByteString.copyFrom("test-route".getBytes())).build();
        packet.setPayload(msg.toByteArray());
View Full Code Here

TOP

Related Classes of com.trendmicro.mist.util.Exchange

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.