@Override public List<String> getIndices() { return indexes.keySet().stream().map(kCluster -> kCluster.getClusterId()).collect(Collectors.toList()); } }
@Override public void delete(KCluster cluster) { this.batchLocks.remove(cluster); this.provider.delete(cluster.getClusterId()); }
@Override public void delete(KCluster cluster) { this.batchLocks.remove(cluster); this.provider.delete(cluster.getClusterId()); }
@Override public boolean isFreshIndex(KCluster cluster) { return this.getIndexSize(cluster.getClusterId()) == 0; }
@Override public boolean isFreshIndex(KCluster cluster) { return this.getIndexSize(cluster.getClusterId()) == 0; }
@Override public void startBatch(KCluster cluster) { prepareBatch(cluster); Map<KCluster, List<IndexEvent>> batchSet = batchSets.get(); if (batchSet.containsKey(cluster)) { throw new IllegalStateException(String.format("Cannot start a batch for cluster [id=%s] when there is already a batch started on this thread [%s]", cluster.getClusterId(), Thread.currentThread().getName())); } else { batchSet.put(cluster, new ArrayList<>()); } }
@Override public boolean isFreshIndex(KCluster cluster) { return this.getIndexSize(cluster.getClusterId()) == 0; }
@Override public void startBatch(KCluster cluster) { prepareBatch(cluster); Map<KCluster, List<IndexEvent>> batchSet = batchSets.get(); if (batchSet.containsKey(cluster)) { throw new IllegalStateException(String.format("Cannot start a batch for cluster [id=%s] when there is already a batch started on this thread [%s]", cluster.getClusterId(), Thread.currentThread().getName())); } else { batchSet.put(cluster, new ArrayList<>()); } }
@Override public boolean isFreshIndex(KCluster cluster) { return this.getIndexSize(cluster.getClusterId()) == 0; }
@Test public void testIndexingFullText() throws IOException, InterruptedException { //Add test files loadProperties("file1.properties", basePath); loadProperties("file2.properties", basePath); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); searchFor(index, new WildcardQuery(new Term(FULL_TEXT_FIELD, "*file*")), 2); }
@Test public void testIndexDecisionTableXLSAttributeName() throws IOException, InterruptedException { //Add test files final Path path1 = loadXLSFile(basePath, "dtable1.xls"); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)) .build(); searchFor(index, query, 1, path1); } }
@Test public void testIndexDecisionTableXLSAttributeName() throws IOException, InterruptedException { //Add test files final Path path1 = loadXLSFile(basePath, "dtable1.xls"); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)) .build(); searchFor(index, query, 1, path1); } }
@Test public void testIndexDecisionTableXLSMultipleTypes() throws IOException, InterruptedException { //Add test files final Path path = loadXLSFile(basePath, "xlsxrule.xlsx"); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueResourceIndexTerm("*", ResourceType.RULE, ValueIndexTerm.TermSearchType.WILDCARD) ) .build(); // Rule name found from xlsxrule searchFor(index, query, 1, path); } }
@Test public void testIndexDrlRuleAttributeNames() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve( "drl1.rdrl" ); final String drl = loadText( "drl1.rdrl" ); ioService().write( path, drl ); Thread.sleep( 5000 ); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueSharedPartIndexTerm( "*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD ) ) .build(); searchFor(index, query, 1 ); } }
@Test public void testIndexDrlRuleAttributeNames() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve( "drl1.rdrl" ); final String drl = loadText( "drl1.rdrl" ); ioService().write( path, drl ); Thread.sleep( 5000 ); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueSharedPartIndexTerm( "*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD ) ) .build(); searchFor(index, query, 1 ); } }
@Test public void testIndexDrlRules() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve( "drl1.tdrl" ); final String drl = loadText( "drl1.tdrl" ); ioService().write( path, drl ); Thread.sleep( 5000 ); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueResourceIndexTerm( "*myRule", ResourceType.RULE, TermSearchType.WILDCARD ) ) .build(); searchFor(index, query, 1); } }
@Test public void testIndexDrlRules() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve( "drl1.rdrl" ); final String drl = loadText( "drl1.rdrl" ); ioService().write( path, drl ); Thread.sleep( 5000 ); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueResourceIndexTerm( "*myRule", ResourceType.RULE, TermSearchType.WILDCARD ) ) .build(); searchFor(index, query, 1 ); } }
@Test public void testIndexDrlRules() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve( "drl1.rdrl" ); final String drl = loadText( "drl1.rdrl" ); ioService().write( path, drl ); Thread.sleep( 5000 ); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueResourceIndexTerm( "*myRule", ResourceType.RULE, TermSearchType.WILDCARD ) ) .build(); searchFor(index, query, 1 ); } }
@Test public void testIndexDrlRules() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve( "drl1.tdrl" ); final String drl = loadText( "drl1.tdrl" ); ioService().write( path, drl ); Thread.sleep( 5000 ); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder( new ValueResourceIndexTerm( "*myRule", ResourceType.RULE, TermSearchType.WILDCARD ) ) .build(); searchFor(index, query, 1); } }
@Test public void testIndexDrlRuleAttributeNames() throws IOException, InterruptedException { //Add test files final Path path = basePath.resolve("drl1.drl"); final String drl = loadText("drl1.drl"); ioService().write(path, drl); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId()); { final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)) .build(); searchFor(index, query, 1); } }