示例#1
0
static	void	Print_flow_control( int16 fc_buf[MAX_PROCS_RING][2] )
{
	int32	proc_id;
	proc	p;
	int	proc_index;
	int	i,j;

	printf("\n");
	printf("========================\n");
	printf("Flow Control Parameters:\n");
	printf("------------------------\n");
	printf("\n");
	printf("Window size:  %d\n",fc_buf[ Conf_num_procs( &Cn )][0]);
	printf("\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 );
		printf("\t%s personal window\t%d\n", p.name, fc_buf[proc_index][0] );

		if (Conf_get_accelerated_ring()) {
		  printf("\t%s accelerated window\t%d\n", p.name, fc_buf[proc_index][1] );
		}
	    }
	    printf("\n");
	}
	printf("\n");
	printf("Monitor> ");
	fflush(stdout);
}
示例#2
0
void	FC_handle_message( sys_scatter *scat )
{

	int16		*cur_fc_buf;
	packet_header	*pack_ptr;
	proc		dummy_proc;
	int		my_index;
	int16		temp_window,temp_personal_window;
        configuration   *Cn;

        Cn = Conf_ref();

	pack_ptr = (packet_header *)scat->elements[0].buf;
        if ( ! Conf_get_dangerous_monitor_state() ) {
                Alarm( FLOW_CONTROL, "FC_handle_message: Request to change flow control from (%d.%d.%d.%d) denied. Monitor in safe mode\n", IP1(pack_ptr->proc_id), IP2(pack_ptr->proc_id), IP3(pack_ptr->proc_id), IP4(pack_ptr->proc_id) );
                return;
        }

	if( ! ( pack_ptr->memb_id.proc_id == 15051963 && Conf_id_in_conf( Cn, pack_ptr->proc_id ) != -1 ) )
	{
		Alarm( FLOW_CONTROL, 
			"FC_handle_message: Illegal monitor request\n");
		return;
	}
	cur_fc_buf = (int16 *)scat->elements[1].buf;

	my_index = Conf_proc_by_id( Conf_my().id, &dummy_proc );

	if( Same_endian( pack_ptr->type ) ) {
		temp_window = cur_fc_buf[Conf_num_procs( Cn )];
		temp_personal_window = cur_fc_buf[my_index];
	}else{
		temp_window = Flip_int16( cur_fc_buf[Conf_num_procs( Cn )] );
		temp_personal_window = Flip_int16( cur_fc_buf[my_index] );
	}
	if( temp_window != -1 ) Window = temp_window;
	if( temp_personal_window != -1 ) Personal_window = temp_personal_window;
	GlobalStatus.window = Window;
	GlobalStatus.personal_window = Personal_window;
	Alarm( FLOW_CONTROL, 
		"FC_handle_message: Got monitor mess, Window %d Personal %d\n", 
			Window, Personal_window );
}
示例#3
0
/* Basic algorithm:
 * 1) have configuration code load new conf file and check for modifications to conf.
 * 2) If only add/sub of daemons, then initiate membership change with token_loss and return;
 * 3) else, then set Conf_reload_state, create singleton partition, and schedule token_loss.
 * 4) When membership completes in Discard_packets() cleanup partition and probe for new members.
 */
void    Prot_initiate_conf_reload( int code, void *data )
{
        bool    need_memb_partition;
        int16   singleton_partition[MAX_PROCS_RING];
        int     i;

        if (Memb_state() != OP ) {
            /* This is a race condition, that the Prot_initiate_conf_reload was scheduled when OP state, 
             * but another membership occured before it was executed.
             * The membership system will requeue this function when it reaches OP state again.
             */
            return;
        }
        /* Disable queueing of this function when OP state reached in membership */
        Prot_clear_need_conf_reload();

        need_memb_partition = Conf_reload_initiate();

        /* Signal all subsystems to update Conf and My strucures */
        Net_signal_conf_reload();
        Memb_signal_conf_reload();
        Sess_signal_conf_reload();

        /* update protocol varialbes with new conf */
        My = Conf_my();
	My_index = Conf_proc_by_id( My.id, &My );

        if (need_memb_partition) {
                /* make partition */
                for ( i = 0 ; i < Conf_num_procs( Conf_ref() ); i++ ) 
                {
                        singleton_partition[i] = i;
                }
                Net_set_partition(singleton_partition);

                Conf_reload_singleton_state_begin();
        }
        E_queue( Memb_token_loss, 0, NULL, Zero_timeout );
}
示例#4
0
void	Discard_packets()
{
	int		pack_entry;
	packet_body	*body_ptr;
	up_queue	*up_ptr;
	int		proc_index;
	int		i;

    if( Aru <= Last_discarded ) return;
    if( Memb_state() == EVS )
    {
	int		found_hole;
	membership_id	reg_memb_id;

	if( Aru != Last_seq ) return;

        /* Deliver packets that must be delivered before the transitional signal.
         * Those up to the Aru for my old ring were delivered in Read_form2().
         * So, it remains to deliver all packets up to the first hole or the first
         * SAFE message. */
        Alarmp( SPLOG_INFO, PROTOCOL,
                "Discard_packets: delivering messages after old ring Aru before transitional\n" );

        for( i = Last_discarded+1; i <= Highest_seq; i++ )
        {
            pack_entry = i & PACKET_MASK;
	    if( ! Packets[pack_entry].exist )
		Alarmp( SPLOG_FATAL, PROTOCOL, "Discard_packets: (EVS before transitional) packet %d not exist\n", i);
	    if( Packets[pack_entry].exist == 3 )
	    {
		Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: Found first Hole in %d\n", i);
                break;
	    }
            if( Is_safe( Packets[pack_entry].head->type ) ) {
                Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: Found first SAFE message in %d", i);
                break;
            }
            /* should deliver packet or dispose the body if it was delivered already */
            if( Packets[pack_entry].exist == 1 ){
                Deliver_packet( pack_entry, 0 );
            } else {
                dispose( Packets[pack_entry].body );
            }
            /* dispose packet header in any case */
            dispose( Packets[pack_entry].head );
            Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: delivering %d in EVS\n",i);
	    Packets[pack_entry].exist = 0;
            Last_discarded = i;
        }

	/* calculate and deliver transitional membership */
        Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: Delivering transitional membership\n" );
	Memb_transitional();
	Sess_deliver_trans_memb( Trans_membership, Memb_trans_id() );

	/* deliver all remaining packets for EVS */
	found_hole = 0;
	for( i = Last_discarded+1; i <= Highest_seq; i++ )
	{
	    pack_entry = i & PACKET_MASK;
	    if( ! Packets[pack_entry].exist )
		Alarm( EXIT, "Discard_packets: (EVS after transitional) packet %d not exist\n", i);
	    if( Packets[pack_entry].exist == 3 )
	    {
		/* 
		 * There is a hole! 
		 * from here, we need to check if the proc_id of the packet
		 * is in commited membership. 
		 */
		found_hole = 1;
		Alarm( PROTOCOL, "Discard_packets: Found a Hole in %d \n",i);

	    }else if( (!found_hole) || 
   (Conf_id_in_conf( &Commit_membership, Packets[pack_entry].head->proc_id ) != -1) ){
		/* should deliver packet or dispose the body if it was delivered already */
		if( Packets[pack_entry].exist == 1 ){
			 Deliver_packet( pack_entry, 0 );
		}else{
			 dispose( Packets[pack_entry].body );
		}
		/* dispose packet header in any case */
		dispose( Packets[pack_entry].head );
		Alarm( PROTOCOL, "Discard_packets: delivering %d in EVS\n",i);
	    }else{
		/* should not deliver packet */
		dispose( Packets[pack_entry].head );
		dispose(   Packets[pack_entry].body );
		Alarm( PROTOCOL, "Discard_packets: Due to hole, not delivering %d \n",i);
	    }
	    Packets[pack_entry].exist = 0;
	}

	/* check up_queue and down_queue */
	if( Down_queue_ptr->num_mess > 0 )
	{
		Down_queue_ptr->cur_element = 0;
	}

	for( proc_index=0; proc_index < MAX_PROCS_RING; proc_index++ )
	{
		if( Up_queue[proc_index].exist )
		{
			if( proc_index != My_index )
			{
			    /* 
			     * dispose only packets that are not mine 
			     * my packets will stay in Down_queue if the message is not
			     * ready to be delivered (because not fully sent yet) 
			     * so we need not to dispose them! 
			     */
			    up_ptr = &Up_queue[proc_index];
			    for( i=0; i < up_ptr->mess->num_elements; i++ )
			    {
				body_ptr = (packet_body *)up_ptr->mess->elements[i].buf;
				dispose( body_ptr );
			    }
			}
			dispose( Up_queue[proc_index].mess );
			Up_queue[proc_index].exist = 0;
		}
	}

	/* calculate and deliver regular membership */
	Memb_regular();
	Log_membership();
	reg_memb_id = Memb_id();
	Sess_deliver_reg_memb( Reg_membership, reg_memb_id );

        /* If in change conf mode; then if singleton (which should be true) and GOP state then:
         * Remove partition
         * Initiate Memb_lookup() to find other daemons 
         */
        if( Conf_in_reload_singleton_state() ) {
                /* GOP state equals value 1, but is private declaration in groups.c */
                if ( (GlobalStatus.gstate != 1 ) || ( Conf_num_procs( &Reg_membership ) != 1 ) ) {
                        Alarmp( SPLOG_FATAL, MEMB, "Discard_packets: Failed to reload configuration - gstate: %d and num_procs in membership: %d\n", GlobalStatus.gstate, Conf_num_procs( &Reg_membership) );
                }
                Net_clear_partition();
                E_queue( Memb_lookup_new_members, 0, NULL, Zero_timeout);
                Conf_reload_singleton_state_end();
        }

	/* set variables for next membership */
        if ( Conf_debug_initial_sequence() ) {
            Last_token->aru	 = INITIAL_SEQUENCE_NEAR_WRAP;
            Highest_seq 	 = INITIAL_SEQUENCE_NEAR_WRAP;
            Highest_fifo_seq     = INITIAL_SEQUENCE_NEAR_WRAP;
            My_aru	    	 = INITIAL_SEQUENCE_NEAR_WRAP;
            Aru		         = INITIAL_SEQUENCE_NEAR_WRAP;
            Set_aru		 = INITIAL_SEQUENCE_NEAR_WRAP -1;
            Last_discarded	 = INITIAL_SEQUENCE_NEAR_WRAP;
            Last_delivered	 = INITIAL_SEQUENCE_NEAR_WRAP;
        } else {
            Last_token->aru	 = 0;
            Highest_seq 	 = 0;
            Highest_fifo_seq     = 0;
            My_aru	    	 = 0;
            Aru		         = 0;
            Set_aru		 = -1;
            Last_discarded	 = 0;
            Last_delivered	 = 0;
        }

	GlobalStatus.my_aru	 = My_aru;
	Token_counter 	= 0;

    }else{

	for( i = Last_discarded+1; i <= Aru; i++ )
	{
	    pack_entry = i & PACKET_MASK;
	    if( ! Packets[pack_entry].exist )
		Alarm( EXIT, "Discard_packets: (NOT EVS) packet %d not exist\n",i);

	    /* should deliver packet or dispose the body if it was delivered already */
	    if( Packets[pack_entry].exist == 1 ) Deliver_packet( pack_entry, 0 );
	    else dispose( Packets[pack_entry].body );
	    /* dispose packet header in any case */
	    dispose( Packets[pack_entry].head );
	    Packets[pack_entry].exist = 0;
	}
	Alarm( PROTOCOL, "Discard_packets: packets %d-%d were discarded\n",
			Last_discarded+1, Aru );

	Last_discarded = Aru;
	if( Last_delivered < Last_discarded ) Last_delivered = Last_discarded;
    }
}
示例#5
0
static	void	Kill_spreads()
{
	int16	Kill_partition[MAX_PROCS_RING];
	proc	p;
	int	proc_index;
	int32	proc_id;
	char	str[80];
	int	legal, ret;
	int	i, j;
	int	end;

	for( i=0; i < MAX_PROCS_RING; i++ )
		Kill_partition[i] = 0;

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

                    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++ )
                                Kill_partition[i] = -1;
                }else if( !strcmp( p.name, "none" ) ){
                        for( i=0; i < Conf_num_procs( &Cn ); i++ )
                                Kill_partition[i] = 0;
                }else{
                        proc_index = Conf_proc_by_name( p.name, &p );
                        if( proc_index != -1 ){
                                Kill_partition[proc_index] = -1;
                        }else printf("Please! enter a legal proc name, none, or all\n");
                }
        }
	for( i=0; i < Conf_num_procs( &Cn ); i++ )
	{
		if( Kill_partition[i] != -1 ) Kill_partition[i] = Partition[i];
	}
	Pack.type    = PARTITION_TYPE;
	Pack.type    = Set_endian( Pack.type );
        Pack.conf_hash = MONITOR_HASH;
	Pack.data_len= sizeof( Kill_partition );;

	Pack_scat.num_elements    = 2;
	Pack_scat.elements[1].len = sizeof( Kill_partition );
	Pack_scat.elements[1].buf = (char *)&Kill_partition;

	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 );
		if( Kill_partition[proc_index] == -1 )
		{
			Alarm( PRINT  , "Monitor: Terminating %s\n", p.name );
			DL_send( SendChan, p.id, p.port, &Pack_scat );
			DL_send( SendChan, p.id, p.port, &Pack_scat );
		}
	    }
	}
}
示例#6
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
}
示例#7
0
static	void	Define_flow_control()
{
	int32	proc_id;
	proc	p;
	int	proc_index;
	char	str[80];
	int	legal,ret,temp;
	int	i,j;

	printf("\n");
	printf("===================\n");
	printf("Define Flow Control\n");
	printf("-------------------\n");

	printf("\n");
	for( legal=0; !legal; )
	{
	    printf("    Window size: ");

	    if( fgets( str,70,stdin ) == NULL )
	    {
		printf("Bye.\n");
		exit(0);
	    }
	    ret = sscanf(str, "%d", &temp );
	    Work_fc_buf[Conf_num_procs( &Cn )][0] = temp;
	    if( ret > 0 ) legal = 1;
	    else if( ret == -1 ){
		legal = 1;
		Work_fc_buf[Conf_num_procs( &Cn )][0] = -1;
	    }else printf("Please enter a number\n");
	}
	printf("\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 );
		for( legal=0; !legal; )
		{
		    printf("\t%s personal window\t", p.name);

		    if( fgets( str, 70, stdin ) == NULL )
		    {
			printf("Bye.\n");
			exit(0);
		    }
		    ret = sscanf(str, "%d", &temp);
		    Work_fc_buf[proc_index][0] = temp;
		    if( ret > 0 ) legal = 1;
		    else if( ret == -1 ){
			legal = 1;
			Work_fc_buf[proc_index][0] = -1;
		    }else printf("Please enter a number\n");
		}

		if (Conf_get_accelerated_ring()) {

		  for( legal=0; !legal; )
		    {
		      printf("\t%s accelerated window\t", p.name);

		      if( fgets( str, 70, stdin ) == NULL )
			{
			  printf("Bye.\n");
			  exit(0);
			}
		      ret = sscanf(str, "%d", &temp);
		      Work_fc_buf[proc_index][1] = temp;
		      if( ret > 0 ) legal = 1;
		      else if( ret == -1 ){
			legal = 1;
			Work_fc_buf[proc_index][1] = -1;
		      }else printf("Please enter a number\n");
		    }
		}
	    }
	    printf("\n");
	}
}
示例#8
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;
	}
}
示例#9
0
int main( int argc, char *argv[] )
{
	int	i;
#ifdef _REENTRANT
        int     ret;
#endif
	fclose(stderr);

	Alarm_set_types( NONE ); 

	Alarmp( SPLOG_PRINT, SYSTEM, "/===========================================================================\\\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| The Spread Toolkit.                                                       |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| Copyright (c) 1993-2014 Spread Concepts LLC                               |\n"); 
	Alarmp( SPLOG_PRINT, SYSTEM, "| All rights reserved.                                                      |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| The Spread package is licensed under the Spread Open-Source License.      |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| You may only use this software in compliance with the License.            |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| A copy of the license can be found at http://www.spread.org/license       |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "| This product uses software developed by Spread Concepts LLC for use       |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "| in the Spread toolkit. For more information about Spread,                 |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "| see http://www.spread.org                                                 |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF     |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| ANY KIND, either express or implied.                                      |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| Creators:                                                                 |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|    Yair Amir             [email protected]                              |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|    Michal Miskin-Amir    [email protected]                        |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|    Jonathan Stanton      [email protected]                      |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    John Schultz          [email protected]                      |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| Contributors:                                                             |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    Amy Babay            [email protected] - accelerated ring protocol.     |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    Ryan Caudy           [email protected] - contribution to process groups.|\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    Claudiu Danilov      [email protected] - scalable, wide-area support.    |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    Cristina Nita-Rotaru [email protected] - GC security.                |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    Theo Schlossnagle    [email protected] - Perl, autoconf, old skiplist   |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|    Dan Schoenblum   [email protected] - Java Interface Developer.       |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| Special thanks to the following for discussions and ideas:                |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|    Ken Birman, Danny Dolev, Jacob Green, Mike Goodrich, Ben Laurie,       |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|    David Shaw, Gene Tsudik, Robbert VanRenesse.                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "| Partial funding provided by the Defense Advanced Research Project Agency  |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "| (DARPA) and the National Security Agency (NSA) 2000-2004. The Spread      |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "| toolkit is not necessarily endorsed by DARPA or the NSA.                  |\n");
        Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| For a full list of contributors, see Readme.txt in the distribution.      |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| WWW:     www.spread.org     www.spreadconcepts.com                        |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| Contact: [email protected]                                          |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "|                                                                           |\n");
	Alarmp( SPLOG_PRINT, SYSTEM, "| Version %d.%02d.%02d Built %-17s                                   |\n", 
		(int)SP_MAJOR_VERSION, (int)SP_MINOR_VERSION, (int)SP_PATCH_VERSION, Spread_build_date );
	Alarmp( SPLOG_PRINT, SYSTEM, "\\===========================================================================/\n");

#ifdef ARCH_PC_WIN95
        ret = WSAStartup( MAKEWORD(2,0), &WSAData );
        if( ret != 0 )
            Alarm( EXIT, "sptmonitor: main: winsock initialization error %d\n", ret );
#endif	/* ARCH_PC_WIN95 */

	Usage( argc, argv );
        
        Alarm_set_interactive();
        read_configuration();

        initialize_locks();

	for( i=0; i < Conf_num_procs( &Cn ); i++ )
		Partition[i] = 0;

	for( i=0; i < Conf_num_procs( &Cn ); i++ )
		Status_vector[i] = 0;

	Pack_scat.elements[0].len = sizeof( packet_header );
	Pack_scat.elements[0].buf = (char *)&Pack;

	Pack.proc_id = My.id;
	Pack.seq = My_port;
	Pack.memb_id.proc_id = 15051963;

	Report_scat.num_elements = 2;
	Report_scat.elements[0].buf = (char *)&Report_pack;
	Report_scat.elements[0].len = sizeof(packet_header);
	Report_scat.elements[1].buf = (char *)&GlobalStatus;
	Report_scat.elements[1].len = sizeof(status);

        SendChan = DL_init_channel( SEND_CHANNEL , My_port, 0, 0 );

        Report_socket = DL_init_channel( RECV_CHANNEL, My_port, 0, 0 );

	E_init(); /* both reentrent and non-reentrant code uses events */

#ifndef	_REENTRANT
	E_attach_fd( 0, READ_FD, User_command, 0, NULL, LOW_PRIORITY );

        E_attach_fd( Report_socket, READ_FD, Report_message, 0, NULL, HIGH_PRIORITY );
#endif	/* _REENTRANT */

        
	Print_menu();

#ifdef	_REENTRANT

#ifndef	        ARCH_PC_WIN95
	ret = pthread_create( &Read_thread, NULL, Read_thread_routine, 0 );
	ret = pthread_create( &Status_thread, NULL, Status_send_thread_routine, 0 );
	ret = pthread_create( &Partition_thread, NULL, Partition_send_thread_routine, 0 );
#else		/* ARCH_PC_WIN95 */
	Read_thread = CreateThread( NULL, 0, Read_thread_routine, NULL, 0, &ret );
	Status_thread = CreateThread( NULL, 0, Status_send_thread_routine, NULL, 0, &ret );
	Partition_thread = CreateThread( NULL, 0, Partition_send_thread_routine, NULL, 0, &ret );
#endif		/* ARCH_PC_WIN95 */

	for(;;)
	{
		User_command();
	}

#else	/*! _REENTRANT */

	E_handle_events();

#endif	/* _REENTRANT */

	return 0;
}
示例#10
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");

}