Package com.trendmicro.codi.lock

Examples of com.trendmicro.codi.lock.ZLock.acquire()


            String lockPath = "/locks/brk_" + broker_ip;
            ZLock brokerLock = new ZLock(lockPath);
            ZNode brokerNode = new ZNode("/broker/" + broker_ip);
            try{

                brokerLock.acquire(LockType.WRITE_LOCK);
                ZooKeeperInfo.Broker.Builder brkBuilder = ZooKeeperInfo.Broker.newBuilder();
                TextFormat.merge(new String(brokerNode.getContent()), brkBuilder);
                brkBuilder.clearStatus().setStatus(ZooKeeperInfo.Broker.Status.ONLINE);
                brokerNode.setContent(brkBuilder.build().toString().getBytes());
                myConsole.logResponseNL("success");
View Full Code Here


            myConsole.logResponse("stopping `%s' ...%n", broker_ip);
            String lockPath = "/locks/brk_" + broker_ip;
            ZLock brokerLock = new ZLock(lockPath);
            ZNode brokerNode = new ZNode("/broker/" + broker_ip);
            try {
                brokerLock.acquire(LockType.WRITE_LOCK);
                ZooKeeperInfo.Broker.Builder brkBuilder = ZooKeeperInfo.Broker.newBuilder();
                TextFormat.merge(new String(brokerNode.getContent()), brkBuilder);
                brkBuilder.clearStatus().setStatus(ZooKeeperInfo.Broker.Status.OFFLINE);
                brokerNode.setContent(brkBuilder.build().toString().getBytes());
View Full Code Here

        if(statusChanged) {
            String lockPath = tmeRoot + "/locks/brk_" + host;
            ZLock lock = new ZLock(lockPath);
            try {
                logger.info("Waiting for broker lock...");
                lock.acquire(LockType.WRITE_LOCK);
                logger.info("Get broker lock.");
                ZooKeeperInfo.Broker.Status newStatus = getNewStatus();
                if((newStatus == ZooKeeperInfo.Broker.Status.ONLINE) != isOnline) {
                    switch(newStatus) {
                    case OFFLINE:
View Full Code Here

                logger.info(String.format("exchange %s uses determined broker %s", exchange.getName(), exchange.getBroker()));
                connection = Daemon.getConnection(sessionConfig.getConnection());
            }
            else {
                logger.info("getting exchange lock: " + lockPath);
                lock.acquire(LockType.WRITE_LOCK);
                logger.info("exchange lock: " + lockPath + " acquired");

                exchange.setBroker(ExchangeFarm.getInstance().queryExchangeHost(exchange));
                if(exchange.getBroker() == null)
                    throw new MistException(String.format("can not request broker from MFR for `%s:%s'", isQueue() ? "queue": "topic", getChannelName()));
View Full Code Here

            if(!isPause)
                connection.decreaseReference();

            if(!brokerDetermined) {
                logger.info("getting lock: " + lockPath);
                lock.acquire(LockType.WRITE_LOCK);
                logger.info("lock acquired: " + lockPath);
                if(!isPause && !isMigrate)
                    ExchangeFarm.getInstance().decExchangeRef(exchange);
            }
        }
View Full Code Here

            try {
                /**
                 * Get the exchange's lock first
                 */
                logger.info("getting exchange lock: " + lockPath);
                lock.acquire(LockType.WRITE_LOCK);
                logger.info("exchange lock: " + lockPath + " acquired");

                /**
                 * If the node does not exist in the refList, it means that it
                 * is discarded by decExchangeRef(), so it can be ignored
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.