Esempio n. 1
0
bool slPath::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	return GetDatabase()->ExecuteVoid(
	           wxT("SELECT ") + GetCluster()->GetSchemaPrefix()
	           + wxT("droppath(") + NumToStr(GetSlId())
	           + wxT(", ") + NumToStr(GetNode()->GetSlId())
	           + wxT(");\n"));
}
Esempio n. 2
0
int slNode::GetIconId()
{
	if (!GetActive())
		return nodeFactory.GetDisabledIconId();
	else if (GetSlId() == GetCluster()->GetLocalNodeID())
		return nodeFactory.GetLocalIconId();
	else
		return nodeFactory.GetIconId();
}
Esempio n. 3
0
pgObject *slNode::Refresh(ctlTree *browser, const wxTreeItemId item)
{
	pgObject *node = 0;
	pgCollection *coll = browser->GetParentCollection(item);
	if (coll)
		node = nodeFactory.CreateObjects(coll, 0, wxT(" WHERE no_id=") + NumToStr(GetSlId()) + wxT("\n"));

	return node;
}
Esempio n. 4
0
pgObject *slPath::Refresh(ctlTree *browser, const wxTreeItemId item)
{
	pgObject *path = 0;
	pgCollection *coll = browser->GetParentCollection(item);
	if (coll)
		path = pathFactory.CreateObjects(coll, 0,
		                                 wxT(" WHERE pa_server=") + NumToStr(GetSlId()) +
		                                 wxT("   AND pa_client=") + NumToStr(GetNode()->GetSlId()) +
		                                 wxT("\n"));

	return path;
}
Esempio n. 5
0
wxString slSequence::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		sql = wxT("-- Register sequence ") + GetName() + wxT(" for replication.\n\n")
		      wxT("SELECT ") + GetCluster()->GetSchemaPrefix() + wxT("setaddsequence(")
		      + NumToStr(GetSet()->GetSlId()) + wxT(", ")
		      + NumToStr(GetSlId()) + wxT(", ")
		      + qtDbString(GetName()) + wxT(", ")
		      + qtDbString(GetComment()) + wxT(");\n");
	}
	return sql;
}
Esempio n. 6
0
pgObject *slListen::Refresh(ctlTree *browser, const wxTreeItemId item)
{
	pgObject *listen = 0;
	pgCollection *coll = browser->GetParentCollection(item);
	if (coll)
		listen = listenFactory.CreateObjects(coll, 0,
		                                     wxT(" WHERE li_origin =") + NumToStr(GetSlId()) +
		                                     wxT("   AND li_provider = ") + NumToStr(GetProviderId()) +
		                                     wxT("   AND li_receiver = ") + NumToStr(GetNode()->GetSlId()) +
		                                     wxT("\n"));

	return listen;
}
Esempio n. 7
0
wxString slPath::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		sql = wxT("-- Register path to node ") + GetName() + wxT(".\n\n")
		      wxT("SELECT ") + GetCluster()->GetSchemaPrefix()
		      + wxT("storepath(") + NumToStr(GetSlId())
		      + wxT(", ") + NumToStr(GetNode()->GetSlId())
		      + wxT(", ") + qtDbString(GetConnInfo())
		      + wxT(", ") + NumToStr(GetConnRetry())
		      + wxT(");\n");
	}
	return sql;
}
Esempio n. 8
0
wxString slNode::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		sql = wxT("-- Create replication node ") + GetName() + wxT(".\n\n")
		      wxT("SELECT ") + GetCluster()->GetSchemaPrefix() + wxT("storenode(")
		      + NumToStr(GetSlId()) + wxT(", ")
		      + qtDbString(GetComment());

		if (GetCluster()->ClusterMinimumVersion(1, 1) && !GetCluster()->ClusterMinimumVersion(2, 0))
			sql += wxT(", ") + BoolToStr(GetSpool());
		sql += wxT(");\n");
	}
	return sql;
}
Esempio n. 9
0
wxString slListen::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		sql = wxT("-- Node  will listen to ") + GetProviderName()
		      + wxT(" for replication data from ") + GetOriginName() + wxT(".\n\n")

		      wxT("SELECT ") + GetCluster()->GetSchemaPrefix()
		      + wxT("storelisten(") + NumToStr(GetSlId())
		      + wxT(", ") + NumToStr(GetProviderId())
		      + wxT(", ") + NumToStr(GetNode()->GetSlId())
		      + wxT(");\n");
	}
	return sql;
}
Esempio n. 10
0
void slSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;

		browser->RemoveDummyChild(this);
	}


	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("ID"), GetSlId());
		properties->AppendYesNoItem(_("Active"), GetActive());
	}
}
Esempio n. 11
0
void slListen::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;

		browser->RemoveDummyChild(this);
	}


	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Origin"), GetOriginName());
		properties->AppendItem(_("Origin ID"), GetSlId());
		properties->AppendItem(_("Provider"), GetProviderName());
		properties->AppendItem(_("Provider ID"), GetProviderId());
	}
}
Esempio n. 12
0
void slPath::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;

		browser->RemoveDummyChild(this);
	}


	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Server name"), GetName().BeforeFirst('\n'));
		properties->AppendItem(_("Server ID"), GetSlId());
		properties->AppendItem(_("Connect info"), GetConnInfo());
		properties->AppendItem(_("Retry"), GetConnRetry());
	}
}
Esempio n. 13
0
bool slNode::CanDrop()
{
	return (GetSlId() != GetCluster()->GetLocalNodeID());
}
Esempio n. 14
0
pgObject *slSequence::Refresh(ctlTree *browser, const wxTreeItemId item)
{
	pgObject *sequence = 0;
	pgCollection *coll = browser->GetParentCollection(item);
	if (coll)
		sequence = slSequenceFactory.CreateObjects(coll, 0, wxT(" WHERE seq_id=") + NumToStr(GetSlId()) + wxT("\n"));

	return sequence;
}
Esempio n. 15
0
void slNode::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	wxString pidcol = wxEmptyString;
	pgConn *conn = GetCluster()->GetNodeConn(form, GetSlId(), pid < 0);

	if (!expandedKids)
	{
		expandedKids = true;

		browser->RemoveDummyChild(this);
		// Log
		wxLogInfo(wxT("Adding child object to node %s"), GetIdentifier().c_str());

		browser->AppendCollection(this, pathFactory);
		browser->AppendCollection(this, listenFactory);
	}


	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("ID"), GetSlId());
		if (GetCluster()->GetLocalNodeID() == GetSlId())
			properties->AppendYesNoItem(_("Local node"), true);
		properties->AppendYesNoItem(_("Active"), GetActive());
		if (GetCluster()->ClusterMinimumVersion(1, 1))
			properties->AppendYesNoItem(_("Log spooler"), GetSpool());
		properties->AppendYesNoItem(_("Connected"), conn != NULL);
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		if (conn && pid < 0)
		{
			if (conn->BackendMinimumVersion(9, 0))
			{
				if (conn->BackendMinimumVersion(9, 2))
					pidcol = wxT("pid");
				else
					pidcol = wxT("procpid");

				pid = StrToLong(conn->ExecuteScalar(
				                    wxT("SELECT nl_backendpid FROM ") + qtIdent(wxT("_") + GetCluster()->GetName()) + wxT(".sl_nodelock nl, ")
				                    wxT("pg_stat_activity sa WHERE nl.nl_backendpid = sa.") + pidcol + wxT(" AND nl_nodeid = ")
				                    + NumToStr(GetCluster()->GetLocalNodeID())));
			}
			else
			{
				pid = StrToLong(conn->ExecuteScalar(
				                    wxT("SELECT listenerpid FROM pg_listener WHERE relname=") + qtDbString(wxT("_") + GetCluster()->GetName() + wxT("_Restart"))));
			}
		}

		if (conn)
		{
			if (GetPid())
				properties->AppendItem(_("Running PID"), GetPid());
			else
				properties->AppendItem(_("Running PID"), _("not running"));
		}
		else
		{
			if (GetSlId() != GetCluster()->GetAdminNodeID())
				properties->AppendItem(_("Running PID"), _("administrative node"));
		}
	}
}
Esempio n. 16
0
bool slSequence::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	return GetDatabase()->ExecuteVoid(
	           wxT("SELECT ") + GetCluster()->GetSchemaPrefix()
	           + wxT("setdropsequence(") + NumToStr(GetSlId()) + wxT(");\n"));
}
Esempio n. 17
0
void slNode::ShowStatistics(frmMain *form, ctlListView *statistics)
{
	CreateListColumns(statistics, _("Statistic"), _("Value"));

	if (GetActive())
	{
		if (GetCluster()->GetLocalNodeID() == GetSlId())
		{
			pgSet *stats = GetDatabase()->ExecuteSet(
			                   wxT("SELECT st_last_event,\n")
			                   wxT("       MAX(st_last_received_ts - st_last_received_event_ts) AS roundtrip,\n")
			                   wxT("       SUM(st_lag_num_events) AS sumlagevents, st_last_event - MAX(st_lag_num_events) as oldestlagevent,\n")
			                   wxT("       MAX(st_last_event_ts - st_last_received_ts) AS maxeventlag\n")
			                   wxT("  FROM ") + GetCluster()->GetSchemaPrefix() + wxT("sl_status\n")
			                   wxT(" WHERE st_origin = ") + NumToStr(GetCluster()->GetLocalNodeID()) + wxT("\n")
			                   wxT("  GROUP BY st_last_event"));

			if (stats)
			{
				wxString roundtrip = stats->GetVal(wxT("roundtrip"));
				long lags = stats->GetLong(wxT("sumlagevents"));
				if (roundtrip.Left(6) == wxT("00:00:"))
					roundtrip = NumToStr(StrToLong(roundtrip.Mid(6))) + roundtrip.Mid(8) + wxT(" s");
				else if (roundtrip.Left(3) == wxT("00:"))
					roundtrip =  NumToStr(StrToLong(roundtrip.Mid(3))) + roundtrip.Mid(5);

				statistics->AppendItem(_("Last event"), stats->GetLong(wxT("st_last_event")));
				statistics->AppendItem(_("Max response time"), roundtrip);
				statistics->AppendItem(_("Acks outstanding"), lags);


				if (lags > 0)
				{
					long lagEvent = stats->GetLong(wxT("oldestlagevent"));
					statistics->AppendItem(_("Oldest outstanding"), lagEvent);
					statistics->AppendItem(_("Outstanding for"), stats->GetVal(wxT("maxeventlag")));
				}

				delete stats;
			}
		}
		else
		{
			pgSet *stats = GetDatabase()->ExecuteSet(
			                   wxT("SELECT st_last_event, st_last_event_ts, st_last_received, st_last_received_ts,\n")
			                   wxT("       st_last_received_ts - st_last_received_event_ts AS roundtrip,\n")
			                   wxT("       st_last_event_ts - st_last_received_ts AS eventlag,")
			                   wxT("       ev_seqno, ev_type || ' ' || COALESCE(ev_data1, '') AS hanging\n")
			                   wxT("  FROM ") + GetCluster()->GetSchemaPrefix() + wxT("sl_status\n")
			                   wxT("  LEFT JOIN ") + GetCluster()->GetSchemaPrefix() + wxT("sl_event ON ev_origin=st_origin AND ev_seqno=\n")
			                   wxT("         (SELECT MIN(ev_seqno) FROM ") + GetCluster()->GetSchemaPrefix() + wxT("sl_event WHERE ev_seqno > st_last_received)\n")
			                   wxT(" WHERE st_origin = ") + NumToStr(GetCluster()->GetLocalNodeID()) + wxT("\n")
			                   wxT("   AND st_received = ") + NumToStr(GetSlId()));

			if (stats)
			{
				long evno = stats->GetLong(wxT("st_last_event"));
				long ack = stats->GetLong(wxT("st_last_received"));
				wxString roundtrip = stats->GetVal(wxT("roundtrip"));
				if (roundtrip.Left(6) == wxT("00:00:"))
					roundtrip = NumToStr(StrToLong(roundtrip.Mid(6))) + roundtrip.Mid(8) + wxT(" s");
				else if (roundtrip.Left(3) == wxT("00:"))
					roundtrip =  NumToStr(StrToLong(roundtrip.Mid(3))) + roundtrip.Mid(5);

				statistics->AppendItem(_("Last event"), evno);
				statistics->AppendItem(_("Last event timestamp"), stats->GetDateTime(wxT("st_last_event_ts")));
				statistics->AppendItem(_("Last acknowledged"), ack);
				statistics->AppendItem(_("Last ack timestamp"), stats->GetDateTime(wxT("st_last_received_ts")));
				statistics->AppendItem(_("Last response time"), roundtrip);

				if (evno > ack)
				{
					statistics->AppendItem(_("Outstanding acks"), evno - ack);
					statistics->AppendItem(_("No ack for"), stats->GetVal(wxT("eventlag")));
					statistics->AppendItem(_("Hanging event"), stats->GetVal(wxT("ev_seqno")));
					statistics->AppendItem(_("Command"), stats->GetVal(wxT("hanging")));
				}

				delete stats;
			}
		}
	}
	else
		statistics->AppendItem(_("not active"), wxEmptyString);
}