
4j.0.0.2-beta.source-code.Main Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kpi4j Show documentation
Show all versions of kpi4j Show documentation
This is an open source library that allows generating performance indicators easily for java based application. This library is configurable through an xml file (similar to log4j) in order to define the performance object types, dimensions, counters, the output format and statistics generation periodicity. Those statistics can be saved as a file (xml/json) or injected directly in a database. Then they can be correlated and analyzed through any Business Intelligence solution in order to check the application performance and quality: number of transactions, ratio of successful and failure ...
The newest version!
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import org.apache.log4j.Logger;
import com.kpi4j.Collector;
import com.kpi4j.config.xml.DomConfigurator;
public class Main extends Thread{
public static Collector coll=Collector.getCollector("node1");
public static Logger logger=Logger.getLogger(Main.class);
static String ot[]= {"ot1","ot2"};
static String counter[]= {"ctr0","ctr1","ctr2","ctr3","ctr4"};
// static String counter[]= {"attTCHSeizures","succTCHSeizures","attImmediateAssignProcs",
// "succImmediateAssignProcs","ethernetStatsBroadcastTx"};
@Override
public void run(){
logger.debug("run thread "+getId());
Random r= new Random();
while(true)
{
coll.incrementCounter("ObjectType","ot2","dim1",r.nextInt(10),counter[r.nextInt(5)],r.nextInt(5));
//coll.incrementCounter("ObjectType","RncFunction","RncFunction","RF-"+(r.nextInt(2)+1),"UtranCell","Gbg-"+(r.nextInt(2)+1),counter[r.nextInt(5)],1);
try {
Thread.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args) throws InterruptedException, ClassNotFoundException {
// TODO Auto-generated method stub
logger.debug("debug");
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",3,"ctr1",1);
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",4,"ctr1",1);
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",4,"ctr1",1);
//
// Thread.sleep(65000);
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",3,"ctr1",1);
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",3,"ctr1",1);
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",4,"ctr1",1);
// coll.incrementCounter("ObjectType","ot1","moid","Cell=997","dim2",4,"ctr1",1);
// System.out.println("increppp");
// coll.incrementCounter("ot1.ctr1",4);
// coll.incrementCounter("ot1.ctr1");
// coll.incrementCounter("ot1.ctr1",5);
for(int i=0;i<100;i++)
new Main().start();
Thread.sleep(70000);
// coll.incrementCounter("ot1.ctr1");
// coll.incrementCounter("ot1.ctr1",5);
//System.exit(0);
//System.out.println(class.getClassLoader().getResource("src/main/resources/kpi4j.xml").toString());
// int[] a={0,1,2,3,4};
// System.out.println(Arrays.toString(Arrays.copyOfRange(a, 1, 6)));
//coll.setCounterValue(PerformanceValue.createPerformanceValue("ot1").addDimension("Dim1", 1).setCounter("ctr1", 12));
//System.out.println(Class.forName("java.lang.String").isInstance(23));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy