Stream

转集合

1
List<String> strList=list.stream.map(T::get).collect(Collectors.toList);

根据分类分组

1
2
3
4
5
6
7
List<AppModel> list=new ArrayList<>();
Map<String, List<AppModel>> groupByCategoryList = appModelList
.stream()
.collect(
Collectors
.groupingBy(AppModel::getModelCategory)
);
阅读更多

Jackson正反序列化

  • 范例1:List<T>
  • 范例1:List<Map<String, T>>
  • 范例2:Map<String, List<T>>
1
2
3
4
5
6
//先构造Map<String,Person>得到innerType,第一个参数为外层对象HashMap,第二个参数为String,第三个参数为Person
JavaType innerType = mapper.getTypeFactory().constructParametricType(HashMap.class, String.class, Person.class);
//再构造List<innerType>
JavaType resultType = mapper.getTypeFactory().constructParametricType(ArrayList.class, innerType);
//反序列化
List<Map<String, Person>> result2 = mapper.readValue(s, resultType);

ELK记录

Filebeat

1
./filebeat -e -c filebeat.yml -d "publish"

https://www.elastic.co/guide/en/beats/filebeat/7.8/filebeat-starting.html

Logstash

1
./logstash -f ../config/logstash-sample.conf  --config.reload.automatic

https://www.elastic.co/guide/en/logstash/current/advanced-pipeline.html

格式

1
2
3
2020-07-21 09:15:38,001 INFO [quartzScheduler_Worker-3] c.g.j.modules.quartz.jobs.SampleJob [SampleJob.java : 20] 定时任务! 时间:2020-07-21 09:15:38

%{TIMESTAMP_ISO8601} %{LOGLEVEL:loglevel} \[%{DATA:thread}\] %{JAVACLASS:class} \[%{JAVAFILE:file} (?:: %{BASE10NUM:line})?\] %{GREEDYDATA:msg}

elasticsearch

查看索引信息

curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'

查看所有索引状态

curl 'localhost:9200/_cat/indices?v'

删除索引

curl -XDELETE http://localhost:9200/index_namee

https://www.cnblogs.com/zhangb8042/articles/11346085.html

nohup ./kibana >/dev/null 2>&1 &

nohup ./elasticsearch >/dev/null 2>&1 &

nohup ./logstash -f ../config/logstash-sample.conf --config.reload.automatic >/dev/null 2>&1 &

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×