首页 \ 问答 \ 如何从运行solr备份solrconfig文件(how to backup solrconfig file from running solr)

如何从运行solr备份solrconfig文件(how to backup solrconfig file from running solr)

我有一个单核心solr服务器。 当solr运行时,在一个集合中solrconfig.xml和schema.xml文件被错误替换。 现在收集工作正确和正确地响应请求,但在conf文件夹中的有效文件被替换为错误文件。 如果我重新加载集合,新的坏文件加载和我的集合无法正常工作。

有没有办法从运行集合中获取solrconfig.xml&schema.xml而不考虑conf文件夹中存在的solrconfig.xml和schema.xml文件?


I have a single core solr server. when solr was running, in one collection solrconfig.xml and schema.xml files replaced by mistake. now collection worked correctly and correctly response to request but valid file in conf folder is replaced by mistake files. surly if i reload collection, new bad files load and my collection not worked correctly.

is there a way than can get solrconfig.xml & schema.xml from running collection without considering solrconfig.xml and schema.xml files that exist in conf folder?


原文:https://stackoverflow.com/questions/39478833
更新时间:2024-01-24 10:01

最满意答案

假设您可以执行以下操作:

// NOT REAL CODE
public interface IMyInterface { } 
public class MyRealClass : IMyInterface { } 

...

public class Domain
{
    private List<MyRealClass> myList;

    public IList<IMyInterface> Interfaces { get { return (IList<IMyInterface>)this.myList; } }
}

什么阻止此Domain类的用户执行此操作?

public class MyFakeClass : IMyInterface { } 

...

domain.Interfaces.Add(new MyFakeClass());

显然这会有问题,因为myList实际上是一个List<MyRealClass> ,但是编译器无法确保只将MyRealClass实例添加到列表中(它需要运行时检查)。 换句话说,这种行为不是类型安全的,因此编译器不允许它。

您可以公开MyRealClassIList / ICollection - 这是类型安全的,但不能确保只将MyRealClass添加到列表中。

public class Domain
{
    private List<IMyInterface> myList;

    public IList<IMyInterface> Interfaces { get { return this.myList; } }
}

或者,您可以公开IEnumerableIMyInterface (或者像Zmbq建议的IReadOnlyList ) - 因为类型参数是协变的(参见泛型中的协方差和反演 )。 虽然这不允许您向集合添加新项目。

public class Domain
{
    private List<MyRealClass> myList;

    public IEnumerable<IMyInterface> Interfaces { get { return this.myList; } }
}

另一种解决方案是实现您自己的实现IList<IMyInterface>的集合类,但如果用户尝试插入除MyRealClass之外的任何内容,则抛出异常。 这不是一个特别优雅的解决方案,实际上,它与简单地暴露IList<MyRealClass>没有任何不同。


Suppose you could do something like this:

// NOT REAL CODE
public interface IMyInterface { } 
public class MyRealClass : IMyInterface { } 

...

public class Domain
{
    private List<MyRealClass> myList;

    public IList<IMyInterface> Interfaces { get { return (IList<IMyInterface>)this.myList; } }
}

What's to stop a user of this Domain class from doing this?

public class MyFakeClass : IMyInterface { } 

...

domain.Interfaces.Add(new MyFakeClass());

Obviously this would be problematic because myList is in reality a List<MyRealClass>, but the compiler cannot ensure that only instances of MyRealClass are added to the list (it would require a run-time check). In other words, this kind of behavior is not type-safe, so the compiler won't allow it.

You can expose a IList / ICollection of IMyInterface—which is type-safe, but doesn't ensure that only your MyRealClass is added to the list.

public class Domain
{
    private List<IMyInterface> myList;

    public IList<IMyInterface> Interfaces { get { return this.myList; } }
}

Alternatively, you can expose an IEnumerable of IMyInterface (or IReadOnlyList, as zmbq suggests)—since the type parameter is covariant (see Covariance and Contravariance in Generics). Although this would not allow you add new items to the collection.

public class Domain
{
    private List<MyRealClass> myList;

    public IEnumerable<IMyInterface> Interfaces { get { return this.myList; } }
}

Another solution would be to implement your own collection class that actually implements of IList<IMyInterface> but throws an exception if a user tries to insert anything other than a MyRealClass. This isn't a particularly elegant solution and in practical terms, it's not any different from simply exposing an IList<MyRealClass>.

相关问答

更多
  • 这里有三个问题:我应该使用什么类型的形式参数? 本地变量应该用什么? 我应该怎么用于返回类型? 正式参数: 这里的原则是不要求比你需要的更多 。 IEnumerable通信“我需要从头到尾得到这个序列的元素”。 IList通信“我需要以任意顺序获取并设置此序列的元素”。 List通信“我需要以任意顺序获取和设置此序列的元素,我只接受列表;我不接受数组。 通过要求比你需要的更多,你(1)使呼叫者做不必要的工作来满足你的不必要的需求,和(2)向读者传达虚假的信息。 只问你要使用什么 这样,如果 ...
  • 我有两条规则: 接受最基本的工作类型 返回用户将需要的最丰富的类型 所以当编写一个收集的函数或方法时,写入它不是一个List,而是一个IList ,一个ICollection 或者IEnumerable 。 通用接口仍然可以用于异构列表,因为System.Object也可以是T。 如果您决定使用Stack或其他数据结构,那么这样做会使您头疼。 如果所有你需要做的功能是通过它,IEnumerable 真的是你应该要求的所有。 另一方面,当从一个函数返回一个对象时,你想给用户最丰富的一组 ...
  • 您可以/应该实现一个类似于ReadOnlyCollection来充当代理。 考虑到它是只读的,它可能是“协变的”(不是语言方面,但在逻辑上,它可以代理TSource的子类/接口TDest ),然后对所有写入方法throw NotSupportedException() 。 像这样的东西(代码未经测试): public class CovariantReadOlyList : IList, IReadOnlyList where TSource ...
  • 使用列表映射,索引将应用于列表中的对象集。 也就是说,如果客户拥有一组63个域,那么通常该列表将包含0到62之间的值,以指示该客户的域集中的域对象的索引。 您已将索引设置为DomainId,即表的主键,这会造成严重破坏。 我猜想Domain表总共有665384行(如果DomainId没有以1开头并且有间隙,则会更少),但我认为63表有效而不是一行。 你有没有检查过它们? :-) With a list mapping, the index applies to the set of objects in t ...
  • 是的,可以创建一个IList(Of IList(Of String)) - 但是List(Of (List(Of String)) 不是一个。考虑到后一种情况你可以调用 listOfLists.Add(arrayOfStrings) 作为字符串数组实现IList(Of String) 。 基本上这与考虑IList(Of Fruit)和List(Of Banana)完全相同 - 一堆香蕉不是水果碗,因为你不能添加苹果。 在您的情况下,您需要创建一个List(Of IList(Of String)) - 或者 ...
  • 由于您使用的是非通用IList,因此您需要输入值: for (int i = 0; i < results.Count; ++i) { Console.WriteLine(((NHibernate.Examples.QuickStart.User)results[i]).EmailAddress); // Not Working } 或者,您可以通过将第一行更改为以下来使您的IList成为通用版本: System.Collections.IList
  • 假设您可以执行以下操作: // NOT REAL CODE public interface IMyInterface { } public class MyRealClass : IMyInterface { } ... public class Domain { private List myList; public IList Interfaces { get { return (IList)t ...
  • 问题 您无法创建.NET中不允许的接口实例。 你不可以做这个: var items = new IList(); // Not allowed 您的错误清楚地表明: 无法创建BLA类型的实例。 Type是接口或抽象类,无法实例化' 解决方案 将其反序列化为List类型,但将其指定为IList类型。 请注意,除了在铸造阶段,右侧的类型不是下面代码中的接口。 IList MyDeserialisedObject = JsonConvert.Dese ...
  • 我觉得这很容易 这是不容易的。 至少不那么容易。 不允许这样做的原因最好用一个例子来解释。 假设它被允许按照你的建议进行分配: // Let's make another trigger unrelated to CompletionTrigger class ContinuationTrigger : ITrigger { } // This is allowed List myTriggers = new List(); // ...
  • AddRange不是IList上的方法,但是Add is,因此您可以轻松地创建扩展方法: public static void AddRange(this IList list, IEnumerable values) { foreach(var value in values) list.Add(value); } 您还可以在扩展方法中检查列表是否实际上是List的实例,在这种情况下,您可以直接调用AddRange AddRange is not a metho ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。