use of com.tagtraum.perf.gcviewer.model.GcResourceSeries in project GCViewer by chewiebug.
the class DataReaderFacade method loadModel.
/**
* Loads a model from a given <code>gcResource</code> logging all exceptions that occur.
*
* @param gcResource where to find data to be parsed
* @return instance of GCModel containing all information that was parsed
* @throws DataReaderException if any exception occurred, it is logged and added as the cause
* to this exception
*/
public GCModel loadModel(GCResource gcResource) throws DataReaderException {
if (gcResource == null) {
throw new NullPointerException("gcResource must never be null");
}
if (gcResource instanceof GcResourceSeries) {
return loadModelFromSeries((GcResourceSeries) gcResource);
}
if (!(gcResource instanceof GcResourceFile))
throw new UnsupportedOperationException("Only supported for files!");
DataReaderException dataReaderException = new DataReaderException();
GCModel model = null;
Logger logger = gcResource.getLogger();
try {
logger.info("GCViewer version " + BuildInfoReader.getVersion() + " (" + BuildInfoReader.getBuildDate() + ")");
model = readModel((GcResourceFile) gcResource);
} catch (RuntimeException | IOException e) {
dataReaderException.initCause(e);
logger.warning(LocalisationHelper.getString("fileopen_dialog_read_file_failed") + "\n" + e.toString() + " " + e.getLocalizedMessage());
}
if (dataReaderException.getCause() != null) {
throw dataReaderException;
}
return model;
}
use of com.tagtraum.perf.gcviewer.model.GcResourceSeries in project GCViewer by chewiebug.
the class GCResourceGroup method getGcResourceSeries.
private GCResource getGcResourceSeries(String entry) {
GCResource resource;
List<GCResource> series = new ArrayList<>();
for (String s : entry.split(SERIES_SEPARATOR)) {
series.add(new GcResourceFile(s));
}
resource = new GcResourceSeries(series);
return resource;
}
use of com.tagtraum.perf.gcviewer.model.GcResourceSeries in project GCViewer by chewiebug.
the class GCModelSeriesLoaderImplTest method loadGcModel.
@Test
public void loadGcModel() throws Exception {
ArrayList<GCResource> gcResourceList = new ArrayList<>();
gcResourceList.add(new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part1.txt").getPath()));
gcResourceList.add(new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part2.txt").getPath()));
gcResourceList.add(new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part3.txt").getPath()));
GCModelSeriesLoaderImpl loader = new GCModelSeriesLoaderImpl(new GcResourceSeries(gcResourceList));
assertThat(loader.loadGcModel(), notNullValue());
}
use of com.tagtraum.perf.gcviewer.model.GcResourceSeries in project GCViewer by chewiebug.
the class TestDataReaderFacade method testLoadModel_forSeries.
@Test
public void testLoadModel_forSeries() throws IOException, DataReaderException {
GCResource file1 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part1.txt").getPath());
GCResource file2 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part2.txt").getPath());
GCResource file3 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part3.txt").getPath());
GCResource file4 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part4.txt").getPath());
GCResource file5 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part5.txt").getPath());
GCResource file6 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part6.txt").getPath());
GCResource file7 = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-Part7.txt").getPath());
GCResource expectedResult = new GcResourceFile(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_8_0Series-ManuallyMerged.txt").getPath());
GCModel expectedModel = dataReaderFacade.loadModel(expectedResult);
List<GCResource> resources = new ArrayList<>();
resources.add(file4);
resources.add(file3);
resources.add(file6);
resources.add(file1);
resources.add(file7);
resources.add(file2);
resources.add(file5);
GcResourceSeries series = new GcResourceSeries(resources);
GCModel result = dataReaderFacade.loadModelFromSeries(series);
assertThat(result.toString(), is(expectedModel.toString()));
}
use of com.tagtraum.perf.gcviewer.model.GcResourceSeries in project GCViewer by chewiebug.
the class GCModelLoaderControllerImpl method openAsSeries.
@Override
public void openAsSeries(List<GCResource> gcResourceList) {
GcResourceSeries resourceSeries = new GcResourceSeries(gcResourceList);
GCModelLoader loader = GCModelLoaderFactory.createFor(resourceSeries);
openGCResource(loader.getGcResource(), loader);
getRecentGCResourcesModel().add(Collections.singletonList(resourceSeries));
}
Aggregations