Dubbo 配置

Dubbo

  1. Zookeeper
  2. Dubbo-admin

dubbo 2.7.0

dubbo-admin 0.2.0

Zookeeper

install Zookeeper configuration center

1
docker pull zookeeper:3.5.6

运行 Zookeeper

1
docker run -d --name zookeeper-3.5.6 -p 2181:2181 zookeeper:3.5.6

测试

1
echo dump | nc 127.0.0.1 2181

Dubbo-admin

apache/dubbo-admin

1
docker pull apache/dubbo-admin:latest

运行

1
docker run -d --name dubbo-admin -p 8080:8080 --link zookeeper-3.5.6:zookeeper -e admin.registry.address=zookeeper://zookeeper:2181 -e admin.config-center=zookeeper://zookeeper:2181 -e admin.metadata-report.address=zookeeper://zookeeper:2181 dubbo-admin:latest

单独构建

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM openjdk:8-jdk
RUN mkdir /source && wget https://github.com/apache/dubbo-admin/archive/0.2.0.zip && unzip 0.2.0.zip -d /source
WORKDIR /source/dubbo-admin-0.2.0
# 使用 settings.xml 的原因是要使用阿里的 maven 源。
ADD settings.xml /source/dubbo-admin-0.2.0
RUN ./mvnw clean package --settings settings.xml -Dmaven.test.skip=true

FROM openjdk:8-jre
LABEL maintainer="dev@dubbo.apache.org"
COPY --from=0 /source/dubbo-admin-0.2.0/dubbo-admin-distribution/target/dubbo-admin-0.2.0.jar /app.jar
ENTRYPOINT ["java","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
EXPOSE 8080

settings.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
</settings>

构建

1
docker build -t dubbo-admin:0.2.0 .

运行

1
docker run -d --name dubbo-admin -p 8080:8080 --link zookeeper-3.5.6:zookeeper -e admin.registry.address=zookeeper://zookeeper:2181 -e admin.config-center=zookeeper://zookeeper:2181 -e admin.metadata-report.address=zookeeper://zookeeper:2181 dubbo-admin:0.2.0

访问

http://IP:8080 用户名:root,密码:root

运行 zookeeper 和 dubbo-admin

docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '3'

services:
zookeeper:
image: zookeeper:3.5.6
ports:
- 2181:2181
admin:
image: apache/dubbo-admin
depends_on:
- zookeeper
ports:
- 8080
environment:
- admin.registry.address=zookeeper://zookeeper:2181
- admin.config-center=zookeeper://zookeeper:2181
- admin.metadata-report.address=zookeeper://zookeeper:2181

Dubbo

安装 JDK

安装 Maven

下载示例

Dubbo 2.7.0

pom.xml 依赖可以更改一下

1
git clone https://github.com/apache/dubbo-samples.git
1
2
cd dubbo-samples/java
mvn clean package

Dubbo Provider

1
2
3
4
5
cd dubbo-samples-basic

mvn -Djava.net.preferIPv4Stack=true \
-Dexec.mainClass=org.apache.dubbo.samples.basic.BasicProvider \
exec:java

Dubbo Consumer

1
2
3
4
5
cd dubbo-samples-basic

mvn -Djava.net.preferIPv4Stack=true \
-Dexec.mainClass=org.apache.dubbo.samples.basic.BasicConsumer \
exec:java

参考

Docker多步构建生成dubbo-admin镜像

使用Docker容器化SpringBoot+Dubbo应用的实践

基于SpringBoot+Dubbo的微服务框架(借助Docker+Jenkins实现自动化、容器化部署)

Dubbo - Dubbo Admin 安装(生产版)

Dubbo - Dubbo Admin 安装(开发版-Dubbo OPS)

dubbo入门学习笔记之环境准备

dubbo提供者注册容器IP问题 | Vnimos’s blog

REST Assured 学习笔记

REST Assured

REST Assured 3.2.0

REST Assured

https://github.com/rest-assured/rest-assured

REST Assured 3.2.0 API

pom.xml

1
2
3
4
5
6
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.2.0</version>
<scope>test</scope>
</dependency>

导入包

1
2
3
4
5
import static io.restassured.RestAssured.*
import static io.restassured.matcher.RestAssuredMatchers.*
import static org.hamcrest.Matchers.*
import static io.restassured.module.jsv.JsonSchemaValidator.*
import static io.restassured.module.mockmvc.RestAssuredMockMvc.*

参考

Testing RESTful Services in Java: Best Practices

Android 使用 adb 指令模拟 touch 滑动解锁

查找手机触摸屏事件 event 的位置,寻找包含touch字段的内容。

1
adb shell cat /proc/bus/input/devices
1
2
3
4
5
6
7
I: Bus=0018 Vendor=0000 Product=0000 Version=0000
N: Name="atmel-maxtouch"
P: Phys=
S: Sysfs=/devices/f9924000.i2c/i2c-2/2-004b/input/input2
U: Uniq=
E: Enabled=0
H: Handlers=kgsl event2 cpufreq

录制解锁步骤,监听event

1
adb shell getevent /dev/input/event2 > unlock.txt

手机上滑动解锁一次

第一种方法:unlock.txt里面的十六进制数转换为十进制数。

hex_to_dec.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__date__ = "2019-01-09 15:22:46"
__author__ = "ovwane"

with open("unlock.txt", "r") as f:
for file in f:
num_list = []

line = file
for i in line.split(" "):
i_num = int(i.rstrip("\n"), 16)
num_list.append(i_num)

print(num_list)
with open("adb_unlock.sh", "a+", encoding="utf-8") as ff:
ff.write("adb shell sendevent /dev/input/event2 {} {} {} \n".format(num_list[0], num_list[1], num_list[2]))
1
2
3
4
5
6
7
8
9
# adb shell getevent //dev/input/event0 >> getevent.log

with open('./getevent2.sh', 'w') as f2:
f2.write("adb shell input keyevent 26\n")
# f2.write("adb shell input keyevent 82\r")
with open('./getevent.log', 'r') as f:
for line in f.readlines():
new_line = " ".join([str(int(it, 16)) for it in line.strip().split(" ")])
f2.write("adb shell sendevent //dev/input/event0 " + new_line + "\r")
1
adb shell getevent /dev/input/event2 | awk '{print "adb shell sendevent /dev/input/event2  "strtonum("0x"$1)" "strtonum("0x"$2)" "strtonum("0x"$3); fflush()}'  >> unlock.sh

第二种方法:unlock.txt里面的十六进制数转换为十进制数。

1
adb shell getevent /dev/input/event2 | awk '{print "adb shell sendevent /dev/input/event2  "strtonum("0x"$1)" "strtonum("0x"$2)" "strtonum("0x"$3); fflush()}'  >> unlock.sh

写到shell script中执行,就可以实现自动解锁了。

1
adb shell sendevent /dev/input/event2

模拟发送电源键事件,点亮屏幕。

1
adb shell input keyevent 26

参考

Android通过指令模拟touch滑动解锁

ADB获取手机屏幕的状态(点亮与否)以及ADB点击事件基本操作

awk 中 对于tail f 的文件重定向

Xposed 教程

Xposed

Xposed Module Repository

下载Xposed Installer

https://repo.xposed.info/module/de.robv.android.xposed.installer

安装Xposed

Android 6.0

刷机安装 xposed.zip

xposed-v89-sdk23-x86

安装apk

XposedInstaller_3.1.5.apk

模块

  • XPrivacy

模拟位置

Android开发 :详细讲解如何使用Xposed拦截修改地理位置信息 ok,看这篇文章搞定了高德地图。

Android之基于Xposed的模拟位置模块实现

Hook实现Android 微信,陌陌 ,探探位置模拟

用Xposed框架拦截微信、人人、QQ等LBS应用的当前位置

参考这篇基于Xposed框架Hook定位功能来破解QQ的LBS红包

Xiaomi Mi4

小米4 Android 6.0 版本 Root 并安装 Xposed 框架攻略

系统版本

cancro_global_images_V9.5.7.0.MXDMIFA_20180815.0000.00_6.0_global_bbfc0f3951.tgz

miui_MI3WMI4WGlobal_8.3.1_b992dfbc34_6.0.zip

TWRP

twrp-3.3.0-0-cancro.img

1
fastboot flash recovery twrp-3.3.0-0-cancro.img

[OFFICIAL] Xposed for Lollipop/Marshmallow/Nougat/Oreo [v90-beta3, 2018/01/29]

XposedInstaller_3.1.5.apk

xposed-v89-sdk23-arm.zip

  1. 使用 twrp 安装 xposed-v89-sdk23-arm.zip。

  2. 安装 XposedInstaller_3.1.5.apk

参考

Android 神器 xposed 框架使用指南

Xposed 使用手册

不需要 Root,也能用上强大的 Xposed 框架:VirtualXposed

Android 系统上的 Xposed 框架中都有哪些值得推荐的模块?

新手不要再被误导!这是一篇最新的Xposed模块编写教程

【Xposed模块开发入门】真·第一课

萌新跟我来入门Hook技术

[OFFICIAL] Xposed for Lollipop/Marshmallow/Nougat/Oreo [v90-beta3, 2018/01/29]

Genymotion 配置

ADB 位置

/Applications/Genymotion.app/Contents/MacOS/tools

位置

/Users/name/.Genymobile/Genymotion/deployed/

ARM_Translation

OpenGapps

1
~/.Genymobile/Genymotion/cache/opengapps

GPS

启动 Genymotin Shell

1
/Applications/Genymotion\ Shell.app/Contents/MacOS/genyshell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 查看设备
devices list

# 选择设备,0是设备id。
devices select 0

# 查看 GPS 状态
gps getstatus

# 开启 GPS
gps setstatus enabled

# 关闭 GPS
gps setstatus disabled

# 获取纬度
gps getlatitude

# 南京
gps setlatitude 32.0523428565

# 广州
gps setlatitude 23.1290765766

# 获取经度
gps getlongitude

# 南京
gps setlongitude 118.7847135259

# 广州
gps setlongitude 113.2643446427

经纬度查询

参考

Starting Genymotion Shell

Genymotion安装配置指南

JavaScript 学习

清除console内容

1
console.clear()

查看console支持的方法

1
console.dir(console);
1
2
3
4
5
var languages = [
{ name: "JavaScript", fileExtension: ".js" },
{ name: "TypeScript", fileExtension: ".ts" },
{ name: "CoffeeScript", fileExtension: ".coffee" }
];

通过console.log()记录数组数据

1
console.log(languages);

通过console.table()记录数组数据

1
console.table(languages);

调试

Paused in debugger(在调试器中暂停)

Paused on breakpoint(在断点处暂停)

参考

利用Console来调试JS程序、Console用法总结

Javascript系列: Google Chrome调试js代码(zz)

chrome浏览器控制台创建js脚本并执行

WebStorm快捷键操作

,