use of org.csstudio.trends.databrowser3.archive.ArchiveFetchJob in project org.csstudio.display.builder by kasemir.
the class ArchiveFetchJobTest method fetchCompleted.
@Override
public void fetchCompleted(final ArchiveFetchJob job) {
System.out.println("Completed " + job);
final PlotSamples samples = item.getSamples();
System.out.println(samples);
got_anything = samples.size() > 0;
}
use of org.csstudio.trends.databrowser3.archive.ArchiveFetchJob in project org.csstudio.display.builder by kasemir.
the class ControllerBase method stop.
/**
* Stop scrolling and model items
* @throws IllegalStateException when not running
*/
public void stop() {
if (!isRunning())
throw new IllegalStateException("Not started");
// Stop ongoing archive access
synchronized (archive_fetch_jobs) {
for (ArchiveFetchJob job : archive_fetch_jobs) job.cancel();
archive_fetch_jobs.clear();
}
// Stop update task
model.stop();
model.removeListener(model_listener);
update_task.cancel(true);
update_task = null;
}
use of org.csstudio.trends.databrowser3.archive.ArchiveFetchJob in project org.csstudio.display.builder by kasemir.
the class ControllerBase method getArchivedData.
/**
* Initiate archive data retrieval for a specific model item
* @param item Model item. NOP for non-PVItem
* @param start Start time
* @param end End time
*/
private void getArchivedData(final ModelItem item, final Instant start, final Instant end) {
// Only useful for PVItems with archive data source
if (!(item instanceof PVItem))
return;
final PVItem pv_item = (PVItem) item;
if (pv_item.getArchiveDataSources().length <= 0)
return;
// Determine ongoing jobs for this item
final List<ArchiveFetchJob> ongoing = new ArrayList<>();
final ArchiveFetchJob new_job = makeArchiveFetchJob(pv_item, start, end);
synchronized (archive_fetch_jobs) {
for (Iterator<ArchiveFetchJob> iter = archive_fetch_jobs.iterator(); iter.hasNext(); ) /**/
{
final ArchiveFetchJob job = iter.next();
if (job.getPVItem() == pv_item) {
ongoing.add(job);
iter.remove();
}
}
// Track new job
archive_fetch_jobs.add(new_job);
}
// job.schedule();
Activator.getThreadPool().execute(() -> {
// In background, stop ongoing jobs
for (ArchiveFetchJob running : ongoing) {
try {
running.cancel();
running.join(10000, null);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot cancel " + running, ex);
}
}
// .. then start new one
new_job.schedule();
});
}
use of org.csstudio.trends.databrowser3.archive.ArchiveFetchJob in project org.csstudio.display.builder by kasemir.
the class ArchiveFetchJobTest method testMultipleArchives.
/**
* Start ArchiveFetchJob for multiple data sources, one that fails, wait for its completion
*/
@Test(timeout = 60000)
public void testMultipleArchives() throws Exception {
final TestProperties settings = new TestProperties();
String url = settings.getString("archive_rdb_url");
if (url == null) {
System.out.println("Skipped");
return;
}
item = new PVItem("DTL_LLRF:IOC1:Load", 1.0);
// First URL is expected to fail
item.addArchiveDataSource(new ArchiveDataSource("Broken_URL", 1, "failed_test"));
// Second URL should return data
item.addArchiveDataSource(new ArchiveDataSource(url, 1, "test"));
runFetchJob();
}
use of org.csstudio.trends.databrowser3.archive.ArchiveFetchJob in project org.csstudio.display.builder by kasemir.
the class ArchiveFetchJobTest method testArchiveFetchJob.
/**
* Start ArchiveFetchJob, wait for its completion
*/
@Test(timeout = 60000)
public void testArchiveFetchJob() throws Exception {
final TestProperties settings = new TestProperties();
String url = settings.getString("archive_rdb_url");
if (url == null) {
System.out.println("Skipped");
return;
}
item = new PVItem("DTL_LLRF:IOC1:Load", 1.0);
item.addArchiveDataSource(new ArchiveDataSource(url, 1, "test"));
runFetchJob();
}
Aggregations