use of org.apache.storm.shade.org.json.simple.parser.ParseException in project storm by apache.
the class JSONOpaqueSerializer method deserialize.
@Override
public OpaqueValue deserialize(byte[] b) {
try {
String s = new String(b, "UTF-8");
List deser = (List) JSONValue.parseWithException(s);
return new OpaqueValue((Long) deser.get(0), deser.get(1), deser.get(2));
} catch (UnsupportedEncodingException | ParseException e) {
throw new RuntimeException(e);
}
}
use of org.apache.storm.shade.org.json.simple.parser.ParseException in project storm by apache.
the class JSONTransactionalSerializer method deserialize.
@Override
public TransactionalValue deserialize(byte[] b) {
try {
String s = new String(b, "UTF-8");
List deser = (List) JSONValue.parseWithException(s);
return new TransactionalValue((Long) deser.get(0), deser.get(1));
} catch (UnsupportedEncodingException | ParseException e) {
throw new RuntimeException(e);
}
}
use of org.apache.storm.shade.org.json.simple.parser.ParseException in project storm by apache.
the class ReturnResultsReducer method complete.
@Override
public void complete(ReturnResultsState state, TridentCollector collector) {
// only one of the multireducers will receive the tuples
if (state.returnInfo != null) {
String result = JSONValue.toJSONString(state.results);
Map<String, Object> retMap;
try {
retMap = (Map<String, Object>) JSONValue.parseWithException(state.returnInfo);
} catch (ParseException e) {
collector.reportError(e);
return;
}
final String host = (String) retMap.get("host");
final int port = ObjectReader.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)) {
try {
clients.put(server, new DRPCInvocationsClient(conf, host, port));
} catch (TTransportException ex) {
throw new RuntimeException(ex);
}
}
client = clients.get(server);
}
try {
client.result(id, result);
} catch (AuthorizationException aze) {
collector.reportError(aze);
} catch (TException e) {
collector.reportError(e);
}
}
}
Aggregations