MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / getReplicator

Function getReplicator

src/jrd/replication/Publisher.cpp:97–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95 }
96
97 IReplicatedSession* getReplicator(thread_db* tdbb)
98 {
99 const auto attachment = tdbb->getAttachment();
100
101 // Disable replication for system attachments
102
103 if (attachment->isSystem())
104 return nullptr;
105
106 // Check whether replication is allowed for this session
107
108 if (!(attachment->att_flags & ATT_replicating))
109 return nullptr;
110
111 // Check whether replication is configured and enabled for this database
112
113 const auto dbb = tdbb->getDatabase();
114 if (!dbb->isReplicating(tdbb))
115 {
116 attachment->att_flags &= ~ATT_replicating;
117 attachment->att_replicator = nullptr;
118 return nullptr;
119 }
120
121 const auto config = dbb->replConfig();
122 fb_assert(config);
123
124 // Create a replicator object, unless it already exists
125
126 if (!attachment->att_replicator)
127 {
128 if (config->pluginName.empty())
129 {
130 auto& pool = *attachment->att_pool;
131 const auto manager = dbb->replManager(true);
132 const auto& guid = dbb->dbb_guid;
133 const auto& userName = attachment->getUserName();
134
135 attachment->att_replicator = FB_NEW Replicator(pool, manager, guid, userName);
136 }
137 else
138 {
139 GetPlugins<IReplicatedSession> plugins(IPluginManager::TYPE_REPLICATOR,
140 config->pluginName.c_str());
141 if (!plugins.hasData())
142 {
143 string msg;
144 msg.printf(NO_PLUGIN_ERROR, config->pluginName.c_str());
145 logPrimaryError(dbb->dbb_filename, msg);
146
147 return nullptr;
148 }
149
150 attachment->att_replicator = plugins.plugin();
151 }
152
153 FbLocalStatus status;
154 const bool replicating =

Callers 6

REPL_trans_cleanupFunction · 0.85
REPL_storeFunction · 0.85
REPL_modifyFunction · 0.85
REPL_eraseFunction · 0.85
REPL_gen_idFunction · 0.85
REPL_exec_sqlFunction · 0.85

Calls 15

logPrimaryErrorFunction · 0.85
checkStatusFunction · 0.85
getDatabaseMethod · 0.80
replConfigMethod · 0.80
replManagerMethod · 0.80
pluginMethod · 0.80
isReplicatedMethod · 0.80
markAsReplicatedMethod · 0.80
ReplicatorClass · 0.70
getAttachmentMethod · 0.45
isSystemMethod · 0.45
isReplicatingMethod · 0.45

Tested by

no test coverage detected