当前位置: 首页>>代码示例>>Java>>正文


Java Utils.from_json方法代码示例

本文整理汇总了Java中backtype.storm.utils.Utils.from_json方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.from_json方法的具体用法?Java Utils.from_json怎么用?Java Utils.from_json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backtype.storm.utils.Utils的用法示例。


在下文中一共展示了Utils.from_json方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseJsonConf

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private String parseJsonConf(String jsonData) {
	Map<Object, Object> remoteConf = (Map)Utils.from_json(jsonData);
	
	StringBuilder sb = new StringBuilder();
	
	for (Entry entry : remoteConf.entrySet()) {
		sb.append(entry.getKey());
		sb.append(":");
		sb.append(entry.getValue());
		sb.append("\n");
	}
	
	return sb.toString();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:15,代码来源:ConfPage.java

示例2: maxTopologyMessageTimeout

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public int maxTopologyMessageTimeout() {
    Integer max = Utils.getInt(_stormConf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS));
    for (String spout : getRawTopology().get_spouts().keySet()) {
        ComponentCommon common = getComponentCommon(spout);
        String jsonConf = common.get_json_conf();
        if (jsonConf != null) {
            Map conf = (Map) Utils.from_json(jsonConf);
            Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS);
            if (comp != null) {
                max = Math.max(Utils.getInt(comp), max);
            }
        }
    }
    return max;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:16,代码来源:GeneralTopologyContext.java

示例3: deserialize

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public Object deserialize(byte[] b) {
    try {
        return Utils.from_json(new String(b, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:9,代码来源:JSONNonTransactionalSerializer.java

示例4: deserialize

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public TransactionalValue deserialize(byte[] b) {
    try {
        String s = new String(b, "UTF-8");
        List deser = (List) Utils.from_json(s);
        return new TransactionalValue((Long) deser.get(0), deser.get(1));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:11,代码来源:JSONTransactionalSerializer.java

示例5: deserialize

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public OpaqueValue deserialize(byte[] b) {
    try {
        String s = new String(b, "UTF-8");
        List deser = (List) Utils.from_json(s);
        return new OpaqueValue((Long) deser.get(0), deser.get(1), deser.get(2));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:11,代码来源:JSONOpaqueSerializer.java

示例6: getData

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public Object getData(String path) {
    path = "/" + path;
    try {
        if(_curator.checkExists().forPath(path)!=null) {
            return Utils.from_json(new String(_curator.getData().forPath(path), "UTF-8"));
        } else {
            return null;
        }
    } catch(Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:13,代码来源:TransactionalState.java

示例7: execute

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
   public void execute(TridentTuple input, TridentCollector collector) {
       String args = input.getString(0);
       List<List<Object>> tuples = (List) Utils.from_json(args);
       for(List<Object> tuple: tuples) {
           collector.emit(tuple);
       }
   }
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:10,代码来源:TuplifyArgs.java

示例8: execute

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(Tuple input) {
	String result = (String) input.getValue(0);
	String returnInfo = (String) input.getValue(1);
	if (returnInfo != null) {
		Map retMap = (Map) Utils.from_json(returnInfo);
		final String host = (String) retMap.get("host");
		final int port = Utils.getInt(retMap.get("port"));
		String id = (String) retMap.get("id");
		DistributedRPCInvocations.Iface client;
		if (local) {
			client = (DistributedRPCInvocations.Iface) ServiceRegistry
					.getService(host);
		} else {
			List server = new ArrayList() {
				{
					add(host);
					add(port);
				}
			};

			if (!_clients.containsKey(server)) {
				_clients.put(server, new DRPCInvocationsClient(host, port));
			}
			client = _clients.get(server);
		}

		try {
			client.result(id, result);
			_collector.ack(input);
		} catch (TException e) {
			LOG.error("Failed to return results to DRPC server", e);
			_collector.fail(input);
		}
	}
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:37,代码来源:ReturnResults.java

示例9: execute

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(TridentTuple input, TridentCollector collector) {
    String args = input.getString(0);
    List<List<Object>> tuples = (List) Utils.from_json(args);
    for(List<Object> tuple: tuples) {
        collector.emit(tuple);
    }
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:9,代码来源:TuplifyArgs.java

示例10: complete

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void complete(ReturnResultsState state, TridentCollector collector) {
    // only one of the multireducers will receive the tuples
    if(state.returnInfo!=null) {
        String result = Utils.to_json(state.results);
        Map retMap = (Map) Utils.from_json(state.returnInfo);
        final String host = (String) retMap.get("host");
        final int port = Utils.getInt(retMap.get("port"));
        String id = (String) retMap.get("id");
        DistributedRPCInvocations.Iface client;
        if(local) {
            client = (DistributedRPCInvocations.Iface) ServiceRegistry.getService(host);
        } else {
            List server = new ArrayList() {{
                add(host);
                add(port);
            }};

            if(!_clients.containsKey(server)) {
                _clients.put(server, new DRPCInvocationsClient(host, port));
            }
            client = _clients.get(server);
        }

        try {
            client.result(id, result);
        } catch(TException e) {
            collector.reportError(e);
        }
    }
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:32,代码来源:ReturnResultsReducer.java

示例11: parseJson

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private static Map parseJson(String json) {
	if (json == null)
		return new HashMap();
	else
		return (Map) Utils.from_json(json);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:7,代码来源:TopologyBuilder.java

示例12: parseFromObj

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static WorkerAssignment parseFromObj(Object obj) {
	if (obj == null) {
		return null;
	}

	if (obj instanceof Map == false) {
		return null;
	}

	try {
		Map<String, String> map = (Map<String, String>)obj;
		
		String supervisorId = map.get(NODEID_TAG);
		String hostname = map.get(HOSTNAME_TAG);
		Integer port = JStormUtils.parseInt(map.get(PORT_TAG));
		String jvm = map.get(JVM_TAG);
		Long mem = JStormUtils.parseLong(map.get(MEM_TAG));
		Integer cpu = JStormUtils.parseInt(map.get(CPU_TAG));
		Map<String, Object> componentToNum = (Map<String, Object>)Utils.from_json(map.get(COMPONENTTONUM_TAG));

		WorkerAssignment ret = new WorkerAssignment(supervisorId, port);

		
		ret.hostName = hostname;
		ret.setNodeId(supervisorId);
		ret.setJvm(jvm);
		if (port != null) {
			ret.setPort(port);
		}
		if (mem != null) {
			ret.setMem(mem);
		}
		if (cpu != null) {
			ret.setCpu(cpu);
		}
		
		for (Entry<String, Object> entry : componentToNum.entrySet()) {
			ret.addComponent(entry.getKey(),
					JStormUtils.parseInt(entry.getValue()));
		}
		return ret;
	} catch (Exception e) {
		LOG.error("Failed to convert to WorkerAssignment,  raw:" + obj, e);
		return null;
	}

}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:48,代码来源:WorkerAssignment.java

示例13: main

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) {
	WorkerAssignment input = new WorkerAssignment();

	 input.setJvm("sb");
	
	 input.setCpu(1);
	
	 input.setMem(2);

	 input.addComponent("2b", 2);

	String outString = Utils.to_json(input);

	System.out.println(input);
	
	//String outString = "[componentToNum={},mem=1610612736,cpu=1,hostName=mobilejstorm-60-1,jvm=<null>,nodeId=<null>,port=0]";

	Object object = Utils.from_json(outString);
	System.out.println(object);

	System.out.println(parseFromObj(object));

	System.out.print(input.equals(parseFromObj(object)));
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:25,代码来源:WorkerAssignment.java

示例14: supervisorConf

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@RequestMapping("/supervisor/{host}/configuration")
public Map supervisorConf(@PathVariable String name, @PathVariable String host) {
    int port = UIUtils.getSupervisorPort(name);
    String json = UIUtils.getSupervisorConf(host, port).getData();
    return (Map) Utils.from_json(json);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:7,代码来源:ConfAPIController.java


注:本文中的backtype.storm.utils.Utils.from_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。