protected static void configureInfoProperties(ConfigurableEnvironment env) { SystemInformation systemInformation = new SystemInformation(); Map<String, Object> infoMap = new HashMap<>(); infoMap.put("info.fileTimestamp", systemInformation.getDeploymentDateAsString()); infoMap.put("info.hostname", systemInformation.getHostname()); env.getPropertySources().addFirst(new MapPropertySource("INFO_MAP", infoMap)); }
@Override public void fail(Object id) { List<LogEntry> list = new ArrayList<LogEntry>(); LogEntry log = new LogEntry(); log.setCategory("Storm"); String message = (String) id; log.setMessage( "FAIL " + message + " " + syinfo.getFQDN() + " CURTIME=" + System.currentTimeMillis()); list.add(log); try { if (!tr.isOpen()) tr.open(); client.Log(list); } catch (org.apache.thrift.TException e) { e.printStackTrace(); } }
/** * Update system time. * * @param date New System Date and Time */ public static void updateSystemTime(final Date date) { Date oldDate = new Date(); // is saved only for LOG message output SimpleDateFormat fmt = new SimpleDateFormat("dd-MM-yyyy"); String actDate = fmt.format(date); fmt.applyPattern("HH:mm:ss"); String actTime = fmt.format(date); try { switch (SystemInformation.getInstance().os()) { case WINDOWS: Runtime rt = Runtime.getRuntime(); rt.exec("cmd /C date " + actDate); rt.exec("cmd /C time " + actTime); break; case LINUX: // with root permits only fmt.applyPattern("MM/dd/yyyy HH:mm:ss"); actDate = fmt.format(date); // String cmdDate = "date -u -s'" + actDate + "' +'%D %T'"; // execCommand(cmdDate); break; default: break; } fmt.applyPattern("dd-MM-yyyy HH:mm:ss"); SystemUtils.LOG.log( Level.INFO, "SystemUtils.updateSystemTime() System time was updated from " + fmt.format(oldDate) + " to " + fmt.format(date)); } catch (IOException e) { // cannot run commands SystemUtils.LOG.log( Level.SEVERE, "SystemUtils.updateSystemTime() Exception while updating sys time.", e); } }