Hive性能测试
有时候我们需要对Hive cluster做性能测试,如下的代码就是用多线程的方式对hive查询,300个线程作查询,从而测试hive的返回速度。
package jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
//import java.sql.SQLException;
import java.sql.Statement;
// Java code for thread creation by extending
// the Thread class
public class App implements Runnable
{
public void run() {
for(int i = 0; i < 10; i++) {
try {
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection conn = DriverManager.getConnection("jdbc:hive2://headnodeFQDN:10001/;principal=hive/_HOST@domainname;transportMode=http", "test@test.com", "password");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * from `default`.sampletable where devicemake = 'Devi