com.sun.jbi.management.system.ServiceAssemblyStatistics Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of manage Show documentation
Show all versions of manage Show documentation
JBI Runtime Management components, providing installation, deployment, and other JMX interfaces for
remote management consoles.
/*
* BEGIN_HEADER - DO NOT EDIT
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* If applicable add the following below this CDDL HEADER,
* with the fields enclosed by brackets "[]" replaced with
* your own identifying information: Portions Copyright
* [year] [name of copyright owner]
*/
/*
* @(#)ServiceAssemblyStatistics.java
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.management.system;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.logging.Logger;
import java.util.Set;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
import javax.management.openmbean.ArrayType;
/**
* This class is used to store statistic information about a SA
* @author Sun Microsystems, Inc.
*/
public class ServiceAssemblyStatistics
{
/**
* name of the sa
*/
private String mName;
/**
* instance name
*/
private String mInstanceName;
/**
* time this SA was started last
*/
private Date mLastStartupTime;
/**
* time this SA was stopped last
*/
private Date mLastStopTime;
/**
* time this SA was shutdown last
*/
private Date mLastShutdownTime;
/**
* SA startup times
*/
private Value mStartupTime = new Value();
/**
* SA stop times
*/
private Value mStopTime = new Value();
/**
* SA shutdown times
*/
private Value mShutdownTime = new Value();
/**
* boolean to track if SA has been started before
*/
private boolean mSAStarted = false;
/**
* boolean to track if SA has been stopped before
*/
private boolean mSAStopped = false;
/**
* boolean to track if SA has been shutdown before
*/
private boolean mSAShutdown = false;
/**
* CompositeType for SU Stats
*/
private CompositeType mServiceUnitStatsType;
/**
* CompositeType for SA Stats
*/
private CompositeType mServiceAssemblyStatsType;
/**
* a list of SU stats
*/
private Map
mServiceUnitStatistics = new HashMap();
/**
* constructor
*/
ServiceAssemblyStatistics(String saName, String instanceName)
throws Exception
{
mName = saName;
mInstanceName = instanceName;
}
/**
* get last startup time
* @return Date last startup time
*/
public Date getLastStartupTime()
{
return mLastStartupTime;
}
/**
* get last stop time
* @return Date last stop time
*/
public Date getLastStopTime()
{
return mLastStopTime;
}
/**
* get last shutdown time
* @return Date last stop time
*/
public Date getLastShutdownTime()
{
return mLastShutdownTime;
}
/**
* get startup times
* @return Value startup times
*/
public Value getStartupTime()
{
return mStartupTime;
}
/**
* get stop times
* @return Value stop times
*/
public Value getStopTime()
{
return mStopTime;
}
/**
* get shutdown times
* @return Value shutdown times
*/
public Value getShutdownTime()
{
return mShutdownTime;
}
/**
* get the name of the su
*/
public String getName()
{
return mName;
}
/**
* get the instance name
* @return String the instance name
*/
public String getInstanceName()
{
return mInstanceName;
}
/**
* set the su list
* @param serviceUnitStats su stats object list
*/
public void setServiceUnitList(Map serviceUnitStats)
{
mServiceUnitStatistics = serviceUnitStats;
}
/**
* this method is used to update the statistics of a SA
* @param beginTime time when the start operation was begun
* @param endTime time when the start operation finished
* @param suTimes map of suNames and their startupTimes
*/
public void updateStartupStatistics(Date beginTime, Date endTime, Map suTimes)
{
mSAStarted = true;
mLastStartupTime = endTime;
mStartupTime.addSample(endTime.getTime() - beginTime.getTime());
Set serviceUnits = mServiceUnitStatistics.keySet();
for (String su : serviceUnits)
{
if (suTimes.containsKey(su))
{
mServiceUnitStatistics.get(su).updateStartupStatistics(suTimes.get(su));
}
}
}
/**
* this method is used to update the statistics of a SA
* @param beginTime time when the stop operation was begun
* @param endTime time when the stop operation finished
* @param suTimes map of suNames and their stopTimes
*/
public void updateStopStatistics(Date beginTime, Date endTime, Map suTimes)
{
mSAStopped = true;
mLastStopTime = endTime;
mStopTime.addSample(endTime.getTime() - beginTime.getTime());
Set serviceUnits = mServiceUnitStatistics.keySet();
for (String su : serviceUnits)
{
if (suTimes.containsKey(su))
{
mServiceUnitStatistics.get(su).updateStopStatistics(suTimes.get(su));
}
}
}
/**
* this method is used to update the statistics of a SA
* @param beginTime time when the shutdown operation was begun
* @param endTime time when the shutdown operation finished
* @param suTimes map of suNames and their shutdownTimes
*/
public void updateShutdownStatistics(Date beginTime, Date endTime, Map suTimes)
{
mSAShutdown = true;
mLastShutdownTime = endTime;
mShutdownTime.addSample(endTime.getTime() - beginTime.getTime());
Set serviceUnits = mServiceUnitStatistics.keySet();
for (String su : serviceUnits)
{
if (suTimes.containsKey(su))
{
mServiceUnitStatistics.get(su).updateShutdownStatistics(suTimes.get(su));
}
}
}
/**
* return the stats as composite data
*/
public CompositeData getCompositeData()
throws OpenDataException
{
Set serviceUnits = mServiceUnitStatistics.keySet();
CompositeData[] serviceUnitStats = new CompositeData[serviceUnits.size()];
CompositeType serviceUnitStatsCompositeType = null;
int i=0;
for(String su : serviceUnits)
{
CompositeData cData = mServiceUnitStatistics.get(su).getCompositeData();
serviceUnitStats[i++] = cData;
serviceUnitStatsCompositeType = cData.getCompositeType();
}
long upTime = 0;
if (getLastStartupTime() != null)
{
upTime = System.currentTimeMillis() - getLastStartupTime().getTime();
}
ArrayList saStatsItemNames = new ArrayList();
ArrayList saStatsItemDescriptions = new ArrayList();
ArrayList saStatsItemTypes = new ArrayList();
ArrayList