1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.search.solr.internal; |
21 |
|
|
22 |
|
import java.io.InputStream; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.configuration.ConfigurationSource; |
30 |
|
import org.xwiki.search.solr.internal.api.SolrConfiguration; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
38 |
|
@Component |
39 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 7 |
Complexity Density: 0.88 |
|
40 |
|
public class DefaultSolrConfiguration implements SolrConfiguration |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
public static final String DEFAULT_SOLR_TYPE = "embedded"; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
public static final String CLASSPATH_LOCATION_PREFIX = "/solr/%s"; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
public static final String CONF_DIRECTORY = "conf"; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
public static final String CONF_FILE_LOCATION_PATTERN = "/%s/%s/%s"; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
public static final String[] HOME_DIRECTORY_FILE_NAMES = {"solr.xml"}; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
public static final String HOME_DIRECTORY_CORE_PACKAGE = "solr.xwiki"; |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
public static final String HOME_DIRECTORY_PREFIX = "solr/"; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
public static final String SOLR_INDEXER_BATCH_SIZE_PROPERTY = "solr.indexer.batch.size"; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
public static final int SOLR_INDEXER_BATCH_SIZE_DEFAULT = 50; |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
public static final String SOLR_INDEXER_BATCH_MAXLENGH_PROPERTY = "solr.indexer.batch.maxLength"; |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
public static final int SOLR_INDEXER_BATCH_MAXLENGH_DEFAULT = 10000; |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
public static final String SOLR_INDEXER_QUEUE_CAPACITY_PROPERTY = "solr.indexer.queue.capacity"; |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
public static final int SOLR_INDEXER_QUEUE_CAPACITY_DEFAULT = 100000; |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
public static final String SOLR_SYNCHRONIZE_AT_STARTUP = "solr.synchronizeAtStartup"; |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
public static final boolean SOLR_SYNCHRONIZE_AT_STARTUP_DEFAULT = true; |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
@Inject |
121 |
|
@Named("xwikiproperties") |
122 |
|
private ConfigurationSource configuration; |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
124 |
3 |
@Override... |
125 |
|
public String getServerType() |
126 |
|
{ |
127 |
3 |
return this.configuration.getProperty("solr.type", DEFAULT_SOLR_TYPE); |
128 |
|
} |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
130 |
6 |
@Override... |
131 |
|
public <T> T getInstanceConfiguration(String instanceType, String propertyName, T defaultValue) |
132 |
|
{ |
133 |
6 |
String actualPropertyName = String.format("%s.%s.%s", "solr", instanceType, propertyName); |
134 |
6 |
return this.configuration.getProperty(actualPropertyName, defaultValue); |
135 |
|
} |
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
4 |
@Override... |
138 |
|
public InputStream getHomeDirectoryConfiguration() |
139 |
|
{ |
140 |
4 |
return getClass().getResourceAsStream("/xwiki-platform-search-solr-server-data.zip"); |
141 |
|
} |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
4234 |
@Override... |
144 |
|
public int getIndexerBatchSize() |
145 |
|
{ |
146 |
4234 |
return this.configuration.getProperty(SOLR_INDEXER_BATCH_SIZE_PROPERTY, SOLR_INDEXER_BATCH_SIZE_DEFAULT); |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
4469 |
@Override... |
150 |
|
public int getIndexerBatchMaxLengh() |
151 |
|
{ |
152 |
4469 |
return this.configuration |
153 |
|
.getProperty(SOLR_INDEXER_BATCH_MAXLENGH_PROPERTY, SOLR_INDEXER_BATCH_MAXLENGH_DEFAULT); |
154 |
|
} |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
3 |
@Override... |
157 |
|
public int getIndexerQueueCapacity() |
158 |
|
{ |
159 |
3 |
return this.configuration |
160 |
|
.getProperty(SOLR_INDEXER_QUEUE_CAPACITY_PROPERTY, SOLR_INDEXER_QUEUE_CAPACITY_DEFAULT); |
161 |
|
} |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
163 |
3 |
@Override... |
164 |
|
public boolean synchronizeAtStartup() |
165 |
|
{ |
166 |
3 |
return this.configuration.getProperty(SOLR_SYNCHRONIZE_AT_STARTUP, SOLR_SYNCHRONIZE_AT_STARTUP_DEFAULT); |
167 |
|
} |
168 |
|
} |