hbase数据库的web小程序,web无法正常运行,无报错
代码在application中能直接运行,但是从web访问时就卡住不动,debug发现卡在 Result res=table.get(get);
实在是不会搞了,向各位前辈大神求助啊。。用的是Struts2做web框架
hbasedao2.java
package hbase.copy;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import news.news;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result;
import org.apache.hadoop.hbase.util.Bytes;
import com.opensymphony.xwork2.config.Configuration;
public class hbasedao2 {
List<news> newslist=new ArrayList<news>();
public List<news> getNewslist() {
return newslist;
}
public void setNewslist(List<news> newslist) {
this.newslist = newslist;
}
public static org.apache.hadoop.conf.Configuration configuration;
public void getData(String tableName,String row,String columnFamily,String column) throws IOException{
configuration = (org.apache.hadoop.conf.Configuration) HBaseConfiguration.create();
((org.apache.hadoop.conf.Configuration) configuration).set("hbase.rootdir","hdfs://localhost:9000/hbase");
HTable table=new HTable(configuration,tableName);
Get get=new Get(Bytes.toBytes(row));
System.out.print(" 1");
org.apache.hadoop.hbase.client.Result result=table.get(get);
System.out.print(" 2");
byte[] rb=result.getValue(Bytes.toBytes(columnFamily),Bytes.toBytes(column));
System.out.print(" 3");
byte[] rb2=result.getRow();
if(rb==null||rb2==null)
return;
news news=new news();
String value=new String(rb,"utf-8");
String value2=new String(rb2,"utf-8");
news.setUrl(value);
news.setKey(value2);
newslist.add(news);
}
}