001package com.astrolabsoftware.FinkBrowser.Januser; 002 003import com.Lomikel.Januser.JanusClient; 004 005// Tinker Pop 006import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.unfold; 007import static org.apache.tinkerpop.gremlin.process.traversal.P.*; 008import org.apache.tinkerpop.gremlin.structure.Vertex; 009 010// Java 011import java.util.List; 012 013// Log4J 014import org.apache.logging.log4j.Logger; 015import org.apache.logging.log4j.LogManager; 016 017/** <code>AlertUtilities</code> provides utility searches for alerts. 018 * @opt attributes 019 * @opt operations 020 * @opt types 021 * @opt visibility 022 * @author <a href="mailto:Julius.Hrivnac@cern.ch">J.Hrivnac</a> */ 023public class AlertUtilities extends JanusClient { 024 025 /** TBD */ 026 public static void main(String[] args) { 027 AlertUtilities au = new AlertUtilities(args[0]); 028 List<Vertex> r = au.searchJd(Double.valueOf(args[1]), Double.valueOf(args[2]), args[3], Integer.valueOf(args[4])); 029 log.info(r); 030 au.close(); 031 } 032 033 /** Create with connection parameters. 034 * @param hostname The HBase hostname. 035 * @param port The HBase port. 036 * @param table The HBase table. */ 037 public AlertUtilities(String hostname, 038 int port, 039 String table) { 040 super(hostname, port, table, false); 041 } 042 043 /** Create with connection parameters. 044 * @param hostname The HBase hostname. 045 * @param port The HBase port. 046 * @param table The HBase table. 047 * @param batch Whether open graph for batch loading. */ 048 public AlertUtilities(String hostname, 049 int port, 050 String table, 051 boolean batch) { 052 super(hostname, port, table, batch); 053 } 054 055 /** Create with connection properties file. 056 * @param properties The file with the complete properties. */ 057 public AlertUtilities(String properties) { 058 super(properties); 059 } 060 061 /** Search {@link Vertex}es between <em>Julian Dates</em>. 062 * @param since The end <em>Julian Date</em>. 063 * @param till The start <em>Julian Date</em>. 064 * @param lbl The {@link Vertex} label. 065 * @param limit The maximal number of resuolts to give. 066 * @return The {@link List} of {@link Vertex}es. 067 */ 068 public List<Vertex> searchJd(double since, 069 double till, 070 String lbl, 071 int limit) { 072 log.info("Searching " + lbl + " within " + since + " - " + till + ", limit = " + limit); 073 if (limit <= 0) { 074 log.info(g().V().has("jd", inside(since, till)).has("lbl", lbl).count()); 075 return null; 076 } 077 return g().V().has("jd", inside(since, till)).has("lbl", lbl).limit(limit).toList(); 078 } 079 080 /** Logging . */ 081 private static Logger log = LogManager.getLogger(AlertUtilities.class); 082 083 }