Package org.apache.derby.iapi.services.jmx

Examples of org.apache.derby.iapi.services.jmx.ManagementService


                }
              );
    clientThread.start();
       
        // Now that we are up and running, register any MBeans
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));
       
        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");
                     
    try {
      // wait until we are told to shutdown or someone sends an InterruptedException
          synchronized(shutdownSync) {
              try {
          shutdownSync.wait();
              }
              catch (InterruptedException e)
              {
                  shutdown = true;
              }
          }
         
          try {
              AccessController.doPrivileged(
                      new PrivilegedAction() {
                          public Object run()  {
                          // Need to interrupt the memcheck thread if it is sleeping.
                              if (mc != null)
                                  mc.interrupt();

                              //interrupt client thread
                              clientThread.interrupt();

                              return null;
                         }
                      });
          } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
          }
     
       // Close out the sessions
       synchronized(sessionTable) {
         for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
         { 
           Session session = (Session) e.nextElement();
           try {
             session.close();
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
       }

      synchronized (threadList)
      {
         //interupt any connection threads still active
         for (int i = 0; i < threadList.size(); i++)
         {
           try {
             final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
                    
              threadi.close();
             AccessController.doPrivileged(
                   new PrivilegedAction() {
                     public Object run() {
                       threadi.interrupt();
                       return null;
                     }
                   });
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
         threadList.clear();
      }
        
        // close the listener socket
        try{
           serverSocket.close();
        }catch(IOException e){
        consolePropertyMessage("DRDA_ListenerClose.S", true);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      // Wake up those waiting on sessions, so
      // they can close down
        try{
        synchronized (runQueue) {
          runQueue.notifyAll();
       
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }
         
          // And now unregister any MBeans.
        try {
            mgmtService.unregisterMBean(versionMBean);
            mgmtService.unregisterMBean(networkServerMBean);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      if (shutdownDatabasesOnShutdown) {
View Full Code Here


                }
              );
    clientThread.start();
       
        // Now that we are up and running, register any MBeans
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));
       
        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");
                     
    // wait until we are told to shutdown or someone sends an InterruptedException
        synchronized(shutdownSync) {
            try {
        shutdownSync.wait();
            }
            catch (InterruptedException e)
            {
                shutdown = true;
            }
        }
       
        AccessController.doPrivileged(
                new PrivilegedAction() {
                    public Object run()  {
                    // Need to interrupt the memcheck thread if it is sleeping.
                        if (mc != null)
                            mc.interrupt();

                        //interrupt client thread
                        clientThread.interrupt();

                        return null;
                    }
                });
   
     // Close out the sessions
     synchronized(sessionTable) {
       for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
       { 
         Session session = (Session) e.nextElement();
         session.close();
       }
     }

    synchronized (threadList)
    {
       //interupt any connection threads still active
       for (int i = 0; i < threadList.size(); i++)
       {
        final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
               
         threadi.close();
        AccessController.doPrivileged(
              new PrivilegedAction() {
                public Object run() {
                  threadi.interrupt();
                  return null;
                }
              });
       }
       threadList.clear();
    }
      
      // close the listener socket
      try{
         serverSocket.close();
      }catch(IOException e){
      consolePropertyMessage("DRDA_ListenerClose.S", true);
      }


    // Wake up those waiting on sessions, so
    // they can close down
    synchronized (runQueue) {
      runQueue.notifyAll();
   
       
        // And now unregister any MBeans.
        mgmtService.unregisterMBean(versionMBean);
        mgmtService.unregisterMBean(networkServerMBean);

    if (shutdownDatabasesOnShutdown) {

      // Shutdown Derby
      try {
View Full Code Here

        // First, register any MBeans. We do this before we start accepting
        // connections from the clients to ease testing of JMX (DERBY-3689).
        // This way we know that once we can connect to the network server,
        // the MBeans will be available.
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));

        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");

        // We accept clients on a separate thread so we don't run into a problem
        // blocking on the accept when trying to process a shutdown
        final ClientThread clientThread = AccessController.doPrivileged(
                new PrivilegedExceptionAction<ClientThread>() {
                    public ClientThread run() throws Exception {
                        return new ClientThread(thisControl, serverSocket);
                    }
                });
        clientThread.start();

        try {
            // wait until we are told to shutdown or someone sends an InterruptedException
            synchronized(shutdownSync) {
                try {
                    while (!shutdown) {
                        shutdownSync.wait();
                    }
                }
                catch (InterruptedException e)
                {
                    shutdown = true;
                }
            }
           
            try {
                AccessController.doPrivileged(
                        new PrivilegedAction<Void>() {
                            public Void run() {
                            // Need to interrupt the memcheck thread if it is sleeping.
                                if (mc != null)
                                    mc.interrupt();

                                //interrupt client thread
                                clientThread.interrupt();

                                return null;
                           }
                        });
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }
           
            // Close out the sessions
            synchronized(sessionTable) {
                for (Session session : sessionTable.values())
                {
                    try {
                        session.close();
                    } catch (Exception exception) {
                        consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
                    }
                }
            }

            synchronized (threadList)
            {
                //interupt any connection threads still active
                for (final DRDAConnThread threadi : threadList)
                {
                    try {
                        threadi.close();
                        AccessController.doPrivileged(
                                new PrivilegedAction<Void>() {
                                    public Void run() {
                                        threadi.interrupt();
                                        return null;
                                    }
                                });
                    } catch (Exception exception) {
                        consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
                    }
                }
                threadList.clear();
            }

            // close the listener socket
            try{
               serverSocket.close();
            }catch(IOException e){
                consolePropertyMessage("DRDA_ListenerClose.S", true);
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }

            // Wake up those waiting on sessions, so
            // they can close down
            try{
                synchronized (runQueue) {
                    runQueue.notifyAll();
                }
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }
           
            // And now unregister any MBeans.
            try {
                mgmtService.unregisterMBean(versionMBean);
                mgmtService.unregisterMBean(networkServerMBean);
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }

            if (shutdownDatabasesOnShutdown) {
View Full Code Here

        // First, register any MBeans. We do this before we start accepting
        // connections from the clients to ease testing of JMX (DERBY-3689).
        // This way we know that once we can connect to the network server,
        // the MBeans will be available.
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));

        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");

        // We accept clients on a separate thread so we don't run into a problem
        // blocking on the accept when trying to process a shutdown
        final ClientThread clientThread = AccessController.doPrivileged(
                new PrivilegedExceptionAction<ClientThread>() {
                    public ClientThread run() throws Exception {
                        return new ClientThread(thisControl, serverSocket);
                    }
                });
        clientThread.start();

        try {
            // wait until we are told to shutdown or someone sends an InterruptedException
            synchronized(shutdownSync) {
                try {
                    while (!shutdown) {
                        shutdownSync.wait();
                    }
                }
                catch (InterruptedException e)
                {
                    shutdown = true;
                }
            }
           
            try {
                AccessController.doPrivileged(
                        new PrivilegedAction<Void>() {
                            public Void run() {
                            // Need to interrupt the memcheck thread if it is sleeping.
                                if (mc != null)
                                    mc.interrupt();

                                //interrupt client thread
                                clientThread.interrupt();

                                return null;
                           }
                        });
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }
           
            // Close out the sessions
            synchronized(sessionTable) {
                for (Session session : sessionTable.values())
                {
                    try {
                        session.close();
                    } catch (Exception exception) {
                        consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
                    }
                }
            }

            synchronized (threadList)
            {
                //interupt any connection threads still active
                for (final DRDAConnThread threadi : threadList)
                {
                    try {
                        threadi.close();
                        AccessController.doPrivileged(
                                new PrivilegedAction<Void>() {
                                    public Void run() {
                                        threadi.interrupt();
                                        return null;
                                    }
                                });
                    } catch (Exception exception) {
                        consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
                    }
                }
                threadList.clear();
            }

            // close the listener socket
            try{
               serverSocket.close();
            }catch(IOException e){
                consolePropertyMessage("DRDA_ListenerClose.S", true);
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }

            // Wake up those waiting on sessions, so
            // they can close down
            try{
                synchronized (runQueue) {
                    runQueue.notifyAll();
                }
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }
           
            // And now unregister any MBeans.
            try {
                mgmtService.unregisterMBean(versionMBean);
                mgmtService.unregisterMBean(networkServerMBean);
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }

            if (shutdownDatabasesOnShutdown) {
View Full Code Here

                }
              );
    clientThread.start();
       
        // Now that we are up and running, register any MBeans
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));
       
        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");
                     
    try {
      // wait until we are told to shutdown or someone sends an InterruptedException
          synchronized(shutdownSync) {
              try {
          shutdownSync.wait();
              }
              catch (InterruptedException e)
              {
                  shutdown = true;
              }
          }
         
          try {
              AccessController.doPrivileged(
                      new PrivilegedAction() {
                          public Object run()  {
                          // Need to interrupt the memcheck thread if it is sleeping.
                              if (mc != null)
                                  mc.interrupt();

                              //interrupt client thread
                              clientThread.interrupt();

                              return null;
                         }
                      });
          } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
          }
     
       // Close out the sessions
       synchronized(sessionTable) {
         for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
         { 
           Session session = (Session) e.nextElement();
           try {
             session.close();
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
       }

      synchronized (threadList)
      {
         //interupt any connection threads still active
         for (int i = 0; i < threadList.size(); i++)
         {
           try {
             final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
                    
              threadi.close();
             AccessController.doPrivileged(
                   new PrivilegedAction() {
                     public Object run() {
                       threadi.interrupt();
                       return null;
                     }
                   });
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
         threadList.clear();
      }
        
        // close the listener socket
        try{
           serverSocket.close();
        }catch(IOException e){
        consolePropertyMessage("DRDA_ListenerClose.S", true);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      // Wake up those waiting on sessions, so
      // they can close down
        try{
        synchronized (runQueue) {
          runQueue.notifyAll();
       
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }
         
          // And now unregister any MBeans.
        try {
            mgmtService.unregisterMBean(versionMBean);
            mgmtService.unregisterMBean(networkServerMBean);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      if (shutdownDatabasesOnShutdown) {
View Full Code Here

        // First, register any MBeans. We do this before we start accepting
        // connections from the clients to ease testing of JMX (DERBY-3689).
        // This way we know that once we can connect to the network server,
        // the MBeans will be available.
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));

        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");

        // We accept clients on a separate thread so we don't run into a problem
        // blocking on the accept when trying to process a shutdown
        final ClientThread clientThread = AccessController.doPrivileged(
                new PrivilegedExceptionAction<ClientThread>() {
                    public ClientThread run() throws Exception {
                        return new ClientThread(thisControl, serverSocket);
                    }
                });
        clientThread.start();

        try {
            // wait until we are told to shutdown or someone sends an InterruptedException
            synchronized(shutdownSync) {
                try {
                    while (!shutdown) {
                        shutdownSync.wait();
                    }
                }
                catch (InterruptedException e)
                {
                    shutdown = true;
                }
            }
           
            try {
                AccessController.doPrivileged(
                        new PrivilegedAction<Void>() {
                            public Void run() {
                            // Need to interrupt the memcheck thread if it is sleeping.
                                if (mc != null)
                                    mc.interrupt();

                                //interrupt client thread
                                clientThread.interrupt();

                                return null;
                           }
                        });
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }
           
            // Close out the sessions
            synchronized(sessionTable) {
                for (Session session : sessionTable.values())
                {
                    try {
                        session.close();
                    } catch (Exception exception) {
                        consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
                    }
                }
            }

            synchronized (threadList)
            {
                //interupt any connection threads still active
                for (final DRDAConnThread threadi : threadList)
                {
                    try {
                        threadi.close();
                        AccessController.doPrivileged(
                                new PrivilegedAction<Void>() {
                                    public Void run() {
                                        threadi.interrupt();
                                        return null;
                                    }
                                });
                    } catch (Exception exception) {
                        consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
                    }
                }
                threadList.clear();
            }

            // close the listener socket
            try{
               serverSocket.close();
            }catch(IOException e){
                consolePropertyMessage("DRDA_ListenerClose.S", true);
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }

            // Wake up those waiting on sessions, so
            // they can close down
            try{
                synchronized (runQueue) {
                    runQueue.notifyAll();
                }
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }
           
            // And now unregister any MBeans.
            try {
                mgmtService.unregisterMBean(versionMBean);
                mgmtService.unregisterMBean(networkServerMBean);
            } catch (Exception exception) {
                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
            }

            if (shutdownDatabasesOnShutdown) {
View Full Code Here

        // First, register any MBeans. We do this before we start accepting
        // connections from the clients to ease testing of JMX (DERBY-3689).
        // This way we know that once we can connect to the network server,
        // the MBeans will be available.
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));

        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");

    // We accept clients on a separate thread so we don't run into a problem
    // blocking on the accept when trying to process a shutdown
    final ClientThread clientThread =  
      (ClientThread) AccessController.doPrivileged(
                new PrivilegedExceptionAction() {
                  public Object run() throws Exception
                  {
                    return new ClientThread(thisControl,
                                serverSocket);
                  }
                }
              );
    clientThread.start();

    try {
      // wait until we are told to shutdown or someone sends an InterruptedException
          synchronized(shutdownSync) {
              try {
                    while (!shutdown) {
                        shutdownSync.wait();
                    }
              }
              catch (InterruptedException e)
              {
                  shutdown = true;
              }
          }
         
          try {
              AccessController.doPrivileged(
                      new PrivilegedAction() {
                          public Object run()  {
                          // Need to interrupt the memcheck thread if it is sleeping.
                              if (mc != null)
                                  mc.interrupt();

                              //interrupt client thread
                              clientThread.interrupt();

                              return null;
                         }
                      });
          } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
          }
     
       // Close out the sessions
       synchronized(sessionTable) {
         for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
         { 
           Session session = (Session) e.nextElement();
           try {
             session.close();
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
       }

      synchronized (threadList)
      {
         //interupt any connection threads still active
         for (int i = 0; i < threadList.size(); i++)
         {
           try {
             final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
                    
              threadi.close();
             AccessController.doPrivileged(
                   new PrivilegedAction() {
                     public Object run() {
                       threadi.interrupt();
                       return null;
                     }
                   });
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
         threadList.clear();
      }
        
        // close the listener socket
        try{
           serverSocket.close();
        }catch(IOException e){
        consolePropertyMessage("DRDA_ListenerClose.S", true);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      // Wake up those waiting on sessions, so
      // they can close down
        try{
        synchronized (runQueue) {
          runQueue.notifyAll();
       
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }
         
          // And now unregister any MBeans.
        try {
            mgmtService.unregisterMBean(versionMBean);
            mgmtService.unregisterMBean(networkServerMBean);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      if (shutdownDatabasesOnShutdown) {
View Full Code Here

                }
              );
    clientThread.start();
       
        // Now that we are up and running, register any MBeans
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));
       
        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");
                     
    try {
      // wait until we are told to shutdown or someone sends an InterruptedException
          synchronized(shutdownSync) {
              try {
                    while (!shutdown) {
                        shutdownSync.wait();
                    }
              }
              catch (InterruptedException e)
              {
                  shutdown = true;
              }
          }
         
          try {
              AccessController.doPrivileged(
                      new PrivilegedAction() {
                          public Object run()  {
                          // Need to interrupt the memcheck thread if it is sleeping.
                              if (mc != null)
                                  mc.interrupt();

                              //interrupt client thread
                              clientThread.interrupt();

                              return null;
                         }
                      });
          } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
          }
     
       // Close out the sessions
       synchronized(sessionTable) {
         for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
         { 
           Session session = (Session) e.nextElement();
           try {
             session.close();
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
       }

      synchronized (threadList)
      {
         //interupt any connection threads still active
         for (int i = 0; i < threadList.size(); i++)
         {
           try {
             final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
                    
              threadi.close();
             AccessController.doPrivileged(
                   new PrivilegedAction() {
                     public Object run() {
                       threadi.interrupt();
                       return null;
                     }
                   });
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
         threadList.clear();
      }
        
        // close the listener socket
        try{
           serverSocket.close();
        }catch(IOException e){
        consolePropertyMessage("DRDA_ListenerClose.S", true);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      // Wake up those waiting on sessions, so
      // they can close down
        try{
        synchronized (runQueue) {
          runQueue.notifyAll();
       
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }
         
          // And now unregister any MBeans.
        try {
            mgmtService.unregisterMBean(versionMBean);
            mgmtService.unregisterMBean(networkServerMBean);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      if (shutdownDatabasesOnShutdown) {
View Full Code Here

                }
              );
    clientThread.start();
       
        // Now that we are up and running, register any MBeans
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));
       
        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");
                     
    // wait until we are told to shutdown or someone sends an InterruptedException
        synchronized(shutdownSync) {
            try {
        shutdownSync.wait();
            }
            catch (InterruptedException e)
            {
                shutdown = true;
            }
        }
       
        AccessController.doPrivileged(
                new PrivilegedAction() {
                    public Object run()  {
                    // Need to interrupt the memcheck thread if it is sleeping.
                        if (mc != null)
                            mc.interrupt();

                        //interrupt client thread
                        clientThread.interrupt();

                        return null;
                    }
                });
   
     // Close out the sessions
     synchronized(sessionTable) {
       for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
       { 
         Session session = (Session) e.nextElement();
         session.close();
       }
     }

    synchronized (threadList)
    {
       //interupt any connection threads still active
       for (int i = 0; i < threadList.size(); i++)
       {
        final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
               
         threadi.close();
        AccessController.doPrivileged(
              new PrivilegedAction() {
                public Object run() {
                  threadi.interrupt();
                  return null;
                }
              });
       }
       threadList.clear();
    }
      
      // close the listener socket
      try{
         serverSocket.close();
      }catch(IOException e){
      consolePropertyMessage("DRDA_ListenerClose.S");
      }


    // Wake up those waiting on sessions, so
    // they can close down
    synchronized (runQueue) {
      runQueue.notifyAll();
   
       
        // And now unregister any MBeans.
        mgmtService.unregisterMBean(versionMBean);
        mgmtService.unregisterMBean(networkServerMBean);

    if (shutdownDatabasesOnShutdown) {

      // Shutdown Derby
      try {
View Full Code Here

        // First, register any MBeans. We do this before we start accepting
        // connections from the clients to ease testing of JMX (DERBY-3689).
        // This way we know that once we can connect to the network server,
        // the MBeans will be available.
        ManagementService mgmtService = ((ManagementService)
                Monitor.getSystemModule(Module.JMX));

        final Object versionMBean = mgmtService.registerMBean(
                           new Version(
                                   getNetProductVersionHolder(),
                                   SystemPermission.SERVER),
                           VersionMBean.class,
                           "type=Version,jar=derbynet.jar");
        final Object networkServerMBean = mgmtService.registerMBean(
                            new NetworkServerMBeanImpl(this),
                            NetworkServerMBean.class,
                            "type=NetworkServer");

    // We accept clients on a separate thread so we don't run into a problem
    // blocking on the accept when trying to process a shutdown
    final ClientThread clientThread =  
      (ClientThread) AccessController.doPrivileged(
                new PrivilegedExceptionAction() {
                  public Object run() throws Exception
                  {
                    return new ClientThread(thisControl,
                                serverSocket);
                  }
                }
              );
    clientThread.start();

    try {
      // wait until we are told to shutdown or someone sends an InterruptedException
          synchronized(shutdownSync) {
              try {
                    while (!shutdown) {
                        shutdownSync.wait();
                    }
              }
              catch (InterruptedException e)
              {
                  shutdown = true;
              }
          }
         
          try {
              AccessController.doPrivileged(
                      new PrivilegedAction() {
                          public Object run()  {
                          // Need to interrupt the memcheck thread if it is sleeping.
                              if (mc != null)
                                  mc.interrupt();

                              //interrupt client thread
                              clientThread.interrupt();

                              return null;
                         }
                      });
          } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
          }
     
       // Close out the sessions
       synchronized(sessionTable) {
         for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
         { 
           Session session = (Session) e.nextElement();
           try {
             session.close();
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
       }

      synchronized (threadList)
      {
         //interupt any connection threads still active
         for (int i = 0; i < threadList.size(); i++)
         {
           try {
             final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
                    
              threadi.close();
             AccessController.doPrivileged(
                   new PrivilegedAction() {
                     public Object run() {
                       threadi.interrupt();
                       return null;
                     }
                   });
           } catch (Exception exception) {
                 consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
           }
         }
         threadList.clear();
      }
        
        // close the listener socket
        try{
           serverSocket.close();
        }catch(IOException e){
        consolePropertyMessage("DRDA_ListenerClose.S", true);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      // Wake up those waiting on sessions, so
      // they can close down
        try{
        synchronized (runQueue) {
          runQueue.notifyAll();
       
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }
         
          // And now unregister any MBeans.
        try {
            mgmtService.unregisterMBean(versionMBean);
            mgmtService.unregisterMBean(networkServerMBean);
        } catch (Exception exception) {
            consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
        }

      if (shutdownDatabasesOnShutdown) {
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.jmx.ManagementService

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.