- 您应该使用哪个库?jsoniter、easyjson 还是 go-json?为什么?
前网易架构师-高司机
游戏服务器开发专栏golangjson开发语言
JSON是一种流行的数据交换格式,广泛应用于各种平台和语言。Golang当然不会错过对JSON的支持。并且通过自己的标准库,例如Kubernetes中APIService的RESTAPI等接口,它可以轻松处理JSON。虽然Go的库效果很好,但我们仍然可以在Github中寻找那些开源的JSON库,以最大限度地提高我们的效率。那么这些库的特性、性能、适用性才是我们应该考虑的。Go中的JSON使用Go的
- PDF转html
八百万
javapdfhtmljava
1.引入gradle依赖implementation'net.sf.cssbox:pdf2dom:1.8'2.定义自己处理图片的handlerpackagecom.easipass.cms.config;importcom.alibaba.fastjson.JSONObject;importcom.easipass.cms.service.ApiService;importcom.easipass
- kubernetes版本升级
捞一碗月光-zq
kubernetes容器云原生
kubernetes版本升级我当前的kubernetes环境是基于二进制安装部署的主机IPservices192.168.21.120apiservice,etcd,kubectl,kube-controller-manager,kube-scheduler,docker192.168.21.121apiservice,etcd,kubectl,kube-controller-manager,ku
- k8s的集群调度
weixin_51694382
dockerkubernetes容器
k8s的集群调度:scheduler:负责调度资源,把pod调度到node节点。预算策略优先策略1、List-watchk8s集群当中,通过list-watch的机制进行每个组件的协作,保持数据同步。每个组件之间的解耦。kubectl配置文件,向APIserver发送命令----apiserver把命令发送到各个组件。list-watch---会在每一步把监听的消息(APIservice:6443
- 利用kotlin协程和retrofit2,LiveData,ViewModel实现一个简单的网络请求框架
儿歌八万首
今天我们利用LiveData,ViewModel,retrofit2,kotlin协程来搭建一个MVVM的网络请求框架,利用数据来驱动UI更新变化,将数据和UI进行分离。1.新建一个ApiService接口,由于我们常用的网络请求是get和post,所以这里利用retrofit定义这两张请求类型的公共方法,由于retrofit2中已经支持了对协程的支持,所以抽取的get和post方法如下:inte
- kubectl top nodes 报错:error: metrics not available yet
我叫MHT
Kuberneteskubernetes运维
问题:K8s集群由于资源不够用,新增一个节点,我重启了所有服务,想让资源均衡使用节点,然后使用kubectltopnodes提示error:metricsnotavailableyet经过网上查找后发现APIservice有问题,修改后解决。检查APIservice[root@master1~]#kubectlgetAPIServiceNAMESERVICEAVAILABLEAGEv1.Local
- K8S集群(kubernetes)(2022)
REMLILI
java容器kubernetes分布式
一、基础(一)关键词集群:物理形态分布式:工作方式生产级别容器编排系统微服务云原生平台容器技术(二)组件1、apiservice:水平扩展所有服务访问统一入口对外暴露K8S的api接口,是外界进行资源操作的唯一入口提供认证、授权、访问控制、API注册和发现等机制;2、crontrollermanager:leader选举负责维护集群的状态,比如故障检测、自动扩展、滚动更新等,它们是处理集群中常规任
- k8s自动化伸缩实践---HPA
婷子1921
kubernetes自动化docker
HPAHorizontalPodAutoscaler(简称HPA)自动化伸缩策略,可以根据服务负载情况自动扩展或缩小实例数量,以应对不同的流量负载。实践1、你需要先一个部署并配置了MetricsServer的集群。KubernetesMetricsServer从集群中的kubelets收集资源指标,并通过KubernetesAPI公开这些指标,使用APIService添加代表指标读数的新资源。ku
- ApiService常用四种方式简单封装 (kotlin)
努力成为大佬的菜鸟
kotlin
我们为什么要封装?首先我们看一下我们不封装的图然后可以看到我们每次请求都需要重写getpostdeleteput方法,这样会导致很累浪费很多时间我们在开发过程中肯定是节约时间,因此我们这边就用到了封装下面是封装的一张图片interfaceApiService{@POST()@FormUrlEncodedfundoPost(@Urlurl:String,@FieldMapmap:Map):@JvmS
- rxjava2 retrofit2的文件下载与保存
手微凉_
保存文件时要使用RxJava的doOnNext、map等操作符,后续更新UI的操作切换到UI线程。主线程中应该避免耗时操作retrofit.create(ApiService.class).dowmBitmap("http://imgcache.qq.com/qzone/space_item/pre/0/66768.gif").compose(this.bindToLifecycle()).sub
- 本地使用kubectl操作远程k8s集群
周六放风筝
javadockermackuberneteslinux
背景我们这里使用的是阿里云的kubenetes托管版本在使用托管版本的时候至少是两台机器。我们这里就用了两台机器。阿里默认提供一个apiservice服务。大家知道我们通过操作apiservice来控制集群。本地没有Kubernetes环境但是需要操作使用kubectl操作远端apiservice。目标1.本机使用kubectl控制远端集群2.本机获取远端的comfigmap内容config文件打
- Retrofit网络请求参数注解Json格式和form-data格式提交数据(实用)
总会颠沛流离
Retrofit以Json格式提交数据(模拟登录功能)1、ApiService/***登录*/@Headers("Content-Type:application/json")@POST("user/login")Observablelogin(@BodyRequestBodyrequestBody);2、创建一个Bean类publicclassUserBean{privateStringnick
- godlibrary-retrofit
MrY_124d
godlibrary-retrofit[图片上传失败...(image-74497d-1565232831855)]简介基于retrofit2的网络请求封装经过项目实战验证。使用方法引用compile'com.abook23:godlibrary-retrofit:2.1'初始化在Application中初始化ApiService包含普通的网络请求和文件上传下载FileService正对文件操作,
- 如何发起参数里面有句号的请求
zewweb
关键词API前言在项目过程中,在发送WS请求的时候,需要传递一个带句号的参数,本文介绍了如何发起这样的请求。步骤在参数后加/\用来转义,详细代码如下getCount(cwsLogin:string):Observable{returnthis.apiService.get(`/count/${cwsLogin}\/`)//注:\反斜线用来转义.pipe(map((res:any)=>resasIC
- springboot封装查询快递物流
吉屋安
前后端分离项目springboot后端java
目录一、ApiClient代码解读二、ApiService代码解读三、HomeController代码解读四、整体代码五、结果展示一、ApiClient代码解读这是一个简单的SpringBoot的RestTemplate客户端,用于执行HTTP请求。首先,这个类被@Component注解标记,这意味着它是一个Spring组件,Spring的依赖注入框架会自动创建并管理这个类的实例。类声明publi
- springboot注解
迷糊银儿
@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值@RequestMapping(value="/task/goById/{id}",method=RequestMethod.POST)publicResponseEntitygoById(@PathVariableLongid){returnnewResponseEntity(apiService.goById(
- [Android]Retrofit多base_url请求解决方案
老汤哥不老
在项目中偶尔会碰到多base_url的情况,其实这个做法很讨厌,但是后端又没办法才这样做的,当使用retrofit作为网络框架的时候,出现多base_url的情况又很麻烦,下面提供我解决的方案在ApiService处publicstaticStringURL_1="url_name:url_1";publicstaticStringURL_2="url_name:url_2";/***登陆**@p
- java Mybatis使用
七百年前
1.StoreMapperMapperimportcom.github.pagehelper.Page;importcom.luyi.apiservice.models.Store;importorg.apache.ibatis.annotations.Mapper;importorg.springframework.stereotype.Repository;importjava.util.Li
- Kotlin协程+Retorfit 网络请求框架简单封装
Knight_Davion
前言自从协程普及以来,基于Kotlin协程+Retrofit的文章和框架简直太多了,这里再来一版自己实现的小框架。说是框架其实就是使用协程+retrofit进行的简单封装,不得不说使用支持协程的Retrofit发起一个网络请求真的是简单的不能在简单了。目录结构企业微信截图_20210705100933.png使用方式普通协程版首先你要有一个ApiService里边定义好接口就像这样interfac
- K8S故障排查
优质&青年
kubernetes容器云原生
故障现象:部署pod时,报错没发调度到节点。排查步骤:1、查看集群的状态[root@k8s-master1nginx]#kubectlgetnodes2、查看k8s组件的状态-kubelet,kube-apiservice3、查看docker的Cgroupdriver和k8s的Cgroupdriver类型,发现docker是cgroup,k8s是systemd,问题点找到了。[root@k8s-m
- kubernetes证书时间修改
呵~女人
kubernetes
此文档针对k8s版本1.14.1(kubeadm安装k8s三主多从)kubeadm默认证书为一年,一年过期后,会导致apiservice不可用,使用过程中会出现:x509:certificatehasexpiredorisnotyetvalid.方案一通过修改kubeadm调整证书过期时间1、创建工作目录[root@master~]#mkdir/data2、下载go环境(搜索go中文网既可下载)[
- k8s1.18.20高可用集群(修改源码延长证书时间)
GeekXuShuo
k8skubernetesdocker容器kubernetes
使用kubeadm搭建k8s(1.18.20版本)高可用集群一、修改源码增加证书有效时间到100年k8s有两种证书:ca证书默认是10年(ca、etcd-ca、front-proxy-ca)客户端证书和集群间认证证书有效期是1年:apiserver、etcd-server、apiserver-etcd-client等过期后,会导致apiservice不可用,使用过程中会出现:x509:certif
- K8S pod 均匀调度分配 —— 筑梦之路
筑梦之路
虚拟化linux系统运维云计算kubernetes容器云原生
pod调度简介在k8s中通过kube-scheduler组件来实现pod的调度,所谓调度,即把需要创建的pod放到合适的node上,大概流程为,通过对应的调度算法和调度策略,为待调度的pod列表中的pod选择一个最合适的Node,然后目标节点上的kubelet通过watch接口监听到kube-schedule产生的Pod绑定事件,通过APIService获取对应的Pod清单,下载image并且启动
- 2020-12-04使用retrofit上传下载文件,监听下载进度
IT_花花牛
retrofit2android文件上传文件下载retrofit2
retrofit2上传、下载文件一、上传文件1、使用表单上传文件;结合Rxjava先定义ApiService接口@Multipart//Multipart表单@POST("{url}")//post上传地址ObservableuploadFiles(@Path(value="url",encoded=true)Stringurl,@PartMap()Mapmaps);//请求body的map集合组
- openapi回调地址请求不通过_XHttp2 一个功能强悍的网络请求库
weixin_39911475
XHttp2一个功能强悍的网络请求库,使用RxJava2+Retrofit2+OKHttp组合进行封装。还不赶紧点击使用说明文档,体验一下吧!项目地址关于我https://github.com/xuexiangjys特征支持默认、全局、局部三个层次的配置功能。支持动态配置和自定义底层框架Okhttpclient、Retrofit.加入基础ApiService,减少Api冗余。支持多种方式访问网络G
- XHttp2 一个功能强悍的网络请求库,使用RxJava2 + Retrofit2 + OKHttp进行组装
weixin_34186128
javajson运维
XHttp2一个功能强悍的网络请求库,使用RxJava2+Retrofit2+OKHttp组合进行封装。关于我特征支持默认、全局、局部三个层次的配置功能。支持动态配置和自定义底层框架Okhttpclient、Retrofit.加入基础ApiService,减少Api冗余。支持多种方式访问网络GET、POST、PUT、DELETE等请求协议。支持网络缓存,六种缓存策略可选,涵盖大多数业务场景。支持固
- Ocelot + Consul的demo(二)集群部署
dhmwidg13313
json
把服务A和服务B接口分别部署在两个ip地址上修改services.json文件,{"encrypt":"7TnJPB4lKtjEcCWWjN6jSA==","services":[{"id":"ApiServiceB","name":"ApiService","tags":["ApiServiceB"],"address":"192.168.1.1","port":5012,"checks":[{
- k8s go client Informer 结合源码分析
shoyu666
背景k8sapiService通过http对外暴露服务,goclient是k8s提供的一套go语言实现的clientlib,封装了通用的流程。goclient中比较重要的就是Informer机制。本文就结合源码分析下goclientinformer的流程。informer是什么goclient的本质就是通过http请求apiService,但是实际需要考虑很多情况,比如1:直接请求apiServi
- K8s之静态Pod
倦~
k8skubernetesdocker运维
前言前面我们详细介绍了Pod的使用,可以通过命令行创建,也可以通过yaml的方式创建。这两种方式都是由ApiService来管理的,会在etcd中保存记录。但其实还有一种Pod它不由ApiService管理。运行在固定的Node上,由kubelet创建。我们把它叫做StaticPod(静态Pod)创建静态Pod有两种方式,通过本地的配置文件和http方式通过配置文件创建静态Podkubelet需要
- API请求 接口/数据 缓存
诚许愿
缓存前端javascript
缓存场景:接口请求时的并发缓存、接口请求后的结果缓存//场景一:并发时的接口缓存letresultCatch=null;exportasyncfunctiongetResult(params){letresult=null;if(isNil(resultCatch)){resultCatch=apiService.apiName(params);result=awaitresultCatch;re
- LeetCode[位运算] - #137 Single Number II
Cwind
javaAlgorithmLeetCode题解位运算
原题链接:#137 Single Number II
要求:
给定一个整型数组,其中除了一个元素之外,每个元素都出现三次。找出这个元素
注意:算法的时间复杂度应为O(n),最好不使用额外的内存空间
难度:中等
分析:
与#136类似,都是考察位运算。不过出现两次的可以使用异或运算的特性 n XOR n = 0, n XOR 0 = n,即某一
- 《JavaScript语言精粹》笔记
aijuans
JavaScript
0、JavaScript的简单数据类型包括数字、字符创、布尔值(true/false)、null和undefined值,其它值都是对象。
1、JavaScript只有一个数字类型,它在内部被表示为64位的浮点数。没有分离出整数,所以1和1.0的值相同。
2、NaN是一个数值,表示一个不能产生正常结果的运算结果。NaN不等于任何值,包括它本身。可以用函数isNaN(number)检测NaN,但是
- 你应该更新的Java知识之常用程序库
Kai_Ge
java
在很多人眼中,Java 已经是一门垂垂老矣的语言,但并不妨碍 Java 世界依然在前进。如果你曾离开 Java,云游于其它世界,或是每日只在遗留代码中挣扎,或许是时候抬起头,看看老 Java 中的新东西。
Guava
Guava[gwɑ:və],一句话,只要你做Java项目,就应该用Guava(Github)。
guava 是 Google 出品的一套 Java 核心库,在我看来,它甚至应该
- HttpClient
120153216
httpclient
/**
* 可以传对象的请求转发,对象已流形式放入HTTP中
*/
public static Object doPost(Map<String,Object> parmMap,String url)
{
Object object = null;
HttpClient hc = new HttpClient();
String fullURL
- Django model字段类型清单
2002wmj
django
Django 通过 models 实现数据库的创建、修改、删除等操作,本文为模型中一般常用的类型的清单,便于查询和使用: AutoField:一个自动递增的整型字段,添加记录时它会自动增长。你通常不需要直接使用这个字段;如果你不指定主键的话,系统会自动添加一个主键字段到你的model。(参阅自动主键字段) BooleanField:布尔字段,管理工具里会自动将其描述为checkbox。 Cha
- 在SQLSERVER中查找消耗CPU最多的SQL
357029540
SQL Server
返回消耗CPU数目最多的10条语句
SELECT TOP 10
total_worker_time/execution_count AS avg_cpu_cost, plan_handle,
execution_count,
(SELECT SUBSTRING(text, statement_start_of
- Myeclipse项目无法部署,Undefined exploded archive location
7454103
eclipseMyEclipse
做个备忘!
错误信息为:
Undefined exploded archive location
原因:
在工程转移过程中,导致工程的配置文件出错;
解决方法:
 
- GMT时间格式转换
adminjun
GMT时间转换
普通的时间转换问题我这里就不再罗嗦了,我想大家应该都会那种低级的转换问题吧,现在我向大家总结一下如何转换GMT时间格式,这种格式的转换方法网上还不是很多,所以有必要总结一下,也算给有需要的朋友一个小小的帮助啦。
1、可以使用
SimpleDateFormat SimpleDateFormat
EEE-三位星期
d-天
MMM-月
yyyy-四位年
- Oracle数据库新装连接串问题
aijuans
oracle数据库
割接新装了数据库,客户端登陆无问题,apache/cgi-bin程序有问题,sqlnet.log日志如下:
Fatal NI connect error 12170.
VERSION INFORMATION: TNS for Linux: Version 10.2.0.4.0 - Product
- 回顾java数组复制
ayaoxinchao
java数组
在写这篇文章之前,也看了一些别人写的,基本上都是大同小异。文章是对java数组复制基础知识的回顾,算是作为学习笔记,供以后自己翻阅。首先,简单想一下这个问题:为什么要复制数组?我的个人理解:在我们在利用一个数组时,在每一次使用,我们都希望它的值是初始值。这时我们就要对数组进行复制,以达到原始数组值的安全性。java数组复制大致分为3种方式:①for循环方式 ②clone方式 ③arrayCopy方
- java web会话监听并使用spring注入
bewithme
Java Web
在java web应用中,当你想在建立会话或移除会话时,让系统做某些事情,比如说,统计在线用户,每当有用户登录时,或退出时,那么可以用下面这个监听器来监听。
import java.util.ArrayList;
import java.ut
- NoSQL数据库之Redis数据库管理(Redis的常用命令及高级应用)
bijian1013
redis数据库NoSQL
一 .Redis常用命令
Redis提供了丰富的命令对数据库和各种数据库类型进行操作,这些命令可以在Linux终端使用。
a.键值相关命令
b.服务器相关命令
1.键值相关命令
&
- java枚举序列化问题
bingyingao
java枚举序列化
对象在网络中传输离不开序列化和反序列化。而如果序列化的对象中有枚举值就要特别注意一些发布兼容问题:
1.加一个枚举值
新机器代码读分布式缓存中老对象,没有问题,不会抛异常。
老机器代码读分布式缓存中新对像,反序列化会中断,所以在所有机器发布完成之前要避免出现新对象,或者提前让老机器拥有新增枚举的jar。
2.删一个枚举值
新机器代码读分布式缓存中老对象,反序列
- 【Spark七十八】Spark Kyro序列化
bit1129
spark
当使用SparkContext的saveAsObjectFile方法将对象序列化到文件,以及通过objectFile方法将对象从文件反序列出来的时候,Spark默认使用Java的序列化以及反序列化机制,通常情况下,这种序列化机制是很低效的,Spark支持使用Kyro作为对象的序列化和反序列化机制,序列化的速度比java更快,但是使用Kyro时要注意,Kyro目前还是有些bug。
Spark
- Hybridizing OO and Functional Design
bookjovi
erlanghaskell
推荐博文:
Tell Above, and Ask Below - Hybridizing OO and Functional Design
文章中把OO和FP讲的深入透彻,里面把smalltalk和haskell作为典型的两种编程范式代表语言,此点本人极为同意,smalltalk可以说是最能体现OO设计的面向对象语言,smalltalk的作者Alan kay也是OO的最早先驱,
- Java-Collections Framework学习与总结-HashMap
BrokenDreams
Collections
开发中常常会用到这样一种数据结构,根据一个关键字,找到所需的信息。这个过程有点像查字典,拿到一个key,去字典表中查找对应的value。Java1.0版本提供了这样的类java.util.Dictionary(抽象类),基本上支持字典表的操作。后来引入了Map接口,更好的描述的这种数据结构。
&nb
- 读《研磨设计模式》-代码笔记-职责链模式-Chain Of Responsibility
bylijinnan
java设计模式
声明: 本文只为方便我个人查阅和理解,详细的分析以及源代码请移步 原作者的博客http://chjavach.iteye.com/
/**
* 业务逻辑:项目经理只能处理500以下的费用申请,部门经理是1000,总经理不设限。简单起见,只同意“Tom”的申请
* bylijinnan
*/
abstract class Handler {
/*
- Android中启动外部程序
cherishLC
android
1、启动外部程序
引用自:
http://blog.csdn.net/linxcool/article/details/7692374
//方法一
Intent intent=new Intent();
//包名 包名+类名(全路径)
intent.setClassName("com.linxcool", "com.linxcool.PlaneActi
- summary_keep_rate
coollyj
SUM
BEGIN
/*DECLARE minDate varchar(20) ;
DECLARE maxDate varchar(20) ;*/
DECLARE stkDate varchar(20) ;
DECLARE done int default -1;
/* 游标中 注册服务器地址 */
DE
- hadoop hdfs 添加数据目录出错
daizj
hadoophdfs扩容
由于原来配置的hadoop data目录快要用满了,故准备修改配置文件增加数据目录,以便扩容,但由于疏忽,把core-site.xml, hdfs-site.xml配置文件dfs.datanode.data.dir 配置项增加了配置目录,但未创建实际目录,重启datanode服务时,报如下错误:
2014-11-18 08:51:39,128 WARN org.apache.hadoop.h
- grep 目录级联查找
dongwei_6688
grep
在Mac或者Linux下使用grep进行文件内容查找时,如果给定的目标搜索路径是当前目录,那么它默认只搜索当前目录下的文件,而不会搜索其下面子目录中的文件内容,如果想级联搜索下级目录,需要使用一个“-r”参数:
grep -n -r "GET" .
上面的命令将会找出当前目录“.”及当前目录中所有下级目录
- yii 修改模块使用的布局文件
dcj3sjt126com
yiilayouts
方法一:yii模块默认使用系统当前的主题布局文件,如果在主配置文件中配置了主题比如: 'theme'=>'mythm', 那么yii的模块就使用 protected/themes/mythm/views/layouts 下的布局文件; 如果未配置主题,那么 yii的模块就使用 protected/views/layouts 下的布局文件, 总之默认不是使用自身目录 pr
- 设计模式之单例模式
come_for_dream
设计模式单例模式懒汉式饿汉式双重检验锁失败无序写入
今天该来的面试还没来,这个店估计不会来电话了,安静下来写写博客也不错,没事翻了翻小易哥的博客甚至与大牛们之间的差距,基础知识不扎实建起来的楼再高也只能是危楼罢了,陈下心回归基础把以前学过的东西总结一下。
*********************************
- 8、数组
豆豆咖啡
二维数组数组一维数组
一、概念
数组是同一种类型数据的集合。其实数组就是一个容器。
二、好处
可以自动给数组中的元素从0开始编号,方便操作这些元素
三、格式
//一维数组
1,元素类型[] 变量名 = new 元素类型[元素的个数]
int[] arr =
- Decode Ways
hcx2013
decode
A message containing letters from A-Z is being encoded to numbers using the following mapping:
'A' -> 1
'B' -> 2
...
'Z' -> 26
Given an encoded message containing digits, det
- Spring4.1新特性——异步调度和事件机制的异常处理
jinnianshilongnian
spring 4.1
目录
Spring4.1新特性——综述
Spring4.1新特性——Spring核心部分及其他
Spring4.1新特性——Spring缓存框架增强
Spring4.1新特性——异步调用和事件机制的异常处理
Spring4.1新特性——数据库集成测试脚本初始化
Spring4.1新特性——Spring MVC增强
Spring4.1新特性——页面自动化测试框架Spring MVC T
- squid3(高命中率)缓存服务器配置
liyonghui160com
系统:centos 5.x
需要的软件:squid-3.0.STABLE25.tar.gz
1.下载squid
wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE25.tar.gz
tar zxf squid-3.0.STABLE25.tar.gz &&
- 避免Java应用中NullPointerException的技巧和最佳实践
pda158
java
1) 从已知的String对象中调用equals()和equalsIgnoreCase()方法,而非未知对象。 总是从已知的非空String对象中调用equals()方法。因为equals()方法是对称的,调用a.equals(b)和调用b.equals(a)是完全相同的,这也是为什么程序员对于对象a和b这么不上心。如果调用者是空指针,这种调用可能导致一个空指针异常
Object unk
- 如何在Swift语言中创建http请求
shoothao
httpswift
概述:本文通过实例从同步和异步两种方式上回答了”如何在Swift语言中创建http请求“的问题。
如果你对Objective-C比较了解的话,对于如何创建http请求你一定驾轻就熟了,而新语言Swift与其相比只有语法上的区别。但是,对才接触到这个崭新平台的初学者来说,他们仍然想知道“如何在Swift语言中创建http请求?”。
在这里,我将作出一些建议来回答上述问题。常见的
- Spring事务的传播方式
uule
spring事务
传播方式:
新建事务
required
required_new - 挂起当前
非事务方式运行
supports
&nbs