Package com.trendmicro.mist

Examples of com.trendmicro.mist.MistException


    }

    private void checkRole(GateTalk.Request.Role role) throws MistException {
        if(this instanceof ProducerSession) {
            if(role == GateTalk.Request.Role.SOURCE)
                throw new MistException(MistException.INCOMPATIBLE_TYPE_SINK);
        }
        else {
            if(role == GateTalk.Request.Role.SINK)
                throw new MistException(MistException.INCOMPATIBLE_TYPE_SOURCE);
        }
    }
View Full Code Here


            }
        }

        synchronized(attachLock) {
            if(isAttached())
                throw new MistException(MistException.ALREADY_ATTACHED);
           
            try {
                localServer = new ServerSocket();
                localServer.setReuseAddress(true);
                localServer.setSoTimeout(1000);
                localServer.bind(null);
            }
            catch(IOException e) {
                logger.error(e.getMessage());
                try {
                    localServer.close();
                }
                catch(Exception e2) {
                }
                throw new MistException(e.getMessage());
            }
            detachNow = false;
            isReady = false;

            sessionThread = new Thread(this);
View Full Code Here

        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);
                addClientIfAttached(c);
View Full Code Here

    public void removeClient(GateTalk.Client clientConfig) throws MistException {
        checkRole(clientConfig.getType() == GateTalk.Client.Type.CONSUMER ? GateTalk.Request.Role.SOURCE: GateTalk.Request.Role.SINK);

        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

     * @throws MistException
     *             If the session id is not valid, throw a MistException
     */
    public synchronized static Session getOrCreateConcreteSession(int sessId, GateTalk.Request.Role role) throws MistException {
        if(!pool.containsKey(sessId))
            throw new MistException("invalid session id " + sessId);
        Session sess = SessionPool.pool.get(sessId);
        if(sess == null && role != null) {
            if(role == GateTalk.Request.Role.SOURCE)
                sess = new ConsumerSession(sessId, null);
            else if(role == GateTalk.Request.Role.SINK)
View Full Code Here

        cl_builder.setType(GateTalk.Client.Type.PRODUCER);
        cl_builder.setAction(GateTalk.Client.Action.MOUNT);
        GateTalk.Client client_config = cl_builder.build();

        if(!Exchange.isValidExchange(client_config.getChannel().getName()))
            throw new MistException(String.format("exchange `%s' not valid", client_config.getChannel().getName()));

        Client client = null;
        try {
            client = addClient(client_config);
            logger.info(String.format("session %d: create exchange `%s:%s'", sessionId, client.isQueue() ? "queue": "topic", client.getChannelName()));
View Full Code Here

                MistMessage.MessageBlock.Builder mblockBuilder = MistMessage.MessageBlock.newBuilder();
                mblockBuilder.mergeFrom(raw);
                mBlock = mblockBuilder.build();
            }
            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());
            }

            msg = mBlock.getMessage().toByteArray();
            if(mBlock.getPropertiesCount() > 0) {
                if(props == null)
                    props = new HashMap<String, String>();
                for(KeyValuePair pair : mBlock.getPropertiesList())
                    props.put(pair.getKey(), pair.getValue());
            }

            for(MessageFilter filter : Daemon.messageFilters) {
                filter.preSend(this);
            }

            if(msg.length > Daemon.MAX_TRANSMIT_MESSAGE_SIZE)
                throw new MistException(MistException.sizeTooLarge(msg.length));
        }
View Full Code Here

                }
                msg.props.put(GOC_REF, ref);
                msg.msg = "".getBytes();
            }
            else {
                throw new MistException("Unable to upload");
            }
        }
        catch(Exception e) {
            logger.error(e.getMessage(), e);
            throw new MistException(e.getMessage());
        }
        finally {
            try {
                conn.getOutputStream().close();
            }
View Full Code Here

                   
                    if(conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                        msg.builder.setMessage(ByteString.copyFrom(IOUtils.toByteArray(conn.getInputStream())));
                    }
                    else {
                        throw new MistException("unable to download " + ref);
                    }
                }
                catch(Exception e) {
                    logger.error(e.getMessage(), e);
                    throw new MistException(e.getMessage());
                }
                finally {
                    try {
                        conn.getOutputStream().close();
                    }
View Full Code Here

        return connList.toString();
    }
   
    public static String parseBrokerType(String t) throws MistException {
        if(!(t.equals("activemq") || t.equals("openmq")))
            throw new MistException(String.format("unknown broker type `%s'", t));
        return t;
    }
View Full Code Here

TOP

Related Classes of com.trendmicro.mist.MistException

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.