コード例 #1
0
ファイル: JMXNodeTool.java プロジェクト: kinzer1/Priam
 public static <T> T getRemoteBean(
     Class<T> clazz, String mbeanName, IConfiguration config, boolean mxbean) {
   try {
     if (mxbean)
       return ManagementFactory.newPlatformMXBeanProxy(
           JMXNodeTool.instance(config).mbeanServerConn, mbeanName, clazz);
     else
       return JMX.newMBeanProxy(
           JMXNodeTool.instance(config).mbeanServerConn, new ObjectName(mbeanName), clazz);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return null;
 }
コード例 #2
0
 public void testIiopWorksOnStandard() throws Exception {
   try {
     deployFailOnError("jbpapp6469.jar");
     String objectNameString = "jboss:service=CorbaNaming";
     MBeanServerConnection mbeanServerConnection = getRMIServer(null);
     ObjectName objectName = new ObjectName(objectNameString);
     CorbaNamingServiceMBean mbean =
         JMX.newMBeanProxy(mbeanServerConnection, objectName, CorbaNamingServiceMBean.class);
     String listing = mbean.list();
     String[] deployments = listing.split("\n");
     for (String deployment : deployments) {
       if (deployment.equals("HelloSessionBean/")) return;
     }
     fail("Did not find IIOP EJB");
   } finally {
     undeployFailOnError("jbpapp6469.jar");
   }
 }
コード例 #3
0
  @Override
  public ProgressNotification getTotalProgress() {

    ObjectName crossbowNotificationObjectName = null;
    try {
      crossbowNotificationObjectName = ObjectName.getInstance("Crossbow:type=CrossbowNotification");

    } catch (Exception e) {
      log.error("Exception while creating workerProgress ObjectName", e);
      e.printStackTrace();
    }

    int total = totalTasks;
    int realised = 0;
    try {

      for (String url : delegate.scGetAllMBeanServers()) {

        try {

          MBeanServerConnection mbsc =
              JMXConnectorFactory.connect(new JMXServiceURL(url)).getMBeanServerConnection();

          CrossbowNotificationMBean crossbowNotification =
              JMX.newMBeanProxy(
                  mbsc, crossbowNotificationObjectName, CrossbowNotificationMBean.class);

          ProgressNotification progress = crossbowNotification.getProgress();
          realised += progress.getCurrent();

        } catch (Exception ex) {
          log.error("Error while querying MBean server (url: " + url + ")", ex);
        }
      }

      progressNotification = new ProgressNotification(realised, total, null);

    } catch (RemoteException ex) {
      log.error("Error while getting MBean servers list.", ex);
    }

    return progressNotification;
  }
コード例 #4
0
  public String getTotalNewLogs() {

    StringBuilder stringBuilder = new StringBuilder();
    ObjectName crossbowNotificationObjectName = null;
    try {
      crossbowNotificationObjectName = ObjectName.getInstance("Crossbow:type=CrossbowNotification");

    } catch (Exception e) {
      log.error("Exception while creating workerProgress ObjectName", e);
      e.printStackTrace();
    }

    try {

      for (String url : delegate.scGetAllMBeanServers()) {

        try {

          MBeanServerConnection mbsc =
              JMXConnectorFactory.connect(new JMXServiceURL(url)).getMBeanServerConnection();

          CrossbowNotificationMBean crossbowNotification =
              JMX.newMBeanProxy(
                  mbsc, crossbowNotificationObjectName, CrossbowNotificationMBean.class);

          String logs = crossbowNotification.getNewLogs();
          if (logs != null && !logs.equals("")) {
            stringBuilder.append(crossbowNotification.getNewLogs());
            stringBuilder.append("\n");
          }

        } catch (Exception ex) {
          log.error("Error while querying MBean server (url: " + url + ")", ex);
        }
      }

    } catch (RemoteException ex) {
      log.error("Error while getting MBean servers list.", ex);
    }

    return stringBuilder.toString();
  }
コード例 #5
0
 public void use() {
   JMXConnector jmxc = null;
   try {
     JMXServiceURL serviceURL = new JMXServiceURL(this.serviceUrl);
     jmxc = JMXConnectorFactory.connect(serviceURL, null);
     MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
     ObjectName mbeanName = new ObjectName(MBeanName);
     StatusMBean mbeanProxy = JMX.newMBeanProxy(mbsc, mbeanName, StatusMBean.class, true);
     System.out.println(mbeanProxy.getName());
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     if (jmxc != null) {
       try {
         jmxc.close();
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
   }
 }
コード例 #6
0
 private void initMbean(MBeanServerConnection mbsc)
     throws IOException, MalformedObjectNameException {
   this.mbean = JMX.newMBeanProxy(mbsc, new ObjectName(MBEAN_NAME), DbManagerMBean.class);
 }
コード例 #7
0
  private void registerNotificationListener() {

    log.debug("Reseting and registering at all WorkerProgressMBeans as listener");

    ObjectName workerProgressObjectName = null;
    ObjectName crossbowNotificationObjectName = null;
    try {
      crossbowNotificationObjectName = ObjectName.getInstance("Crossbow:type=CrossbowNotification");
      workerProgressObjectName = ObjectName.getInstance("Crossbow:type=WorkerProgress");

    } catch (Exception e) {
      log.error("Exception while creating workerProgress ObjectName", e);
      e.printStackTrace();
    }

    MBeanServer server = JimsMBeanServer.findJimsMBeanServer();

    try {

      for (String url : delegate.scGetAllMBeanServers()) {

        try {

          MBeanServerConnection mbsc =
              JMXConnectorFactory.connect(new JMXServiceURL(url)).getMBeanServerConnection();

          CrossbowNotificationMBean crossbowNotification =
              JMX.newMBeanProxy(
                  mbsc, crossbowNotificationObjectName, CrossbowNotificationMBean.class);

          crossbowNotification.reset();

          try {
            mbsc.removeNotificationListener(
                workerProgressObjectName, crossbowNotificationObjectName);
          } catch (Exception e) {
            log.error(
                "Exception while removing notification listener from MBean server (url: "
                    + url
                    + ")",
                e);
          }
          mbsc.addNotificationListener(
              workerProgressObjectName, crossbowNotificationObjectName, null, null);

          log.info(
              "CrosbowNotification successfully registered lestener at WorkerProgressMBean (url: "
                  + url
                  + ")");

        } catch (Exception ex) {
          log.error("Error while querying MBean server (url: " + url + ")", ex);
        }
      }

      progressNotification = new ProgressNotification(0, totalTasks, WorkerProgress.getIpAddress());

    } catch (RemoteException ex) {
      log.error("Error while getting MBean servers list.", ex);
    }
  }