BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.INFO);
Logger.getLogger("org.rhq").setLevel(Level.DEBUG);
EntityManagerFactory entityManagerFactory = null;
EntityManager entityManager = null;
ExistingDataBulkExportSource source = null;
try {
entityManagerFactory = createEntityManager();
entityManager = entityManagerFactory.createEntityManager();
source = new ExistingPostgresDataBulkExportSource(entityManager,
"SELECT schedule_id, time_stamp, value, minvalue, maxvalue FROM RHQ_MEASUREMENT_DATA_NUM_1D");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
source.initialize();
int rowIndex = 0;
int maxResults = 30000;
for (;;) {
List<Object[]> existingData = source.getData(rowIndex, maxResults);
if (existingData.size() < maxResults) {
break;
} else {
rowIndex += maxResults;
}
}
stopWatch.stop();
System.out.println("Execution: " + stopWatch);
} finally {
if (source != null) {
source.close();
}
if (entityManager != null) {
entityManager.close();
}
if (entityManagerFactory != null) {