Search in sources :

Example 6 with TTransportException

use of org.apache.storm.thrift.transport.TTransportException 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

TTransportException (org.apache.storm.thrift.transport.TTransportException)6 AuthorizationException (org.apache.storm.generated.AuthorizationException)4 List (java.util.List)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 DistributedRPCInvocations (org.apache.storm.generated.DistributedRPCInvocations)2 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)2 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)2 NimbusInfo (org.apache.storm.nimbus.NimbusInfo)2 KeeperException (org.apache.storm.shade.org.apache.zookeeper.KeeperException)2 ParseException (org.apache.storm.shade.org.json.simple.parser.ParseException)2 TException (org.apache.storm.thrift.TException)2 NimbusClient (org.apache.storm.utils.NimbusClient)2 WrappedKeyNotFoundException (org.apache.storm.utils.WrappedKeyNotFoundException)2 Principal (java.security.Principal)1 DRPCInvocationsClient (org.apache.storm.drpc.DRPCInvocationsClient)1 Nimbus (org.apache.storm.generated.Nimbus)1 NimbusSummary (org.apache.storm.generated.NimbusSummary)1 ReadableBlobMeta (org.apache.storm.generated.ReadableBlobMeta)1