Search in sources :

Example 1 with MockTisCoreAdminHandler

use of org.apache.solr.handler.admin.MockTisCoreAdminHandler in project plugins by qlangtech.

the class TestLocalTableDumpAndIndex method indexFlowback2SolrEngineNode.

// public void testIndexFlowback2SolrEngineNode() throws Exception {
// 
// int footerMagic = CodecUtil.FOOTER_MAGIC;
// File cfs = new File("/opt/data/tis/localOffline/search4employees/all/0/output/20210204144833/index/0/_m.cfs");
// 
// try {
// byte[] bytes = IOUtils.toByteArray(FileUtils.openInputStream(cfs));
// for (int i = 0; i < bytes.length; i++) {
// if (getInt(bytes, i) == footerMagic) {
// System.out.println("match the FOOTER_MAGIC:" + i);
// }
// }
// } catch (Throwable e) {
// 
// }
// 
// CountingInputStream input = new CountingInputStream(new BufferedInputStream(FileUtils.openInputStream(cfs)));
// input.skip(819826);
// byte[] b = new byte[4];
// input.read(b, 0, 4);
// System.out.println("===========" + (getInt(b, 0) == footerMagic));
// 
// //        System.out.println("cfs.length():" + cfs.getParent().length());
// //        System.out.println("FileUtils.sizeOf(cfs):" + FileUtils.sizeOf(cfs.getParentFile()));
// //        System.out.println("IOUtils.toByteArray(FileUtils.openInputStream(cfs) ).length:" + IOUtils.toByteArray(FileUtils.openInputStream(cfs)).length);
// 
// String mockSolrCore = INDEX_COLLECTION + "_shard1_replica_n1";
// File localOfflineDir = LocalTableDumpFactory.getLocalOfflineRootDir();
// //String timepoint ="20210309104515";
// String timepoint = "20210204144833";
// indexFlowback2SolrEngineNode(mockSolrCore, timepoint, localOfflineDir, 123);
// }
// 
// private int getInt(byte[] bytes, int offset) {
// return ((bytes[offset] & 0xFF) << 24) | ((bytes[offset + 1] & 0xFF) << 16)
// | ((bytes[offset + 2] & 0xFF) << 8) | (bytes[offset + 3] & 0xFF);
// }
private void indexFlowback2SolrEngineNode(String solrCoreName, String timePoint, File localOfflineDir, Integer taskId) throws IOException {
    MockTisCoreAdminHandler coreAdminHandler = new MockTisCoreAdminHandler(null);
    coreAdminHandler.addRunningTask(String.valueOf(taskId));
    File indexDir = new File(localOfflineDir, "index");
    FileUtils.forceMkdir(indexDir);
    SolrQueryResponse solrResponse = new SolrQueryResponse();
    // 将索引文件回流到目标目录里去
    coreAdminHandler.downloadIndexFile2IndexDir(null, Long.parseLong(timePoint), solrCoreName, indexDir, solrResponse, String.valueOf(taskId));
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) File(java.io.File) MockTisCoreAdminHandler(org.apache.solr.handler.admin.MockTisCoreAdminHandler)

Aggregations

File (java.io.File)1 MockTisCoreAdminHandler (org.apache.solr.handler.admin.MockTisCoreAdminHandler)1 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)1