Package javax.management.remote

Examples of javax.management.remote.NotificationResult


            }

            // init the clientSequenceNumber if not reconnected.
            if (!reconnected) {
                try {
                    NotificationResult nr = fetchNotifs(-1, 0, 0);

                    if (state != STOPPED) { // JDK-8038940
                                            // reconnection must happen during
                                            // fetchNotifs(-1, 0, 0), and a new
                                            // thread takes over the fetching job
                        return;
                    }

                    clientSequenceNumber = nr.getNextSequenceNumber();
                } catch (ClassNotFoundException e) {
                    // can't happen
                    logger.warning("init", "Impossible exception: "+ e);
                    logger.debug("init",e);
                }
View Full Code Here


                    setState(STARTED);
                }
            }


            NotificationResult nr = null;
            if (!shouldStop() && (nr = fetchNotifs()) != null) {
                // nr == null means got exception

                final TargetedNotification[] notifs =
                    nr.getTargetedNotifications();
                final int len = notifs.length;
                final Map<Integer, ClientListenerInfo> listeners;
                final Integer myListenerID;

                long missed = 0;

                synchronized(ClientNotifForwarder.this) {
                    // check sequence number.
                    //
                    if (clientSequenceNumber >= 0) {
                        missed = nr.getEarliestSequenceNumber() -
                            clientSequenceNumber;
                    }

                    clientSequenceNumber = nr.getNextSequenceNumber();

                    listeners = new HashMap<Integer, ClientListenerInfo>();

                    for (int i = 0 ; i < len ; i++) {
                        final TargetedNotification tn = notifs[i];
View Full Code Here

                "startSequenceNumber is " + startSequenceNumber +
                ", the timeout is " + timeout +
                ", the maxNotifications is " + maxNotifications);
        }

        NotificationResult nr;
        final long t = Math.min(connectionTimeout, timeout);
        try {
            nr = notifBuffer.fetchNotifications(bufferFilter,
                startSequenceNumber,
                t, maxNotifications);
            snoopOnUnregister(nr);
        } catch (InterruptedException ire) {
            nr = new NotificationResult(0L, 0L, new TargetedNotification[0]);
        }

        if (logger.traceOn()) {
            logger.trace("fetchNotifs", "Forwarding the notifs: "+nr);
        }
View Full Code Here

        }

        private NotificationResult fetchNotifs() {
            try {
                NotificationResult nr = ClientNotifForwarder.this.
                    fetchNotifs(clientSequenceNumber,maxNotifications,
                                timeout);

                if (logger.traceOn()) {
                    logger.trace("NotifFetcher-run",
View Full Code Here

            long startSequenceNumber = clientSequenceNumber;

            int notFoundCount = 0;

            NotificationResult result = null;
            long firstEarliest = -1;

            while (result == null && !shouldStop()) {
                NotificationResult nr;

                try {
                    // 0 notifs to update startSequenceNumber
                    nr = cnf.fetchNotifs(startSequenceNumber, 0, 0L);
                } catch (ClassNotFoundException e) {
                    logger.warning("NotifFetcher.fetchOneNotif",
                                   "Impossible exception: " + e);
                    logger.debug("NotifFetcher.fetchOneNotif",e);
                    return null;
                } catch (IOException e) {
                    if (!shouldStop())
                        logger.trace("NotifFetcher.fetchOneNotif", e);
                    return null;
                }

                if (shouldStop())
                    return null;

                startSequenceNumber = nr.getNextSequenceNumber();
                if (firstEarliest < 0)
                    firstEarliest = nr.getEarliestSequenceNumber();

                try {
                    // 1 notif to skip possible missing class
                    result = cnf.fetchNotifs(startSequenceNumber, 1, 0L);
                } catch (ClassNotFoundException | NotSerializableException | UnmarshalException e) {
                    logger.warning("NotifFetcher.fetchOneNotif",
                                   "Failed to deserialize a notification: "+e.toString());
                    if (logger.traceOn()) {
                        logger.trace("NotifFetcher.fetchOneNotif",
                                     "Failed to deserialize a notification.", e);
                    }

                    notFoundCount++;
                    startSequenceNumber++;
                } catch (Exception e) {
                    if (!shouldStop())
                        logger.trace("NotifFetcher.fetchOneNotif", e);
                    return null;
                }
            }

            if (notFoundCount > 0) {
                final String msg =
                    "Dropped " + notFoundCount + " notification" +
                    (notFoundCount == 1 ? "" : "s") +
                    " because classes were missing locally or incompatible";
                lostNotifs(msg, notFoundCount);
                // Even if result.getEarliestSequenceNumber() is now greater than
                // it was initially, meaning some notifs have been dropped
                // from the buffer, we don't want the caller to see that
                // because it is then likely to renotify about the lost notifs.
                // So we put back the first value of earliestSequenceNumber
                // that we saw.
                if (result != null) {
                    result = new NotificationResult(
                            firstEarliest, result.getNextSequenceNumber(),
                            result.getTargetedNotifications());
                }
            }
View Full Code Here

    */
   public void run()
   {
      try
      {
         NotificationResult result = connection.fetchNotifications(clientSequenceNumber, maxNotifications, fetchTimeout);
         if(result != null)
         {
            clientSequenceNumber = result.getNextSequenceNumber();
            TargetedNotification[] targetedNotifications = result.getTargetedNotifications();
            if(targetedNotifications != null)
            {
               deliverNotifications(targetedNotifications);
            }
         }
View Full Code Here

      if(clientSequenceNumber < 0)
      {
         //TODO: -TME this means will be the next notification that comes in (JBREM-150)
      }

      NotificationResult result = null;
      boolean waitForTimeout = true;
      boolean timeoutReached = false;

      int startIndex = 0;

      while(waitForTimeout)
      {
         synchronized(clientListenerNotifications)
         {
            waitForTimeout = false;

            // since the startSequence should be in sync with the first (0) index of the clientListenerNotifications,
            // will use this to determine how far up the index to start.
            if(clientSequenceNumber > startSequence)
            {
               startIndex = (int) (clientSequenceNumber - startSequence);

               if(startIndex > clientListenerNotifications.size())
               {
                  if(timeout > 0 && !timeoutReached)
                  {
                     //need to wait
                     try
                     {
                        clientListenerNotifications.wait(timeout);
                        waitForTimeout = true;
                        timeoutReached = true;
                     }
                     catch(InterruptedException e)
                     {
                        log.debug("Caught InterruptedException waiting for clientListenerNotifications.");
                     }
                  }
                  else
                  {
                     startIndex = clientListenerNotifications.size();
                  }
               }
            }

            int endIndex = maxNotifications > (clientListenerNotifications.size() - startIndex) ? clientListenerNotifications.size() : maxNotifications;

            // handle timeout
            if(endIndex == startIndex)
            {
               if(timeout > 0 && !timeoutReached)
               {
                  //need to wait
                  try
                  {
                     clientListenerNotifications.wait(timeout);
                     waitForTimeout = true;
                     timeoutReached = true;
                  }
                  catch(InterruptedException e)
                  {
                     log.debug("Caught InterruptedException waiting for clientListenerNotifications.");
                  }
               }
            }

            List fetchedNotifications = clientListenerNotifications.subList(startIndex, endIndex);
            TargetedNotification[] targetedNotifications = (TargetedNotification[]) fetchedNotifications.toArray(new TargetedNotification[fetchedNotifications.size()]);

            result = new NotificationResult(clientSequenceNumber, currentSequence, targetedNotifications);
         }
      }

      return result;
   }
View Full Code Here

        }

        private NotificationResult fetchNotifs() {
            try {
                NotificationResult nr = ClientNotifForwarder.this.
                        fetchNotifs(clientSequenceNumber, maxNotifications,
                        timeout);

                if (logger.traceOn()) {
                    logger.trace("NotifFetcher-run",
View Full Code Here

            long startSequenceNumber = clientSequenceNumber;

            int notFoundCount = 0;

            NotificationResult result = null;

            while (result == null && !shouldStop()) {
                NotificationResult nr;

                try {
                    // 0 notifs to update startSequenceNumber
                    nr = cnf.fetchNotifs(startSequenceNumber, 0, 0L);
                } catch (ClassNotFoundException e) {
                    logger.warning("NotifFetcher.fetchOneNotif",
                            "Impossible exception: " + e);
                    logger.debug("NotifFetcher.fetchOneNotif", e);
                    return null;
                } catch (IOException e) {
                    if (!shouldStop()) {
                        logger.trace("NotifFetcher.fetchOneNotif", e);
                    }
                    return null;
                }

                if (shouldStop()) {
                    return null;
                }

                startSequenceNumber = nr.getNextSequenceNumber();

                try {
                    // 1 notif to skip possible missing class
                    result = cnf.fetchNotifs(startSequenceNumber, 1, 0L);
                } catch (Exception e) {
View Full Code Here

                "startSequenceNumber is " + startSequenceNumber +
                ", the timeout is " + timeout +
                ", the maxNotifications is " + maxNotifications);
        }
       
        NotificationResult nr = null;
        final long t = Math.min(connectionTimeout, timeout);
        try {
            nr = notifBuffer.fetchNotifications(bufferFilter,
                startSequenceNumber,
                t, maxNotifications);
        } catch (InterruptedException ire) {
            nr = new NotificationResult(0L, 0L, new TargetedNotification[0]);
        }

        if (logger.traceOn()) {
            logger.trace("fetchNotifs", "Forwarding the notifs: "+nr);
        }
View Full Code Here

TOP

Related Classes of javax.management.remote.NotificationResult

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.