use of org.opennms.netmgt.collection.api.PersistException in project opennms by OpenNMS.
the class TcpPersistOperationBuilder method commit.
/**
* Commit.
*
* @throws PersistException the persist exception
*/
@Override
public void commit() throws PersistException {
if (m_dbl_declarations.size() == 0 && m_str_declarations.size() == 0) {
return;
}
try {
final String ownerName = m_resource.getOwnerName();
final String absolutePath = getResourceDir(m_resource).getAbsolutePath();
String rrdFile = absolutePath + File.separator + m_rrdName + fileExt;
long timestamp = m_timeKeeper.getCurrentTime();
long time = (timestamp + 500L) / 1000L;
m_tcpStrategy.updateData(rrdFile, ownerName, new Long(time), getDblValues(), getStrValues());
} catch (FileNotFoundException e) {
LoggerFactory.getLogger(getClass()).warn("Could not get resource directory: " + e.getMessage(), e);
return;
} catch (Exception e) {
throw new PersistException(e);
}
}
use of org.opennms.netmgt.collection.api.PersistException in project opennms by OpenNMS.
the class RrdPersistOperationBuilder method commit.
/**
* <p>commit</p>
*
* @throws org.opennms.netmgt.collection.api.PersistException if any.
*/
public void commit() throws PersistException {
if (m_declarations.size() == 0) {
// Nothing to do. In fact, we'll get an error if we try to create an RRD file with no data sources
return;
}
try {
final String ownerName = m_resource.getOwnerName();
final String absolutePath = getResourceDir(m_resource);
RrdMetaDataUtils.createMetaDataFile(absolutePath, m_rrdName, m_metaData);
List<RrdDataSource> dataSources = getDataSources();
if (dataSources != null && dataSources.size() > 0) {
createRRD(m_rrdStrategy, ownerName, absolutePath, m_rrdName, getRepository().getStep(), dataSources, getRepository().getRraList());
updateRRD(m_rrdStrategy, ownerName, absolutePath, m_rrdName, m_timeKeeper.getCurrentTime(), getValues());
}
} catch (FileNotFoundException e) {
LoggerFactory.getLogger(getClass()).warn("Could not get resource directory: " + e.getMessage(), e);
return;
} catch (RrdException e) {
throw new PersistException(e);
}
}
Aggregations