Package com.trendmicro.mist

Examples of com.trendmicro.mist.MistException


     * @throws MistException
     *             If the client is closed.
     */
    public MessagePair getMessage(int timeout) throws MistException {
        if(error)
            throw new MistException("session error, close and recreate it");
        if(onClose)
            throw new MistException("session closed");
        waitingThread = Thread.currentThread();
        if(timeout > 0) {
            try {
                return localQueue.poll(timeout, TimeUnit.MILLISECONDS);
            }
            catch(InterruptedException e) {
                throw new MistException("connection to MIST is broken!");
            }
        }
        else {
            try {
                return localQueue.take();
            }
            catch(InterruptedException e) {
                throw new MistException("connection to MIST is broken!");
            }
        }
    }
View Full Code Here


     * @throws MistException
     *             The session is closed or sending error occurs
     */
    public boolean writeMessage(MessageBlock msg, int timeout) throws MistException {
        if(error)
            throw new MistException("session error, close and recreate it");
        if(onClose)
            throw new MistException("session closed");
        waitingThread = Thread.currentThread();

        long startTs = System.currentTimeMillis();
        Acker acker = new Acker();
        if(timeout > 0) {
            try {
                if(!localQueue.offer(new MessagePair(msg, acker), timeout, TimeUnit.MILLISECONDS))
                    return false;

                long timeElapsed = (System.currentTimeMillis() - startTs);
                long timeLeft = timeout - timeElapsed;
                if(timeLeft <= 0)
                    return false;
                synchronized(acker) {
                    // if it is already acked, return true, or wait to be acked
                    if(acker.acked())
                        return true;
                    acker.wait(timeLeft);
                    return acker.acked();
                }
            }
            catch(InterruptedException e) {
                if(errorStr == null)
                    throw new MistException("connection to MIST is broken!");
                else
                    throw new MistException(errorStr);
            }
        }
        else {
            try {
                localQueue.put(new MessagePair(msg, acker));
                synchronized(acker) {
                    if(acker.acked())
                        return true;
                    acker.wait();
                    return acker.acked();
                }
            }
            catch(InterruptedException e) {
                if(errorStr == null)
                    throw new MistException("connection to MIST is broken!");
                else
                    throw new MistException(errorStr);
            }
        }
    }
View Full Code Here

                    }
                }
            }
            catch(Exception e) {
            }
            throw new MistException("cannot create session");
        }
View Full Code Here

                    }
                }
            }
            catch(Exception e) {
            }
            throw new MistException(String.format("cannot mount %s:%s", (isQueue ? "queue": "topic"), exName));
        }
View Full Code Here

                    }
                }
            }
            catch(Exception e) {
            }
            throw new MistException(String.format("cannot umount %s:%s", (isQueue ? "queue": "topic"), exName));
        }
View Full Code Here

                    }
                }
            }
            catch(Exception e) {
            }
            throw new MistException("cannot attach session");
        }
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.