tonglin0325的个人主页

Java排序算法——希尔排序

 

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package sort;

import java.util.Arrays;

class Arrays_Shell{
private int[] arrays;
private int curNum;

public Arrays_Shell(int max) { //建立一个max长度的空数组
super();
arrays = new int[max];
curNum = 0;
}

public void insert(int value){ //往空的数组里面增加元素
arrays[curNum] = value;
curNum++;
}

public void display(){ //显示数组
System.out.println(Arrays.toString(arrays));
}

public void ShellSort(){
int out,in;
int temp;

int h = 1;
while(h <= curNum/3) //求出最大的增量,5刚开始的增量为4
h = h*3+1; //1,4,13,40,121,....
while(h>0){
for(out=h;out<curNum;out++){//out从1开始递增,把out前的数两两排序
temp = arrays[out];
in = out;
while(in>h-1 &amp;&amp; arrays[in-h] >= temp){//刚开始in是比较0和h的大小
arrays[in] = arrays[in-h];
in -= h;
}
arrays[in] = temp;
//display();
}

h = (h-1)/3;
}

}

}

public class ShellSort {

public static void main(String[] args) {
// TODO 自动生成的方法存根
int maxSize = 100;
Arrays_Shell arrays_demo = new Arrays_Shell(maxSize);
arrays_demo.insert(58);
arrays_demo.insert(57);
arrays_demo.insert(56);
arrays_demo.insert(60);
arrays_demo.insert(59);
arrays_demo.display();
arrays_demo.ShellSort();
arrays_demo.display();
}

}

 

arthas使用方法

arthas是阿里开发的一个java诊断工具,官网

1
2
https://arthas.aliyun.com/zh-cn/

下载地址

1
2
https://github.com/alibaba/arthas/releases

 

启动arthas-boot.jar

选择java程序的pid,注意启动arthas-boot.jar的用户需要和所监控的java进程的用户是同一个,否则会报下面的错误

1
2
3
4
5
6
7
8
9
10
[ERROR] Start arthas failed, exception stack trace:
java.io.IOException: well-known file /tmp/.java_pid29923 is not secure: file should be owned by the current user (which is 0) but is owned by 987
at sun.tools.attach.LinuxVirtualMachine.checkPermissions(Native Method)
at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:117)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:250)
at com.taobao.arthas.core.Arthas.attachAgent(Arthas.java:102)
at com.taobao.arthas.core.Arthas.<init>(Arthas.java:27)
at com.taobao.arthas.core.Arthas.main(Arthas.java:161)

如果切换用户的时候遇到

1
2
This account is currently not available.

则可以使用下面命令来切换

全文 >>

英文写作——冠词的使用(Use 0f Articles)

1.使用’a’,’an’,’the’和不使用冠词的基本规则:

  <1>泛指,不可数名词不能有任何冠词

  <2>泛指,可数,复数名词前不能有冠词

  <3>泛指,可数,单数名词前加’a’或者’an’

  <4>特殊的,特定的,或者一类名词中的一个前要加上’the’

 

2.不定冠词’a’,’an’的使用:

  使用于单数可数名词

 

3.定冠词the的使用:

  <1>特指的时候,如上文提到电脑,后一句说这台电脑的时候要用the

  <2>分词短语作定语的时候,如:The computer sitting on his desk

  <3>独一无二的事物,如:the sun

全文 >>

Datagrip查询开启kerberos的impala

1.查看impala的版本,版本是2.12.0+cdh5.16.2+0

2.去官网下载impala的jdbc驱动文件:ImpalaJDBC41.jar

3.添加driver,注意要使用Custom JARs

4.使用keytab进行认证

1
2
kinit -kt ~/Downloads/hive.keytab  hive/master@HADOOP.COM

需要在你运行datagrip的机器上配置好kinit的环境,参考:kerberos相关

5.创建一个impala data source

全文 >>

HUE认证方式

HUE是一个支持数据库和数据仓库的开源SQL编辑器,官网

1
2
https://gethue.com/

HUE由python+django开发,其登录界面如下

HUE官方支持多个认证方式,比如 django.contrib.auth.backends.ModelBackend,desktop.auth.backend.LdapBackend等,详见如下表格

HUE支持的认证方式(也可以同时配置多个认证方式,配置文件中用逗号分隔) 备注
django.contrib.auth.backends.ModelBackend 完整的Django后端认证
desktop.auth.backend.AllowAllBackend 没有认证,允许所有人
desktop.auth.backend.AllowFirstUserDjangoBackend 第一次登录的时候,会要求你创建用户
desktop.auth.backend.LdapBackend 连接LDAP服务器进行认证
desktop.auth.backend.PamBackend 使用PAM(Pluggable Authentication Modules)即可插拔式认证模块进行认证
desktop.auth.backend.SpnegoDjangoBackend Spnego模式是一种由微软提出的使用GSS-API接口的认证模式,它扩展了Kerberos协议 
desktop.auth.backend.RemoteUserDjangoBackend Django支持使用远程用户方式进行认证
libsaml.backend.SAML2Backend SAML认证方式,一般用于支持SSO单点登录
libopenid.backend.OpenIDBackend OpenID认证方式,比如可以使用keycloak这个开源openid方案
liboauth.backend.OAuthBackend 新的认证方式,支持 Twitter, Facebook, Google+ 和 Linkedin

各HUE版本支持的认证方式可以去源码里面进行查询,HUE认证的代码如下

1
https://github.com/cloudera/hue/blob/master/desktop/core/src/desktop/auth/backend.py&nbsp;

比如CDH5.16.2版本中的HUE3.9.0,只支持如下几种backend

全文 >>