Package org.jboss.errai.bus.client.framework

Examples of org.jboss.errai.bus.client.framework.Payload


                    m = queue.poll();
                }

                int payLoadSize = 0;

                Payload p = new Payload(m == null ? heartBeat : m);

                if (_windowPolling) {
                    windowPolling = true;
                    _windowPolling = false;
                } else if (windowPolling) {
                    while (!queue.isEmpty() && payLoadSize < MAXIMUM_PAYLOAD_SIZE
                            && !isWindowExceeded()) {
                        p.addMessage(queue.poll());
                        payLoadSize++;

                        try {
                            if (queue.isEmpty())
                                Thread.sleep(nanoTime() - endWindow);
                        }
                        catch (Exception e) {
                            // just resume.
                        }
                    }

                    if (!throttleIncoming && queue.size() > lastQueueSize) {
                        if (transmissionWindow < MAX_TRANSMISSION_WINDOW) {
                            transmissionWindow += millis(50);
                        } else {
                            throttleIncoming = true;
                            System.err.println("[Warning: A queue has become saturated and " +
                                    "performance is now being degraded.]");
                        }

                    } else if (queue.isEmpty()) {
                        transmissionWindow = DEFAULT_TRANSMISSION_WINDOW;
                        throttleIncoming = false;
                    }
                }

                lastQueueSize = queue.size();
                endWindow = (lastTransmission = nanoTime()) + transmissionWindow;

                return p;

            }
            catch (InterruptedException e) {
                e.printStackTrace();
            }
            finally {
                lock.release();
            }

        }
        return new Payload(heartBeat);
    }
View Full Code Here


//            }

                int payLoadSize = 0;

                Payload p = new Payload(m == null ? heartBeat : m);

                if (_windowPolling) {
                    windowPolling = true;
                    _windowPolling = false;
                } else if (windowPolling) {

                    //     try {
                    //   if (lock.tryAcquire(0, TimeUnit.SECONDS)) {
                    while (!queue.isEmpty() && payLoadSize < MAXIMUM_PAYLOAD_SIZE
                            && !isWindowExceeded()) {
                        p.addMessage(queue.poll());
                        payLoadSize++;

                        try {
                            if (queue.isEmpty())
                                Thread.sleep(currentTimeMillis() - endWindow);
                        }
                        catch (Exception e) {
                            // just resume.
                        }
                    }
                    //      }
                    //    }
                    //    finally {
                    //        lock.release();
                    //    }

                    if (!throttleIncoming && queue.size() > lastQueueSize) {
                        if (transmissionWindow < MAX_TRANSMISSION_WINDOW) {
                            transmissionWindow += 5;
                            System.err.println("[Congestion on queue -- New transmission window: "
                                    + transmissionWindow + "; Queue size: " + queue.size() + ")]");
                        } else {
                            throttleIncoming = true;
                            System.err.println("[Warning: A queue has become saturated and " +
                                    "performance is now being degraded.]");
                        }

                    } else if (queue.isEmpty()) {
                        transmissionWindow = DEFAULT_TRANSMISSION_WINDOW;
                        throttleIncoming = false;
                    }
                }

                lastQueueSize = queue.size();
                endWindow = (lastTransmission = currentTimeMillis()) + transmissionWindow;

                return p;

            }
            catch (InterruptedException e) {
                e.printStackTrace();
            }
            finally {
                lock.release();
            }

        }
        return new Payload(heartBeat);
    }
View Full Code Here

                }


                int payLoadSize = 0;

                Payload p = new Payload(m == null ? heartBeat : m);

                if (_windowPolling) {
                    windowPolling = true;
                    _windowPolling = false;
                } else if (windowPolling) {
                    while (!queue.isEmpty() && payLoadSize < MAXIMUM_PAYLOAD_SIZE
                            && !isWindowExceeded()) {
                        p.addMessage(queue.poll());
                        payLoadSize++;

                        try {
                            if (queue.isEmpty())
                                Thread.sleep(nanoTime() - endWindow);
                        }
                        catch (Exception e) {
                            // just resume.
                        }
                    }

                    if (!throttleIncoming && queue.size() > lastQueueSize) {
                        if (transmissionWindow < MAX_TRANSMISSION_WINDOW) {
                            transmissionWindow += millis(50);
                            System.err.println("[Congestion on queue -- New transmission window: "
                                    + transmissionWindow + "; Queue size: " + queue.size() + ")]");
                        } else {
                            throttleIncoming = true;
                            System.err.println("[Warning: A queue has become saturated and " +
                                    "performance is now being degraded.]");
                        }

                    } else if (queue.isEmpty()) {
                        transmissionWindow = DEFAULT_TRANSMISSION_WINDOW;
                        throttleIncoming = false;
                    }
                }

                lastQueueSize = queue.size();
                endWindow = (lastTransmission = nanoTime()) + transmissionWindow;

                return p;

            }
            catch (InterruptedException e) {
                e.printStackTrace();
            }
            finally {
                lock.release();
            }

        }
        return new Payload(heartBeat);
    }
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.client.framework.Payload

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.