4 |
4 |
import java.io.InputStream;
|
5 |
5 |
import java.io.StringReader;
|
6 |
6 |
import java.io.StringWriter;
|
|
7 |
import java.net.URI;
|
7 |
8 |
import java.util.List;
|
8 |
9 |
|
9 |
10 |
import javax.annotation.Resource;
|
... | ... | |
70 |
71 |
if (!StringUtils.isBlank(getRottenRecordsPathParam())) {
|
71 |
72 |
token.getEnv().setAttribute(getRottenRecordsPathParam(), "/tmp" + getFileName(token, "rottenrecords"));
|
72 |
73 |
}
|
73 |
|
token.getEnv().setAttribute("index.solr.url.zk", getIndexSolrUrlZk());
|
74 |
|
token.getEnv().setAttribute("index.solr.url.local", getIndexSolrUrlLocal());
|
75 |
|
token.getEnv().setAttribute("index.solr.url.list", getIndexSolrUrlList());
|
76 |
74 |
|
|
75 |
token.getEnv().setAttribute("index.solr.url", getIndexSolrUrl(token));
|
|
76 |
|
77 |
77 |
token.getEnv().setAttribute("index.shutdown.wait.time", getIndexSolrShutdownWait());
|
78 |
78 |
token.getEnv().setAttribute("index.buffer.flush.threshold", getIndexBufferFlushTreshold());
|
79 |
|
token.getEnv().setAttribute("index.solr.local.feeding", isIndexLocalFeeding());
|
80 |
79 |
token.getEnv().setAttribute("index.solr.sim.mode", isFeedingSimulationMode());
|
81 |
80 |
|
82 |
|
token.getEnv().setAttribute("index.solr.collection", getCollectionName(token));
|
83 |
81 |
token.getEnv().setAttribute("index.feed.timestamp", DateUtils.now_ISO8601());
|
84 |
82 |
|
85 |
83 |
token.getEnv().setAttribute(getOafSchemaLocationProperty(), getPropertyFetcher().getProperty(getOafSchemaLocationProperty()));
|
... | ... | |
87 |
85 |
return Arc.DEFAULT_ARC;
|
88 |
86 |
}
|
89 |
87 |
|
90 |
|
public String getIndexSolrUrlZk() throws ISLookUpException {
|
91 |
|
return getServiceConfigValue("for $x in /RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexServiceResourceType'] return $x//PROTOCOL[./@name='SOLR']/@address/string()");
|
|
88 |
private String getIndexSolrUrl(final NodeToken token) throws ISLookUpException {
|
|
89 |
String baseUrl = "http://" + getSolrServerHost() + ":" + getSolrServerPort() + "/" + getSolrWebappContext() + "/" + getCollectionName(token);
|
|
90 |
URI uri = URI.create(baseUrl);
|
|
91 |
return uri.toString();
|
92 |
92 |
}
|
93 |
93 |
|
94 |
|
public String getIndexSolrUrlLocal() throws ISLookUpException {
|
95 |
|
return queryForServiceProperty("hadoopLocalUrl");
|
|
94 |
private String getSolrServerHost() throws ISLookUpException {
|
|
95 |
return queryForServiceProperty("solr:host");
|
96 |
96 |
}
|
97 |
97 |
|
98 |
|
public String getIndexSolrUrlList() throws ISLookUpException {
|
99 |
|
return queryForServiceProperty("clientPoolUrls");
|
|
98 |
private String getSolrServerPort() throws ISLookUpException {
|
|
99 |
return queryForServiceProperty("solr:port");
|
100 |
100 |
}
|
101 |
101 |
|
|
102 |
private String getSolrWebappContext() throws ISLookUpException {
|
|
103 |
return queryForServiceProperty("solr:webContext");
|
|
104 |
}
|
|
105 |
|
102 |
106 |
public String getIndexSolrShutdownWait() throws ISLookUpException {
|
103 |
107 |
return queryForServiceProperty("feedingShutdownTolerance");
|
104 |
108 |
}
|
... | ... | |
123 |
127 |
private String getServiceConfigValue(final String xquery) throws ISLookUpException {
|
124 |
128 |
log.debug("quering for service property: " + xquery);
|
125 |
129 |
final List<String> urls = lookupLocator.getService().quickSearchProfile(xquery);
|
126 |
|
if ((urls == null) || (urls.size() != 1)) throw new IllegalStateException("unable to find unique service property, xquery: " + xquery);
|
|
130 |
if ((urls == null) || (urls.size() != 1)) { throw new IllegalStateException("unable to find unique service property, xquery: " + xquery); }
|
127 |
131 |
return Iterables.getOnlyElement(urls);
|
128 |
132 |
}
|
129 |
133 |
|
changed properties passed to index feed m/r job