Package com.alipay.bluewhale.core.cluster

Examples of com.alipay.bluewhale.core.cluster.StormClusterState




  public static <T> void transitionName(NimbusData data, String topologyName,
    boolean errorOnNoTransition, StatusType transition_status, T... args) throws NotAliveException {
      StormClusterState stormClusterState = data.getStormClusterState();
      String topologyId = Common.get_storm_id(stormClusterState, topologyName);
      if (topologyId == null){
    throw new NotAliveException(topologyName);
      }
      transition(data, topologyId, errorOnNoTransition, transition_status, args);
View Full Code Here


    StormTopology newtopology = new StormTopology(topology);
    // TODO TOPOLOGY_OPTIMIZE
    // if ((Boolean) totalStormConf.get(Config.TOPOLOGY_OPTIMIZE)) {
    // newtopology = optimizeTopology(topology);
    // }
    StormClusterState stormClusterState = data.getStormClusterState();
    // this validates the structure of the topology
    Common.system_topology(totalStormConf, newtopology);
    LOG.info("Received topology submission for " + topologyname
        + " with conf " + serializedConf);
    synchronized (data.getSubmitLock()) {
      try {
        // �ϴ�code�������л�topology��������Ϣ
        setupStormCode(conf, topologyId, uploadedJarLocation,
            serializedConf, newtopology);
        // ��������
        stormClusterState.setup_heartbeats(topologyId);
        //Ϊtask�����Ӧcomponentid
        setupStormStatic(conf, topologyId, stormClusterState);
        //make assignments for a topology
        NimbusUtils.mkAssignments(data, topologyId);
        //����topology������״̬Ϊ:active
View Full Code Here

   *  ����topology����Ϣ��topologyid��topologyname����������worker��������ʱ���״̬
   *  @return ClusterSummary
         */
  @Override
  public ClusterSummary getClusterInfo() throws TException {
    StormClusterState stormClusterState = data.getStormClusterState();
    //����ѷ���Ķ˿ںͶ˿������е�����
    Map<String, Set<Integer>> assigned = NimbusUtils
        .assigned_Slots(stormClusterState);
    //�������supervisor����Ϣ
    Map<String, SupervisorInfo> supervisorInfos = NimbusUtils
        .allSupervisorInfo(stormClusterState, null);
    //���supervisorSummaries
    List<SupervisorSummary> supervisorSummaries = new ArrayList<SupervisorSummary>();
    if (supervisorInfos == null) {
      supervisorInfos = new HashMap<String, SupervisorInfo>();
    }
    Set<Entry<String, SupervisorInfo>> sinfoEntry = supervisorInfos.entrySet();
    for (Iterator<Entry<String, SupervisorInfo>> it = sinfoEntry.iterator(); it.hasNext();) {
      Entry<String, SupervisorInfo> entry = it.next();
      String supervisorId = entry.getKey();
      SupervisorInfo info = entry.getValue();
     
      List<Integer> ports = info.getWorkPorts();
      int num_used_workers = 0;
      int num_workers = 0;
      if (assigned != null && assigned.get(supervisorId) != null){
          num_used_workers = assigned.get(supervisorId).size();
      }
                        if (ports != null){
                            num_workers = ports.size();
      }
      supervisorSummaries.add(new SupervisorSummary(info.getHostName(),
          info.getUptimeSecs(),num_workers , num_used_workers));
    }
    //���nimbus������ʱ��
    int uptime = data.uptime();
   
    //�������״̬Ϊactive��topology
    Map<String, StormBase> bases = Common.topology_bases(stormClusterState);

    if (bases == null) {
      bases = new HashMap<String, StormBase>();
    }

    //������м�Ⱥ����Ϣ
    List<TopologySummary> topologySummaries = new ArrayList<TopologySummary>();

    Set<Entry<String, StormBase>> basesEntry = bases.entrySet();
    for (Iterator<Entry<String, StormBase>> it = basesEntry.iterator(); it.hasNext();) {
      Entry<String, StormBase> entry = it.next();
      String stormId = entry.getKey();
      StormBase base = entry.getValue();
      Assignment assignment = stormClusterState.assignment_info(stormId,null);
      if (assignment != null) {
        HashSet<NodePort> workers = new HashSet<NodePort>();
        Collection<NodePort> entryColl = assignment.getTaskToNodeport().values();
        workers.addAll(entryColl);
        topologySummaries.add(new TopologySummary(stormId, base.getStormName(), assignment.getTaskToNodeport().size(),
View Full Code Here

  @Override
  public TopologyInfo getTopologyInfo(String topologyIdthrows NotAliveException, TException {
   
    TopologyInfo topologyInfo=null;
   
    StormClusterState stormClusterState = data.getStormClusterState();
   
    //���topology��������Ϣ�� ����ID �� componentid
    HashMap<Integer, String> taskInfo = Common.topology_task_info(stormClusterState, topologyId);// <taskid,componentid>
   
    //���topology��name������ʱ���״̬
    StormBase base = stormClusterState.storm_base(topologyId, null);
   
    //���topology�����������Ϣ
    Assignment assignment = stormClusterState.assignment_info(topologyId,null);
   
    if (base != null && assignment != null) {
      List<TaskSummary> taskSummarys = new ArrayList<TaskSummary>();
      Set<Entry<Integer, String>> taskInfoSet = taskInfo.entrySet();
      for (Iterator<Entry<Integer, String>> it = taskInfoSet.iterator(); it.hasNext();) {
        Entry<Integer, String> entry =  it.next();
        Integer taskId =  entry.getKey();
        String componentId =  entry.getValue();
        NodePort np = (NodePort) assignment.getTaskToNodeport().get(taskId);
        //���ָ��task��������Ϣ
        TaskHeartbeat heartbeat = stormClusterState.task_heartbeat(topologyId, taskId);
        if (np == null || heartbeat == null) {
          continue;
        }
        String host = (String) assignment.getNodeHost().get(np.getNode());
        List<TaskError> errors = stormClusterState.task_errors(topologyId, taskId);
        List<ErrorInfo> newErrors = new ArrayList<ErrorInfo>();

        if (errors != null) {
          int size = errors.size();
          for (int i = 0; i < size; i++) {
View Full Code Here

  }

  TimeCacheMap<String, Long> lastneedClean=new TimeCacheMap<String, Long>(3600);
  @Override
  public void run() {
    StormClusterState clusterState = data.getStormClusterState();

    List<String> active_topologys = clusterState.active_storms();
    if (active_topologys != null){
        for (String topologyid : active_topologys) {
      StatusTransition.transition(data, topologyid, false, StatusType.monitor);
        }
    }
   
    long times=index.incrementAndGet();
    if(times%10!=0)
    {
      return ;
    }
    if(times>10000000)
    {
      index.set(0l);
    }


    // �̰߳�ȫ��������submitTopology��transition״̬ʱ
    synchronized (data.getSubmitLock()) {
      Set<String> to_cleanup_ids = do_cleanup(clusterState,active_topologys);
      if (to_cleanup_ids != null && to_cleanup_ids.size() > 0) {
        for (String storm_id : to_cleanup_ids) {
          if(!lastneedClean.containsKey(storm_id))
          {
              LOG.info("nexttime Cleaning up " + storm_id);
              lastneedClean.put(storm_id, System.currentTimeMillis() );
            continue;
          }
            LOG.info("Cleaning up " + storm_id);
          clusterState.teardown_heartbeats(storm_id);
          clusterState.teardown_task_errors(storm_id);
          // ��ȡĿ¼ /nimbus/stormdist/topologyid
          String master_stormdist_root = StormConfig
              .masterStormdistRoot(data.getConf(), storm_id);
          try {
            // ǿ��ɾ��topologyid��Ӧ��Ŀ¼
View Full Code Here

public class TableList {
 

  public static String[] getTablelist() throws Exception
  {
    StormClusterState stat=GetShards.getCluster();
    List<String> list=stat.higo_tableList();
    String[] rtn=new String[list.size()];
    return list.toArray(rtn);
  }
View Full Code Here

  }
 
  public static long getRecordCount(String tableName) throws Exception
  {

    StormClusterState zkCluster = GetShards.getCluster();
    List<Integer> list=zkCluster.higo_ids(tableName);
    Long recordCount=0l;
    for(Integer id:list)
    {
        SolrInfo info=zkCluster.higo_info(tableName, id);
        if(info!=null)
        {
          if(info.stat==ShardsState.SERVICE)
          {
            for(Entry<String, ShardCount> e:info.recorecount.entrySet())
View Full Code Here

  }
 
 
  public static String[] getTableShards_table(String tableName)throws Exception
  {
    StormClusterState zkCluster = GetShards.getCluster();
    List<Integer> list=zkCluster.higo_ids(tableName);
    List<String> listrtntotal=new ArrayList<String>();
    List<String> listrtn=new ArrayList<String>();
    listrtntotal.add("进程数:"+list.size()+"<br>");
    Long recordCount=0l;
      HashMap<String,Long> partionCount = new HashMap<String, Long>();
      HashMap<String,Long> dayCount = new HashMap<String, Long>();
      HashMap<String,Long> dayAmt = new HashMap<String, Long>();

    for(Integer id:list)
    {
        SolrInfo info=zkCluster.higo_info(tableName, id);
        if(info!=null)
        {
          if(info.stat==ShardsState.SERVICE)
          {
            for(Entry<String, ShardCount> e:info.recorecount.entrySet())
View Full Code Here

import com.alimama.mdrill.partion.GetShards;
public class Topology {
 
  public static String[] active_storms() throws Exception
  {
    StormClusterState stat=GetShards.getCluster();
    List<String> list=stat.active_storms();
    String[] rtn=new String[list.size()];
    return list.toArray(rtn);
  }
View Full Code Here

    return list.toArray(rtn);
  }
 
  public static String[] heartbeat_storms() throws Exception
  {
    StormClusterState stat=GetShards.getCluster();
    List<String> list=stat.heartbeat_storms();
    String[] rtn=new String[list.size()];
    return list.toArray(rtn);
  }
View Full Code Here

TOP

Related Classes of com.alipay.bluewhale.core.cluster.StormClusterState

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.