2020-06-28 18:20:38 +08:00
package cn.ac.iie ;
2020-06-29 19:06:23 +08:00
import cn.ac.iie.dao.BaseArangoData ;
2020-06-28 18:20:38 +08:00
import cn.ac.iie.utils.ArangoDBConnect ;
2020-06-29 19:06:23 +08:00
import cn.ac.iie.utils.ExecutorThreadPool ;
2020-06-28 18:20:38 +08:00
import com.arangodb.entity.* ;
import java.util.* ;
2020-06-29 19:06:23 +08:00
import java.util.concurrent.ConcurrentHashMap ;
2020-06-28 18:20:38 +08:00
public class TestMap {
public static void main ( String [ ] args ) {
/ *
long maxTime = 1592794800 ;
long minTime = 1590112800 ;
String where = " common_recv_time >= " + minTime + " AND common_recv_time <= " + maxTime + " AND (common_schema_type = 'HTTP' or common_schema_type = 'SSL') " ;
String sql = " SELECT common_schema_type,http_host,ssl_sni,MAX(common_recv_time) as LAST_FOUND_TIME,MIN(common_recv_time) as FIRST_FOUND_TIME,COUNT(*) as COUNT_TOTAL,groupArray(30)(common_server_ip) as DIST_CIP_RECENT FROM tsg_galaxy_v3.connection_record_log WHERE " + where + " GROUP BY common_schema_type,http_host,ssl_sni " ;
System . out . println ( sql ) ;
long start = System . currentTimeMillis ( ) ;
try {
DruidPooledConnection connection = ClickhouseConnect . getInstance ( ) . getConnection ( ) ;
Statement statement = connection . createStatement ( ) ;
ResultSet resultSet = statement . executeQuery ( sql ) ;
HashMap < String , HashMap < String , Long > > schemaHashMap = new HashMap < > ( ) ;
while ( resultSet . next ( ) ) {
String [ ] distCipRecents = ( String [ ] ) resultSet . getArray ( " DIST_CIP_RECENT " ) . getArray ( ) ;
for ( String s : distCipRecents ) {
System . out . print ( s + " , " ) ;
}
System . out . println ( ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
* /
// long[] longs = new long[]{1,2,3,4,5,6,7};
/ *
long [ ] longs = new long [ ] { 1 , 2 , 3 , 4 } ;
long [ ] longs1 = new long [ 7 ] ;
System . arraycopy ( longs , 0 , longs1 , 1 , longs . length - 1 ) ;
longs1 [ 0 ] = 0 ;
for ( long c : longs1 ) {
System . out . println ( c ) ;
}
* /
2020-06-29 19:06:23 +08:00
2020-06-28 18:20:38 +08:00
String [ ] distCipRecents = new String [ ] { " 2.3 " } ;
ArrayList < BaseDocument > baseEdgeDocuments = new ArrayList < > ( ) ;
BaseDocument newDoc = new BaseDocument ( ) ;
newDoc . setKey ( " 111$#$ " ) ;
// newDoc.setKey("11111");
newDoc . addAttribute ( " FIRST_FOUND_TIME " , 123 ) ;
newDoc . addAttribute ( " LAST_FOUND_TIME " , 123 ) ;
BaseDocument document = new BaseDocument ( ) ;
document . setKey ( " 4399pk.com2142379111 " ) ;
document . addAttribute ( " FIRST_FOUND_TIME " , 1592743297 ) ;
document . addAttribute ( " LAST_FOUND_TIME " , 1592743297 ) ;
baseEdgeDocuments . add ( newDoc ) ;
baseEdgeDocuments . add ( document ) ;
ArangoDBConnect instance = ArangoDBConnect . getInstance ( ) ;
instance . overwrite ( baseEdgeDocuments , " FQDN " ) ;
ArangoDBConnect . clean ( ) ;
2020-06-29 19:06:23 +08:00
/ *
BaseArangoData . BaseEFqdnAddressIpDataMap ( ) ;
ExecutorThreadPool . shutdown ( ) ;
ExecutorThreadPool . awaitThreadTask ( ) ;
try {
ConcurrentHashMap . KeySetView < String , BaseEdgeDocument > keySet = BaseArangoData . e_Fqdn_Address_Ip_Map . keySet ( ) ;
ArrayList < BaseEdgeDocument > baseEdgeDocuments = new ArrayList < > ( ) ;
ArangoDBConnect instance = ArangoDBConnect . getInstance ( ) ;
for ( String key : keySet ) {
BaseEdgeDocument baseEdgeDocument = BaseArangoData . e_Fqdn_Address_Ip_Map . get ( key ) ;
// Long[] tls_cnt_recents = (Long[]) baseEdgeDocument.getAttribute("TLS_CNT_RECENT");
ArrayList < Long > tlsCntRecent = ( ArrayList < Long > ) baseEdgeDocument . getAttribute ( " TLS_CNT_RECENT " ) ;
Long [ ] tlsCntRecentsSrc = tlsCntRecent . toArray ( new Long [ tlsCntRecent . size ( ) ] ) ;
System . out . println ( Arrays . toString ( tlsCntRecentsSrc ) ) ;
tlsCntRecent . set ( tlsCntRecent . size ( ) - 2 , 99L ) ;
baseEdgeDocument . addAttribute ( " TLS_CNT_RECENT " , tlsCntRecent ) ;
baseEdgeDocuments . add ( baseEdgeDocument ) ;
}
instance . overwrite ( baseEdgeDocuments , " R_LOCATE_FQDN2IP " ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
} finally {
ArangoDBConnect . clean ( ) ;
}
* /
2020-06-28 18:20:38 +08:00
}
}