Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gladky committed Sep 2, 2016
2 parents 64c2984 + a4f5211 commit f9bb4bc
Show file tree
Hide file tree
Showing 163 changed files with 1,210,702 additions and 930 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ DAQAggregator.properties
target
/visualization/
/doc/
/logs/
/logs/
63 changes: 38 additions & 25 deletions DAQAggregator_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,65 @@
# 1. duplicate this file as DAQAggregator.properties in project root
# 2. set your credentials
# 3. DAQAggregator.properties is ignored by git (.gitignore) by default
# but make sure you don't commit it (if you put it in different directory than project root)
# but make sure you don't commit it
#
#

comment = Test
sortpriority = 1

# cDAQ production
#session.lasURLgeneral = http://pc-c2e11-18-01.cms:9941/urn:xdaq-application:service=xmaslas2g
#session.l0filter1 = toppro
#session.l0filter2 = PublicGlobal
#monitor.lasURLs = \
#http://pc-c2e11-18-01.cms:9941/urn:xdaq-application:service=xmaslas2g \
#http://pc-c2e11-18-01.cms:9942/urn:xdaq-application:service=xmaslas2g
#session.lasURLgeneral = http://pc-c2e11-34-01.cms/escaped
#monitor.lasURLs = http://pc-c2e11-34-01.cms/escaped

# daqval
session.lasURLgeneral = http://dvsrv-c2f36-10-01.cms:9941/urn:xdaq-application:service=xmaslas2g
session.l0filter1 = cmsrc-daqval
session.l0filter2 = 31500
monitor.lasURLs = http://dvsrv-c2f36-10-01.cms:9941/urn:xdaq-application:service=xmaslas2g http://dvsrv-c2f36-10-01.cms:9942/urn:xdaq-application:service=xmaslas2g
session.lasURLgeneral = http://pc-c2e11-29-01.cms:9941/urn:xdaq-application:service=xmaslas2g
session.l0filter1 = toppro
session.l0filter2 = PublicGlobal
monitor.lasURLs = \
http://pc-c2e11-29-01.cms:9941/urn:xdaq-application:service=xmaslas2g \
http://pc-c2e11-29-01.cms:9942/urn:xdaq-application:service=xmaslas2g \
http://pc-c2e11-23-01.cms:9945/urn:xdaq-application:service=xmaslas2g


#
# settings concerning HWCFG DB
# ask your collegue for credentials
#
#hwcfgdb.dburl = jdbc:oracle:thin:@cms_rcms
hwcfgdb.sid = ask your colleague...
hwcfgdb.host = localhost
hwcfgdb.port = 10121
hwcfgdb.sid =
hwcfgdb.login =
hwcfgdb.pwd =


#
# SOCKS proxy settings
#
socksproxy.enableproxy = true
socksproy.host = localhost
socksproxy.port = 1080


#
# Mode of run. Determines if DAQAggregator will run in real time mode or batch (file-based) mode.
# possible values: rt ,file
#
run.mode = file

#
# mode of persistence (snapshot/flashlist/all)
#
persistence.mode = snapshot

#
# directory where snapshots will be persisted
# directory where snapshots/flashlists will be persisted
#
persistence.dir = /tmp/snapshots/
persistence.snapshot.dir = /tmp/daqaggregator-dev/snapshots/
persistence.flashlist.dir = /tmp/daqaggregator-dev/flashlists2/

#
# format of snapshosts (smile/json/JSONREFPREFIXED/JSONUGLY/JSONREFPREFIXEDUGLY)
# format of snapshots/snapshots (smile/json/JSONREFPREFIXED/JSONUGLY/JSONREFPREFIXEDUGLY)
#
persistence.format = smile
persistence.snapshot.format = json
persistence.flashlist.format = json

logfile = /tmp/daqaggregator.log
#
# other
#
logfile = /tmp/daqaggregator.log
comment = Test
sortpriority = 1
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.cern</groupId>
<artifactId>DAQAggregator</artifactId>
<version>1.2.8</version>
<version>1.4.0</version>
<repositories>
<repository>
<id>libs-release-local</id>
Expand Down Expand Up @@ -107,6 +107,14 @@
<version>1.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>



</dependencies>
</project>
89 changes: 89 additions & 0 deletions src/main/java/rcms/utilities/daqaggregator/Application.java
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;
}
}
63 changes: 63 additions & 0 deletions src/main/java/rcms/utilities/daqaggregator/Converter.java
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);
}
}

}
Loading

0 comments on commit f9bb4bc

Please sign in to comment.