use of org.apache.solr.core.SolrCore in project lucene-solr by apache.
the class StreamHandler method inform.
public void inform(SolrCore core) {
/* The stream factory will always contain the zkUrl for the given collection
* Adds default streams with their corresponding function names. These
* defaults can be overridden or added to in the solrConfig in the stream
* RequestHandler def. Example config override
* <lst name="streamFunctions">
* <str name="group">org.apache.solr.client.solrj.io.stream.ReducerStream</str>
* <str name="count">org.apache.solr.client.solrj.io.stream.RecordCountStream</str>
* </lst>
* */
String defaultCollection;
String defaultZkhost;
CoreContainer coreContainer = core.getCoreContainer();
this.coreName = core.getName();
if (coreContainer.isZooKeeperAware()) {
defaultCollection = core.getCoreDescriptor().getCollectionName();
defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
streamFactory.withDefaultZkHost(defaultZkhost);
modelCache = new ModelCache(250, defaultZkhost, clientCache);
}
streamFactory.withFunctionName("search", CloudSolrStream.class).withFunctionName("facet", FacetStream.class).withFunctionName("update", UpdateStream.class).withFunctionName("jdbc", JDBCStream.class).withFunctionName("topic", TopicStream.class).withFunctionName("commit", CommitStream.class).withFunctionName("random", RandomStream.class).withFunctionName("knn", KnnStream.class).withFunctionName("merge", MergeStream.class).withFunctionName("unique", UniqueStream.class).withFunctionName("top", RankStream.class).withFunctionName("group", GroupOperation.class).withFunctionName("reduce", ReducerStream.class).withFunctionName("parallel", ParallelStream.class).withFunctionName("rollup", RollupStream.class).withFunctionName("stats", StatsStream.class).withFunctionName("innerJoin", InnerJoinStream.class).withFunctionName("leftOuterJoin", LeftOuterJoinStream.class).withFunctionName("hashJoin", HashJoinStream.class).withFunctionName("outerHashJoin", OuterHashJoinStream.class).withFunctionName("intersect", IntersectStream.class).withFunctionName("complement", ComplementStream.class).withFunctionName(SORT, SortStream.class).withFunctionName("train", TextLogitStream.class).withFunctionName("features", FeaturesSelectionStream.class).withFunctionName("daemon", DaemonStream.class).withFunctionName("shortestPath", ShortestPathStream.class).withFunctionName("gatherNodes", GatherNodesStream.class).withFunctionName("nodes", GatherNodesStream.class).withFunctionName("select", SelectStream.class).withFunctionName("shortestPath", ShortestPathStream.class).withFunctionName("gatherNodes", GatherNodesStream.class).withFunctionName("nodes", GatherNodesStream.class).withFunctionName("scoreNodes", ScoreNodesStream.class).withFunctionName("model", ModelStream.class).withFunctionName("classify", ClassifyStream.class).withFunctionName("fetch", FetchStream.class).withFunctionName("executor", ExecutorStream.class).withFunctionName("null", NullStream.class).withFunctionName("priority", PriorityStream.class).withFunctionName("significantTerms", SignificantTermsStream.class).withFunctionName("cartesianProduct", CartesianProductStream.class).withFunctionName("shuffle", ShuffleStream.class).withFunctionName("calc", CalculatorStream.class).withFunctionName("eval", EvalStream.class).withFunctionName("echo", EchoStream.class).withFunctionName("cell", CellStream.class).withFunctionName("list", ListStream.class).withFunctionName("let", LetStream.class).withFunctionName("get", GetStream.class).withFunctionName("timeseries", TimeSeriesStream.class).withFunctionName("tuple", TupStream.class).withFunctionName("sql", SqlStream.class).withFunctionName("col", ColumnEvaluator.class).withFunctionName("predict", PredictEvaluator.class).withFunctionName("regress", RegressionEvaluator.class).withFunctionName("cov", CovarianceEvaluator.class).withFunctionName("conv", ConvolutionEvaluator.class).withFunctionName("normalize", NormalizeEvaluator.class).withFunctionName("rev", ReverseEvaluator.class).withFunctionName("length", LengthEvaluator.class).withFunctionName("rank", RankEvaluator.class).withFunctionName("scale", ScaleEvaluator.class).withFunctionName("distance", DistanceEvaluator.class).withFunctionName("copyOf", CopyOfEvaluator.class).withFunctionName("copyOfRange", CopyOfRangeEvaluator.class).withFunctionName("percentile", PercentileEvaluator.class).withFunctionName("empiricalDistribution", EmpiricalDistributionEvaluator.class).withFunctionName("describe", DescribeEvaluator.class).withFunctionName("finddelay", FindDelayEvaluator.class).withFunctionName("sequence", SequenceEvaluator.class).withFunctionName("array", ArrayEvaluator.class).withFunctionName("hist", HistogramEvaluator.class).withFunctionName("anova", AnovaEvaluator.class).withFunctionName("movingAvg", MovingAverageEvaluator.class).withFunctionName("min", MinMetric.class).withFunctionName("max", MaxMetric.class).withFunctionName("avg", MeanMetric.class).withFunctionName("sum", SumMetric.class).withFunctionName("count", CountMetric.class).withFunctionName("replace", ReplaceOperation.class).withFunctionName("concat", ConcatOperation.class).withFunctionName("group", GroupOperation.class).withFunctionName("distinct", DistinctOperation.class).withFunctionName("having", HavingStream.class).withFunctionName("val", RawValueEvaluator.class).withFunctionName("and", AndEvaluator.class).withFunctionName("eor", ExclusiveOrEvaluator.class).withFunctionName("eq", EqualsEvaluator.class).withFunctionName("gt", GreaterThanEvaluator.class).withFunctionName("gteq", GreaterThanEqualToEvaluator.class).withFunctionName("lt", LessThanEvaluator.class).withFunctionName("lteq", LessThanEqualToEvaluator.class).withFunctionName("not", NotEvaluator.class).withFunctionName("or", OrEvaluator.class).withFunctionName(TemporalEvaluatorYear.FUNCTION_NAME, TemporalEvaluatorYear.class).withFunctionName(TemporalEvaluatorMonth.FUNCTION_NAME, TemporalEvaluatorMonth.class).withFunctionName(TemporalEvaluatorDay.FUNCTION_NAME, TemporalEvaluatorDay.class).withFunctionName(TemporalEvaluatorDayOfYear.FUNCTION_NAME, TemporalEvaluatorDayOfYear.class).withFunctionName(TemporalEvaluatorHour.FUNCTION_NAME, TemporalEvaluatorHour.class).withFunctionName(TemporalEvaluatorMinute.FUNCTION_NAME, TemporalEvaluatorMinute.class).withFunctionName(TemporalEvaluatorSecond.FUNCTION_NAME, TemporalEvaluatorSecond.class).withFunctionName(TemporalEvaluatorEpoch.FUNCTION_NAME, TemporalEvaluatorEpoch.class).withFunctionName(TemporalEvaluatorWeek.FUNCTION_NAME, TemporalEvaluatorWeek.class).withFunctionName(TemporalEvaluatorQuarter.FUNCTION_NAME, TemporalEvaluatorQuarter.class).withFunctionName(TemporalEvaluatorDayOfQuarter.FUNCTION_NAME, TemporalEvaluatorDayOfQuarter.class).withFunctionName("abs", AbsoluteValueEvaluator.class).withFunctionName("add", AddEvaluator.class).withFunctionName("div", DivideEvaluator.class).withFunctionName("mult", MultiplyEvaluator.class).withFunctionName("sub", SubtractEvaluator.class).withFunctionName("log", NaturalLogEvaluator.class).withFunctionName("pow", PowerEvaluator.class).withFunctionName("mod", ModuloEvaluator.class).withFunctionName("ceil", CeilingEvaluator.class).withFunctionName("floor", FloorEvaluator.class).withFunctionName("sin", SineEvaluator.class).withFunctionName("asin", ArcSineEvaluator.class).withFunctionName("sinh", HyperbolicSineEvaluator.class).withFunctionName("cos", CosineEvaluator.class).withFunctionName("acos", ArcCosineEvaluator.class).withFunctionName("cosh", HyperbolicCosineEvaluator.class).withFunctionName("tan", TangentEvaluator.class).withFunctionName("atan", ArcTangentEvaluator.class).withFunctionName("tanh", HyperbolicTangentEvaluator.class).withFunctionName("round", RoundEvaluator.class).withFunctionName("sqrt", SquareRootEvaluator.class).withFunctionName("cbrt", CubedRootEvaluator.class).withFunctionName("coalesce", CoalesceEvaluator.class).withFunctionName("uuid", UuidEvaluator.class).withFunctionName("corr", CorrelationEvaluator.class).withFunctionName("if", IfThenElseEvaluator.class).withFunctionName("analyze", AnalyzeEvaluator.class).withFunctionName("convert", ConversionEvaluator.class);
// This pulls all the overrides and additions from the config
List<PluginInfo> pluginInfos = core.getSolrConfig().getPluginInfos(Expressible.class.getName());
for (PluginInfo pluginInfo : pluginInfos) {
Class<? extends Expressible> clazz = core.getMemClassLoader().findClass(pluginInfo.className, Expressible.class);
streamFactory.withFunctionName(pluginInfo.name, clazz);
}
core.addCloseHook(new CloseHook() {
@Override
public void preClose(SolrCore core) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void postClose(SolrCore core) {
clientCache.close();
}
});
}
use of org.apache.solr.core.SolrCore in project lucene-solr by apache.
the class ReplicationHandler method registerCloseHook.
/**
* register a closehook
*/
private void registerCloseHook() {
core.addCloseHook(new CloseHook() {
@Override
public void preClose(SolrCore core) {
// we don't wait for shutdown - this can deadlock core reload
if (executorService != null)
executorService.shutdown();
}
@Override
public void postClose(SolrCore core) {
if (pollingIndexFetcher != null) {
pollingIndexFetcher.destroy();
}
if (currentIndexFetcher != null && currentIndexFetcher != pollingIndexFetcher) {
currentIndexFetcher.destroy();
}
}
});
core.addCloseHook(new CloseHook() {
@Override
public void preClose(SolrCore core) {
ExecutorUtil.shutdownAndAwaitTermination(restoreExecutor);
if (restoreFuture != null) {
restoreFuture.cancel(false);
}
}
@Override
public void postClose(SolrCore core) {
}
});
}
use of org.apache.solr.core.SolrCore in project lucene-solr by apache.
the class IndexFetcher method openNewSearcherAndUpdateCommitPoint.
private void openNewSearcherAndUpdateCommitPoint() throws IOException {
RefCounted<SolrIndexSearcher> searcher = null;
IndexCommit commitPoint;
// must get the latest solrCore object because the one we have might be closed because of a reload
// todo stop keeping solrCore around
SolrCore core = solrCore.getCoreContainer().getCore(solrCore.getName());
try {
Future[] waitSearcher = new Future[1];
searcher = core.getSearcher(true, true, waitSearcher, true);
if (waitSearcher[0] != null) {
try {
waitSearcher[0].get();
} catch (InterruptedException | ExecutionException e) {
SolrException.log(LOG, e);
}
}
commitPoint = searcher.get().getIndexReader().getIndexCommit();
} finally {
if (searcher != null) {
searcher.decref();
}
core.close();
}
// update the commit point in replication handler
replicationHandler.indexCommitPoint = commitPoint;
}
use of org.apache.solr.core.SolrCore in project lucene-solr by apache.
the class CreateSnapshotOp method execute.
@Override
public void execute(CoreAdminHandler.CallInfo it) throws Exception {
CoreContainer cc = it.handler.getCoreContainer();
final SolrParams params = it.req.getParams();
String commitName = params.required().get(CoreAdminParams.COMMIT_NAME);
String cname = params.required().get(CoreAdminParams.CORE);
try (SolrCore core = cc.getCore(cname)) {
if (core == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to locate core " + cname);
}
String indexDirPath = core.getIndexDir();
IndexCommit ic = core.getDeletionPolicy().getLatestCommit();
if (ic == null) {
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
ic = searcher.get().getIndexReader().getIndexCommit();
} finally {
searcher.decref();
}
}
SolrSnapshotMetaDataManager mgr = core.getSnapshotMetaDataManager();
mgr.snapshot(commitName, indexDirPath, ic.getGeneration());
it.rsp.add(CoreAdminParams.CORE, core.getName());
it.rsp.add(CoreAdminParams.COMMIT_NAME, commitName);
it.rsp.add(SolrSnapshotManager.INDEX_DIR_PATH, indexDirPath);
it.rsp.add(SolrSnapshotManager.GENERATION_NUM, ic.getGeneration());
it.rsp.add(SolrSnapshotManager.FILE_LIST, ic.getFileNames());
}
}
use of org.apache.solr.core.SolrCore in project lucene-solr by apache.
the class BackupCoreOp method execute.
@Override
public void execute(CoreAdminHandler.CallInfo it) throws Exception {
ZkController zkController = it.handler.coreContainer.getZkController();
if (zkController == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Internal SolrCloud API");
}
final SolrParams params = it.req.getParams();
String cname = params.get(CoreAdminParams.CORE);
if (cname == null) {
throw new IllegalArgumentException(CoreAdminParams.CORE + " is required");
}
String name = params.get(NAME);
if (name == null) {
throw new IllegalArgumentException(CoreAdminParams.NAME + " is required");
}
String repoName = params.get(CoreAdminParams.BACKUP_REPOSITORY);
BackupRepository repository = it.handler.coreContainer.newBackupRepository(Optional.ofNullable(repoName));
String location = repository.getBackupLocation(params.get(CoreAdminParams.BACKUP_LOCATION));
if (location == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "'location' is not specified as a query" + " parameter or as a default repository property");
}
// An optional parameter to describe the snapshot to be backed-up. If this
// parameter is not supplied, the latest index commit is backed-up.
String commitName = params.get(CoreAdminParams.COMMIT_NAME);
URI locationUri = repository.createURI(location);
try (SolrCore core = it.handler.coreContainer.getCore(cname)) {
SnapShooter snapShooter = new SnapShooter(repository, core, locationUri, name, commitName);
// file system. Otherwise, perhaps the FS location isn't shared -- we want an error.
if (!snapShooter.getBackupRepository().exists(snapShooter.getLocation())) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Directory to contain snapshots doesn't exist: " + snapShooter.getLocation());
}
snapShooter.validateCreateSnapshot();
snapShooter.createSnapshot();
} catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Failed to backup core=" + cname + " because " + e, e);
}
}
Aggregations