Exemple #1
0
static	void	Handle_mature()
{
  if (Maturity == 1) return;
  
  Maturity = 1;
  E_dequeue( Turn_mature, 0, 0 );
  
  wack_alarm(LOGIC,"Handle_mature");
  if ( State != GATHER )
    {
      /* ### deterministically grab ip addresses */
      Priority_claim();
      Claim_unclaimed();
      wack_alarm(LOGIC, "Shifting to RUN in Handle_mature()" );
      State = RUN;
      E_queue( Balance, 0, 0, Balance_timer );
    }
}
Exemple #2
0
static	void	Handle_membership()
{
  int	i;
  
  wack_alarm(LOGIC, "Handle_membership");
  
  if( strcmp( Sender, Spread_group ) != 0 )
    {
      Bye();
      Clean_up();
      wack_alarm(EXIT, "Handle_membership:  Bug! got a membership for group %s",
	     Sender );
      
    }
  
  memcpy( &Gid, Mess, sizeof( group_id ) );
  Num_pending_states = Num_groups;
  
  Num_members = Num_groups;

  for( i = 0; i < Num_members; i++ )
    {
      memcpy( Members[i].private_group_name, Target_groups[i], MAX_GROUP_NAME );
      My_index = Mess_type;
      _rif_ip_s(Members[i]) = 0;
      Members[i].num_allocated = 0;
      Members[i].got_state_from = 0;
    }
  if(State != GATHER && State != BOOT)
    memcpy( Old_table, Allocation_table, MAX_PSEUDO * sizeof( entry ) );

  for ( i = 0; i < Num_pseudo; i++ )
    {
      _rif_ip_s(Allocation_table[i]) = 0;/* added 4/27/01 */
      Allocation_table[i].claim_priority = UNCLAIMED;
    }
  Send_state_message();		/* ### */
  wack_alarm(LOGIC,  "Shifting to GATHER" );
  State = GATHER;
  wack_alarm(LOGIC,  "Dequeuing Balance" ); /* Debug */
  E_dequeue( Balance, 0, 0 );

}
Exemple #3
0
static	void	Activate_status()
{
	proc	p;
	int	proc_index;
	char	str[80];
	int	legal,ret;
	int	i;
	int	end;

	printf("\n");
	printf("=============\n");
	printf("Activate Status\n");
	printf("-------------\n");

	printf("\n");

	end = 0;
	while( !end )
	{
		for( legal=0; !legal; )
		{
		    printf("\tEnter Proc Name: ");

		    if( fgets( str, 70, stdin ) == NULL )
		    {
			printf("Bye.\n");
			exit(0);
		    }
		    ret = sscanf(str, "%s", p.name );
		    if( ret > 0  || str[0] == '\n' ) legal = 1;
		    else printf("Please enter a legal proc name, none, or all\n");
		}
		if( str[0] == '\n' ){
			end = 1;
		}else if( !strcmp( p.name, "all" ) ){
			for( i=0; i < Conf_num_procs( &Cn ); i++ )
				Status_vector[i] = 1;
		}else if( !strcmp( p.name, "none" ) ){
			for( i=0; i < Conf_num_procs( &Cn ); i++ )
				Status_vector[i] = 0;
		}else{
			proc_index = Conf_proc_by_name( p.name, &p );
			if( proc_index != -1 ){
				Status_vector[proc_index] = 1;
			}else printf("Please! enter a legal proc name, none, or all\n");
		}
	}
#ifndef _REENTRANT
	E_dequeue( Send_status_query, 0, NULL );
#endif
        Mutex_lock( &Status_mutex );
        Status_active = 0;
	for( i=0; i < Conf_num_procs( &Cn ); i++ )
	{
		if( Status_vector[i] )
		{
                    Status_active = 1;
			break;
		}
	}
        Mutex_unlock( &Status_mutex );
#ifndef _REENTRANT
        if (Status_active)
            Send_status_query();
#endif
}
Exemple #4
0
static	void	User_command()
{
	char	command[80];
	int	i;

	if( fgets( command,70,stdin ) == NULL )
	{
		printf("Bye.\n");
		exit( 0 );
	}

	switch( command[0] )
	{
		case '0':
			Activate_status();

			printf("\n");
			printf("Monitor> ");
			fflush(stdout);

			break;

		case '1':
			Define_partition();
			Print_partition( Work_partition );

			break;

		case '2':
			for( i=0; i < Conf_num_procs( &Cn ); i++ )
				Partition[i] = Work_partition[i];
                        Mutex_lock( &Partition_mutex );
                        Partition_active = 1;
                        Mutex_unlock( &Partition_mutex );
#ifndef _REENTRANT
			Send_partition();
#endif

			printf("\n");
			printf("Monitor> ");
			fflush(stdout);

			break;

		case '3':
			Print_partition( Partition );

			break;

		case '4':
			for( i=0; i < Conf_num_procs( &Cn ); i++ )
			{
				Partition[i] = 0;
				Work_partition[i] = 0;
			}
                        Mutex_lock( &Partition_mutex );
                        Partition_active = 0;
                        Mutex_unlock( &Partition_mutex );

			Send_partition();
#ifndef _REENTRANT
			E_dequeue( Send_partition, 0, NULL );
#endif
			printf("\n");
			printf("Monitor> ");
			fflush(stdout);

			break;

		case '5':
			Define_flow_control();
			Print_flow_control( Work_fc_buf );

			break;

		case '6':
		        for( i=0; i < Conf_num_procs( &Cn )+1; i++ ) {
				Fc_buf[i][0] = Work_fc_buf[i][0];
				Fc_buf[i][1] = Work_fc_buf[i][1];
			}
			Send_flow_control();

			printf("\n");
			printf("Monitor> ");
			fflush(stdout);

			break;

		case '7':
			Print_flow_control( Fc_buf );

			break;

		case '8':
			Kill_spreads();

			printf("\n");
			printf("Monitor> ");
			fflush(stdout);

			break;

                case 'r':
                        /* trigger reload of spread configuration */
                        Reload_Conf();
                        printf("Reload Membership. \n");

                        break;
		case '9':
		case 'q':
			printf("Bye.\n");
			exit( 0 );

			break;

		default:
			printf("\nUnknown commnad\n");
			Print_menu();

			break;
	}
}
Exemple #5
0
/* Send message to all daemons to reload their configuration files to change the set of daemons */
static  void    Reload_Conf()
{
       	int32	proc_id;
	proc	p;
	int	proc_index;
	int	i,j;

	Pack.type    = RELOAD_TYPE;
	Pack.type    = Set_endian( Pack.type );
        Pack.conf_hash = MONITOR_HASH;
	Pack.data_len = 0;

	Pack_scat.num_elements    = 1;

        Alarm( PRINT, "Old configuration hash is: %u\n", Cn.hash_code);

	Alarm( PRINT  , "Monitor: send conf reload command\n");
	for( i=0; i < Cn.num_segments ; i++ )
	{
	    for( j=0; j < Cn.segments[i].num_procs; j++ )
	    {
		proc_id = Cn.segments[i].procs[j]->id;
		proc_index = Conf_proc_by_id( proc_id, &p );
		DL_send( SendChan, p.id, p.port, &Pack_scat );
	    }
	}
        /* Now reload monitor's configuration 
         * and clear all Partition, Status, FC arrays as they are now inaccurate
         */

        read_configuration();

        for( i=0; i < Conf_num_procs( &Cn ); i++ )
	{
            Partition[i] = 0;
            Work_partition[i] = 0;
            Fc_buf[i][0] = 0;
            Fc_buf[i][1] = 0;
            Work_fc_buf[i][0] = 0;
            Work_fc_buf[i][1] = 0;
            Status_vector[i] = 0;
	}
        Mutex_lock( &Partition_mutex );
        Partition_active = 0;
        Mutex_unlock( &Partition_mutex );
        
#ifndef _REENTRANT
        E_dequeue( Send_partition, 0, NULL );
#endif

        Mutex_lock( &Status_mutex );
        Status_active = 0;
        Mutex_unlock( &Status_mutex );

#ifndef _REENTRANT
	E_dequeue( Send_status_query, 0, NULL );
#endif

        Alarm( PRINT, "New configuration hash is: %u\n", Cn.hash_code);
        Alarm( PRINT, "All Status, Partition, FC, etc commands are reset by configuration reload!\n");

}