use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-modules-public by infiniteautomation.
the class ReportsDwr method purgeAllNow.
/**
* Purge all Reports Now
* @return
*/
@DwrPermission(custom = ReportPermissionDefinition.PERMISSION)
public ProcessResult purgeAllNow() {
ProcessResult response = new ProcessResult();
int deleteCount = ReportDao.instance.purgeReportsBefore(Common.timer.currentTimeMillis());
LOG.info("Report purge ended, " + deleteCount + " report instances deleted");
response.addData("purgeMessage", new TranslatableMessage("systemSettings.reports.reportsPurged", deleteCount).translate(Common.getTranslations()));
return response;
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-modules-public by infiniteautomation.
the class ReportsDwr method purgeNow.
/**
* Purge Reports using settings
* @param reportPurgePeriods
* @param reportPurgePeriodType
* @return
*/
@DwrPermission(custom = ReportPermissionDefinition.PERMISSION)
public ProcessResult purgeNow() {
ProcessResult response = new ProcessResult();
DateTime cutoff = DateUtils.truncateDateTime(new DateTime(), Common.TimePeriods.DAYS);
cutoff = DateUtils.minus(cutoff, SystemSettingsDao.getIntValue(ReportPurgeDefinition.REPORT_PURGE_PERIOD_TYPE, Common.TimePeriods.MONTHS), SystemSettingsDao.getIntValue(ReportPurgeDefinition.REPORT_PURGE_PERIODS, 1));
int deleteCount = ReportDao.instance.purgeReportsBefore(cutoff.getMillis());
LOG.info("Report purge ended, " + deleteCount + " report instances deleted");
response.addData("purgeMessage", new TranslatableMessage("systemSettings.reports.reportsPurged", deleteCount).translate(Common.getTranslations()));
return response;
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-modules-public by infiniteautomation.
the class VMStatDataSourceRT method initialize.
//
// /
// / Lifecycle
// /
//
@Override
public void initialize() {
super.initialize();
String command;
String osName = System.getProperty("os.name");
if (osName.equals("Linux")) {
osName = "linux";
command = "vmstat -n ";
} else if (osName.startsWith("Win")) {
osName = "windows";
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.initializationError", "OS: " + osName + " Not Supported"));
return;
} else // since 0.9.0 ->
if (osName.equals("SunOS")) {
osName = "solaris";
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.initializationError", "OS: " + osName + " Not Supported"));
return;
} else if (osName.equals("Mac OS X") || osName.equals("Darwin")) {
// os.name "Darwin" since 2.6.0
osName = "mac_os_x";
// TODO Implement this for OSX, output format is different
command = "vm_stat -n";
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.initializationError", "OS: " + osName + " Not Supported"));
return;
} else {
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.initializationError", "OS: " + osName + " Not Supported"));
return;
}
switch(vo.getOutputScale()) {
case VMStatDataSourceVO.OutputScale.LOWER_K:
command += "-S k ";
break;
case VMStatDataSourceVO.OutputScale.UPPER_K:
command += "-S K ";
break;
case VMStatDataSourceVO.OutputScale.LOWER_M:
command += "-S m ";
break;
case VMStatDataSourceVO.OutputScale.UPPER_M:
command += "-S M ";
break;
}
command += vo.getPollSeconds();
try {
vmstatProcess = Runtime.getRuntime().exec(command);
// Create the input stream readers.
in = new BufferedReader(new InputStreamReader(vmstatProcess.getInputStream()));
// Read the first two lines of output. They are the headers.
in.readLine();
String headers = in.readLine();
// Create a mapping of attribute ids to split array positions.
attributePositions = new HashMap<Integer, Integer>();
headers = headers.trim();
String[] headerParts = headers.split("\\s+");
for (int i = 0; i < headerParts.length; i++) {
int attributeId = -1;
if ("r".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.PROCS_R;
else if ("b".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.PROCS_B;
else if ("swpd".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.MEMORY_SWPD;
else if ("free".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.MEMORY_FREE;
else if ("buff".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.MEMORY_BUFF;
else if ("cache".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.MEMORY_CACHE;
else if ("si".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.SWAP_SI;
else if ("so".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.SWAP_SO;
else if ("bi".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.IO_BI;
else if ("bo".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.IO_BO;
else if ("in".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.SYSTEM_IN;
else if ("cs".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.SYSTEM_CS;
else if ("us".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.CPU_US;
else if ("sy".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.CPU_SY;
else if ("id".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.CPU_ID;
else if ("wa".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.CPU_WA;
else if ("st".equals(headerParts[i]))
attributeId = VMStatPointLocatorVO.Attributes.CPU_ST;
if (attributeId != -1)
attributePositions.put(attributeId, i);
}
// Read the first line of data. This is a summary of beginning of time until now, so it is no good for
// our purposes. Just throw it away.
in.readLine();
returnToNormal(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis());
} catch (IOException e) {
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.initializationError", e.getMessage()));
}
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-modules-public by infiniteautomation.
the class PointLinkRT method getSetPointSourceMessage.
@Override
public TranslatableMessage getSetPointSourceMessage() {
if (vo.isWriteAnnotation()) {
DataPointVO vo = DataPointDao.instance.get(this.vo.getSourcePointId());
String xid;
if (vo != null)
xid = vo.getXid();
else
xid = "unknown";
return new TranslatableMessage("annotation.pointLink", xid);
}
return null;
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-modules-public by infiniteautomation.
the class JsonConfigImportWebSocketHandler method notify.
protected void notify(WebSocketSession session, ImportStatusProvider model) {
try {
User user = this.getUser(session);
if (user == null) {
return;
}
sendMessage(session, model);
} catch (Exception e) {
// TODO Mango 3.4 add new exception type for closed session and don't try and send error if it was a closed session exception
try {
this.sendErrorMessage(session, MangoWebSocketErrorType.SERVER_ERROR, new TranslatableMessage("rest.error.serverError", e.getMessage()));
} catch (Exception e1) {
LOG.error(e1.getMessage(), e1);
}
}
}
Aggregations