Search in sources :

Example 1 with GcResourceSeries

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;
}
Also used : IOException(java.io.IOException) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) Logger(java.util.logging.Logger) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries) GCModel(com.tagtraum.perf.gcviewer.model.GCModel)

Example 2 with GcResourceSeries

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;
}
Also used : GCResource(com.tagtraum.perf.gcviewer.model.GCResource) ArrayList(java.util.ArrayList) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries)

Example 3 with GcResourceSeries

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());
}
Also used : GCResource(com.tagtraum.perf.gcviewer.model.GCResource) ArrayList(java.util.ArrayList) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries) Test(org.junit.Test)

Example 4 with GcResourceSeries

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()));
}
Also used : GCResource(com.tagtraum.perf.gcviewer.model.GCResource) ArrayList(java.util.ArrayList) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GCModel(com.tagtraum.perf.gcviewer.model.GCModel) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries) Test(org.junit.Test)

Example 5 with GcResourceSeries

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));
}
Also used : GCModelLoader(com.tagtraum.perf.gcviewer.ctrl.GCModelLoader) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries)

Aggregations

GcResourceSeries (com.tagtraum.perf.gcviewer.model.GcResourceSeries)14 GcResourceFile (com.tagtraum.perf.gcviewer.model.GcResourceFile)11 Test (org.junit.Test)11 GCResource (com.tagtraum.perf.gcviewer.model.GCResource)10 ArrayList (java.util.ArrayList)6 GCModel (com.tagtraum.perf.gcviewer.model.GCModel)3 GCModelLoader (com.tagtraum.perf.gcviewer.ctrl.GCModelLoader)2 File (java.io.File)2 GCViewerGuiController (com.tagtraum.perf.gcviewer.ctrl.impl.GCViewerGuiController)1 IOException (java.io.IOException)1 Logger (java.util.logging.Logger)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)1