• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ endpoint::Ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中endpoint::Ptr的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SyncClient

void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint)
{
	try {
		{
			ObjectLock olock(endpoint);

			endpoint->SetSyncing(true);
		}

		Log(LogInformation, "ApiListener")
		    << "Sending updates for endpoint '" << endpoint->GetName() << "'.";

		/* sync zone file config */
		SendConfigUpdate(aclient);
		/* sync runtime config */
		SendRuntimeConfigObjects(aclient);

		Log(LogInformation, "ApiListener")
		    << "Finished sending updates for endpoint '" << endpoint->GetName() << "'.";

		ReplayLog(aclient);
	} catch (const std::exception& ex) {
		Log(LogCritical, "ApiListener")
		    << "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
	}
}
开发者ID:Thomas-Gelf,项目名称:icinga2,代码行数:26,代码来源:apilistener.cpp


示例2: Dictionary

	BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
		if (!endpoint->GetConnected())
			continue;

		double ts = endpoint->GetRemoteLogPosition();

		if (ts == 0)
			continue;

		Dictionary::Ptr lparams = new Dictionary();
		lparams->Set("log_position", ts);

		Dictionary::Ptr lmessage = new Dictionary();
		lmessage->Set("jsonrpc", "2.0");
		lmessage->Set("method", "log::SetLogPosition");
		lmessage->Set("params", lparams);

		double maxTs = 0;

		BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
			if (client->GetTimestamp() > maxTs)
				maxTs = client->GetTimestamp();
		}

		BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
			if (client->GetTimestamp() != maxTs)
				client->Disconnect();
			else
				client->SendMessage(lmessage);
		}

		Log(LogNotice, "ApiListener")
		    << "Setting log position for identity '" << endpoint->GetName() << "': "
		    << Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", ts);
	}
开发者ID:ajoaugustine,项目名称:icinga2-cipher_list,代码行数:35,代码来源:apilistener.cpp


示例3: OnAllConfigLoaded

void Zone::OnAllConfigLoaded()
{
	ObjectImpl<Zone>::OnAllConfigLoaded();

	m_Parent = Zone::GetByName(GetParentRaw());

	if (m_Parent && m_Parent->IsGlobal())
		BOOST_THROW_EXCEPTION(ScriptError("Zone '" + GetName() + "' can not have a global zone as parent.", GetDebugInfo()));

	Zone::Ptr zone = m_Parent;
	int levels = 0;

	Array::Ptr endpoints = GetEndpointsRaw();

	if (endpoints) {
		ObjectLock olock(endpoints);
		for (const String& endpoint : endpoints) {
			Endpoint::Ptr ep = Endpoint::GetByName(endpoint);

			if (ep)
				ep->SetCachedZone(this);
		}
	}

	while (zone) {
		m_AllParents.push_back(zone);

		zone = Zone::GetByName(zone->GetParentRaw());
		levels++;

		if (levels > 32)
			BOOST_THROW_EXCEPTION(ScriptError("Infinite recursion detected while resolving zone graph. Check your zone hierarchy.", GetDebugInfo()));
	}
}
开发者ID:bebehei,项目名称:icinga2,代码行数:34,代码来源:zone.cpp


示例4: IdentityAccessor

Value EndpointsTable::IdentityAccessor(const Value& row)
{
	Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row);

	if (!endpoint)
		return Empty;

	return endpoint->GetName();
}
开发者ID:andrewmeyer,项目名称:icinga2,代码行数:9,代码来源:endpointstable.cpp


示例5: IsMaster

bool ApiListener::IsMaster(void) const
{
	Endpoint::Ptr master = GetMaster();

	if (!master)
		return false;

	return master->GetName() == GetIdentity();
}
开发者ID:jsabari,项目名称:icinga2,代码行数:9,代码来源:apilistener.cpp


示例6: GetLocalZone

Zone::Ptr Zone::GetLocalZone()
{
	Endpoint::Ptr local = Endpoint::GetLocalEndpoint();

	if (!local)
		return nullptr;

	return local->GetZone();
}
开发者ID:bebehei,项目名称:icinga2,代码行数:9,代码来源:zone.cpp


示例7: GetLocalZone

Zone::Ptr Zone::GetLocalZone(void)
{
	Endpoint::Ptr local = Endpoint::GetLocalEndpoint();

	if (!local)
		return Zone::Ptr();

	return local->GetZone();
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:9,代码来源:zone.cpp


示例8: EndpointIsConnected

int EndpointDbObject::EndpointIsConnected(const Endpoint::Ptr& endpoint)
{
    unsigned int is_connected = endpoint->IsConnected() ? 1 : 0;

    /* if identity is equal to node, fake is_connected */
    if (endpoint->GetName() == IcingaApplication::GetInstance()->GetNodeName())
        is_connected = 1;

    return is_connected;
}
开发者ID:hudayou,项目名称:icinga2,代码行数:10,代码来源:endpointdbobject.cpp


示例9: CalculateZoneLag

double ApiListener::CalculateZoneLag(const Endpoint::Ptr& endpoint)
{
	double remoteLogPosition = endpoint->GetRemoteLogPosition();
	double eplag = Utility::GetTime() - remoteLogPosition;

	if ((endpoint->GetSyncing() || !endpoint->GetConnected()) && remoteLogPosition != 0)
		return eplag;

	return 0;
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:10,代码来源:apilistener.cpp


示例10: GetConfigFields

Dictionary::Ptr EndpointDbObject::GetConfigFields(void) const
{
    Dictionary::Ptr fields = new Dictionary();
    Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(GetObject());

    fields->Set("identity", endpoint->GetName());
    fields->Set("node", IcingaApplication::GetInstance()->GetNodeName());

    return fields;
}
开发者ID:hudayou,项目名称:icinga2,代码行数:10,代码来源:endpointdbobject.cpp


示例11: GetStatusFields

Dictionary::Ptr EndpointDbObject::GetStatusFields(void) const
{
	Dictionary::Ptr fields = make_shared<Dictionary>();
	Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(GetObject());

	Log(LogDebug, "EndpointDbObject", "update status for endpoint '" + endpoint->GetName() + "'");

	fields->Set("identity", endpoint->GetName());
	fields->Set("node", IcingaApplication::GetInstance()->GetNodeName());
	fields->Set("is_connected", EndpointIsConnected(endpoint));

	return fields;
}
开发者ID:3v,项目名称:icinga2,代码行数:13,代码来源:endpointdbobject.cpp


示例12: ZoneAccessor

Value EndpointsTable::ZoneAccessor(const Value& row)
{
	Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row);

	if (!endpoint)
		return Empty;

	Zone::Ptr zone = endpoint->GetZone();

	if (!zone)
		return Empty;

	return zone->GetName();
}
开发者ID:zijam,项目名称:icinga2,代码行数:14,代码来源:endpointstable.cpp


示例13: GetMetric

int ClusterLink::GetMetric(void) const
{
	int metric = 0;

	Endpoint::Ptr fromEp = Endpoint::GetByName(From);
	if (fromEp)
		metric += fromEp->GetMetric();

	Endpoint::Ptr toEp = Endpoint::GetByName(To);
	if (toEp)
		metric += toEp->GetMetric();

	return metric;
}
开发者ID:nv1r,项目名称:icinga2,代码行数:14,代码来源:clusterlink.cpp


示例14: IsConnectedAccessor

Value EndpointsTable::IsConnectedAccessor(const Value& row)
{
	Endpoint::Ptr endpoint = static_cast<Endpoint::Ptr>(row);

	if (!endpoint)
		return Empty;

	unsigned int is_connected = endpoint->IsConnected() ? 1 : 0;

	/* if identity is equal to node, fake is_connected */
	if (endpoint->GetName() == IcingaApplication::GetInstance()->GetNodeName())
		is_connected = 1;

	return is_connected;
}
开发者ID:andrewmeyer,项目名称:icinga2,代码行数:15,代码来源:endpointstable.cpp


示例15: SetLogPositionHandler

Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
	if (!params)
		return Empty;

	double log_position = params->Get("log_position");
	Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();

	if (!endpoint)
		return Empty;

	if (log_position > endpoint->GetLocalLogPosition())
		endpoint->SetLocalLogPosition(log_position);

	return Empty;
}
开发者ID:Freeaqingme,项目名称:icinga2,代码行数:16,代码来源:apiclient.cpp


示例16: SendConfigUpdate

void ApiListener::SendConfigUpdate(const JsonRpcConnection::Ptr& aclient)
{
	Endpoint::Ptr endpoint = aclient->GetEndpoint();
	ASSERT(endpoint);

	Zone::Ptr azone = endpoint->GetZone();
	Zone::Ptr lzone = Zone::GetLocalZone();

	/* don't try to send config updates to our master */
	if (!azone->IsChildOf(lzone))
		return;

	Dictionary::Ptr configUpdateV1 = new Dictionary();
	Dictionary::Ptr configUpdateV2 = new Dictionary();

	String zonesDir = Configuration::DataDir + "/api/zones";

	for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
		String zoneDir = zonesDir + "/" + zone->GetName();

		if (!zone->IsChildOf(azone) && !zone->IsGlobal())
			continue;

		if (!Utility::PathExists(zoneDir))
			continue;

		Log(LogInformation, "ApiListener")
			<< "Syncing configuration files for " << (zone->IsGlobal() ? "global " : "")
			<< "zone '" << zone->GetName() << "' to endpoint '" << endpoint->GetName() << "'.";

		ConfigDirInformation config = LoadConfigDir(zonesDir + "/" + zone->GetName());
		configUpdateV1->Set(zone->GetName(), config.UpdateV1);
		configUpdateV2->Set(zone->GetName(), config.UpdateV2);
	}

	Dictionary::Ptr message = new Dictionary({
		{ "jsonrpc", "2.0" },
		{ "method", "config::Update" },
		{ "params", new Dictionary({
			{ "update", configUpdateV1 },
			{ "update_v2", configUpdateV2 }
		}) }
	});

	aclient->SendMessage(message);
}
开发者ID:bebehei,项目名称:icinga2,代码行数:46,代码来源:apilistener-filesync.cpp


示例17: SyncClient

void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint, bool needSync)
{
	try {
		{
			ObjectLock olock(endpoint);

			endpoint->SetSyncing(true);
		}

		/* Make sure that the config updates are synced
		 * before the logs are replayed.
		 */

		Log(LogInformation, "ApiListener")
		    << "Sending config updates for endpoint '" << endpoint->GetName() << "'.";

		/* sync zone file config */
		SendConfigUpdate(aclient);
		/* sync runtime config */
		SendRuntimeConfigObjects(aclient);

		Log(LogInformation, "ApiListener")
		    << "Finished sending config updates for endpoint '" << endpoint->GetName() << "'.";

		if (!needSync) {
			ObjectLock olock2(endpoint);
			endpoint->SetSyncing(false);
			return;
		}

		Log(LogInformation, "ApiListener")
		    << "Sending replay log for endpoint '" << endpoint->GetName() << "'.";

		ReplayLog(aclient);

		if (endpoint->GetZone() == Zone::GetLocalZone())
			UpdateObjectAuthority();

		Log(LogInformation, "ApiListener")
		    << "Finished sending replay log for endpoint '" << endpoint->GetName() << "'.";
	} catch (const std::exception& ex) {
		ObjectLock olock2(endpoint);
		endpoint->SetSyncing(false);

		Log(LogCritical, "ApiListener")
		    << "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
	}
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:48,代码来源:apilistener.cpp


示例18: OnConfigUpdate

void EndpointDbObject::OnConfigUpdate(void)
{
	/* update current status on config dump once */
	Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(GetObject());

	DbQuery query1;
	query1.Table = "endpointstatus";
	query1.Type = DbQueryInsert;

	Dictionary::Ptr fields1 = make_shared<Dictionary>();
	fields1->Set("identity", endpoint->GetName());
	fields1->Set("node", IcingaApplication::GetInstance()->GetNodeName());
	fields1->Set("is_connected", EndpointIsConnected(endpoint));
	fields1->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
	fields1->Set("endpoint_object_id", endpoint);
	fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
	query1.Fields = fields1;

	OnQuery(query1);
}
开发者ID:3v,项目名称:icinga2,代码行数:20,代码来源:endpointdbobject.cpp


示例19: OnAllConfigLoaded

void Checkable::OnAllConfigLoaded(void)
{
	ObjectImpl<Checkable>::OnAllConfigLoaded();

	Endpoint::Ptr endpoint = GetCommandEndpoint();

	if (endpoint) {
		Zone::Ptr checkableZone = static_pointer_cast<Zone>(GetZone());

		if (!checkableZone)
			checkableZone = Zone::GetLocalZone();

		Zone::Ptr cmdZone = endpoint->GetZone();

		if (checkableZone && cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
			BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("command_endpoint"),
			    "Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof."));
		}
	}
}
开发者ID:leeclemens,项目名称:icinga2,代码行数:20,代码来源:checkable.cpp


示例20: OnAllConfigLoaded

void Checkable::OnAllConfigLoaded()
{
	ObjectImpl<Checkable>::OnAllConfigLoaded();

	Endpoint::Ptr endpoint = GetCommandEndpoint();

	if (endpoint) {
		Zone::Ptr checkableZone = static_pointer_cast<Zone>(GetZone());

		if (checkableZone) {
			Zone::Ptr cmdZone = endpoint->GetZone();

			if (cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
				BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
					"Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof."));
			}
		} else {
			BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
				"Command endpoint must not be set."));
		}
	}
}
开发者ID:Icinga,项目名称:icinga2,代码行数:22,代码来源:checkable.cpp



注:本文中的endpoint::Ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ entrylist::Iter类代码示例发布时间:2022-05-31
下一篇:
C++ elevationlayervector::iterator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap