MCPcopy Create free account
hub / github.com/apache/solr / runImpl

Method runImpl

solr/core/src/java/org/apache/solr/cli/ZkCpTool.java:119–209  ·  view source on GitHub ↗
(CommandLine cli)

Source from the content-addressed store, hash-verified

117 return sb.toString();
118 }
119
120 @Override
121 public void runImpl(CommandLine cli) throws Exception {
122 String zkHost = CLIUtils.getZkHost(cli);
123
124 echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...");
125 String src = cli.getArgs()[0];
126 String dst = cli.getArgs()[1];
127 boolean recursive = cli.hasOption(CommonCLIOptions.RECURSIVE_OPTION);
128 echo("Copying from '" + src + "' to '" + dst + "'. ZooKeeper at " + zkHost);
129
130 boolean srcIsZk = src.toLowerCase(Locale.ROOT).startsWith("zk:");
131 boolean dstIsZk = dst.toLowerCase(Locale.ROOT).startsWith("zk:");
132
133 String srcName = src;
134 if (srcIsZk) {
135 srcName = src.substring(3);
136 } else if (srcName.toLowerCase(Locale.ROOT).startsWith("file:")) {
137 srcName = srcName.substring(5);
138 }
139
140 String dstName = dst;
141 if (dstIsZk) {
142 dstName = dst.substring(3);
143 if (!dstName.startsWith("/")) {
144 dstName = "/" + dstName;
145 }
146 } else {
147 if (dstName.toLowerCase(Locale.ROOT).startsWith("file:")) {
148 dstName = dstName.substring(5);
149 }
150 }
151
152 int minStateByteLenForCompression = -1;
153 Compressor compressor = new ZLibCompressor();
154
155 if (dstIsZk) {
156 String solrHome = cli.getOptionValue(SOLR_HOME_OPTION);
157 if (StrUtils.isNullOrEmpty(solrHome)) {
158 solrHome = EnvUtils.getProperty("solr.home");
159 }
160
161 if (solrHome != null) {
162 echoIfVerbose("Using SolrHome: " + solrHome);
163 try {
164 // Be aware that if you start Solr and pass in some variables via -D like
165 // solr start -DminStateByteLenForCompression=0 -c, this logic will not
166 // know about the -DminStateByteLenForCompression and only return the
167 // version set in the solr.xml. So you must edit solr.xml directly.
168 Path solrHomePath = Path.of(solrHome);
169 Properties props = new Properties();
170 props.put(SolrXmlConfig.ZK_HOST, zkHost);
171 NodeConfig nodeConfig = NodeConfig.loadNodeConfig(solrHomePath, props);
172 minStateByteLenForCompression =
173 nodeConfig.getCloudConfig().getMinStateByteLenForCompression();
174 String stateCompressorClass = nodeConfig.getCloudConfig().getStateCompressorClass();
175 if (StrUtils.isNotNullOrEmpty(stateCompressorClass)) {
176 Class<? extends Compressor> compressionClass =

Callers

nothing calls this directly

Calls 15

getZkHostMethod · 0.95
isNullOrEmptyMethod · 0.95
loadNodeConfigMethod · 0.95
getCloudConfigMethod · 0.95
isNotNullOrEmptyMethod · 0.95
echoIfVerboseMethod · 0.80
echoMethod · 0.80
forNameMethod · 0.80
withTimeoutMethod · 0.80

Tested by

no test coverage detected