MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / instance

Method instance

src/tsd/RpcManager.java:129–161  ·  view source on GitHub ↗

Get or create the singleton instance of the manager, loading all the plugins enabled in the given TSDB's Config. @return the shared instance of RpcManager. It's okay to hold this reference once obtained.

(final TSDB tsdb)

Source from the content-addressed store, hash-verified

127 * hold this reference once obtained.
128 */
129 public static synchronized RpcManager instance(final TSDB tsdb) {
130 final RpcManager existing = INSTANCE.get();
131 if (existing != null) {
132 return existing;
133 }
134
135 final RpcManager manager = new RpcManager(tsdb);
136
137 // Load any plugins that are enabled via Config. Fail if any plugin cannot be loaded.
138
139 final ImmutableList.Builder<RpcPlugin> rpcBuilder = ImmutableList.builder();
140 if (tsdb.getConfig().hasProperty("tsd.rpc.plugins")) {
141 final String[] plugins = tsdb.getConfig().getString("tsd.rpc.plugins").split(",");
142 manager.initializeRpcPlugins(plugins, rpcBuilder);
143 }
144 manager.rpc_plugins = rpcBuilder.build();
145
146 final ImmutableMap.Builder<String, TelnetRpc> telnetBuilder = ImmutableMap.builder();
147 final ImmutableMap.Builder<String, HttpRpc> httpBuilder = ImmutableMap.builder();
148 manager.initializeBuiltinRpcs(tsdb.getMode(), telnetBuilder, httpBuilder);
149 manager.telnet_commands = telnetBuilder.build();
150 manager.http_commands = httpBuilder.build();
151
152 final ImmutableMap.Builder<String, HttpRpcPlugin> httpPluginsBuilder = ImmutableMap.builder();
153 if (tsdb.getConfig().hasProperty("tsd.http.rpc.plugins")) {
154 final String[] plugins = tsdb.getConfig().getString("tsd.http.rpc.plugins").split(",");
155 manager.initializeHttpRpcPlugins(tsdb.getMode(), plugins, httpPluginsBuilder);
156 }
157 manager.http_plugin_commands = httpPluginsBuilder.build();
158
159 INSTANCE.set(manager);
160 return manager;
161 }
162
163 /**
164 * @return {@code true} if the shared instance has been initialized;

Callers 14

loadHttpRpcPluginsMethod · 0.95
loadRpcPluginMethod · 0.95
validHttpPathEndToEndMethod · 0.95
beforeMethod · 0.95
mainMethod · 0.95
runMethod · 0.95

Calls 12

initializeRpcPluginsMethod · 0.95
initializeBuiltinRpcsMethod · 0.95
getModeMethod · 0.80
setMethod · 0.80
getMethod · 0.45
builderMethod · 0.45
hasPropertyMethod · 0.45
getConfigMethod · 0.45
splitMethod · 0.45
getStringMethod · 0.45
buildMethod · 0.45

Tested by 10

loadHttpRpcPluginsMethod · 0.76
loadRpcPluginMethod · 0.76
validHttpPathEndToEndMethod · 0.76
beforeMethod · 0.76