Package org.apache.thrift7.transport

Examples of org.apache.thrift7.transport.TTransport


  public void finishFileUpload(String location) throws TException {

    TimeCacheMap<Object, Object> uploaders = data.getUploaders();
    Object obj = uploaders.get(location);
    if (obj == null) {
      throw new TException(
          "File for that location does not exist (or timed out)");
    }
    try {
      if (obj instanceof WritableByteChannel) {
        WritableByteChannel channel = (WritableByteChannel) obj;
        channel.close();
        uploaders.remove(location);
        LOG.info("Finished uploading file from client: " + location);
      } else {
        throw new TException("Object isn't WritableByteChannel for "
            + location);
      }
    } catch (IOException e) {
      LOG.error(" WritableByteChannel close failed when finishFileUpload "
          + location);
View Full Code Here


      is = new BufferFileInputStream(file, bufferSize);
      id = UUID.randomUUID().toString();
      data.getDownloaders().put(id, is);
    } catch (FileNotFoundException e) {
      LOG.error(e + "file:" + file + " not found");
      throw new TException(e);
    }

    return id;
  }
View Full Code Here

  @Override
  public ByteBuffer downloadChunk(String id) throws TException {
    TimeCacheMap<Object, Object> downloaders = data.getDownloaders();
    Object obj = downloaders.get(id);
    if (obj == null) {
      throw new TException("Could not find input stream for that id");
    }

    try {
      if (obj instanceof BufferFileInputStream) {

        BufferFileInputStream is = (BufferFileInputStream) obj;
        byte[] ret = is.read();
        if (ret != null) {
          downloaders.put(id, (BufferFileInputStream) is);
          return ByteBuffer.wrap(ret);
        }
      } else {
        throw new TException("Object isn't BufferFileInputStream for "
            + id);
      }
    } catch (IOException e) {
      LOG.error("BufferFileInputStream read failed when downloadChunk ",
          e);
      throw new TException(e);
    }
    byte[] empty = {};
    return ByteBuffer.wrap(empty);
  }
View Full Code Here

    } catch (TException e) {
      LOG.info("Failed to get ClusterSummary ", e);
      throw e;
    } catch (Exception e) {
      LOG.info("Failed to get ClusterSummary ", e);
      throw new TException(e);
    }
  }
View Full Code Here

          break;
        }
      }

      if (supervisorId == null) {
        throw new TException("No supervisor of " + host);
      }

      Map<String, Assignment> assignments = new HashMap<String, Assignment>();

      // get all active topology's StormBase
      Map<String, StormBase> bases = Cluster
          .topology_bases(stormClusterState);
      for (Entry<String, StormBase> entry : bases.entrySet()) {

        String topologyId = entry.getKey();
        StormBase base = entry.getValue();

        Assignment assignment = stormClusterState.assignment_info(
            topologyId, null);
        if (assignment == null) {
          LOG.error("Failed to get assignment of " + topologyId);
          continue;
        }
        assignments.put(topologyId, assignment);

      }

      Map<Integer, WorkerSummary> portWorkerSummarys = new TreeMap<Integer, WorkerSummary>();
      Map<String, Integer> supervisorToUsedSlotNum = new HashMap<String, Integer>();
      for (Entry<String, Assignment> entry : assignments.entrySet()) {
        String topologyId = entry.getKey();
        Assignment assignment = entry.getValue();

        Map<Integer, String> taskToComponent = Cluster
            .topology_task_info(stormClusterState, topologyId);
        Map<Integer, String> taskToComponentType = Cluster
            .topology_task_compType(stormClusterState, topologyId);

        Set<ResourceWorkerSlot> workers = assignment.getWorkers();

        for (ResourceWorkerSlot worker : workers) {
          if (supervisorId.equals(worker.getNodeId()) == false) {
            continue;
          }
          Integer slotNum = supervisorToUsedSlotNum
              .get(supervisorId);
          if (slotNum == null) {
            slotNum = 0;
            supervisorToUsedSlotNum.put(supervisorId, slotNum);
          }
          supervisorToUsedSlotNum.put(supervisorId, ++slotNum);

          Integer port = worker.getPort();
          WorkerSummary workerSummary = portWorkerSummarys
              .get(port);
          if (workerSummary == null) {
            workerSummary = new WorkerSummary();
            workerSummary.set_port(port);
            workerSummary.set_topology(topologyId);
            workerSummary
                .set_tasks(new ArrayList<TaskSummary>());

            portWorkerSummarys.put(port, workerSummary);
          }
         
          for (Integer taskId : worker.getTasks()) {

            String componentName = taskToComponent.get(taskId);
            String componentType = taskToComponentType.get(taskId);
            int uptime = TimeUtils.time_delta(assignment
                .getTaskStartTimeSecs().get(taskId));
            List<TaskSummary> tasks = workerSummary.get_tasks();

            TaskSummary taskSummary = NimbusUtils
                .mkSimpleTaskSummary(worker, taskId,
                    componentName, componentType, host, uptime);

            tasks.add(taskSummary);
          }
        }
      }

      List<WorkerSummary> wokersList = new ArrayList<WorkerSummary>();
      wokersList.addAll(portWorkerSummarys.values());

      SupervisorSummary supervisorSummary = NimbusUtils
          .mkSupervisorSummary(supervisorInfo, supervisorId,
              supervisorToUsedSlotNum);
      return new SupervisorWorkers(supervisorSummary, wokersList);

    } catch (TException e) {
      LOG.info("Failed to get ClusterSummary ", e);
      throw e;
    } catch (Exception e) {
      LOG.info("Failed to get ClusterSummary ", e);
      throw new TException(e);
    }
  }
View Full Code Here

      // get topology's Assignment
      Assignment assignment = stormClusterState.assignment_info(
          topologyId, null);
      if (assignment == null) {
        throw new TException("Failed to get StormBase from ZK of "
            + topologyId);
      }

      // get topology's map<taskId, componentId>
      Map<Integer, String> taskInfo = Cluster.topology_task_info(
          stormClusterState, topologyId);

      Map<Integer, TaskSummary> tasks = NimbusUtils.mkTaskSummary(
          stormClusterState, assignment, taskInfo, topologyId);
      List<TaskSummary> taskSumms = new ArrayList<TaskSummary>();
      for (Entry<Integer, TaskSummary> entry : tasks.entrySet()) {
        taskSumms.add(entry.getValue());
      }
      topologyInfo.set_tasks(taskSumms);
      List<WorkerSummary> workers = NimbusUtils.mkWorkerSummary(
          topologyId, assignment, tasks);
      topologyInfo.set_workers(workers);

      return topologyInfo;
    } catch (TException e) {
      LOG.info("Failed to get topologyInfo " + topologyId, e);
      throw e;
    } catch (Exception e) {
      LOG.info("Failed to get topologyInfo " + topologyId, e);
      throw new TException("Failed to get topologyInfo" + topologyId);
    }

  }
View Full Code Here

          .read_nimbus_topology_conf(conf, id);
      rtn = JStormUtils.to_json(topologyConf);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      LOG.info("Failed to get configuration of " + id, e);
      throw new TException(e);
    }
    return rtn;
  }
View Full Code Here

    StormTopology topology = null;
    try {
      StormTopology stormtopology = StormConfig
          .read_nimbus_topology_code(conf, id);
      if (stormtopology == null) {
        throw new TException("topology:" + id + "is null");
      }

      Map<Object, Object> topologyConf = (Map<Object, Object>) StormConfig
          .read_nimbus_topology_conf(conf, id);

      topology = Common.system_topology(topologyConf, stormtopology);
    } catch (Exception e) {
      LOG.error("Failed to get topology " + id + ",", e);
      throw new TException("Failed to get system_topology");
    }
    return topology;
  }
View Full Code Here

          throw new NotAliveException("Failed to update metricsMonitor status as " + topologyName + " is not alive");
        }
    } catch(Exception e) {
      String errMsg = "Failed to update metricsMonitor " + topologyName;
      LOG.error(errMsg, e);
      throw new TException(e);
    }
   
  }
View Full Code Here

        }
       
    } catch(Exception e) {
      String errMsg = "Failed to get topology Metric Data " + topologyId;
      LOG.error(errMsg, e);
      throw new TException(e);
    }
   
    return topologyMetricInfo;
  }
View Full Code Here

TOP

Related Classes of org.apache.thrift7.transport.TTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.