随记

......

DOCKER

查看指定服务名的日志(只有一个服务实列)
docker service ps t_mserv_espare|grep Running|awk '{print $1}'|xargs docker service logs -f

构建镜像

docker build -t <TAG_NAME> <Dockerfile_PATH>

运行镜像

docker run -d -p 3000:3000/tcp -v /d:\\test:/home/test gettingg-started

-d(etach) 后台模式运行 -p(ublish) <hostPort>:<containerPort>/<protocol[tpc,udp...]> 端口映射

-v(olume) 磁盘映射 hostPath:containerPath

查看镜像列表

docker images

查看容器实例列表

docker ps 或者 docker container ls

查看实例中运行的程序的STD_OUT(标准输出)(eg:c语言中的print/printf,node:console.log,java:System.out…)

docker logs <containerId>

运行当前运行中容器中的命令

docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Options:
-d, --detach Detached mode: run command in the background
--detach-keys string Override the key sequence for detaching a
container
-e, --env list Set environment variables
-i, --interactive Keep STDIN open even if not attached
--privileged Give extended privileges to the command
-t, --tty Allocate a pseudo-TTY
-u, --user string Username or UID (format:
<name|uid>[:<group|gid>])
-w, --workdir string Working directory inside the container

eg: docker exec -it 12e /bin/sh

执行上述命令后会会自动连接到目标容易的终端

删除容器

`docker rm -f

创建服务

docker service create [OPTIONS] IMAGE [COMMAND] [ARG...]

强制重启服务

docker service update your_service_name --force

查看service的containerId

for f in $(docker service ps -q t_mserv_base_mq);do docker inspect --format '{{.ServiceID}} {{.NodeID}} {{.Status.ContainerStatus.ContainerID}} {{.DesiredState}}' $f; done

docker 容器可视化

docker pull dockersamples/visualizer:latest
docker service create \
--name=viz \
--publish=12306:8080/tcp \
--constraint=node.role==manager \
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
dockersamples/visualizer:latest

DockerFile

COPY SRC DEST

复制src文件到dest

ADD SRC DEST

复制src文件到dest,如果src为压缩文件,怎复制和自动解压

CMD cmd args…

docker run 时运行

RUN cmd args…

docker build时运行,可能

HEX(NUM) -> DECIMAL
int r= (int)(NUM / 10)*16 + NUM%10

日志

docker service logs --help

Usage:  docker service logs [OPTIONS] SERVICE|TASK

Fetch the logs of a service or task

Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--no-resolve Do not map IDs to Names in output
--no-task-ids Do not include task IDs in output
--no-trunc Do not truncate output
--raw Do not neatly format logs
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
-n, --tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps

eg:

查询日志通过服务名

docker service logs t_mserv_xgb_project --since 2022-04-22

查询日志通过taskId

获取服务对应的taskId

docker service ps t_mserv_xgb_project

通过taskId获取日志输出

docker service logs taskId --since 2022-04-22

网上搜索了很多文章都没解决,只好自己动手排查

通过对比可以正常转换的m3u8文件,发现出现问题的文件里少了 #EXTM3U

如果你遇到类似问题不妨检查下你的m3u8文件首行是不是#EXTM3U

https://users.cs.fiu.edu/~downeyt/webdev/Hibernate_Validator_Reference_Guide.htm

https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-method-validation-prerequisite-relaxation
https://my.oschina.net/u/4390157/blog/3476201
https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-ann-initbinder

<?xml version="1.0" encoding="UTF-8"?>
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
<default-provider>org.hibernate.validator.HibernateValidator</default-provider>

<property name="hibernate.validator.allow_parameter_constraint_override">true</property>
<property name="hibernate.validator.allow_multiple_cascaded_validation_on_result">true</property>
<property name="hibernate.validator.allow_parallel_method_parameter_constraint">true</property>
</validation-config>

ConditionalOnNacosDiscoveryEnabled
@ConditionalOnProperty(value = “spring.cloud.nacos.discovery.enabled”, matchIfMissing = true)
@ConditionalOnProperty(value = “spring.cloud.service-registry.auto-registration.enabled”, matchIfMissing = true)

thread join 实现(java层)

public final void join() throws InterruptedException {
join(0);
}

public final synchronized void join(long millis)
throws InterruptedException {
long base = System.currentTimeMillis();
long now = 0;

if (millis < 0) {
throw new IllegalArgumentException("timeout value is negative");
}

if (millis == 0) {
while (isAlive()) {
//等待唤醒
wait(0);
}
} else {
while (isAlive()) {
long delay = millis - now;
if (delay <= 0) {
break;
}
wait(delay);
now = System.currentTimeMillis() - base;
}
}
}

什么时候被唤醒呢

Threadc++实现


static void ensure_join(JavaThread* thread) {
// We do not need to grap the Threads_lock, since we are operating on ourself.
Handle threadObj(thread, thread->threadObj());
assert(threadObj.not_null(), "java thread object must exist");
ObjectLocker lock(threadObj, thread);
// Ignore pending exception (ThreadDeath), since we are exiting anyway
thread->clear_pending_exception();
// Thread is exiting. So set thread_status field in java.lang.Thread class to TERMINATED.
java_lang_Thread::set_thread_status(threadObj(), java_lang_Thread::TERMINATED);
// Clear the native thread instance - this makes isAlive return false and allows the join()
// to complete once we've done the notify_all below
java_lang_Thread::set_thread(threadObj(), NULL);
//唤醒所有执行了wait方法的线程
lock.notify_all(thread);
// Ignore pending exception (ThreadDeath), since we are exiting anyway
thread->clear_pending_exception();
}

ensure_join在什么时候执行呢

// For any new cleanup additions, please check to see if they need to be applied to
// cleanup_failed_attach_current_thread as well.
void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
//...
// Notify waiters on thread object. This has to be done after exit() is called
// on the thread (if the thread is the last thread in a daemon ThreadGroup the
// group should have the destroyed bit set before waiters are notified).
ensure_join(s)
}

线程执行完毕(退出时)

public class TestVolatile1{
public volatile static int i=0;
/**
* 0 getstatic #2 <online/githuboy/concurrent/TestVolatile1.i>
* 3 iconst_1
* 4 iadd
* 5 putstatic #2 <online/githuboy/concurrent/TestVolatile1.i>
* 8 return
*/
public void add(){
i++;
}
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(() -> {
for (int i = 0; i < 10000; i++) {
add();
}
});
Thread t2 = new Thread(() -> {
for (int i = 0; i < 10000; i++) {
add();
}
});
t1.start();
t2.start();
t1.join();
t2.join();
System.out.println(i);
}
}

i = 10
t1
int temp = i + 1
//ThreadContextSwitch t2
t2
int tmep = i+ 1
i = 11
//write result to main memory

t1
continue execute
reread from temp
write i = 11
sync to main memory

今天访问这个网站查看i7-10700F
查看性能参数,谁知道给我弹出一个密码输入框
p1

然后需要关注公众号,才能获取密码,我开始以为是免费的。结果需要3元RMB.
本着研究的精神,决定看下网站是如何验证的。

F12本以为能打开浏览器调试工具,结果直接弹出一个新的window.

好吧那只能通过菜单栏打开调试工具了。

通过快捷按键无法打开调试工具,说明该网站拦截了keyDown事件.

关键代码如下:

document.onkeydown=function(){
var e = window.event||arguments[0];
if(e.keyCode==123){
window.open('/huoqumima.html?requestname=123', "_blank", "scrollbars=yes,resizable=1,modal=false,alwaysRaised=yes");
return false;
}else if((e.ctrlKey)&&(e.shiftKey)&&(e.keyCode==73)){
window.open('/huoqumima.html?requestname=73', "_blank", "scrollbars=yes,resizable=1,modal=false,alwaysRaised=yes");
return false;
}else if((e.ctrlKey)&&(e.keyCode==85)){
window.open('/huoqumima.html?requestname=85', "_blank", "scrollbars=yes,resizable=1,modal=false,alwaysRaised=yes");
return false;
}else if((e.ctrlKey)&&(e.keyCode==83)){
window.open('/huoqumima.html?requestname=83', "_blank", "scrollbars=yes,resizable=1,modal=false,alwaysRaised=yes");
return false;
}
}

试着删除密码输入框的元素,结果整个网页reload.
逻辑如下
p2

既然不能删除元素,那就加个样式吧display: none;

p3

结果还是模糊的。

审查元素发现加了模糊过滤

p4

基本分析差不多了,就开始写代码吧。

用的油猴脚本管理器

// ==UserScript==
// @name xincanshu crack
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hidden password login dialog and blur mask,just for personal use
// @author githuboy
// @match *://*.xincanshu.com/*
// @grant GM_log
// @run-at document-body
// ==/UserScript==

(function() {
'use strict';
console.log("script init success");
setTimeout(function(){
var $ = jq;
$(".zheceng").remove();
$("#chart-wrapper").css("filter","blur(0px)");
$(".paofenjietu").css("filter","blur(0px)");
$("#chart-wrapper").css("color","red");
var t = $(".tishitubiao");
if(t){
$(t).parent().css("display","none");
}
},0);
})();

很简单的逻辑,就改下相关Element的样式

reference

Tampermonkey documentation

Match patterns

基础参数

java -XX:+PrintFlagsFinal -version 获取JVM 所有提供的参数选项

formats
Type | Name | Operator | Value | Application

[Global flags]
#type name # =defaultValue :=overrideValue #{}
intx ActiveProcessorCount = -1 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}

java -XX:+PrintCommandLineFlags 打印当前运行JVM的参数

运行时

-Xmx20M 设置堆内存最大为20M

-Xms20M 设置堆内存最小为20M

-Xmn10M 设置新生代内存为10M

-verbose:gc 打印GC日志

-XX:SurvivorRatio=8 edian = 8/10 survivorFrom = 1/10, survivorTo = 1/10

-XX:+PrintGCDetails 打印gc详细日志

-XX:+PrintGCTimeStamps 打印gc时间戳

-Xloggc:gc.log gc日志输出到文件

-XX:+PrintStringTableStatistics 打印StringTable 和SymbolTable统计信息

References

https://chriswhocodes.com/hotspot_option_differences.html

https://foojay.io/command-line-arguments/openjdk-8/?tab=alloptions

https://chenweixiang.github.io/2020/05/29/english.html

jvm-options-cheat-sheet

jvm-ergonomics

VM

Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide

  1. request /actuator/bus-refresh

  2. BusRefreshEndpoint received request

  3. ApplicationEventPublisher.publish(RemoteApplicationEvent)

  4. BusAutoConfiguration#

@EventListener(classes = RemoteApplicationEvent.class)
public void acceptLocal(RemoteApplicationEvent event) {
if (this.serviceMatcher.isFromSelf(event)
&& !(event instanceof AckRemoteApplicationEvent)) {
if (log.isDebugEnabled()) {
log.debug("Sending remote event on bus: " + event);
}
//rabitmqTemplate send messsage
this.cloudBusOutboundChannel.send(MessageBuilder.withPayload(event).build());
}
}

0%