Search in sources :

Example 6 with ParseException

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);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) List(java.util.List) ArrayList(java.util.ArrayList) ParseException(org.apache.storm.shade.org.json.simple.parser.ParseException)

Example 7 with ParseException

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);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) List(java.util.List) ArrayList(java.util.ArrayList) ParseException(org.apache.storm.shade.org.json.simple.parser.ParseException)

Example 8 with ParseException

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);
        }
    }
}
Also used : TException(org.apache.storm.thrift.TException) AuthorizationException(org.apache.storm.generated.AuthorizationException) ArrayList(java.util.ArrayList) DistributedRPCInvocations(org.apache.storm.generated.DistributedRPCInvocations) TTransportException(org.apache.storm.thrift.transport.TTransportException) DRPCInvocationsClient(org.apache.storm.drpc.DRPCInvocationsClient) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(org.apache.storm.shade.org.json.simple.parser.ParseException)

Aggregations

ParseException (org.apache.storm.shade.org.json.simple.parser.ParseException)8 ArrayList (java.util.ArrayList)4 List (java.util.List)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 AuthorizationException (org.apache.storm.generated.AuthorizationException)2 ComponentObject (org.apache.storm.generated.ComponentObject)2 DistributedRPCInvocations (org.apache.storm.generated.DistributedRPCInvocations)2 TException (org.apache.storm.thrift.TException)2 TTransportException (org.apache.storm.thrift.transport.TTransportException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 LinkedHashMap (java.util.LinkedHashMap)1 NavigableMap (java.util.NavigableMap)1 TreeMap (java.util.TreeMap)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 DRPCInvocationsClient (org.apache.storm.drpc.DRPCInvocationsClient)1