mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-28 14:17:02 +10:00
[유치수] [NOBTS] fix flow iterator.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@683 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.nhn.hippo.web.controller;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -15,8 +18,15 @@ public class FlowChartController {
|
||||
@Autowired
|
||||
private FlowChartService flow;
|
||||
|
||||
@RequestMapping(value = "/flow", method = RequestMethod.POST)
|
||||
public String arcus(Model model, @RequestParam("id") int id) {
|
||||
@RequestMapping(value = "/flow", method = RequestMethod.GET)
|
||||
public String arcus(Model model, @RequestParam("host") String[] hosts, @RequestParam("from") long from, @RequestParam("to") long to) {
|
||||
|
||||
Iterator<Map<String, Object>> iterator = flow.selectTraces(hosts, from, to);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
System.out.println(iterator.next());
|
||||
}
|
||||
|
||||
return "flow";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.nhn.hippo.web.service;
|
||||
|
||||
public interface FlowChartService {
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FlowChartService {
|
||||
public Iterator<Map<String, Object>> selectTraces(String[] agentIds, long from, long to);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,76 @@
|
||||
package com.nhn.hippo.web.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.profiler.common.hbase.HBaseClient;
|
||||
import com.profiler.common.hbase.HBaseQuery;
|
||||
import com.profiler.common.hbase.HBaseQuery.HbaseColumn;
|
||||
import com.profiler.common.hbase.HBaseTables;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class FlowChartServiceImpl implements FlowChartService {
|
||||
|
||||
// @Autowired
|
||||
// @Qualifier("memberDaoJdbc")
|
||||
// MemberDao dao;
|
||||
@Autowired
|
||||
@Qualifier("hbaseClient")
|
||||
HBaseClient client;
|
||||
|
||||
public Iterator<Map<String, Object>> selectTraces(String[] agentIds, long from, long to) {
|
||||
List<HbaseColumn> column = new ArrayList<HBaseQuery.HbaseColumn>();
|
||||
column.add(new HbaseColumn("Trace", "ID"));
|
||||
|
||||
final List<Iterator<Map<String, Object>>> list = new ArrayList<Iterator<Map<String, Object>>>();
|
||||
|
||||
for (String agentId : agentIds) {
|
||||
byte[] s = ArrayUtils.addAll(Bytes.toBytes(agentId), Bytes.toBytes(from));
|
||||
byte[] e = ArrayUtils.addAll(Bytes.toBytes(agentId), Bytes.toBytes(to));
|
||||
|
||||
HBaseQuery query = new HBaseQuery(HBaseTables.TRACE_INDEX, s, e, column);
|
||||
Iterator<Map<String, Object>> result = client.getHBaseData(query);
|
||||
list.add(result);
|
||||
}
|
||||
|
||||
return new Iterator<Map<String, Object>>() {
|
||||
int pos = 0;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
while (pos < list.size()) {
|
||||
if (list.get(pos).hasNext()) {
|
||||
break;
|
||||
} else {
|
||||
pos++;
|
||||
|
||||
if (pos >= list.size()) {
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> next() {
|
||||
return list.get(pos).next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new RuntimeException("NOT SUPPORTED METHOD");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user