Jump to content

IG onSlaveConnected callback never called


photo

Recommended Posts

Hello, 2.13.1.1 here and I try to have a callback called when a slave is connected.

So I use this code in the init of a SystemLogic module:

int MySystemLogic::init()
{
	auto ig = IG::Manager::get();
	ig->addOnSlaveConnectedCallback(this, MakeCallback(this, &MySystemLogic::onSlaveConnected)); //< This callback is never called
	return 1;
}

But the callback is never called.

Instead, if I use the Syncker directly then its callback is correctly called:

int MySystemLogic::init() 
{
	auto ig = IG::Manager::get();
	if (ig->isMaster())
		ig->getSynckerMaster()->addCallback(Syncker::Master::SLAVE_CONNECTED, MakeCallback(this, &MySystemLogic::onSynckerSlaveConnected));
	// now the callback is correctly called when a slave is connected
	return 1;
}

What am I missing?

 

Edit: How can I know when the slave is fully ready? (because apparently the Syncker "slave connected" callback is called *before* the manager send the full state to the slave, so my callback is useless as the moment)

Edited by Amerio.Stephane
Link to comment
1 hour ago, Amerio.Stephane said:

But the callback is never called.

Instead, if I use the Syncker directly then its callback is correctly called:

its strange behavior, because IG::onSlaveConnected called directly from Master::SLAVE_CONNECTED callback
 

// IGManager
void Manager::init()
{
//...
syncker_master->addCallback(Plugins::Syncker::Master::SLAVE_CONNECTED, MakeCallback(this, &Manager::on_slave_connect));
syncker_master->addCallback(Plugins::Syncker::Master::SLAVE_DISCONNECTED, MakeCallback(this, &Manager::on_slave_disconnect));
syncker_master->addCallback(Plugins::Syncker::Master::SESSION_CONTINUED, MakeCallback(this, &Manager::on_session_continued));
//...
}
//...
void Manager::on_slave_connect(int index)
{
	String view = getSlaveName(index);
	if (ig_ready)
		extra_slaves.append(view);

	RUN_CALLBACKS(SlaveConnected, index, view.get()); // {for (auto &callback :  OnSlaveConnecedCallbacks) callback.data->run(__VA_ARGS__);}
}

 

full state sent to the slave in Master::SESSION_CONTINUED callback for the new extra_slave (connected after session start)

void Manager::on_session_continued()
{
	// create and send full state to each slave (including existing)
	BlobPtr blob = Blob::create();
	saveState(blob);
	net.send(FULL_STATE, database_id, uint64_t(blob->getSize()), &blob);
	Log::message("%s(): sent full state to slaves (%d bytes)\n", __IFUNC__, blob->getSize());

	// set view to new extraslave
	for (int i = 0; i < extra_slaves.size(); i++)
	{
		String &view = extra_slaves[i];
		setSlaveView(view, slave_views.contains(view) ? slave_views[view] : current_view_id);
	}

	// clear queue
	extra_slaves.clear();
}

you can also subscribe to this callback - it will be called after the IG callback.


I will try to check what is happening with the callbacks, but only next week - we all in preparing release 2.15

Link to comment
×
×
  • Create New...