use of com.qlangtech.tis.cloud.ITISCoordinator in project plugins by qlangtech.
the class TestLocalTableDumpAndIndex method startIndexBuild.
public void startIndexBuild(String solrCoreName, IJoinTaskContext execContext, ITISCoordinator zkCoordinator, String timePoint) throws Exception {
LocalIndexBuilderTriggerFactory builderTriggerFactory = new LocalIndexBuilderTriggerFactory();
File localOfflineDir = LocalTableDumpFactory.getLocalOfflineRootDir();
String indexName = ITestDumpCommon.INDEX_COLLECTION;
String groupNum = "0";
Integer taskId = 123;
ITISFileSystem fileSystem = builderTriggerFactory.getFileSystem();
ImportDataProcessInfo buildParam = new ImportDataProcessInfo(taskId, fileSystem, zkCoordinator);
buildParam.setIndexName(indexName);
MockDataSourceFactory employeesDataSource = MockDataSourceFactory.getMockEmployeesDataSource();
List<ColumnMetaData> eployeeTableMeta = employeesDataSource.getTableMetadata(TABLE_EMPLOYEES);
String colsLiteria = eployeeTableMeta.stream().map((c) -> c.getKey()).collect(Collectors.joining(","));
buildParam.setBuildTableTitleItems(colsLiteria);
SnapshotDomain snapshot = com.qlangtech.tis.manage.common.SnapshotDomainUtils.mockEmployeeSnapshotDomain();
snapshot.writeResource2fs(fileSystem, buildParam.getCoreName(Integer.parseInt(groupNum)), ConfigFileReader.FILE_SCHEMA);
snapshot.writeResource2fs(fileSystem, buildParam.getCoreName(Integer.parseInt(groupNum)), ConfigFileReader.FILE_SOLR);
IRemoteJobTrigger buildJob = builderTriggerFactory.createBuildJob(execContext, timePoint, indexName, groupNum, buildParam);
buildJob.submitJob();
/**
* -----------------------------------------------------------
* 开始执行索引build
* -----------------------------------------------------------
*/
TestLocalTableDumpAndIndex.waitJobTerminatorAndAssert(buildJob);
// long hdfsTimeStamp, String hdfsUser, SolrCore core, File indexDir, SolrQueryResponse rsp, String taskId
indexFlowback2SolrEngineNode(solrCoreName, timePoint, localOfflineDir, taskId);
}
use of com.qlangtech.tis.cloud.ITISCoordinator in project tis by qlangtech.
the class TestCollectionAction method testDeleteCollection.
public void testDeleteCollection() throws Exception {
ITISCoordinator zkCoordinator = MockZKUtils.createZkMock();
MockZooKeeperGetter.mockCoordinator = zkCoordinator;
// createCoordinatorMock((r) -> {
// });
request.setParameter("emethod", "deleteIndex");
request.setParameter("action", "collection_action");
JSONObject content = new JSONObject();
// search4search4employees
content.put(CollectionAction.KEY_INDEX_NAME, TEST_TABLE_EMPLOYEES_NAME);
request.setContent(content.toJSONString().getBytes(TisUTF8.get()));
ActionProxy proxy = getActionProxy();
this.replay();
String result = proxy.execute();
assertEquals("CollectionAction_ajax", result);
AjaxValve.ActionExecResult aResult = showBizResult();
assertNotNull(aResult);
assertTrue(aResult.isSuccess());
this.verifyAll();
}
use of com.qlangtech.tis.cloud.ITISCoordinator in project tis by qlangtech.
the class TestCoreAction method testTriggerFullbuildTaskByWithoutDefinePrimaryTable.
/**
* 执行索引全量构建过程中,测试ERRule没有定义主表,会导致final表的分区函数无法正常创建,需要主动抛出一个异常
*/
public void testTriggerFullbuildTaskByWithoutDefinePrimaryTable() throws Exception {
TableMeta tableMeta = new TableMeta(totalpayinfo.getTableName(), null);
HttpUtils.addMockApply(-1, "tis-assemble/trigger", "assemble.trigger.result.faild.json", TestCoreAction.class);
ITISCoordinator zkCoordinator = MockZKUtils.createZkMock();
MockZooKeeperGetter.mockCoordinator = zkCoordinator;
// this.createCoordinatorMock(false, (zk) -> {
// });
triggerFullbuildTask(tableMeta, (aResult) -> {
assertFalse(aResult.isSuccess());
List<String> errorMsgs = aResult.getErrorMsgs();
assertNotNull(errorMsgs);
assertTrue(errorMsgs.size() > 0);
});
}
use of com.qlangtech.tis.cloud.ITISCoordinator in project tis by qlangtech.
the class TestCoreAction method testTriggerFullbuildTask.
/**
* 触发全量构建
*/
public void testTriggerFullbuildTask() throws Exception {
TableMeta tableMeta = new TableMeta(totalpayinfo.getTableName(), "entity_id");
ITISCoordinator zkCoordinator = MockZKUtils.createZkMock();
MockZooKeeperGetter.mockCoordinator = zkCoordinator;
HttpUtils.addMockApply(-1, "tis-assemble/trigger", "assemble.trigger.result.success.json", TestCoreAction.class);
// this.createCoordinatorMock(false, (zk) -> {
// TestCollectionAction.createAssembleLogCollectPathMock(zk);
// });
triggerFullbuildTask(tableMeta, (aResult) -> {
assertTrue(aResult.isSuccess());
org.json.JSONObject biz = (org.json.JSONObject) aResult.getBizResult();
assertEquals(1234, biz.getInt(IParamContext.KEY_TASK_ID));
});
}
use of com.qlangtech.tis.cloud.ITISCoordinator in project tis by qlangtech.
the class TestAddAppAction method testDoCreateCollection.
/**
* 测试创建
*
* @throws Exception
*/
public void testDoCreateCollection() throws Exception {
request.setParameter("emethod", "create_collection");
request.setParameter("action", "add_app_action");
try (InputStream content = this.getClass().getResourceAsStream("create_confirm_index_http_body.json")) {
assertNotNull(content);
request.setContent(IOUtils.toByteArray(content));
}
ITISCoordinator zkCoordinator = MockZKUtils.createZkMock();
MockZooKeeperGetter.mockCoordinator = zkCoordinator;
setCollection(TestSchemaAction.collection);
ActionProxy proxy = getActionProxy();
replay();
String result = proxy.execute();
assertEquals("AddAppAction_ajax", result);
AjaxValve.ActionExecResult aResult = showBizResult();
assertNotNull(aResult);
assertTrue(aResult.isSuccess());
verifyAll();
IAppSource appSource = IAppSource.load(null, TestSchemaAction.collection);
assertTrue(appSource instanceof SingleTableAppSource);
}
Aggregations