提交 22a1d7eb 编写于 作者: X Xin Zhang 提交者: Xin Zhang

Add #define macros for gp_segment_configuration

Signed-off-by: NAshwin Agrawal <aagrawal@pivotal.io>
上级 ebac7aaa
......@@ -1093,7 +1093,7 @@ master_standby_dbid(void)
/*
* SELECT * FROM gp_segment_configuration
* WHERE content = -1 AND role = 'm'
* WHERE content = -1 AND role = GP_SEGMENT_CONFIGURATION_ROLE_MIRROR
*/
rel = heap_open(GpSegmentConfigRelationId, AccessShareLock);
ScanKeyInit(&scankey[0],
......@@ -1103,7 +1103,7 @@ master_standby_dbid(void)
ScanKeyInit(&scankey[1],
Anum_gp_segment_configuration_role,
BTEqualStrategyNumber, F_CHAREQ,
CharGetDatum('m'));
CharGetDatum(GP_SEGMENT_CONFIGURATION_ROLE_MIRROR));
/* no index */
scan = systable_beginscan(rel, InvalidOid, false,
SnapshotNow, 2, scankey);
......
......@@ -407,13 +407,13 @@ readCdbComponentInfoAndUpdateStatus(MemoryContext probeContext)
if (SEGMENT_IS_ACTIVE_PRIMARY(segInfo))
segStatus |= FTS_STATUS_PRIMARY;
if (segInfo->preferred_role == 'p')
if (segInfo->preferred_role == GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY)
segStatus |= FTS_STATUS_DEFINEDPRIMARY;
if (segInfo->mode == 's')
if (segInfo->mode == GP_SEGMENT_CONFIGURATION_MODE_INSYNC)
segStatus |= FTS_STATUS_SYNCHRONIZED;
if (segInfo->mode == 'c')
if (segInfo->mode == GP_SEGMENT_CONFIGURATION_MODE_CHANGETRACKING)
segStatus |= FTS_STATUS_CHANGELOGGING;
ftsProbeInfo->fts_status[segInfo->dbid] = segStatus;
......@@ -855,7 +855,7 @@ probeUpdateConfig(FtsSegmentStatusChange *changes, int changeCount)
"FTS: content %d fault marking status %s%s role %c",
change->segindex, valid ? "UP" : "DOWN",
(changelogging) ? " mode: change-tracking" : "",
primary ? 'p' : 'm');
primary ? GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY : GP_SEGMENT_CONFIGURATION_ROLE_MIRROR);
histvals[Anum_gp_configuration_history_desc-1] =
CStringGetTextDatum(desc);
......@@ -879,15 +879,15 @@ probeUpdateConfig(FtsSegmentStatusChange *changes, int changeCount)
RelationGetRelationName(configrel));
}
configvals[Anum_gp_segment_configuration_role-1] =
CharGetDatum(primary ? 'p' : 'm');
CharGetDatum(primary ? GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY : GP_SEGMENT_CONFIGURATION_ROLE_MIRROR);
repls[Anum_gp_segment_configuration_role-1] = true;
configvals[Anum_gp_segment_configuration_status-1] =
CharGetDatum(valid ? 'u' : 'd');
CharGetDatum(valid ? GP_SEGMENT_CONFIGURATION_STATUS_UP : GP_SEGMENT_CONFIGURATION_STATUS_DOWN);
repls[Anum_gp_segment_configuration_status-1] = true;
if (changelogging)
{
configvals[Anum_gp_segment_configuration_mode-1] =
CharGetDatum('c');
CharGetDatum(GP_SEGMENT_CONFIGURATION_MODE_CHANGETRACKING);
}
repls[Anum_gp_segment_configuration_mode-1] = changelogging;
......@@ -958,10 +958,10 @@ FtsDumpChanges(FtsSegmentStatusChange *changes, int changeEntries)
elog(LOG, "FTS: change state for segment (dbid=%d, content=%d) from ('%c','%c') to ('%c','%c')",
changes[i].dbid,
changes[i].segindex,
(old_alive ? 'u' : 'd'),
(old_pri ? 'p' : 'm'),
(new_alive ? 'u' : 'd'),
(new_pri ? 'p' : 'm'));
(old_alive ? GP_SEGMENT_CONFIGURATION_STATUS_UP : GP_SEGMENT_CONFIGURATION_STATUS_DOWN),
(old_pri ? GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY : GP_SEGMENT_CONFIGURATION_ROLE_MIRROR),
(new_alive ? GP_SEGMENT_CONFIGURATION_STATUS_UP : GP_SEGMENT_CONFIGURATION_STATUS_DOWN),
(new_pri ? GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY : GP_SEGMENT_CONFIGURATION_ROLE_MIRROR));
}
}
......@@ -1038,7 +1038,7 @@ FtsMarkSegmentsInSync(CdbComponentDatabaseInfo *primary, CdbComponentDatabaseInf
elog(ERROR,"FTS cannot find dbid (%d, %d) in %s", primary->dbid,
mirror->dbid, RelationGetRelationName(configrel));
}
configvals[Anum_gp_segment_configuration_mode-1] = CharGetDatum('s');
configvals[Anum_gp_segment_configuration_mode-1] = CharGetDatum(GP_SEGMENT_CONFIGURATION_MODE_INSYNC);
repls[Anum_gp_segment_configuration_mode-1] = true;
newtuple = heap_modify_tuple(configtuple, RelationGetDescr(configrel),
configvals, confignulls, repls);
......
......@@ -760,8 +760,8 @@ gp_add_segment(PG_FUNCTION_ARGS)
new.db.address = address;
new.db.port = port;
new.db.filerep_port = -1;
new.db.mode = 's';
new.db.status = 'u';
new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_INSYNC;
new.db.status = GP_SEGMENT_CONFIGURATION_STATUS_UP;
new.db.role = SEGMENT_ROLE_PRIMARY;
new.db.preferred_role = SEGMENT_ROLE_PRIMARY;
......@@ -885,8 +885,8 @@ gp_add_segment_mirror(PG_FUNCTION_ARGS)
new.db.address = address;
new.db.port = port;
new.db.filerep_port = rep_port;
new.db.mode = 's';
new.db.status = 'u';
new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_INSYNC;
new.db.status = GP_SEGMENT_CONFIGURATION_STATUS_UP;
new.db.role = SEGMENT_ROLE_MIRROR;
new.db.preferred_role = preferredPrimaryDbId == 0 ? SEGMENT_ROLE_PRIMARY : SEGMENT_ROLE_MIRROR;
......@@ -999,7 +999,7 @@ gp_add_master_standby(PG_FUNCTION_ARGS)
/*
* Don't reference GpIdentity.dbid, as it is legitimate to set -1
* for -b option in utility mode. Content ID = -1 AND role = 'p' is
* for -b option in utility mode. Content ID = -1 AND role = GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY is
* the definition of primary master.
*/
master_dbid = contentid_get_dbid(MASTER_CONTENT_ID,
......@@ -1010,8 +1010,8 @@ gp_add_master_standby(PG_FUNCTION_ARGS)
new.db.dbid = maxdbid + 1;
new.db.role = SEGMENT_ROLE_MIRROR;
new.db.preferred_role = SEGMENT_ROLE_MIRROR;
new.db.mode = 's';
new.db.status = 'u';
new.db.mode = GP_SEGMENT_CONFIGURATION_MODE_INSYNC;
new.db.status = GP_SEGMENT_CONFIGURATION_STATUS_UP;
new.db.hostname = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(PG_GETARG_TEXT_P(0))));
......
......@@ -26,6 +26,19 @@
#define MASTER_CONTENT_ID (-1)
#define InvalidDbid 0
#define GP_SEGMENT_CONFIGURATION_ROLE_PRIMARY 'p'
#define GP_SEGMENT_CONFIGURATION_ROLE_MIRROR 'm'
#define GP_SEGMENT_CONFIGURATION_STATUS_UP 'u'
#define GP_SEGMENT_CONFIGURATION_STATUS_DOWN 'd'
#define GP_SEGMENT_CONFIGURATION_MODE_INSYNC 's'
#define GP_SEGMENT_CONFIGURATION_MODE_NOTINSYNC 'n'
#define GP_SEGMENT_CONFIGURATION_MODE_CHANGETRACKING 'c'
#define GP_SEGMENT_CONFIGURATION_MODE_RESYNC 'r'
/* ----------------
* gp_segment_configuration definition. cpp turns this into
* typedef struct FormData_gp_segment_configuration
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册