This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
163 changed files
with
1,210,702 additions
and
930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ DAQAggregator.properties | |
target | ||
/visualization/ | ||
/doc/ | ||
/logs/ | ||
/logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/rcms/utilities/daqaggregator/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package rcms.utilities.daqaggregator; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
public class Application { | ||
|
||
// settings concerning session definition | ||
public static String PROPERTYNAME_SESSION_LASURL_GE = "session.lasURLgeneral"; | ||
public static String PROPERTYNAME_SESSION_L0FILTER1 = "session.l0filter1"; | ||
public static String PROPERTYNAME_SESSION_L0FILTER2 = "session.l0filter2"; | ||
|
||
// settings for monitoring | ||
public static String PROPERTYNAME_MONITOR_SETUPNAME = "monitor.setupName"; | ||
public static String PROPERTYNAME_MONITOR_URLS = "monitor.lasURLs"; | ||
|
||
// settings concerning HWCFG DB | ||
public static String PROPERTYNAME_HWCFGDB_DBURL = "hwcfgdb.dburl"; | ||
public static String PROPERTYNAME_HWCFGDB_HOST = "hwcfgdb.host"; | ||
public static String PROPERTYNAME_HWCFGDB_PORT = "hwcfgdb.port"; | ||
public static String PROPERTYNAME_HWCFGDB_SID = "hwcfgdb.sid"; | ||
public static String PROPERTYNAME_HWCFGDB_LOGIN = "hwcfgdb.login"; | ||
public static String PROPERTYNAME_HWCFGDB_PWD = "hwcfgdb.pwd"; | ||
|
||
// settings concerning SOCKS proxy | ||
public static String PROPERTYNAME_PROXY_ENABLE = "socksproxy.enableproxy"; // optional | ||
public static String PROPERTYNAME_PROXY_HOST = "socksproy.host"; | ||
public static String PROPERTYNAME_PROXY_PORT = "socksproxy.port"; | ||
|
||
// settings concerning persistence | ||
public static String PERSISTENCE_FLASHLIST_DIR = "persistence.flashlist.dir"; | ||
public static String PERSISTENCE_SNAPSHOT_DIR = "persistence.snapshot.dir"; | ||
public static String PERSISTENCE_FLASHLIST_FORMAT = "persistence.flashlist.format"; | ||
public static String PERSISTENCE_SNAPSHOT_FORMAT = "persistence.snapshot.format"; | ||
public static String PERSISTENCE_MODE = "persistence.mode"; | ||
|
||
public static String RUN_MODE = "run.mode"; | ||
|
||
private final Properties prop; | ||
|
||
public static Application get() { | ||
if (instance == null) { | ||
throw new RuntimeException("Not initialized"); | ||
} | ||
return instance; | ||
} | ||
|
||
public static void initialize(String propertiesFile) { | ||
String message = "Required property missing "; | ||
instance = new Application(propertiesFile); | ||
if (!instance.prop.containsKey(PROPERTYNAME_SESSION_LASURL_GE)) | ||
throw new RuntimeException(message + PROPERTYNAME_SESSION_LASURL_GE); | ||
if (!instance.prop.containsKey(PROPERTYNAME_MONITOR_URLS)) | ||
throw new RuntimeException(message + PROPERTYNAME_MONITOR_URLS); | ||
if (!instance.prop.containsKey(PERSISTENCE_MODE)) | ||
throw new RuntimeException(message + PERSISTENCE_MODE); | ||
if (!instance.prop.containsKey(RUN_MODE)) | ||
throw new RuntimeException(message + RUN_MODE); | ||
} | ||
|
||
private Application(String propertiesFile) { | ||
prop = load(propertiesFile); | ||
} | ||
|
||
private static Application instance; | ||
|
||
private Properties load(String propertiesFile) { | ||
|
||
try { | ||
FileInputStream propertiesInputStream = new FileInputStream(propertiesFile); | ||
Properties properties = new Properties(); | ||
properties.load(propertiesInputStream); | ||
|
||
return properties; | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException("Cannot run application without configuration file"); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException("Cannot run application without configuration file"); | ||
} | ||
} | ||
|
||
public Properties getProp() { | ||
return prop; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package rcms.utilities.daqaggregator; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map.Entry; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import rcms.utilities.daqaggregator.datasource.Flashlist; | ||
import rcms.utilities.daqaggregator.persistence.PersistenceExplorer; | ||
import rcms.utilities.daqaggregator.persistence.PersistenceFormat; | ||
import rcms.utilities.daqaggregator.persistence.StructureSerializer; | ||
|
||
/** | ||
* Converts flashlists from one format to another | ||
* | ||
* @author Maciej Gladki ([email protected]) | ||
* | ||
*/ | ||
public class Converter { | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
// Times here are in UTC | ||
Long startTimestamp = javax.xml.bind.DatatypeConverter.parseDateTime("2016-08-30T19:50:00").getTimeInMillis(); | ||
Long endTimestamp = javax.xml.bind.DatatypeConverter.parseDateTime("2016-08-30T20:40:00").getTimeInMillis(); | ||
String sourceDir = "/tmp/daqaggregator-dev/flashlists/LEVEL_ZERO_FM_DYNAMIC/"; | ||
String targetDir = "/tmp/flashlists-request/flashlist-LEVEL_ZERO_FM_DYNAMIC-2016-08-30T20:00:00/"; | ||
PersistenceFormat sourceFormat = PersistenceFormat.SMILE; | ||
PersistenceFormat targetFormat = PersistenceFormat.JSON; | ||
|
||
Converter converter = new Converter(); | ||
|
||
converter.convert(startTimestamp, endTimestamp, sourceDir, targetDir, sourceFormat, targetFormat); | ||
} | ||
|
||
private void convert(Long startTimestamp, Long endTimestamp, String sourceDir, String targetDir, | ||
PersistenceFormat sourceFormat, PersistenceFormat targetFormat) throws IOException { | ||
|
||
StructureSerializer serializer = new StructureSerializer(); | ||
|
||
Entry<Long, List<File>> result = PersistenceExplorer.get().explore(startTimestamp, endTimestamp, sourceDir); | ||
|
||
System.out.println("Explored: " + result.getValue()); | ||
|
||
for (File file : result.getValue()) { | ||
|
||
Flashlist flashlist = serializer.deserializeFlashlist(file, sourceFormat); | ||
|
||
String flashlistFilename = flashlist.getRetrievalDate().getTime() + targetFormat.getExtension(); | ||
|
||
File targetFile = new File(targetDir + flashlistFilename); | ||
|
||
ObjectMapper mapper = targetFormat.getMapper(); | ||
|
||
FileOutputStream fos = new FileOutputStream(targetFile); | ||
mapper.writerWithDefaultPrettyPrinter().writeValue(fos, flashlist); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.