Пример #1
0
int storaged_lbg_initialize(mstorage_t *s, int index) {
    int lbg_size;
    int ret;
    int i;
    int local=1;
    
    DEBUG_FUNCTION;    
#if 0
    
    /*
    ** configure the callback that is intended to perform the polling of the storaged on each TCP connection
    */
   ret =  north_lbg_attach_application_supervision_callback(s->lbg_id[index],(af_stream_poll_CBK_t)storcli_lbg_cnx_polling);
   if (ret < 0)
   {
     severe("Cannot configure Soraged polling callback");   
   }


   ret =  north_lbg_set_application_tmo4supervision(s->lbg_id[index],20);
   if (ret < 0)
   {
     severe("Cannot configure application TMO");   
   }   
#endif
   /*
   ** set the dscp for storio connections
   */
   af_inet_storaged_conf.dscp=(uint8_t)common_config.storio_dscp;
   af_inet_storaged_conf.dscp = af_inet_storaged_conf.dscp <<2;
    /*
    ** store the IP address and port in the list of the endpoint
    */
    lbg_size = s->sclients_nb;
    for (i = 0; i < lbg_size; i++)
    {
      my_list[i].remote_port_host   = s->sclients[i].port;
      my_list[i].remote_ipaddr_host = s->sclients[i].ipv4;
      if (!is_this_ipV4_local(s->sclients[i].ipv4)) local = 0;
    }
     af_inet_storaged_conf.recv_srv_type = ROZOFS_RPC_SRV;
     af_inet_storaged_conf.rpc_recv_max_sz = rozofs_storcli_south_large_buf_sz;
              
     ret = north_lbg_configure_af_inet(s->lbg_id[index],
                                          s->host,
                                          INADDR_ANY,0,
                                          my_list,
                                          ROZOFS_SOCK_FAMILY_STORAGE_NORTH,lbg_size,&af_inet_storaged_conf, local);
     if (ret < 0)
     {
      severe("Cannot create Load Balancing Group %d for storaged %s",s->lbg_id[index],s->host);
      return -1;    
     }
     north_lbg_set_next_global_entry_idx_p(s->lbg_id[index],&storcli_next_storio_global_index);
     return  0;
}     
Пример #2
0
/**
*  Init of the load balancing group associated with the exportd
   (used by rozofsmount only)
   
   @param exportclt: data structure that describes the remote exportd
   @param prog: export program name
   @param vers: exportd program version
   @param port_num: tcp port of the exportd (0 for dynamic port )
   @param supervision_callback: supervision callback (NULL if none)
   
   @retval 0 on success
   @retval < 0 on error (see errno for details)
*/
int export_lbg_initialize(exportclt_t *exportclt ,unsigned long prog,
        		  unsigned long vers,uint32_t port_num,
			  af_stream_poll_CBK_t supervision_callback) 
{
    int status = -1;
    struct sockaddr_in server;
    struct hostent *hp;
    int port = 0;
    int lbg_size;
    int export_index=0;
    char * pHost;
    int ret;
    
    DEBUG_FUNCTION;    
    rpcclt_t * client = &exportclt->rpcclt;

    server.sin_family = AF_INET;

    lbg_size = 0;
    for (export_index=0; export_index < ROZOFS_HOST_LIST_MAX_HOST; export_index++) { 

        pHost = rozofs_host_list_get_host(export_index);
	    if (pHost == NULL) break;
	
        if ((hp = gethostbyname(pHost)) == 0) {
            severe("gethostbyname failed for host : %s, %s", pHost,
                    strerror(errno));
            continue;
	 }

	 bcopy((char *) hp->h_addr, (char *) &server.sin_addr, hp->h_length);
	 if (port_num == 0) {
         if ((port = pmap_getport(&server, prog, vers, IPPROTO_TCP)) == 0) {
             warning("pmap_getport failed%s", clnt_spcreateerror(""));
             errno = EPROTO;
             goto out;
         }
         server.sin_port = htons(port);
	 } else {
         server.sin_port = htons(port_num);
	 }
	/*
	** store the IP address and port in the list of the endpoint
	*/
	my_list[lbg_size].remote_port_host = ntohs(server.sin_port);
	my_list[lbg_size].remote_ipaddr_host = ntohl(server.sin_addr.s_addr);
	lbg_size++;
    }
    if (lbg_size == 0) goto out;
    
     af_inet_exportd_conf.recv_srv_type = ROZOFS_RPC_SRV;
     af_inet_exportd_conf.rpc_recv_max_sz = rozofs_large_tx_recv_size;
     
     /*
     ** allocate a load balancing group
     */
     client->lbg_id = north_lbg_create_no_conf();
     if (client->lbg_id < 0)
     {     
        /*
	** cannot create the load balancing group
	*/
	severe("Out of lbg context while creating EXPORTD load balancing group");
	goto out;
     }
     /*
     ** put the supervision callback if any declared
     */
 #if 1
     if (supervision_callback != NULL)
     {	
       ret = north_lbg_attach_application_supervision_callback(client->lbg_id,supervision_callback);
       if (ret < 0)
       {
          /*
	  ** cannot create the load balancing group
	  */
	  severe("failure while configuring EXPORTD load balancing group");
	  goto out;     
       }
       ret = north_lbg_set_application_tmo4supervision(client->lbg_id,3);
       if (ret < 0)
       {
          /*
	  ** cannot create the load balancing group
	  */
	  severe("failure while configuring EXPORTD load balancing group");
	  goto out;     
       }
       north_lbg_set_active_standby_mode(client->lbg_id);
     }
#endif
     client->lbg_id = north_lbg_configure_af_inet(client->lbg_id,"METADATA",INADDR_ANY,0,my_list,ROZOFS_SOCK_FAMILY_EXPORT_NORTH,
                                                  lbg_size,&af_inet_exportd_conf,0);
     if (client->lbg_id >= 0)
     {
       status = 0;
       /*
       ** the timer is started only to address the case of a dynamic port
       */
       if (port_num == 0) export_lbg_start_timer (exportclt);      
       return status;    
     }
     severe("Cannot create Load Balancing Group for Exportd");

out:
     return  status;
}