Package com.trendmicro.mist.util

Examples of com.trendmicro.mist.util.Exchange


            if(!Exchange.isValidExchange(client_config.getChannel().getName()))
                res_builder.setSuccess(false).setException(String.format("exchange `%s' not valid", client_config.getChannel().getName()));
            else if(!SessionPool.pool.containsKey(sessId))
                res_builder.setSuccess(false).setException(String.format("invalid session id %d", sessId));
            else {
                Exchange exchange = new Exchange(client_config.getChannel().getName());

                Session sess = SessionPool.getOrCreateConcreteSession(sessId, client_config.getType() == GateTalk.Client.Type.CONSUMER ? GateTalk.Request.Role.SOURCE: GateTalk.Request.Role.SINK);
                if(client_config.getAction() == GateTalk.Client.Action.MOUNT) {
                    sess.addClient(client_config);
                    res_builder.setSuccess(true).setContext(String.format("exchange %s mounted", exchange.toString()));
                }
                else if(client_config.getAction() == GateTalk.Client.Action.UNMOUNT) {
                    sess.removeClient(client_config);
                    res_builder.setSuccess(true).setContext(String.format("exchange %s unmounted", exchange.getName()));
                }
            }
        }
        catch(MistException e) {
            res_builder.setSuccess(false).setException(e.getMessage());
View Full Code Here


        }
       
        public MessagePrepared(BytesMessage msg) throws MistException, JMSException, IOException {
            Destination d = msg.getJMSDestination();
            if(d instanceof Queue)
                from = new Exchange("queue:" + ((Queue) d).getQueueName());
            else if(d instanceof Topic)
                from = new Exchange("topic:" + ((Topic) d).getTopicName());
           
            builder = MistMessage.MessageBlock.newBuilder();
            builder.setId(from.toString());
           
            byte[] payload = convertJMSMessage(msg);
View Full Code Here

        // A producer client cannot be added to a source session and vice versa
        checkRole(clientConfig.getType() == GateTalk.Client.Type.CONSUMER ? GateTalk.Request.Role.SOURCE: GateTalk.Request.Role.SINK);

        synchronized(allClients) {
            // Check if the client is already mounted, if not, add to the map
            if(allClients.containsKey(new Exchange(clientConfig.getChannel().getName())))
                throw new MistException(MistException.ALREADY_MOUNTED);

            Client c = new Client(clientConfig, sessionConfig);
            if(isAttached()){
                c.openClient(determinedConnection, false, false);
View Full Code Here

        synchronized(allClients) {
            if(allClients.isEmpty())
                throw new MistException(MistException.EMPTY_SESSION);

            Exchange exchange = new Exchange((clientConfig.getChannel().getType() == GateTalk.Channel.Type.QUEUE ? "queue": "topic") + ":" + clientConfig.getChannel().getName());
            Client c = findClient(exchange);
            if(c == null)
                throw new MistException(MistException.exchangeNotFound(exchange.toString()));
            c.closeClient(false, false);
            allClients.remove(exchange);
        }
    }
View Full Code Here

            catch(Exception e) {
                throw new MistException(MistException.UNABLE_TO_PARSE_MIST_MESSAGE);
            }

            // Unpack the attributes
            dest = new Exchange(mBlock.getId());
            if(mBlock.hasTtl()) {
                props = new HashMap<String, String>();
                ttl = mBlock.getTtl();
                props.put(Session.MIST_MESSAGE_TTL, new Long(ttl).toString());
            }
View Full Code Here

        /**
         * Test add a normal queue client
         */
        GateTalk.Client clientConfig = genClientConfig("foo.out", true, true);
        sess.addClient(clientConfig);
        assertEquals(clientConfig, sess.findClient(new Exchange("queue:foo.out")).getConfig());

        /**
         * Test re-mount the same exchange
         */
        Exception ex = null;
        try {
            sess.addClient(clientConfig);
        }
        catch(MistException e) {
            ex = e;
        }
        assertEquals(MistException.ALREADY_MOUNTED, ex.getMessage());

        /**
         * Test add a normal topic client
         */
        clientConfig = genClientConfig("foo.out", true, false);
        sess.addClient(clientConfig);
        assertEquals(clientConfig, sess.findClient(new Exchange("topic:foo.out")).getConfig());

        /**
         * Test using mist-source to mount a producer session
         */
        clientConfig = genClientConfig("bar.out", false, true);
View Full Code Here

        /**
         * Test add normal a queue client and open
         */
        GateTalk.Client clientConfig = genClientConfig("foo.out", true, true);
        Client c = sess.addClient(clientConfig);
        assertEquals(clientConfig, sess.findClient(new Exchange("queue:foo.out")).getConfig());
        sess.open(false);
        MessageProducer producer = sess.findClient(new Exchange("queue:foo.out")).getProducer();
        assertNotNull(producer);

        /**
         * Deliver a message
         */
        BytesMessage msg = c.getJMSSession().createBytesMessage();
        msg.writeBytes("test".getBytes());
        producer.send(msg);
        assertEquals("test", new String(brk.getMessage(true, "foo.out")));

        /**
         * Test add another queue client
         */
        clientConfig = genClientConfig("bar.out", true, true);
        c = sess.addClient(clientConfig);
        assertEquals(clientConfig, sess.findClient(new Exchange("queue:bar.out")).getConfig());
        sess.open(false);
        producer = sess.findClient(new Exchange("queue:bar.out")).getProducer();
        assertNotNull(producer);

        msg = c.getJMSSession().createBytesMessage();
        msg.writeBytes("test_bar".getBytes());
        producer.send(msg);
View Full Code Here

            }

            switch(cmd.getType()) {
            case MIGRATE_EXCHANGE:
                logger.info("migrating exchange " + cmd.getArgument(0));
                Exchange exchange = new Exchange(cmd.getArgument(0));
                migrateExchange(exchange);
                break;
            default:
                break;
            }
View Full Code Here

            jmxConnectServer();
            ArrayList<Exchange> result = new ArrayList<Exchange>();

            ObjectName objname = new ObjectName("com.sun.messaging.jms.server:type=Destination,subtype=Monitor,desttype=q,name=*");
            for(ObjectName n : connection.queryNames(objname, null)) {
                Exchange excQ = new Exchange(connection.getAttribute(n, "Name").toString());
                excQ.setQueue();
                result.add(excQ);
            }
            objname = new ObjectName("com.sun.messaging.jms.server:type=Destination,subtype=Monitor,desttype=t,name=*");
            for(ObjectName n : connection.queryNames(objname, null)) {
                Exchange excT = new Exchange(connection.getAttribute(n, "Name").toString());
                excT.setTopic();
                result.add(excT);
            }
            Exchange excAdmin = new Exchange("mq.sys.dmq");
            excAdmin.setQueue();
            result.remove(excAdmin);
            return result;
        }
        catch(Exception e) {
            throw new MistException(e.getMessage());
View Full Code Here

        if(!isMigrate) {
            /**
             * If it is exchange migration, then the exchange is definitely
             * exists, so exchange migration does not need the following check
             */
            String existingHost = checkExistingExchange(new Exchange(name), loadingMap.keySet());
            if(existingHost != null)
                return existingHost;
        }

        for(Entry<String, ZooKeeperInfo.Loading> e : loadingMap.entrySet())
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.