Пример #1
0
  public static void shutdown() {
    logger_.info("Shutting down ...");
    synchronized (MessagingService.class) {
      /* Stop listening on any socket */
      for (SelectionKey skey : listenSockets_.values()) {
        SelectorManager.getSelectorManager().cancel(skey);
      }
      listenSockets_.clear();

      /* Shutdown the threads in the EventQueue's */
      messageDeserializationExecutor_.shutdownNow();
      messageSerializerExecutor_.shutdownNow();
      messageDeserializerExecutor_.shutdownNow();
      streamExecutor_.shutdownNow();

      /* shut down the cachetables */
      taskCompletionMap_.shutdown();
      callbackMap_.shutdown();

      /* Interrupt the selector manager thread */
      SelectorManager.getSelectorManager().interrupt();

      poolTable_.clear();
      verbHandlers_.clear();
      bShutdown_ = true;
    }
    logger_.debug("Shutdown invocation complete.");
  }
    public Map<Token, Float> describeOwnership(List<Token> sortedTokens) {
      // allTokens will contain the count and be returned, sorted_ranges is shorthand for
      // token<->token math.
      Map<Token, Float> allTokens = new HashMap<Token, Float>();
      List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>();

      // this initializes the counts to 0 and calcs the ranges in order.
      Token lastToken = sortedTokens.get(sortedTokens.size() - 1);
      for (Token node : sortedTokens) {
        allTokens.put(node, new Float(0.0));
        sortedRanges.add(new Range<Token>(lastToken, node));
        lastToken = node;
      }

      for (String ks : Schema.instance.getKeyspaces()) {
        for (CFMetaData cfmd : Schema.instance.getKSMetaData(ks).cfMetaData().values()) {
          for (Range<Token> r : sortedRanges) {
            // Looping over every KS:CF:Range, get the splits size and add it to the count
            allTokens.put(
                r.right,
                allTokens.get(r.right)
                    + StorageService.instance.getSplits(ks, cfmd.cfName, r, 1).size());
          }
        }
      }

      // Sum every count up and divide count/total for the fractional ownership.
      Float total = new Float(0.0);
      for (Float f : allTokens.values()) total += f;
      for (Map.Entry<Token, Float> row : allTokens.entrySet())
        allTokens.put(row.getKey(), row.getValue() / total);

      return allTokens;
    }
Пример #3
0
 public static ConnectionStatistics[] getPoolStatistics() {
   Set<ConnectionStatistics> stats = new HashSet<ConnectionStatistics>();
   Iterator<TcpConnectionManager> it = poolTable_.values().iterator();
   while (it.hasNext()) {
     TcpConnectionManager cp = it.next();
     ConnectionStatistics cs =
         new ConnectionStatistics(
             cp.getLocalEndPoint(),
             cp.getRemoteEndPoint(),
             cp.getPoolSize(),
             cp.getConnectionsInUse());
     stats.add(cs);
   }
   return stats.toArray(new ConnectionStatistics[0]);
 }