geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vfor...@apache.org
Subject [01/15] incubator-geode git commit: GEODE-341: Refactor Java packages to reflect Apache organization. - Root package changed to "org.apache.geode.jvsd". - pom.xml changed to use "org.apache.geode" as the groupId.
Date Wed, 13 Jan 2016 17:14:26 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-78 fb4de6a3c -> 8a86c01a3


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c8a9cb6/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/model/stats/StatArchiveFormat.java
----------------------------------------------------------------------
diff --git a/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/model/stats/StatArchiveFormat.java
b/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/model/stats/StatArchiveFormat.java
new file mode 100644
index 0000000..a2ab53d
--- /dev/null
+++ b/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/model/stats/StatArchiveFormat.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.jvsd.model.stats;
+
+/**
+ * StatArchiveFormat defines constants related to the statistic archive file
+ * format.
+ */
+public class StatArchiveFormat {
+
+	/**
+	 * ARCHIVE_VERSION identifies the format of the contents of the archive. It
+	 * should be changed any time an incompatible change is made. Its current
+	 * value is <code>3</code>.
+	 * <p>
+	 * <ol>
+	 * <li> Changed from 2 to 3 with addition of
+	 * <code>RESOURCE_INSTANCE_INITIALIZE_TOKEN</code>
+	 * <li> Changed from 3 to 4 with addition of largerBetter boolean in statistic
+	 * descriptor
+	 * </ol>
+	 */
+	public static final byte ARCHIVE_VERSION = 4;
+
+	/**
+	 * Token consists of a timestamp and any statistic value changes.
+	 */
+	public static final byte SAMPLE_TOKEN = 0;
+	/**
+	 * Token defines a new resource type.
+	 */
+	public static final byte RESOURCE_TYPE_TOKEN = 1;
+	/**
+	 * Token defines a new resource instance.
+	 */
+	public static final byte RESOURCE_INSTANCE_CREATE_TOKEN = 2;
+	/**
+	 * Token notes that a previous resource instance no longer exists and thus
+	 * will have any more samples of its statistic values taken.
+	 */
+	public static final byte RESOURCE_INSTANCE_DELETE_TOKEN = 3;
+	/**
+	 * Token defines a new resource instance with initial data.
+	 */
+	public static final byte RESOURCE_INSTANCE_INITIALIZE_TOKEN = 4;
+	/**
+	 * Token defines a new archive and provides some global information about the
+	 * environment the archive was created in.
+	 */
+	public static final byte HEADER_TOKEN = 77;
+
+	/**
+	 * The value used to signal the end of a list of resource instances.
+	 */
+	public static final int ILLEGAL_RESOURCE_INST_ID = -1;
+	/**
+	 * The maximum value a resource inst id can have and still be stored in the
+	 * archive as an unsigned byte.
+	 */
+	public static final int MAX_BYTE_RESOURCE_INST_ID = 252;
+	/**
+	 * Used to say that the next two bytes contain the resource inst id as an
+	 * unsigned short.
+	 */
+	public static final int SHORT_RESOURCE_INST_ID_TOKEN = 253;
+	/**
+	 * Used to say that the next four bytes contain the resource inst id as an
+	 * int.
+	 */
+	public static final int INT_RESOURCE_INST_ID_TOKEN = 254;
+	/**
+	 * Used to say that the current byte represents the ILLEGAL_RESOURCE_INST_ID.
+	 */
+	public static final int ILLEGAL_RESOURCE_INST_ID_TOKEN = 255;
+	/**
+	 * The maximum value a resource inst id can have and still be stored in the
+	 * archive as an unsigned short.
+	 */
+	public static final int MAX_SHORT_RESOURCE_INST_ID = 65535;
+	/**
+	 * The value used to signal the end of a list of statistic samples.
+	 */
+	public static final int ILLEGAL_STAT_OFFSET = 255;
+
+	/**
+	 * The maximum value a timestamp can have and still be stored in the archive
+	 * as an unsigned short.
+	 */
+	public static final int MAX_SHORT_TIMESTAMP = 65534;
+	/**
+	 * Means the next 4 bytes contain the timestamp as an int.
+	 */
+	public static final int INT_TIMESTAMP_TOKEN = 65535;
+
+	/**
+	 * The maximum value a compact value can have and still be stored in the
+	 * archive as one byte.
+	 */
+	public static final int MAX_1BYTE_COMPACT_VALUE = Byte.MAX_VALUE;
+	/**
+	 * The minimum value a compact value can have and still be stored in the
+	 * archive as one byte.
+	 */
+	public static final int MIN_1BYTE_COMPACT_VALUE = Byte.MIN_VALUE + 7;
+	/**
+	 * The maximum value a compact value can have and still be stored in the
+	 * archive as two bytes.
+	 */
+	public static final int MAX_2BYTE_COMPACT_VALUE = Short.MAX_VALUE;
+	/**
+	 * The minimum value a compact value can have and still be stored in the
+	 * archive as two bytes.
+	 */
+	public static final int MIN_2BYTE_COMPACT_VALUE = Short.MIN_VALUE;
+
+	/**
+	 * Means the next 2 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_2_TOKEN = Byte.MIN_VALUE;
+	/**
+	 * Means the next 3 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_3_TOKEN = Byte.MIN_VALUE + 1;
+	/**
+	 * Means the next 4 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_4_TOKEN = Byte.MIN_VALUE + 2;
+	/**
+	 * Means the next 5 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_5_TOKEN = Byte.MIN_VALUE + 3;
+	/**
+	 * Means the next 6 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_6_TOKEN = Byte.MIN_VALUE + 4;
+	/**
+	 * Means the next 7 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_7_TOKEN = Byte.MIN_VALUE + 5;
+	/**
+	 * Means the next 8 bytes hold the compact value's data.
+	 */
+	public static final int COMPACT_VALUE_8_TOKEN = Byte.MIN_VALUE + 6;
+
+	/**
+	 * Statistic represents a <code>boolean</code> java primitive.
+	 */
+	public static final int BOOLEAN_CODE = 1;
+	/**
+	 * Statistic represents a <code>char</code> java primitive.
+	 */
+	public static final int CHAR_CODE = 2;
+	/**
+	 * Statistic represents a <code>char</code> java primitive.
+	 */
+	public static final int WCHAR_CODE = 12;
+	/**
+	 * Statistic represents a <code>byte</code> java primitive.
+	 */
+	public static final int BYTE_CODE = 3;
+	/**
+	 * Statistic represents a <code>short</code> java primitive.
+	 */
+	public static final int SHORT_CODE = 4;
+	/**
+	 * Statistic represents a <code>int</code> java primitive.
+	 */
+	public static final int INT_CODE = 5;
+	/**
+	 * Statistic represents a <code>long</code> java primitive.
+	 */
+	public static final int LONG_CODE = 6;
+	/**
+	 * Statistic represents a <code>float</code> java primitive.
+	 */
+	public static final int FLOAT_CODE = 7;
+	/**
+	 * Statistic represents a <code>double</code> java primitive.
+	 */
+	public static final int DOUBLE_CODE = 8;
+	/**
+	 * Number of nanoseconds in one millisecond
+	 */
+	public static final long NANOS_PER_MILLI = 1000000;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c8a9cb6/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/stats/Utility.java
----------------------------------------------------------------------
diff --git a/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/stats/Utility.java b/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/stats/Utility.java
new file mode 100644
index 0000000..6af8cf4
--- /dev/null
+++ b/jvsdfx-mm/src/main/java/org/apache/geode/jvsd/stats/Utility.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.jvsd.stats;
+
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Vince Ford
+ */
+public class Utility {
+
+	/**
+	 *
+	 * @param timestamps
+	 * @return
+	 */
+	private static Logger logger = null;
+	private static ConsoleHandler ch = null;
+	private static int horizontalScreenSize = 0;
+	private static int verticalScreenSize = 0;
+
+	static {
+		logger = Logger.getLogger("com.gemstone.gemfire.support.Utility");
+		logger.setUseParentHandlers(false);
+		ch = new ConsoleHandler();
+		ch.setLevel(Level.FINE);
+		logger.addHandler(ch);
+		logger.setLevel(Level.FINE);
+	}
+
+	public static int getHorizontalScreenSize() {
+		return horizontalScreenSize;
+	}
+
+	public static int getVerticalScreenSize() {
+		return verticalScreenSize;
+	}
+
+	public static void initScreenSize() {
+		horizontalScreenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
+		verticalScreenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;
+	}
+
+	public static long computeTimeSampleAverage(long[] timestamps) {
+		long tempSum = 0;
+		if (timestamps.length > 0 && timestamps.length / 2 > 0) {
+			for (int i = 0; i < timestamps.length - 1; i++) {
+				tempSum = tempSum + (timestamps[i + 1] - timestamps[i]) / 2;
+			}
+			return tempSum / (timestamps.length / 2);
+		}
+		return 0;
+	}
+
+	/**
+	 *
+	 * @param timestamp
+	 * @param timestamp2
+	 * @param value
+	 * @param value2
+	 * @param sampleperiod
+	 * @return
+	 */
+	public static double computePerSecondValue(long timestamp, long timestamp2,
+      double value, double value2, long sampleperiod) {
+		return ((value - value2) / ((timestamp - timestamp2) / 1000));
+	}
+
+//	public static void dumpCharts(List<StatFileParser.ResourceInst> ril) {
+//		logger.info("Dumping Charts");
+//		for (StatFileParser.ResourceInst o : ril) {
+//			logger.fine("RESOURCE:" + o.getType().getName() + o.getName() + "," + o.
+//							toString());
+//			StatFileParser.StatValue[] sv = o.getStatValues();
+//			long[] timestamps = sv[0].getRawAbsoluteTimeStamps();
+//			double[] datavalue = sv[0].getRawSnapshots();
+//			long timesampleaverage = Utility.computeTimeSampleAverage(timestamps);
+//			long sampleperiod = timesampleaverage / 1000;
+//			logger.
+//							finest("timestampaverage:" + timesampleaverage + " sampleperiod:" + sampleperiod);
+//			for (StatFileParser.StatValue svtemp : sv) {
+//				logger.
+//								finest("Name:" + svtemp.getDescriptor().getName() + " typecode:" + svtemp.
+//												getDescriptor().getTypeCode());
+//				logger.finest("DEBUG:" + svtemp.getDescriptor().getUnits());
+//				logger.finest("DEBUG:" + svtemp.getDescriptor().isCounter());
+//				logger.finest("DEBUG:" + svtemp.getDescriptor().getUnits());
+//				logger.finest("DEBUG:filter:" + svtemp.getFilter());
+//				XYSeries sample = new XYSeries(svtemp.getDescriptor().getName());
+//				logger.
+//								finest("Average:" + svtemp.getSnapshotsAverage() + " Max:" + svtemp.
+//												getSnapshotsMaximum() + " Size:" + svtemp.
+//												getSnapshotsSize());
+//				if (!(svtemp.getSnapshotsAverage() == 0 && svtemp.getSnapshotsMaximum() ==
0 && svtemp.
+//								getSnapshotsMinimum() == 0)) {
+//					timestamps = svtemp.getRawAbsoluteTimeStamps();
+//					datavalue = svtemp.getRawSnapshots();
+//					if (svtemp.getFilter() == svtemp.FILTER_PERSEC) {
+//
+//						for (int d = 0; d < timestamps.length; d++) {
+//							long timestamp = timestamps[d];
+//							double value = datavalue[d];
+//							if (d == 0) {
+//								value = Utility.
+//                    computePerSecondValue(timestamp,
+//                        timestamp - timesampleaverage, value, svtemp.
+//                        getSnapshotsAverage(), sampleperiod);
+//								sample.add(timestamp, value);
+//							} else {
+//								value = Utility.
+//                    computePerSecondValue(timestamp, timestamps[d - 1], value,
+//                        datavalue[d - 1], sampleperiod);
+//								sample.add(timestamp, value);
+//							}
+//						}
+//					} else {
+//						for (int d = 0; d < timestamps.length; d++) {
+//							sample.add(timestamps[d], datavalue[d]);
+//						}
+//					}
+//					XYSeriesCollection xysc = new XYSeriesCollection(sample);
+//					JFreeChart chart = ChartFactory.
+//									createTimeSeriesChart(null, null, null, xysc, true, true, true);
+//					try {
+//						ChartUtilities.saveChartAsJPEG(new File(o.getName() + "_" + svtemp.
+//										getDescriptor().getName() + ".jpg"), chart, 1000, 300);
+//					} catch (IOException ex) {
+//						logger.severe("Couldn't create chart:" + o.getName() + "_" + svtemp.
+//										getDescriptor().getName() + ".jpg");
+//					}
+//				}
+//			}
+//		}
+//		logger.info("Finished Charts");
+//	}
+
+//	static public void dumpCSV(StatFileManager sfm, File file) {
+//		int numFiles = sfm.length();
+//		try {
+//			System.out.println("Writing CSV file: " + file.getAbsolutePath());
+//			file.createNewFile();
+//			PrintWriter pw = new PrintWriter(file);
+//			for (int x = 0; x < numFiles; x++) {
+//				StatFileWrapper sfWrapper = sfm.getFile(x);
+//				StatFileParser.ArchiveInfo aInfo = sfWrapper.getaInfo();
+//				pw.print("FILE INFO, ");
+//				pw.print(aInfo.getArchiveFileName() + ", ");
+//				pw.print(aInfo.getMachine() + ", ");
+//				pw.print(aInfo.getOs() + ", ");
+//				pw.print(aInfo.getProductVersion() + ", ");
+//				pw.print(aInfo.getStartTimeMillis() + ", ");
+//				pw.print(aInfo.getSystem() + ", ");
+//				pw.print(aInfo.getSystemId() + ", ");
+//				pw.print(aInfo.getSystemStartTimeMillis() + ", ");
+//				pw.print(aInfo.getTimeZone());
+//				pw.println();
+//				pw.flush();
+//				List<StatFileParser.ResourceInst> rl = sfWrapper.getResourceList();
+//				for (StatFileParser.ResourceInst ri : rl) {
+//					pw.print("STATTYPE, ");
+//					pw.print(ri.getType().getName() + ", ");
+//					pw.print(ri.getName());
+//					pw.println();
+//					StatFileParser.StatValue[] svArray = ri.getStatValues();
+//					for (StatFileParser.StatValue sv : svArray) {
+//						pw.print("STAT, ");
+//						pw.print(sv.getDescriptor().getName() + ", ");
+//						if (sv.getFilter() == sv.FILTER_NONE) {
+//							pw.print("NO FILTER, ");
+//						} else {
+//							if (sv.getFilter() == sv.FILTER_PERSAMPLE) {
+//								pw.print("PERSAMPLE FILTER, ");
+//							} else {
+//								if (sv.getFilter() == sv.FILTER_PERSEC) {
+//									pw.print("PERSECOND FILTER, ");
+//								}
+//							}
+//						}
+//						pw.println();
+//						pw.print("TIME, ");
+//						long[] timesnapshot = sv.getRawAbsoluteTimeStamps();
+//						for (long time : timesnapshot) {
+//							pw.print(time);
+//							pw.print(", ");
+//						}
+//						pw.println();
+//						pw.print("DATA, ");
+//						double[] datasnapshot = sv.getRawSnapshots();
+//						for (double data : datasnapshot) {
+//							pw.print(data);
+//							pw.print(", ");
+//						}
+//						pw.println();
+//					}
+//					pw.println();
+//					pw.flush();
+//				}
+//				pw.close();
+//			}
+//			System.out.println("Finished writing CSV file: " + file.getAbsolutePath());
+//		} catch (IOException ex) {
+//			Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+//		}
+//
+//	}
+//
+//	static public JMenu createMenu(String menuName, JMenuBar menubar) {
+//		JMenu menu = new JMenu(menuName);
+//		menubar.add(menu);
+//		return menu;
+//	}
+//
+//	static public JMenuItem createMenuItem(String menuItem, JMenu menu, ActionListener al)
{
+//		JMenuItem mi = new JMenuItem(menuItem);
+//		mi.addActionListener(al);
+//		menu.add(mi);
+//		return mi;
+//	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c8a9cb6/jvsdfx-mm/src/main/resources/chart.fxml
----------------------------------------------------------------------
diff --git a/jvsdfx-mm/src/main/resources/chart.fxml b/jvsdfx-mm/src/main/resources/chart.fxml
index 4112ecd..6a24ce1 100644
--- a/jvsdfx-mm/src/main/resources/chart.fxml
+++ b/jvsdfx-mm/src/main/resources/chart.fxml
@@ -5,7 +5,7 @@
 <?import javafx.scene.control.*?>
 <?import javafx.scene.layout.*?>
 
-<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="720.0" prefWidth="1080.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.pivotal.jvsd.fx.VSDChartWindow">
+<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="720.0" prefWidth="1080.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.apache.geode.jvsd.fx.VSDChartWindow">
   <top>
     <HBox alignment="CENTER_LEFT" prefHeight="50.0" BorderPane.alignment="CENTER">
       <children>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c8a9cb6/jvsdfx-mm/src/main/resources/jvsd.fxml
----------------------------------------------------------------------
diff --git a/jvsdfx-mm/src/main/resources/jvsd.fxml b/jvsdfx-mm/src/main/resources/jvsd.fxml
index 17657ca..91a9455 100644
--- a/jvsdfx-mm/src/main/resources/jvsd.fxml
+++ b/jvsdfx-mm/src/main/resources/jvsd.fxml
@@ -19,7 +19,7 @@
 <?import javafx.scene.layout.AnchorPane?>
 <?import javafx.scene.layout.HBox?>
 
-<BorderPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.pivotal.jvsd.controller.RootController">
+<BorderPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.apache.geode.jvsd.controller.RootController">
   <top>
     <MenuBar BorderPane.alignment="CENTER">
       <menus>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c8a9cb6/jvsdfx-mm/src/test/java/io/pivotal/jvsd/Copy_2_of_Test.java
----------------------------------------------------------------------
diff --git a/jvsdfx-mm/src/test/java/io/pivotal/jvsd/Copy_2_of_Test.java b/jvsdfx-mm/src/test/java/io/pivotal/jvsd/Copy_2_of_Test.java
index 43def79..eee5490 100644
--- a/jvsdfx-mm/src/test/java/io/pivotal/jvsd/Copy_2_of_Test.java
+++ b/jvsdfx-mm/src/test/java/io/pivotal/jvsd/Copy_2_of_Test.java
@@ -1,11 +1,9 @@
 package io.pivotal.jvsd;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
-import java.util.Random;
 
 public class Copy_2_of_Test {
   private static int count = 10485760; // 10 MB


Mime
View raw message