use of java.util.Map in project cachecloud by sohutv.
the class ClientDataCollectReportExecutor method collectReportAllData.
/**
* 收集上报数据
* @param currentMinuteStamp
*/
private void collectReportAllData(String currentMinuteStamp) {
//1. 获取上一分钟的所有数据
String lastMinute = getLastMinute(currentMinuteStamp);
if (lastMinute == null || "".equals(lastMinute.trim())) {
return;
}
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.addAll(collectReportCostTimeData(lastMinute));
list.addAll(collectReportValueDistriData(lastMinute));
list.addAll(collectReportExceptionData(lastMinute));
//上报统计数据,观察是否存在内存泄露的情况
Map<String, Object> otherInfo = new HashMap<String, Object>(4, 1);
otherInfo.put(ClientReportConstant.COST_MAP_SIZE, UsefulDataCollector.getDataCostTimeMapAll().size());
otherInfo.put(ClientReportConstant.VALUE_MAP_SIZE, UsefulDataCollector.getDataValueLengthDistributeMapAll().size());
otherInfo.put(ClientReportConstant.EXCEPTION_MAP_SIZE, UsefulDataCollector.getDataExceptionMapAll().size());
otherInfo.put(ClientReportConstant.COLLECTION_MAP_SIZE, UsefulDataCollector.getCollectionCostTimeMapAll().size());
//2. 上报数据
if (!list.isEmpty()) {
ClientReportBean ccReportBean = new ClientReportBean(clientIp, NumberUtil.toLong(lastMinute), System.currentTimeMillis(), list, otherInfo);
ClientReportDataCenter.reportData(ccReportBean);
}
}
use of java.util.Map in project cachecloud by sohutv.
the class ClientDataCollectReportExecutor method collectReportValueDistriData.
/**
* 收集值分布
*
* @param lastMinute
*/
private List<Map<String, Object>> collectReportValueDistriData(String lastMinute) {
try {
// 1. 只取当前时间前一分钟的的数据
Map<ValueLengthModel, Long> jedisValueLengthMap = UsefulDataCollector.getValueLengthLastMinute(lastMinute);
if (jedisValueLengthMap == null || jedisValueLengthMap.isEmpty()) {
return Collections.emptyList();
}
// 2.解析拼接数据
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for (Entry<ValueLengthModel, Long> entry : jedisValueLengthMap.entrySet()) {
ValueLengthModel model = entry.getKey();
Long count = entry.getValue();
Map<String, Object> tempMap = new HashMap<String, Object>();
tempMap.put(ClientReportConstant.VALUE_DISTRI, model.getRedisValueSizeEnum().getValue());
tempMap.put(ClientReportConstant.VALUE_COUNT, count);
tempMap.put(ClientReportConstant.VALUE_COMMAND, model.getCommand());
tempMap.put(ClientReportConstant.VALUE_HOST_PORT, model.getHostPort());
tempMap.put(ClientReportConstant.CLIENT_DATA_TYPE, ClientCollectDataTypeEnum.VALUE_LENGTH_DISTRI_TYPE.getValue());
list.add(tempMap);
}
return list;
} catch (Exception e) {
UsefulDataCollector.collectException(e, "", System.currentTimeMillis(), ClientExceptionType.CLIENT_EXCEPTION_TYPE);
logger.error("collectReportValueDistriData:" + e.getMessage(), e);
return Collections.emptyList();
}
}
use of java.util.Map in project cachecloud by sohutv.
the class HashesCommandsTest method hgetAllPipeline.
@Test
public void hgetAllPipeline() {
Map<byte[], byte[]> bh = new HashMap<byte[], byte[]>();
bh.put(bbar, bcar);
bh.put(bcar, bbar);
jedis.hmset(bfoo, bh);
Pipeline pipeline = jedis.pipelined();
Response<Map<byte[], byte[]>> bhashResponse = pipeline.hgetAll(bfoo);
pipeline.sync();
Map<byte[], byte[]> bhash = bhashResponse.get();
assertEquals(2, bhash.size());
assertArrayEquals(bcar, bhash.get(bbar));
assertArrayEquals(bbar, bhash.get(bcar));
}
use of java.util.Map in project sonatype-aether by sonatype.
the class DependencyGraphParser method addNode.
private void addNode(DependencyNode root, int level, List<NodeEntry> entries) {
NodeEntry entry = new NodeEntry();
Dependency dependency = root.getDependency();
StringBuilder defBuilder = new StringBuilder();
if (dependency == null) {
defBuilder.append("(null)");
} else {
Artifact artifact = dependency.getArtifact();
defBuilder.append(artifact.getGroupId()).append(":").append(artifact.getArtifactId()).append(":").append(artifact.getExtension()).append(":").append(artifact.getVersion());
if (dependency.getScope() != null && (!"".equals(dependency.getScope()))) {
defBuilder.append(":").append(dependency.getScope());
}
Map<String, String> properties = artifact.getProperties();
if (!(properties == null || properties.isEmpty())) {
for (Map.Entry<String, String> prop : properties.entrySet()) {
defBuilder.append(";").append(prop.getKey()).append("=").append(prop.getValue());
}
}
}
entry.setDefinition(defBuilder.toString());
entry.setLevel(level++);
entries.add(entry);
for (DependencyNode node : root.getChildren()) {
addNode(node, level, entries);
}
}
use of java.util.Map in project elasticsearch-jetty by sonian.
the class JettyHttpServerTransport method doStart.
@Override
protected void doStart() throws ElasticsearchException {
PortsRange portsRange = new PortsRange(port);
final AtomicReference<Exception> lastException = new AtomicReference<Exception>();
Log.setLog(loggerWrapper);
portsRange.iterate(new PortsRange.PortCallback() {
@Override
public boolean onPortNumber(int portNumber) {
try {
Server server = null;
XmlConfiguration lastXmlConfiguration = null;
Object[] objs = new Object[jettyConfig.length];
Map<String, String> esProperties = jettySettings(bindHost, portNumber);
for (int i = 0; i < jettyConfig.length; i++) {
String configFile = jettyConfig[i];
URL config = environment.resolveConfig(configFile);
XmlConfiguration xmlConfiguration = new XmlConfiguration(config);
// in the later configurations
if (lastXmlConfiguration != null) {
xmlConfiguration.getIdMap().putAll(lastXmlConfiguration.getIdMap());
} else {
xmlConfiguration.getIdMap().put("ESServerTransport", JettyHttpServerTransport.this);
xmlConfiguration.getIdMap().put("ESClient", client);
}
// Inject elasticsearch properties
xmlConfiguration.getProperties().putAll(esProperties);
objs[i] = xmlConfiguration.configure();
lastXmlConfiguration = xmlConfiguration;
}
// Find jetty Server with id jettyConfigServerId
Object serverObject = lastXmlConfiguration.getIdMap().get(jettyConfigServerId);
if (serverObject != null) {
if (serverObject instanceof Server) {
server = (Server) serverObject;
}
} else {
// For compatibility - if it's not available, find first available jetty Server
for (Object obj : objs) {
if (obj instanceof Server) {
server = (Server) obj;
break;
}
}
}
if (server == null) {
logger.error("Cannot find server with id [{}] in configuration files [{}]", jettyConfigServerId, jettyConfig);
lastException.set(new ElasticsearchException("Cannot find server with id " + jettyConfigServerId));
return true;
}
// Keep it for now for backward compatibility with previous versions of jetty.xml
server.setAttribute(TRANSPORT_ATTRIBUTE, JettyHttpServerTransport.this);
// Start all lifecycle objects configured by xml configurations
for (Object obj : objs) {
if (obj instanceof LifeCycle) {
LifeCycle lifeCycle = (LifeCycle) obj;
if (!lifeCycle.isRunning()) {
lifeCycle.start();
}
}
}
jettyServer = server;
lastException.set(null);
} catch (BindException e) {
lastException.set(e);
return false;
} catch (Exception e) {
logger.error("Jetty Startup Failed ", e);
lastException.set(e);
return true;
}
return true;
}
});
if (lastException.get() != null) {
throw new BindHttpException("Failed to bind to [" + port + "]", lastException.get());
}
InetSocketAddress jettyBoundAddress = findFirstInetConnector(jettyServer);
if (jettyBoundAddress != null) {
InetSocketAddress publishAddress;
try {
publishAddress = new InetSocketAddress(networkService.resolvePublishHostAddress(publishHost), jettyBoundAddress.getPort());
} catch (Exception e) {
throw new BindTransportException("Failed to resolve publish address", e);
}
this.boundAddress = new BoundTransportAddress(new InetSocketTransportAddress(jettyBoundAddress), new InetSocketTransportAddress(publishAddress));
} else {
throw new BindHttpException("Failed to find a jetty connector with Inet transport");
}
}
Aggregations