new-integration-tests/src/test/resources/apps/clusterview/src/java/oracle/weblogic/kubernetes/applications/clusterview/ClusterViewServlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
      out.println("<!DOCTYPE html>");
      out.println("<html>");
      out.println("<head>");
      out.println("<title>ClusterViewServlet</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<pre>");

      String queryServers = request.getParameter("queryServers");
      if (queryServers != null) {
        // print all mbeans and its attributes in the server runtime
        out.println("Querying server: " + localMBeanServer.toString());
        Set<ObjectInstance> mbeans = localMBeanServer.queryMBeans(null, null);
        for (ObjectInstance mbeanInstance : mbeans) {
          out.println("<br>ObjectName: " + mbeanInstance.getObjectName() + "<br>");
          MBeanInfo mBeanInfo = localMBeanServer.getMBeanInfo(mbeanInstance.getObjectName());
          MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes();
          for (MBeanAttributeInfo attribute : attributes) {
            out.println("<br>Type: " + attribute.getType() + "<br>");
            out.println("<br>Name: " + attribute.getName() + "<br>");
          }
        }
      }

      ClusterRuntimeMBean clusterRuntime = serverRuntime.getClusterRuntime();
      //if the server is part of a cluster get its cluster details
      if (clusterRuntime != null) {
        String[] serverNames = clusterRuntime.getServerNames();
        out.println("Alive:" + clusterRuntime.getAliveServerCount());
        out.println("Health:" + clusterRuntime.getHealthState().getState());
        out.println("Members:" + String.join(",", serverNames));
        out.println("ServerName:" + serverRuntime.getName());

        // lookup JNDI for other clustered servers bound in tree
        for (String serverName : serverNames) {
          try {
            if (ctx.lookup(serverName) != null) {
              out.println("Bound:" + serverName);
            }
          } catch (NameNotFoundException nnfex) {
            out.println(nnfex.getMessage());
          }
        }
      }

      String listServers = request.getParameter("listServers");
      if (listServers != null) {
        ServerRuntimeMBean[] serverRuntimes = domainRuntimeServiceMbean.getServerRuntimes();
        for (ServerRuntimeMBean serverRuntime : serverRuntimes) {
          out.println(serverRuntime.getName() + ":STATUS<BR>");
          int state = serverRuntime.getHealthState().getState();
          switch (state) {
            case HealthState.HEALTH_OK:
              out.print(serverRuntime.getName() + ":HEALTH_OK");
              break;
            case HealthState.HEALTH_CRITICAL:
              out.print(serverRuntime.getName() + ":HEALTH_CRITICAL");
              break;
            case HealthState.HEALTH_FAILED:
              out.print(serverRuntime.getName() + ":HEALTH_FAILED");
              break;
            case HealthState.HEALTH_OVERLOADED:
              out.print(serverRuntime.getName() + ":HEALTH_OVERLOADED");
              break;
            case HealthState.HEALTH_WARN:
              out.print(serverRuntime.getName() + ":HEALTH_WARN");
              break;
            default:
              out.print(serverRuntime.getName() + ":HEALTH_WARN");
          }
          out.println("<BR>");
        }
      }
      out.println("</pre>");
      out.println("</body>");
      out.println("</html>");
    } catch (NamingException | InstanceNotFoundException
        | IntrospectionException | ReflectionException ex) {
      Logger.getLogger(ClusterViewServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
/**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
Processes requests for both HTTP GET and POST methods.
@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
Processes requests for both HTTP GET and POST methods . @param request servlet request @param response servlet response @throws ServletException if a servlet - specific error occurs @throws IOException if an I / O error occurs
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
      out.println("<!DOCTYPE html>");
      out.println("<html>");
      out.println("<head>");
      out.println("<title>ClusterViewServlet</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<pre>");
      String queryServers = request.getParameter("queryServers");
      if (queryServers != null) {
        out.println("Querying server: " + localMBeanServer.toString());
        Set<ObjectInstance> mbeans = localMBeanServer.queryMBeans(null, null);
        for (ObjectInstance mbeanInstance : mbeans) {
          out.println("<br>ObjectName: " + mbeanInstance.getObjectName() + "<br>");
          MBeanInfo mBeanInfo = localMBeanServer.getMBeanInfo(mbeanInstance.getObjectName());
          MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes();
          for (MBeanAttributeInfo attribute : attributes) {
            out.println("<br>Type: " + attribute.getType() + "<br>");
            out.println("<br>Name: " + attribute.getName() + "<br>");
          }
        }
      }
      ClusterRuntimeMBean clusterRuntime = serverRuntime.getClusterRuntime();
      if (clusterRuntime != null) {
        String[] serverNames = clusterRuntime.getServerNames();
        out.println("Alive:" + clusterRuntime.getAliveServerCount());
        out.println("Health:" + clusterRuntime.getHealthState().getState());
        out.println("Members:" + String.join(",", serverNames));
        out.println("ServerName:" + serverRuntime.getName());
        for (String serverName : serverNames) {
          try {
            if (ctx.lookup(serverName) != null) {
              out.println("Bound:" + serverName);
            }
          } catch (NameNotFoundException nnfex) {
            out.println(nnfex.getMessage());
          }
        }
      }
      String listServers = request.getParameter("listServers");
      if (listServers != null) {
        ServerRuntimeMBean[] serverRuntimes = domainRuntimeServiceMbean.getServerRuntimes();
        for (ServerRuntimeMBean serverRuntime : serverRuntimes) {
          out.println(serverRuntime.getName() + ":STATUS<BR>");
          int state = serverRuntime.getHealthState().getState();
          switch (state) {
            case HealthState.HEALTH_OK:
              out.print(serverRuntime.getName() + ":HEALTH_OK");
              break;
            case HealthState.HEALTH_CRITICAL:
              out.print(serverRuntime.getName() + ":HEALTH_CRITICAL");
              break;
            case HealthState.HEALTH_FAILED:
              out.print(serverRuntime.getName() + ":HEALTH_FAILED");
              break;
            case HealthState.HEALTH_OVERLOADED:
              out.print(serverRuntime.getName() + ":HEALTH_OVERLOADED");
              break;
            case HealthState.HEALTH_WARN:
              out.print(serverRuntime.getName() + ":HEALTH_WARN");
              break;
            default:
              out.print(serverRuntime.getName() + ":HEALTH_WARN");
          }
          out.println("<BR>");
        }
      }
      out.println("</pre>");
      out.println("</body>");
      out.println("</html>");
    } catch (NamingException | InstanceNotFoundException
        | IntrospectionException | ReflectionException ex) {
      Logger.getLogger(ClusterViewServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "text/html;charset=UTF-8" ) ; try ( PrintWriter out = response . getWriter ( ) ) { out . println ( "<!DOCTYPE html>" ) ; out . println ( "<html>" ) ; out . println ( "<head>" ) ; out . println ( "<title>ClusterViewServlet</title>" ) ; out . println ( "</head>" ) ; out . println ( "<body>" ) ; out . println ( "<pre>" ) ; String queryServers = request . getParameter ( "queryServers" ) ; if ( queryServers != null ) { out . println ( "Querying server: " + localMBeanServer . toString ( ) ) ; Set < ObjectInstance > mbeans = localMBeanServer . queryMBeans ( null , null ) ; for ( ObjectInstance mbeanInstance : mbeans ) { out . println ( "<br>ObjectName: " + mbeanInstance . getObjectName ( ) + "<br>" ) ; MBeanInfo mBeanInfo = localMBeanServer . getMBeanInfo ( mbeanInstance . getObjectName ( ) ) ; MBeanAttributeInfo [ ] attributes = mBeanInfo . getAttributes ( ) ; for ( MBeanAttributeInfo attribute : attributes ) { out . println ( "<br>Type: " + attribute . getType ( ) + "<br>" ) ; out . println ( "<br>Name: " + attribute . getName ( ) + "<br>" ) ; } } } ClusterRuntimeMBean clusterRuntime = serverRuntime . getClusterRuntime ( ) ; if ( clusterRuntime != null ) { String [ ] serverNames = clusterRuntime . getServerNames ( ) ; out . println ( "Alive:" + clusterRuntime . getAliveServerCount ( ) ) ; out . println ( "Health:" + clusterRuntime . getHealthState ( ) . getState ( ) ) ; out . println ( "Members:" + String . join ( "," , serverNames ) ) ; out . println ( "ServerName:" + serverRuntime . getName ( ) ) ; for ( String serverName : serverNames ) { try { if ( ctx . lookup ( serverName ) != null ) { out . println ( "Bound:" + serverName ) ; } } catch ( NameNotFoundException nnfex ) { out . println ( nnfex . getMessage ( ) ) ; } } } String listServers = request . getParameter ( "listServers" ) ; if ( listServers != null ) { ServerRuntimeMBean [ ] serverRuntimes = domainRuntimeServiceMbean . getServerRuntimes ( ) ; for ( ServerRuntimeMBean serverRuntime : serverRuntimes ) { out . println ( serverRuntime . getName ( ) + ":STATUS<BR>" ) ; int state = serverRuntime . getHealthState ( ) . getState ( ) ; switch ( state ) { case HealthState . HEALTH_OK : out . print ( serverRuntime . getName ( ) + ":HEALTH_OK" ) ; break ; case HealthState . HEALTH_CRITICAL : out . print ( serverRuntime . getName ( ) + ":HEALTH_CRITICAL" ) ; break ; case HealthState . HEALTH_FAILED : out . print ( serverRuntime . getName ( ) + ":HEALTH_FAILED" ) ; break ; case HealthState . HEALTH_OVERLOADED : out . print ( serverRuntime . getName ( ) + ":HEALTH_OVERLOADED" ) ; break ; case HealthState . HEALTH_WARN : out . print ( serverRuntime . getName ( ) + ":HEALTH_WARN" ) ; break ; default : out . print ( serverRuntime . getName ( ) + ":HEALTH_WARN" ) ; } out . println ( "<BR>" ) ; } } out . println ( "</pre>" ) ; out . println ( "</body>" ) ; out . println ( "</html>" ) ; } catch ( NamingException | InstanceNotFoundException | IntrospectionException | ReflectionException ex ) { Logger . getLogger ( ClusterViewServlet . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } }
Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
Processes requests for both HTTP <code > GET< / code > and <code > POST< / code > methods .
// print all mbeans and its attributes in the server runtime //if the server is part of a cluster get its cluster details // lookup JNDI for other clustered servers bound in tree