コード例 #1
0
  @Test
  public void testInitialiseDynamicShardsOnStartup() throws Exception {
    EntityIndexBinding entityIndexBinding =
        getExtendedSearchIntegrator().getIndexBindings().get(Animal.class);
    assertThat(entityIndexBinding.getIndexManagers()).hasSize(0);

    insertAnimals(elephant, spider, bear);

    assertThat(entityIndexBinding.getIndexManagers()).hasSize(2);

    assertThat(getIndexManagersAfterReopening()).hasSize(2);
  }
コード例 #2
0
 @Override
 public void optimize(Class entityType) {
   EntityIndexBinding entityIndexBinding = getSafeIndexBindingForEntity(entityType);
   for (IndexManager im : entityIndexBinding.getIndexManagers()) {
     im.optimize();
   }
 }
コード例 #3
0
  @Test
  public void testDynamicCreationOfShards() throws Exception {
    EntityIndexBinding entityIndexBinding =
        getExtendedSearchIntegrator().getIndexBindings().get(Animal.class);
    assertThat(entityIndexBinding.getIndexManagers()).hasSize(0);

    insertAnimals(elephant);
    assertThat(entityIndexBinding.getIndexManagers()).hasSize(1);

    insertAnimals(spider);
    assertThat(entityIndexBinding.getIndexManagers()).hasSize(2);

    insertAnimals(bear);
    assertThat(entityIndexBinding.getIndexManagers()).hasSize(2);

    assertEquals(2, getNumberOfDocumentsInIndex("Animal.Mammal"));
    assertEquals(1, getNumberOfDocumentsInIndex("Animal.Insect"));
  }
コード例 #4
0
 private Collection<IndexManager> uniqueIndexManagerForTypes(Collection<Class<?>> entityTypes) {
   HashMap<String, IndexManager> uniqueBackends =
       new HashMap<String, IndexManager>(entityTypes.size());
   for (Class<?> type : entityTypes) {
     EntityIndexBinding indexBindingForEntity = searchFactoryImplementor.getIndexBinding(type);
     if (indexBindingForEntity != null) {
       IndexManager[] indexManagers = indexBindingForEntity.getIndexManagers();
       for (IndexManager im : indexManagers) {
         uniqueBackends.put(im.getIndexName(), im);
       }
     }
   }
   return uniqueBackends.values();
 }
コード例 #5
0
 @Override
 public IndexedTypeDescriptor getIndexedTypeDescriptor(Class<?> entityType) {
   IndexedTypeDescriptor typeDescriptor;
   if (indexedTypeDescriptors.containsKey(entityType)) {
     typeDescriptor = indexedTypeDescriptors.get(entityType);
   } else {
     EntityIndexBinding indexBinder = indexBindingForEntities.get(entityType);
     IndexedTypeDescriptor indexedTypeDescriptor;
     if (indexBinder == null) {
       indexedTypeDescriptor = new IndexedTypeDescriptorForUnindexedType(entityType);
     } else {
       indexedTypeDescriptor =
           new IndexedTypeDescriptorImpl(
               indexBinder.getDocumentBuilder().getMetadata(), indexBinder.getIndexManagers());
     }
     indexedTypeDescriptors.put(entityType, indexedTypeDescriptor);
     typeDescriptor = indexedTypeDescriptor;
   }
   return typeDescriptor;
 }