User: juha    
  Date: 01/02/18 12:10:37

  Added:       src/org/jboss/admin/dataholder BeanCacheEntry.java
                        InvocationEntry.java MemoryMonitorEntry.java
                        ThreadMonitorEntry.java
  Log:
  Value holder classes for metrics topic messages.
  
  Revision  Changes    Path
  1.1                  admin/src/org/jboss/admin/dataholder/BeanCacheEntry.java
  
  Index: BeanCacheEntry.java
  ===================================================================
  package org.jboss.admin.dataholder;
  
  // standard imports
  import java.io.Serializable;
  
  import javax.jms.Message;
  import javax.jms.JMSException;
  
  
  /**
   * ...
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   */
  public class BeanCacheEntry implements Serializable {
  
      private String application = "<undefined>";
      private String bean        = "<undefined>";
      private String type        = "<undefined>";
      private long   time        = 0;
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */
   
      public BeanCacheEntry() {}
  
      public BeanCacheEntry(String application, String bean,
                            String type, long time) {
          
          //setApplication(application);
          setBean(bean);
          setType(type);
          setTime(time);
      }
  
      public BeanCacheEntry(Message msg) throws JMSException {
          
          //setApplication(msg.getStringProperty("APPLICATION"));
          setBean(msg.getStringProperty("BEAN"));
          setType(msg.getStringProperty("TYPE"));
          setTime(msg.getLongProperty("TIME"));
      }
      
  /*
   *************************************************************************
   *
   *      PUBLIC INSTANCE METHODS
   *
   *************************************************************************
   */
   
      public void setApplication(String applicationName) {
          if ((applicationName == null) || ("").equals(applicationName))
              return;
              
          this.application = applicationName;
      }
      
      public String getApplication() {
          return application;
      }
      
      public void setBean(String beanName) {
          if ((beanName == null) || ("").equals(beanName))
              return;
              
          this.bean = beanName;
      }
      
      public String getBean() {
          return bean;
      }
      
      public void setType(String type) {
          if ((type == null) || ("").equals(type))
              return;
              
          this.type = type;
      }
      
      public String getType() {
          return type;
      }
      
      public void setTime(long time) {
          this.time = time;
      }
      
      public long getTime() {
          return time;
      }
      
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */
   
      public String toString() {
          return application + "/" + bean + ", time: " + time;
      }
  
  }
  
  
  
  1.1                  admin/src/org/jboss/admin/dataholder/InvocationEntry.java
  
  Index: InvocationEntry.java
  ===================================================================
  package org.jboss.admin.dataholder;
  
  // standard imports
  import java.io.Serializable;
  
  import javax.jms.Message;
  import javax.jms.JMSException;
  import javax.transaction.Status;
  
  
  /**
   * ...
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   */
  public class InvocationEntry implements Serializable {
  
      private String checkPoint  = "<undefined>";
      private String application = "<undefined>";
      private String bean        = "<undefined>";
      private String method      = "<undefined>";
      private String txID        = "<undefined>";
      
      private long   time        = 0;
      private int    status      = Status.STATUS_UNKNOWN;
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */
   
      public InvocationEntry() {}
  
      public InvocationEntry(String checkpoint, String application, String bean,
                             String txID,   int status,  long time) {
          
          setCheckPoint(checkpoint);
          setApplication(application);
          setBean(bean);
          setTxID(txID);
          setStatus(status);
          setTime(time);
      }
  
      public InvocationEntry(Message msg) throws JMSException {
          
          setCheckPoint(msg.getStringProperty("CHECKPOINT"));
          setApplication(msg.getStringProperty("APPLICATION"));
          setBean(msg.getStringProperty("BEAN"));
          setMethod(msg.getStringProperty("METHOD"));
          setTxID(msg.getStringProperty("ID"));
          setTime(msg.getLongProperty("TIME"));
      }
      
  /*
   *************************************************************************
   *
   *      PUBLIC INSTANCE METHODS
   *
   *************************************************************************
   */
   
      public void setCheckPoint(String checkpoint) {
          if ((checkpoint == null) || ("").equals(checkpoint))
              return;
              
          this.checkPoint = checkpoint;
      }
      
      public String getCheckPoint() {
          return checkPoint;
      }
      
      public void setApplication(String applicationName) {
          if ((applicationName == null) || ("").equals(applicationName))
              return;
              
          this.application = applicationName;
      }
      
      public String getApplication() {
          return application;
      }
      
      public void setBean(String beanName) {
          if ((beanName == null) || ("").equals(beanName))
              return;
              
          this.bean = beanName;
      }
      
      public String getBean() {
          return bean;
      }
      
      public void setMethod(String method) {
          if ((method == null) || ("").equals(method))
              return;
              
          this.method = method;
      }
      
      public String getMethod() {
          return method;
      }
      
      public void setTxID(String txID) {
          if ((txID == null) || ("").equals(txID))
              return;
              
          this.txID = txID;
      }
      
      public String getTxID() {
          return txID;
      }
      
      public void setTime(long time) {
          this.time = time;
      }
      
      public long getTime() {
          return time;
      }
      
      public void setStatus(int status) {
          this.status = status;
      }
      
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */
   
      public String toString() {
          return checkPoint + ": " + application + "/" + bean + " [TxID:"  +
                 txID       + ", " + printTxStatus(status)    + ", time: " +
                 time       + "]";
      }
      
  /*
   *************************************************************************
   *
   *      PRIVATE INSTANCE METHODS
   *
   *************************************************************************
   */
   
      private String printTxStatus(int status) {
       
          String stat = "";
          
          switch (status) {
              
          case Status.STATUS_ACTIVE:          stat = "ACTIVE";
              break;
          case Status.STATUS_COMMITTED:       stat = "COMMITTED";
              break;
          case Status.STATUS_COMMITTING:      stat = "COMMITTING";
              break;
          case Status.STATUS_MARKED_ROLLBACK: stat = "MARKED_ROLLBACK";
              break;
          case Status.STATUS_NO_TRANSACTION:  stat = "NO_TRANSACTION";
              break;
          case Status.STATUS_PREPARED:        stat = "STATUS_PREPARED";
              break;
          case Status.STATUS_PREPARING:       stat = "STATUS_PREPARING";
              break;
          case Status.STATUS_ROLLEDBACK:      stat = "STATUS_ROLLEDBACK";
              break;
          case Status.STATUS_ROLLING_BACK:    stat = "STATUS_ROLLING_BACK";
              break;
          case Status.STATUS_UNKNOWN:         stat = "STATUS_UNKNOWN";
              break;
              
          default:
              stat = "<undefined>";            
          }
          
          return stat;
      }
  
                 
  }
  
  
  
  1.1                  admin/src/org/jboss/admin/dataholder/MemoryMonitorEntry.java
  
  Index: MemoryMonitorEntry.java
  ===================================================================
  /*
   * Class MemoryMonitorEntry
   * Copyright (C) 2001  Juha Lindfors
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public
   * License as published by the Free Software Foundation; either
   * version 2 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Library General Public License for more details.
   *
   * You should have received a copy of the GNU Library General Public
   * License along with this library; if not, write to the
   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   * Boston, MA  02111-1307, USA.
   *
   * This package and its source code is available at www.jboss.org
   * $Id: MemoryMonitorEntry.java,v 1.1 2001/02/18 20:10:36 juha Exp $
   */     
  package org.jboss.admin.dataholder;
  
  // standard imports
  import java.io.Serializable;
  import javax.jms.Message;
  import javax.jms.JMSException;
  
  // non-standard class dependencies
  import org.jboss.monitor.MetricsConstants;
  
  /**
   * ...
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   */
  public class MemoryMonitorEntry implements MetricsConstants,
                                             Serializable {
  
      private String type        = "<undefined>";
      private long   time        = 0;
      private long freeMem       = 0;
      private long totalMem      = 0;
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */
   
      public MemoryMonitorEntry() {}
  
      public MemoryMonitorEntry(String type, long time, long total, long free) {
          setType(type);
          setTime(time);
          setFreeMem(free);
          setTotalMem(total);
      }
  
      public MemoryMonitorEntry(Message msg) throws JMSException {
          setType(msg.getStringProperty(TYPE));
          setTime(msg.getJMSTimestamp());
          setFreeMem(msg.getLongProperty("FreeMem"));
          setTotalMem(msg.getLongProperty("TotalMem"));
      }
      
  /*
   *************************************************************************
   *
   *      PUBLIC INSTANCE METHODS
   *
   *************************************************************************
   */
   
      public void setType(String type) {
          if ((type == null) || ("").equals(type))
              return;
              
          this.type = type;
      }
      
      public String getType() {
          return type;
      }
      
      public void setTime(long time) {
          if (time < 0)
              return;
              
          this.time = time;
      }
      
      public long getTime() {
          return time;
      }
      
      public void setFreeMem(long freeBytes) {
          if (freeBytes < 0)
              return;
              
          this.freeMem = freeBytes;
      }
      
      public long getFreeMem() {
          return freeMem;
      }
      
      public void setTotalMem(long totalBytes) {
          if (totalBytes < 0)
              return;
              
          this.totalMem = totalBytes;
      }
      
      public long getTotalMem() {
          return totalMem;
      }
      
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */
   
      public String toString() {
          return "Total: " + getTotalMem() + " Free: " + getFreeMem();
      }
  
  }
  
  
  
  1.1                  admin/src/org/jboss/admin/dataholder/ThreadMonitorEntry.java
  
  Index: ThreadMonitorEntry.java
  ===================================================================
  /*
   * Class ThreadMonitorEntry
   * Copyright (C) 2001  Juha Lindfors
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public
   * License as published by the Free Software Foundation; either
   * version 2 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Library General Public License for more details.
   *
   * You should have received a copy of the GNU Library General Public
   * License along with this library; if not, write to the
   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   * Boston, MA  02111-1307, USA.
   *
   * This package and its source code is available at www.jboss.org
   * $Id: ThreadMonitorEntry.java,v 1.1 2001/02/18 20:10:36 juha Exp $
   */     
  package org.jboss.admin.dataholder;
  
  // standard imports
  import java.io.Serializable;
  import javax.jms.Message;
  import javax.jms.JMSException;
  
  // non-standard class dependencies
  import org.jboss.monitor.MetricsConstants;
  
  
  /**
   * ...
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   */
  public class ThreadMonitorEntry implements MetricsConstants,
                                             Serializable {
  
      private String type        = "<undefined>";
      private int    threadCount = 0;
      private long   time        = 0;
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */
   
      public ThreadMonitorEntry() {}
  
      public ThreadMonitorEntry(String type, long time, int threadCount) {
          setType(type);
          setTime(time);
          setThreadCount(threadCount);
      }
  
      public ThreadMonitorEntry(Message msg) throws JMSException {
          
          setType(msg.getStringProperty(MetricsConstants.TYPE));
          setTime(msg.getJMSTimestamp());
          setThreadCount(msg.getIntProperty("ThreadCount"));
      }
      
  /*
   *************************************************************************
   *
   *      PUBLIC INSTANCE METHODS
   *
   *************************************************************************
   */
   
      public void setType(String type) {
          if ((type == null) || ("").equals(type))
              return;
              
          this.type = type;
      }
      
      public String getType() {
          return type;
      }
      
      public void setTime(long time) {
          if (time < 0)
              return;
              
          this.time = time;
      }
      
      public long getTime() {
          return time;
      }
      
      public void setThreadCount(int count) {
          if (count < 0)
              return;
              
          this.threadCount = count;
      }
      
      public int getThreadCount() {
          return threadCount;
      }
      
      
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */
   
      public String toString() {
          return "Threads: " + getThreadCount();
      }
  
  }
  
  
  

Reply via email to